/* DESIGN SYSTEM & CUSTOM PROPERTIES */
:root {
  --bg-shell: #090a0f;
  --bg-phone: #10121b;
  --bg-card: rgba(18, 20, 32, 0.75);
  --bg-card-hover: rgba(26, 29, 46, 0.85);
  
  --primary-purple: #8257e5;
  --primary-purple-glow: rgba(130, 87, 229, 0.5);
  --accent-cyan: #00f0ff;
  --accent-cyan-glow: rgba(0, 240, 255, 0.4);
  --accent-pink: #ff007f;
  --accent-pink-glow: rgba(255, 0, 127, 0.4);
  
  --status-ok: #00ff87;
  --status-err: #ff3366;
  
  --text-primary: #f0f2f5;
  --text-secondary: #9aa0b9;
  --text-muted: #626884;
  
  --border-light: rgba(130, 87, 229, 0.2);
  --border-glow: rgba(0, 240, 255, 0.25);
  --border-pink: rgba(255, 0, 127, 0.25);
  
  --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-gaming: 'Orbitron', 'Inter', sans-serif;
  
  --phone-width: 410px;
  --phone-height: 820px;
}

/* GENERAL STYLES & RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

body {
  font-family: var(--font-family-sans);
  background-color: var(--bg-shell);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

/* SCROLLBAR CUSTOMIZATION */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-purple);
}

/* BUTTONS & COMPONENT UTILITIES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-family: var(--font-family-sans);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-purple), #6332d1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.1);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px var(--primary-purple-glow);
}

.btn-secondary {
  background: rgba(30, 34, 54, 0.6);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  background: rgba(45, 51, 80, 0.8);
  border-color: var(--accent-cyan);
  color: #fff;
}

.btn-danger {
  background: rgba(255, 51, 102, 0.15);
  color: var(--status-err);
  border-color: rgba(255, 51, 102, 0.3);
}
.btn-danger:hover {
  background: var(--status-err);
  color: #fff;
}

.btn-glow {
  box-shadow: 0 0 15px rgba(130, 87, 229, 0.3);
}
.btn-glow:hover {
  box-shadow: 0 0 25px var(--primary-purple-glow), 0 0 10px var(--accent-cyan-glow);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* APP SHELL (Ambient desktop view) */
#app-shell {
  width: 100vw;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 30% 20%, #150f2e 0%, var(--bg-shell) 60%),
              radial-gradient(circle at 80% 80%, #0d2836 0%, var(--bg-shell) 100%);
  position: relative;
}

/* PHONE CONTAINER MOCKUP */
#phone-container {
  width: 100%;
  max-width: var(--phone-width);
  height: 100%;
  max-height: var(--phone-height);
  background-color: var(--bg-phone);
  border-radius: 40px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8),
              0 0 1px 2px rgba(255, 255, 255, 0.08),
              0 0 40px rgba(130, 87, 229, 0.15);
  border: 8px solid #222530;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* On real mobile devices: fill the entire screen, remove mockup borders */
@media (max-width: 480px) {
  body {
    align-items: stretch;
  }
  #app-shell {
    align-items: stretch;
  }
  #phone-container {
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
}

/* APP HEADER */
.app-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  background: rgba(16, 18, 27, 0.85);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.header-logo {
  font-family: var(--font-family-gaming);
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 1px;
}
.logo-accent {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-cyan-glow);
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.status-disconnected {
  background: rgba(255, 51, 102, 0.1);
  color: var(--status-err);
  border: 1px solid rgba(255, 51, 102, 0.2);
}

.status-connected {
  background: rgba(0, 255, 135, 0.1);
  color: var(--status-ok);
  border: 1px solid rgba(0, 255, 135, 0.2);
  box-shadow: 0 0 8px rgba(0, 255, 135, 0.15);
}

/* PROFILE HEADER widget */
.profile-header {
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(22, 26, 38, 0.5) 0%, rgba(16, 18, 27, 0) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  animation: fadeIn 0.4s ease;
}

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

.avatar-glow {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(130, 87, 229, 0.15);
  border: 2px solid var(--primary-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px var(--primary-purple-glow);
  color: var(--primary-purple);
}

.avatar-icon {
  width: 20px;
  height: 20px;
}

.user-meta h2 {
  font-family: var(--font-family-gaming);
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  color: #fff;
}

.branch-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 500;
  margin-top: 2px;
}
.branch-indicator i {
  width: 12px;
  height: 12px;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 0, 127, 0.1);
  border: 1px solid var(--border-pink);
  padding: 6px 12px;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.1);
}

/* Profile right grouping (streak + logout) */
.profile-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Logout Button */
.btn-logout {
  width: 34px;
  height: 34px;
  background: rgba(255, 51, 102, 0.08);
  border: 1px solid rgba(255, 51, 102, 0.2);
  border-radius: 10px;
  color: rgba(255, 51, 102, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  flex-shrink: 0;
}
.btn-logout i {
  width: 16px;
  height: 16px;
}
.btn-logout:hover {
  background: rgba(255, 51, 102, 0.2);
  border-color: var(--status-err);
  color: var(--status-err);
  box-shadow: 0 0 10px rgba(255, 51, 102, 0.2);
  transform: translateY(-1px);
}

.streak-icon {
  color: var(--accent-pink);
  fill: var(--accent-pink);
  width: 18px;
  height: 18px;
  animation: pulseGlow 2s infinite;
}

.streak-text {
  display: flex;
  flex-direction: column;
}

.streak-count {
  font-family: var(--font-family-gaming);
  font-weight: 900;
  font-size: 0.9rem;
  color: #fff;
  line-height: 1;
}

.streak-lbl {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

/* APP VIEWPORT */
.app-viewport {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 16px 20px calc(80px + env(safe-area-inset-bottom, 0px)) 20px; /* offset bottom nav + safe area */
  position: relative;
}

/* PULL TO REFRESH INDICATOR */
.pull-refresh-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: height 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease, margin-bottom 0.2s ease;
  margin-bottom: 0;
  pointer-events: none;
}

.pull-refresh-indicator.visible {
  opacity: 1;
}

.pull-refresh-indicator.refreshing .pull-refresh-icon i {
  animation: spin 0.8s linear infinite;
}

.pull-refresh-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px var(--accent-cyan-glow);
  flex-shrink: 0;
}

.pull-refresh-icon i {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

#pull-refresh-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.5px;
  font-family: var(--font-family-sans);
}

.app-view {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.app-view.active {
  display: flex;
}

/* GLASS CARD COMPONENT */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}
.glass-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(130, 87, 229, 0.35);
}

/* GUEST WELCOME CARD */
.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 30px 20px;
  border-color: var(--border-pink);
  box-shadow: 0 10px 30px rgba(255, 0, 127, 0.05);
  margin-top: 40px;
}

.welcome-icon {
  width: 56px;
  height: 56px;
  color: var(--accent-pink);
  filter: drop-shadow(0 0 10px var(--accent-pink-glow));
  animation: bounceSlow 3s infinite;
}

.welcome-card h3 {
  font-family: var(--font-family-gaming);
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: 0.5px;
}

.welcome-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* POINTS CARD & CIRCLE */
.points-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.card-subtitle {
  font-family: var(--font-family-gaming);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
}

.points-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle, rgba(130, 87, 229, 0.05) 50%, rgba(130, 87, 229, 0.15) 100%);
  border: 4px solid var(--primary-purple);
  box-shadow: 0 0 30px rgba(130, 87, 229, 0.25), inset 0 0 30px rgba(130, 87, 229, 0.2);
}

.points-glow {
  position: absolute;
  top: -6px; left: -6px; right: -6px; bottom: -6px;
  border-radius: 50%;
  border: 2px dashed var(--accent-cyan);
  opacity: 0.4;
  animation: spin 30s linear infinite;
}

.points-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 2;
}

.points-value {
  font-family: var(--font-family-gaming);
  font-size: 3rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.5), 0 0 25px var(--primary-purple);
  line-height: 1;
}

.points-label {
  font-size: 0.7rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
  margin-top: 4px;
}

.points-subtext {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

/* POWER CARD (MULTIPLIER PROGRESS) */
.power-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-color: var(--border-glow);
}

.power-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-family-gaming);
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}
.power-header i {
  vertical-align: middle;
  margin-right: 4px;
}

.power-percentage {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-cyan-glow);
  font-size: 0.95rem;
  font-weight: 900;
}

.power-progress-container {
  height: 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  position: relative;
  margin: 15px 0 25px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.power-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-purple), var(--accent-cyan));
  border-radius: 10px;
  box-shadow: 0 0 10px var(--accent-cyan-glow);
  position: relative;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.power-ticks {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

.tick {
  position: absolute;
  top: -3px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tick-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #191c2b;
  border: 2px solid var(--text-muted);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  transition: all 0.3s ease;
}

.tick-lbl {
  font-family: var(--font-family-gaming);
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 8px;
  transition: all 0.3s ease;
}

/* Active tick styles */
.tick.active .tick-dot {
  background: var(--accent-cyan);
  border-color: #fff;
  box-shadow: 0 0 10px var(--accent-cyan-glow);
  transform: scale(1.15);
}
.tick.active .tick-lbl {
  color: var(--accent-cyan);
  text-shadow: 0 0 8px var(--accent-cyan-glow);
  font-weight: 800;
}

.power-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 12px;
}
.power-footer i {
  color: var(--accent-cyan);
  width: 14px;
  height: 14px;
}

/* LOG CARD */
.log-card h3 {
  font-family: var(--font-family-gaming);
  font-size: 0.85rem;
  margin-bottom: 12px;
  color: #fff;
}

.log-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border-left: 3px solid var(--accent-cyan);
  font-size: 0.78rem;
}

.log-branch {
  font-weight: 600;
  color: #fff;
}

.log-time {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.log-points {
  font-family: var(--font-family-gaming);
  font-weight: 700;
  color: var(--status-ok);
}

.log-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}

/* RANKINGS & LEADERBOARD */
.rankings-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ranking-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.03);
}

.ranking-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family-gaming);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 10px 4px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.ranking-tab span {
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.7;
}

.ranking-tab:hover {
  color: #fff;
}

.ranking-tab.active {
  background: var(--bg-card);
  color: #fff;
  border: 1px solid var(--border-light);
  box-shadow: 0 0 10px rgba(130, 87, 229, 0.15);
}

.ranking-tab.active i {
  color: var(--accent-cyan);
}

.leaderboard-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0 4px;
}
.leaderboard-meta i {
  width: 12px;
  height: 12px;
  vertical-align: middle;
  margin-right: 2px;
}

.leaderboard-card {
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.leaderboard-headers {
  display: grid;
  grid-template-columns: 40px 1fr 80px;
  padding: 8px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 40px 1fr 80px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  font-size: 0.8rem;
  transition: background 0.2s ease;
}
.leaderboard-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.leaderboard-item:last-child {
  border-bottom: none;
}

.rank-number {
  font-family: var(--font-family-gaming);
  font-weight: 800;
  color: var(--text-secondary);
}

/* Podium styling for top 3 */
.leaderboard-item.rank-1 .rank-number {
  color: #ffd700; /* Gold */
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
  font-size: 0.95rem;
}
.leaderboard-item.rank-2 .rank-number {
  color: #c0c0c0; /* Silver */
  text-shadow: 0 0 10px rgba(192, 192, 192, 0.3);
  font-size: 0.9rem;
}
.leaderboard-item.rank-3 .rank-number {
  color: #cd7f32; /* Bronze */
  text-shadow: 0 0 10px rgba(205, 127, 50, 0.3);
}

.player-info-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.player-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.leaderboard-item.rank-1 .player-avatar {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.05);
}

.player-name-val {
  font-family: var(--font-family-gaming);
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score-cell {
  font-family: var(--font-family-gaming);
  font-weight: 800;
  color: var(--text-primary);
  text-align: right;
}

/* User item custom highlights */
.leaderboard-item.is-current-user {
  background: rgba(130, 87, 229, 0.15) !important;
  border-left: 3px solid var(--primary-purple);
  border-right: 3px solid var(--primary-purple);
}
.leaderboard-item.is-current-user .player-name-val {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* Sticky floating rank banner */
.user-sticky-rank {
  border-color: var(--primary-purple);
  background: linear-gradient(90deg, rgba(13, 11, 23, 0.95), rgba(130, 87, 229, 0.2));
  display: grid;
  grid-template-columns: 40px 1fr 80px;
  align-items: center;
  padding: 12px 20px;
  border-radius: 16px;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(130, 87, 229, 0.15);
  font-size: 0.8rem;
  margin-top: 8px;
}

/* NAVIGATION FOOTER */
.app-nav {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: calc(72px + env(safe-area-inset-bottom, 0px));
  background: rgba(16, 18, 27, 0.9);
  backdrop-filter: blur(15px);
  border-top: 1px solid var(--border-light);
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  align-items: center;
  padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.25s ease;
  height: 100%;
}
.nav-item i {
  width: 22px;
  height: 22px;
}
.nav-item span {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.nav-item:hover, .nav-item.active {
  color: #fff;
}
.nav-item.active i {
  color: var(--primary-purple);
  filter: drop-shadow(0 0 5px var(--primary-purple-glow));
}

/* SCAN QR CENTER BUTTON */
.nav-scan-btn {
  position: relative;
  top: -14px;
  height: auto;
}

.scan-button-inner {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--primary-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 15px rgba(0, 240, 255, 0.3), 0 0 20px rgba(130, 87, 229, 0.2);
  color: #fff;
  border: 4px solid var(--bg-phone);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.scan-button-inner i {
  width: 26px;
  height: 26px;
}

.nav-scan-btn:hover .scan-button-inner {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 240, 255, 0.45), 0 0 25px rgba(130, 87, 229, 0.3);
}

.scan-label {
  margin-top: 2px;
  font-weight: 700 !important;
  color: var(--accent-cyan) !important;
}

/* MODAL OVERLAYS */
.modal-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 6, 10, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

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

.modal-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(130, 87, 229, 0.15);
  border-radius: 24px;
  padding: 24px;
  position: relative;
  animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Login stays compact on desktop while remaining fluid on phones. */
#modal-auth .modal-card {
  width: min(430px, 100%);
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.05);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.modal-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}
.modal-close i {
  width: 16px;
  height: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-title-icon {
  color: var(--accent-cyan);
  width: 24px;
  height: 24px;
}

.modal-header h2 {
  font-family: var(--font-family-gaming);
  font-size: 1.1rem;
  color: #fff;
}

/* Form Styles */
.auth-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(0,0,0,0.3);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,0.02);
}

.auth-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-toggle-btn.active {
  background: rgba(130, 87, 229, 0.2);
  color: #fff;
  border: 1px solid var(--border-light);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-group input {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  font-family: var(--font-family-sans);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.25s ease;
}
.form-group input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* SCAN QR MODAL BODY */
.qr-camera-mock {
  min-height: 180px;
  border: 2px dashed var(--border-light);
  background: rgba(0,0,0,0.4);
  border-radius: 16px;
  margin: 16px 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
}

#qr-reader {
  width: 100%;
  border: none !important;
}
#qr-reader video {
  width: 100% !important;
  height: 180px !important;
  object-fit: cover !important;
  border-radius: 14px;
}
#qr-reader__scan_region {
  background: transparent !important;
}
#qr-reader__dashboard, #qr-reader__header_message, #qr-reader__status_span {
  display: none !important;
}

#qr-camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0; left: 0;
}
#qr-camera-placeholder.hidden {
  display: none !important;
}

.qr-scanner-line {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: scanLines 2.5s ease-in-out infinite;
}

.scan-frame-icon {
  width: 48px;
  height: 48px;
  color: var(--border-light);
  margin-bottom: 8px;
}

.scanner-text {
  font-size: 0.75rem;
  font-weight: 600;
}

.branch-selection-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.btn-branch-action {
  justify-content: flex-start;
  padding: 10px 16px;
  font-size: 0.85rem;
}
.btn-branch-action i {
  color: var(--accent-cyan);
  width: 16px;
  height: 16px;
}

/* GPS SYNC LOADING CARD */
.gps-sync-loader {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 10px auto 20px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compass-icon {
  width: 36px;
  height: 36px;
  color: var(--accent-cyan);
  z-index: 2;
  animation: spinCompass 3s cubic-bezier(0.68, -0.6, 0.32, 1.6) infinite;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  opacity: 0;
  animation: radarPulse 1.8s ease-out infinite;
}

#sync-loading-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 8px 0;
}

.sync-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* SUCCESS MODAL CARD */
.success-card {
  border-color: var(--status-ok);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 35px rgba(0, 255, 135, 0.15);
}

.success-icon-container {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 255, 135, 0.1);
  border: 2px solid var(--status-ok);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
  box-shadow: 0 0 15px rgba(0, 255, 135, 0.2);
}
.success-icon {
  width: 36px;
  height: 36px;
  color: var(--status-ok);
}

.success-message {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 16px;
}

.points-reward-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: left;
}

.reward-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 0;
}

.reward-value {
  font-family: var(--font-family-gaming);
  font-weight: 700;
  color: #fff;
}

.reward-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin: 8px 0;
}

.reward-row.total {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}
.reward-row.total .reward-value {
  font-size: 1.1rem;
  color: var(--status-ok);
  text-shadow: 0 0 10px rgba(0, 255, 135, 0.3);
}

.success-info-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.info-block {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.info-block i {
  width: 18px;
  height: 18px;
}
.info-block strong {
  color: #fff;
  font-size: 0.8rem;
}


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

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

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

.text-glow {
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2), 0 0 20px var(--primary-purple-glow);
}

.text-accent {
  color: var(--accent-cyan) !important;
}

.small-text {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ANIMATIONS Definitions */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes spinCompass {
  0% { transform: rotate(0deg); }
  20% { transform: rotate(-30deg); }
  60% { transform: rotate(390deg); }
  80% { transform: rotate(350deg); }
  100% { transform: rotate(360deg); }
}

@keyframes radarPulse {
  0% { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

@keyframes pulseGlow {
  0% { filter: drop-shadow(0 0 2px var(--accent-pink-glow)); }
  50% { filter: drop-shadow(0 0 8px var(--accent-pink)); }
  100% { filter: drop-shadow(0 0 2px var(--accent-pink-glow)); }
}

@keyframes bounceSlow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes scanLines {
  0% { top: 0%; opacity: 0.3; }
  50% { top: 100%; opacity: 0.8; }
  100% { top: 0%; opacity: 0.3; }
}

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

/* Screen adaptation for widescreen preview - centres the phone mockup with a neat desktop decoration */
@media (min-width: 768px) {
  #app-shell::before {
    content: "LOCAL LEGENDS MVP PLATFORM";
    position: absolute;
    top: 5%;
    font-family: var(--font-family-gaming);
    font-weight: 900;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.03);
    letter-spacing: 5px;
    pointer-events: none;
  }
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATION SYSTEM
═══════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
  width: min(420px, 92vw);
}

.toast {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 16px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: all;
  animation: toastIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.toast.toast-success {
  background: rgba(0, 255, 135, 0.08);
  border-color: rgba(0, 255, 135, 0.25);
}
.toast.toast-success::before {
  background: linear-gradient(90deg, transparent, #00ff87, transparent);
}

.toast.toast-error {
  background: rgba(255, 51, 102, 0.1);
  border-color: rgba(255, 51, 102, 0.3);
}
.toast.toast-error::before {
  background: linear-gradient(90deg, transparent, #ff3366, transparent);
}

.toast.toast-warning {
  background: rgba(255, 170, 0, 0.08);
  border-color: rgba(255, 170, 0, 0.25);
}
.toast.toast-warning::before {
  background: linear-gradient(90deg, transparent, #ffaa00, transparent);
}

.toast.toast-info {
  background: rgba(0, 240, 255, 0.07);
  border-color: rgba(0, 240, 255, 0.2);
}
.toast.toast-info::before {
  background: linear-gradient(90deg, transparent, #00f0ff, transparent);
}

.toast-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast-icon i { width: 18px; height: 18px; }

.toast.toast-success .toast-icon { background: rgba(0,255,135,0.15); color: #00ff87; }
.toast.toast-error   .toast-icon { background: rgba(255,51,102,0.15); color: #ff3366; }
.toast.toast-warning .toast-icon { background: rgba(255,170,0,0.15);  color: #ffaa00; }
.toast.toast-info    .toast-icon { background: rgba(0,240,255,0.12);  color: #00f0ff; }

.toast-body { flex: 1; }

.toast-title {
  font-family: var(--font-family-gaming);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.toast.toast-success .toast-title { color: #00ff87; }
.toast.toast-error   .toast-title { color: #ff3366; }
.toast.toast-warning .toast-title { color: #ffaa00; }
.toast.toast-info    .toast-title { color: #00f0ff; }

.toast-message {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.toast-close:hover { color: #fff; }
.toast-close i { width: 14px; height: 14px; }

.toast.toast-exit {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0)    scale(1);   }
  to   { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

/* ═══════════════════════════════════════════
   CUSTOM CONFIRM MODAL
═══════════════════════════════════════════ */
.confirm-card {
  background: linear-gradient(145deg, #1a1d2e, #12141f);
  border: 1px solid rgba(130, 87, 229, 0.3);
  border-radius: 24px;
  padding: 32px 28px 24px;
  max-width: 340px;
  width: 90vw;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.05);
  animation: confirmIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

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

.confirm-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: rgba(255, 170, 0, 0.12);
  border: 1px solid rgba(255, 170, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: #ffaa00;
}
.confirm-icon i { width: 26px; height: 26px; }

.confirm-card h3 {
  font-family: var(--font-family-gaming);
  font-size: 0.95rem;
  color: #fff;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.confirm-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}
.confirm-actions .btn {
  flex: 1;
  padding: 11px 16px;
  font-size: 0.85rem;
}

/* ============================================================
   MODE SELECTION SCREEN
   ============================================================ */
.mode-select-header {
  text-align: center;
  padding: 24px 20px 18px;
}
.mode-select-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-family-gaming);
  color: var(--accent-cyan);
  margin-bottom: 6px;
}
.mode-select-header p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 16px 24px;
}
.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 22px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.mode-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
  box-shadow: 0 8px 32px rgba(0, 240, 255, 0.18);
}
.mode-card-event {
  border-color: rgba(130, 87, 229, 0.4);
  min-height: 140px;
}
.mode-card-event:hover {
  border-color: var(--primary-purple);
  box-shadow: 0 8px 32px rgba(130, 87, 229, 0.3);
}
.mode-card-event-overlay {
  background: linear-gradient(to top, rgba(9,10,15,0.95) 40%, rgba(9,10,15,0.5) 100%);
  position: absolute;
  inset: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.mode-card-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.mode-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-family-gaming);
  color: var(--text-primary);
  margin-bottom: 6px;
}
.mode-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
}
.mode-card-action {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mode-card-event .mode-card-action { color: #c084fc; }

/* ============================================================
   BACK BUTTON
   ============================================================ */
.btn-back-mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-family-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 13px;
  cursor: pointer;
  margin: 14px 16px 10px;
  transition: border-color 0.2s, color 0.2s;
}
.btn-back-mode:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.btn-back-mode svg { width: 14px; height: 14px; }

/* ============================================================
   EVENT BANNER
   ============================================================ */
.event-banner-wrap {
  width: calc(100% - 32px);
  margin: 0 16px 14px;
  height: 110px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #7C3AED, #4F46E5);
}
.event-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.2) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 20px;
}
.event-banner-title {
  font-size: 1.1rem;
  font-weight: 800;
  font-family: var(--font-family-gaming);
  color: #fff;
}
.event-banner-stage {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   EVENT PROGRESS CARD
   ============================================================ */
.event-progress-card { padding: 16px 18px; }
.event-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.event-progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: visible;
  position: relative;
  margin-bottom: 18px;
}
.event-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-purple), var(--accent-cyan));
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}
.event-tiers-row {
  position: relative;
  height: 20px;
  width: 100%;
}
.event-tier-marker {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  top: -26px;
}
.event-tier-marker::before {
  content: '';
  width: 2px;
  height: 26px;
  background: rgba(255,255,255,0.12);
  border-radius: 1px;
  margin-bottom: 2px;
  display: block;
}
.event-tier-marker.reached::before { background: var(--accent-cyan); }
.tier-marker-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  background: rgba(16,18,27,0.9);
  padding: 1px 4px;
  border-radius: 3px;
  position: absolute;
  top: -12px;
  transform: translateX(-50%);
  left: 50%;
}
.event-tier-marker.reached .tier-marker-label {
  color: var(--accent-cyan);
}

/* ============================================================
   EVENT STATS GRID
   ============================================================ */
.event-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 16px 14px;
}
.event-stat-card {
  padding: 14px 16px;
  text-align: center;
}
.event-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.event-stat-val {
  font-size: 1.3rem;
  font-weight: 800;
  font-family: var(--font-family-gaming);
  color: var(--accent-cyan);
}

/* ============================================================
   EVENT STAGE TABS & ACTION BUTTONS
   ============================================================ */
.event-stage-tabs {
  display: flex;
  gap: 8px;
  margin: 0 16px 12px;
}
.pill {
  padding: 6px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: var(--font-family-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.pill:hover {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
}
.pill.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
}
.btn-event-ranking {
  margin: 0 16px 16px;
  width: calc(100% - 32px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  background: rgba(130, 87, 229, 0.15);
  border: 1px solid var(--border-light);
  color: #c084fc;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-event-ranking:hover {
  background: rgba(130, 87, 229, 0.3);
  border-color: var(--primary-purple);
}
