:root {
  --bg-dark: #060a06;
  --bg-surface: #0c140c;
  --bg-surface-elevated: #111d11;
  --border-dim: #1c2e1c;
  --border-bright: #22c55e;
  --neon-green: #4ade80;
  --neon-glow: rgba(74, 222, 128, 0.25);
  --neon-cyan: #38bdf8;
  --neon-gold: #facc15;
  --neon-orange: #fb923c;
  --neon-purple: #c084fc;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
}

/* Screen Transitions */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 1;
}

.screen.active {
  display: flex;
  opacity: 1;
  z-index: 5;
}

/* ==========================================================================
   1. LANDING PAGE
   ========================================================================== */
#screen-landing {
  background: radial-gradient(circle at 50% 40%, #0d220d 0%, #060a06 70%);
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.landing-backdrop-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: 36px 36px;
  background-image: 
    linear-gradient(to right, rgba(74, 222, 128, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(74, 222, 128, 0.04) 1px, transparent 1px);
  mask-image: radial-gradient(circle at 50% 50%, black 30%, transparent 80%);
  pointer-events: none;
}

.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 520px;
  padding: 20px;
  z-index: 2;
  animation: fadeInLanding 0.5s ease-out;
}

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

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(22, 101, 52, 0.3);
  border: 1px solid var(--border-bright);
  border-radius: 9999px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--neon-green);
  box-shadow: 0 0 15px var(--neon-glow);
}

.landing-title {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: linear-gradient(180deg, #ffffff 30%, #86efac 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(74, 222, 128, 0.3);
}

.landing-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.landing-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 210px;
  height: 52px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #030703;
  font-size: 17px;
  font-weight: 800;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: all 0.2s ease;
}

.landing-play-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 40px rgba(34, 197, 94, 0.6);
}

.landing-play-btn:active {
  transform: translateY(1px);
}

.landing-footer {
  position: absolute;
  bottom: 16px;
  font-size: 11px;
  color: #4b5563;
  font-family: var(--font-mono);
}

/* ==========================================================================
   2. FULL-SCREEN LANDSCAPE LOBBY
   ========================================================================== */
#screen-lobby {
  background: radial-gradient(circle at 50% 30%, #0d1a0d 0%, #060a06 85%);
  display: flex;
  flex-direction: column;
}

/* Top Navbar */
.lobby-nav {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dim);
  background: rgba(12, 20, 12, 0.9);
  backdrop-filter: blur(10px);
  z-index: 10;
  flex-shrink: 0;
  gap: 8px;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-nav-back {
  background: #000;
  color: var(--text-muted);
  border: 1px solid var(--border-dim);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-nav-back:hover {
  color: #fff;
  border-color: var(--border-bright);
}

.net-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #000;
  border: 1px solid var(--border-dim);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 6px var(--neon-green);
  animation: pulse 1.6s infinite;
}

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

.wallet-badge-pill {
  background: #000;
  border: 1px solid var(--border-bright);
  padding: 4px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.wallet-badge-pill:hover {
  box-shadow: 0 0 10px var(--neon-glow);
}

.btn-nav-action {
  background: rgba(74, 222, 128, 0.1);
  color: var(--neon-green);
  border: 1px solid rgba(74, 222, 128, 0.3);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-nav-action:hover {
  background: rgba(74, 222, 128, 0.2);
  border-color: var(--neon-green);
}

/* Main Grid Layout (Landscape Optimized) */
.lobby-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  padding: 12px 16px;
  min-height: 0;
  overflow: hidden;
}

/* Left Showcase Canvas + Carousel */
.showcase-container {
  background: radial-gradient(circle at 50% 60%, #102010 0%, #080f08 85%);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.showcase-canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: block;
}

.carousel-dock {
  height: 60px;
  background: rgba(0, 0, 0, 0.7);
  border-top: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  overflow-x: auto;
  flex-shrink: 0;
}

.carousel-btn {
  background: #0a110a;
  border: 1px solid var(--border-dim);
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}

.carousel-btn.active {
  background: #166534;
  color: #fff;
  border-color: var(--neon-green);
  box-shadow: 0 0 12px var(--neon-glow);
}

/* Right Specs & Action Panel */
.specs-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  justify-content: space-between;
  overflow-y: auto;
}

.specs-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.role-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-start;
}
.role-buggy { background: #374151; color: #fff; }
.role-keeper { background: #166534; color: var(--neon-green); }
.role-suit { background: #854d0e; color: var(--neon-gold); }
.role-worker { background: #9a3412; color: var(--neon-orange); }
.role-phantom { background: #581c87; color: var(--neon-purple); }

.specs-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.specs-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Compact Bars */
.stat-bars-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
}

.stat-bar-track {
  width: 140px;
  height: 5px;
  background: #172417;
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: var(--neon-green);
  border-radius: 3px;
  box-shadow: 0 0 6px var(--neon-glow);
}

.specs-actions-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.price-display-box {
  background: #000;
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.btn-equip-action {
  width: 100%;
  height: 38px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #030703;
  font-size: 13px;
  font-weight: 800;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-equip-action:hover {
  box-shadow: 0 0 15px var(--neon-glow);
}

.btn-equip-action.equipped {
  background: #192b19;
  color: #86efac;
  border: 1px solid var(--border-dim);
  cursor: default;
  box-shadow: none;
}

.btn-equip-action.select {
  background: #166534;
  color: #fff;
  border: 1px solid var(--neon-green);
}

.bottom-buttons-row {
  display: flex;
  gap: 8px;
}

.btn-boost-trigger {
  flex: 1;
  height: 42px;
  background: #000;
  color: var(--neon-orange);
  border: 1px solid rgba(251, 146, 60, 0.4);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-boost-trigger:hover {
  background: rgba(251, 146, 60, 0.1);
  box-shadow: 0 0 12px rgba(251, 146, 60, 0.3);
}

.btn-start-race-main {
  flex: 1.4;
  height: 42px;
  background: linear-gradient(90deg, #16a34a, #22c55e);
  color: #000;
  font-size: 14px;
  font-weight: 900;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-start-race-main:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.7);
}

/* ==========================================================================
   3. GAME ARENA SCREEN
   ========================================================================== */
#screen-game {
  position: relative;
  background: #000;
}

canvas#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.game-top-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
}

.btn-game-back {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid var(--border-dim);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-game-back:hover {
  border-color: var(--neon-green);
  background: #0d170d;
}

/* In-game HUD */
#hud {
  position: absolute;
  top: 12px;
  left: 140px;
  right: 12px;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 10;
}

.hud-card {
  background: rgba(12, 20, 12, 0.85);
  border: 1px solid var(--border-dim);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 110px;
}

.hud-label {
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hud-value {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #fff;
}

.fuel-bar-container {
  width: 120px;
  height: 8px;
  background: #172417;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #223a22;
  margin-top: 2px;
}

.fuel-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #10b981);
  width: 100%;
  transition: width 0.1s linear;
}

/* Touch Controls */
#touch-controls {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 15;
}

.pedal-group {
  display: flex;
  gap: 10px;
}

.pedal-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(12, 20, 12, 0.85);
  border: 2px solid var(--border-dim);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: manipulation;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6);
  transition: transform 0.1s, background 0.1s;
}

.pedal-btn:active, .pedal-btn.active {
  transform: scale(0.92);
  background: rgba(22, 101, 52, 0.9);
  border-color: var(--neon-green);
  box-shadow: 0 0 12px var(--neon-glow);
}

.pedal-btn.brake {
  border-color: #7f1d1d;
}
.pedal-btn.brake:active, .pedal-btn.brake.active {
  background: rgba(153, 27, 27, 0.9);
  border-color: var(--danger);
}

.pedal-btn.boost {
  width: 60px;
  height: 60px;
  border-color: var(--neon-orange);
  color: var(--neon-orange);
  background: rgba(30, 15, 8, 0.85);
}
.pedal-btn.boost:active, .pedal-btn.boost.active {
  background: rgba(249, 115, 22, 0.9);
  color: #fff;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.7);
}

/* ==========================================================================
   4. MODALS & POPUPS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-sheet {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 20px var(--neon-glow);
}

.modal-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 8px;
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}
.btn-close-modal:hover { color: #fff; }

/* Seed phrase display box */
.seed-phrase-box {
  background: #000;
  border: 1px dashed var(--border-bright);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.seed-word-item {
  background: #0d170d;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--neon-green);
  display: flex;
  gap: 4px;
}

.seed-word-num {
  color: #4b5563;
  font-size: 9px;
}

.warning-callout {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: var(--neon-gold);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.4;
}

.auth-tab-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.auth-tab-btn {
  flex: 1;
  padding: 6px 10px;
  background: #000;
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.auth-tab-btn.active {
  background: #166534;
  color: #fff;
  border-color: var(--neon-green);
}

.text-input-field {
  width: 100%;
  background: #000;
  border: 1px solid var(--border-dim);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 6px;
  outline: none;
}
.text-input-field:focus {
  border-color: var(--neon-green);
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #0c140c;
  border: 1px solid var(--neon-green);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.8), 0 0 10px var(--neon-glow);
  display: flex;
  align-items: center;
  gap: 6px;
  animation: toastIn 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
