:root {
  /* Color Palette - Soft Pastel Blues and Whites */
  --bg-primary: #f0f5fa;
  --bg-secondary: #ffffff;
  --primary-color: #63a4ff;
  --primary-hover: #4b93f0;
  --primary-light: #e6f0fa;
  --text-main: #2b394a;
  --text-muted: #7d8c9e;
  --border-color: #e2ebf5;
  --accent-color: #ffd666;
  --success-color: #66e0a3;
  --error-color: #ff7875;
  --shadow-sm: 0 4px 12px rgba(142, 172, 204, 0.12);
  --shadow-md: 0 8px 24px rgba(142, 172, 204, 0.2);
  --shadow-lg: 0 16px 40px rgba(142, 172, 204, 0.3);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

/* Base Reset & Layout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* App Wrapper for centering on desktop */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 920px;
  background-color: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (max-width: 480px) {
  body {
    background-color: var(--bg-secondary);
  }
  .app-container {
    height: 100%;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    max-height: none;
  }
}

/* Screen Management */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  padding-bottom: 96px; /* Nav bar spacer */
}

.screen.active {
  display: flex;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Custom Scrollbar */
.screen::-webkit-scrollbar {
  width: 6px;
}
.screen::-webkit-scrollbar-track {
  background: transparent;
}
.screen::-webkit-scrollbar-thumb {
  background-color: rgba(99, 164, 255, 0.2);
  border-radius: 10px;
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

/* Logo & Headers */
.brand-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-color) 0%, #a5cbfb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.brand-subtitle {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
}

.brand-title-sm {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.app-header {
  margin-bottom: 24px;
  text-align: center;
}

.header-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

/* Cards & Containers */
.card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(10px);
}

.auth-card {
  margin-top: auto;
  margin-bottom: auto;
  border-radius: var(--radius-xl);
}

.register-card {
  margin-top: auto;
  margin-bottom: auto;
}

/* Forms & Inputs */
.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

input[type="tel"],
input[type="text"] {
  width: 100%;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 1rem;
  background-color: var(--bg-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

input[type="tel"]:focus,
input[type="text"]:focus {
  border-color: var(--primary-color);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(99, 164, 255, 0.15);
}

.phone-input-container {
  display: flex;
  gap: 10px;
}

#select-country-code {
  width: 140px;
  flex-shrink: 0;
  padding: 14px 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background-color: var(--bg-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232b394a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 32px;
}

#select-country-code:focus {
  border-color: var(--primary-color);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(99, 164, 255, 0.15);
}

.phone-input-container input[type="tel"] {
  flex: 1;
}

/* Generic Form Select (Registration dropdowns) */
.form-select {
  width: 100%;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 1rem;
  background-color: var(--bg-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232b394a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 38px;
}

.form-select:focus {
  border-color: var(--primary-color);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(99, 164, 255, 0.15);
}

.input-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 14px 24px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 164, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 164, 255, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background-color: #c4d7ec;
  color: #ffffff;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.btn-secondary:hover {
  background-color: var(--primary-color);
  color: #ffffff;
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-text:hover {
  color: var(--text-main);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Image Upload Widget */
.image-upload-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.avatar-picker-label {
  display: flex;
  width: 160px;
  height: 160px;
  border-radius: 12px;
  border: 3px dashed var(--primary-color);
  background-color: var(--primary-light);
  cursor: pointer;
  overflow: hidden;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: var(--transition);
}

.avatar-picker-label:hover {
  border-color: var(--primary-hover);
  background-color: #d0e4fa;
  transform: scale(1.03);
}

#avatar-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--primary-color);
}

.upload-icon {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.upload-label {
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-display);
}

#avatar-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Location Status Widget */
.location-status-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 28px;
}

.location-info {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
}

.location-icon {
  font-size: 1.5rem;
  background-color: #ffffff;
  padding: 8px;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.location-info h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
}

/* Mash/Game Arena */
.mash-arena {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  justify-content: center;
  align-items: center;
  padding-bottom: 12px;
}

.mash-card {
  width: 100%;
  max-width: 320px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
}

.mash-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-md);
}

.mash-card:active {
  transform: scale(0.98);
}

.image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background-color: #e9f0f8;
}

.image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mash-card-info {
  padding: 12px;
  display: flex;
  justify-content: center;
  background-color: #ffffff;
  border-top: 1px solid var(--border-color);
}

.profile-elo-tag {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary-color);
  background-color: var(--primary-light);
  padding: 4px 12px;
  border-radius: 12px;
}

.mash-vs {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-muted);
  text-align: center;
  align-self: center;
  background-color: var(--bg-primary);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid #ffffff;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.card-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease;
  z-index: 5;
}

.card-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Spinner Animation */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--primary-light);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Bottom Nav bar */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 72px;
  background-color: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--border-color);
  display: flex;
  backdrop-filter: blur(10px);
  z-index: 10;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}

.nav-item {
  flex: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  transition: var(--transition);
  gap: 3px;
}

.nav-item:hover {
  color: var(--primary-color);
}

.nav-item.active {
  color: var(--primary-color);
}

.nav-icon {
  font-size: 1.4rem;
  transition: transform 0.2s ease;
}

.nav-item.active .nav-icon {
  transform: translateY(-2px) scale(1.1);
}

.nav-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
}

/* Tabs */
.tabs {
  display: flex;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn.active {
  background-color: #ffffff;
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

/* Leaderboard List */
.leaderboard-container {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 8px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rank-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  animation: slideIn 0.3s ease-out;
}

.rank-row:hover {
  border-color: var(--primary-color);
  transform: translateX(4px);
}

@keyframes slideIn {
  from { transform: translateX(-10px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--bg-primary);
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  margin-right: 12px;
  flex-shrink: 0;
}

.rank-row:nth-child(1) .rank-badge {
  background-color: #fff1b8;
  color: #d48806;
}
.rank-row:nth-child(2) .rank-badge {
  background-color: #f5f5f5;
  color: #595959;
}
.rank-row:nth-child(3) .rank-badge {
  background-color: #ffe7ba;
  color: #d46b08;
}

.rank-avatar {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  margin-right: 14px;
  border: 2px solid var(--border-color);
  flex-shrink: 0;
}

.rank-row:nth-child(-n+3) .rank-avatar {
  border-color: var(--primary-color);
}

.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.rank-elo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--primary-color);
  flex-shrink: 0;
}

/* Sticky rank bar */
.sticky-rank-row {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  background-color: var(--primary-light);
  border: 2px solid var(--primary-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  position: sticky;
  bottom: 0px;
  margin-top: auto;
  z-index: 8;
  animation: slideUp 0.3s ease-out;
}

.sticky-rank-row .user-rank {
  background-color: var(--primary-color);
  color: #ffffff;
}

.sticky-rank-row .rank-elo {
  color: var(--primary-hover);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Profile Screen CSS */
.profile-avatar-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 12px;
}

.profile-large-avatar {
  width: 110px;
  height: 110px;
  border-radius: 12px;
  object-fit: cover;
  border: 4px solid var(--primary-light);
  box-shadow: var(--shadow-sm);
  display: block;
}

.edit-photo-btn {
  margin-top: 10px;
  padding: 6px 14px;
  font-size: 0.8rem;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  display: inline-block;
}

.profile-header-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.profile-header-info h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.stats-grid {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  flex: 1;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border-color);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 600;
}

.ranks-section {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 16px;
  margin-bottom: 28px;
}

.ranks-section h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.rank-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9rem;
}

.rank-item:not(:last-child) {
  border-bottom: 1px dashed var(--border-color);
}

.rank-item-label {
  color: var(--text-muted);
}

.rank-item-val {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-main);
}

/* Loader Screen styles */
#screen-loader {
  justify-content: center;
  align-items: center;
  background-color: var(--bg-primary);
  z-index: 100;
  height: 100%;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.logo-spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 6px solid #dbe9fd;
  border-top-color: var(--primary-color);
  animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.animated {
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.05); opacity: 1; }
}

.loader-text {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Toast System */
.toast-container {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: rgba(43, 57, 74, 0.95);
  color: #ffffff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  background-color: rgba(102, 224, 163, 0.95);
  color: #1e5237;
}

.toast-error {
  background-color: rgba(255, 120, 117, 0.95);
  color: #5c1816;
}

/* Modal Overlays & Cropping Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1500;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

.modal-content {
  width: 90%;
  max-width: 400px;
  animation: modal-slide-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.mash-card {
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

.mash-card.fade-out {
  opacity: 0;
  pointer-events: none;
}

@keyframes modal-slide-in {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Locked Bottom Navigation Item styling */
.nav-item.locked-nav {
  opacity: 0.4;
  filter: grayscale(100%);
  cursor: not-allowed !important;
}

.nav-item.locked-nav:active {
  transform: none !important;
}

/* Range input styling for zoom */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

