:root {
  color-scheme: dark;
  /* Official wilco.network palette: Azul Noche #1B2F4B, Arena #D9CDB8, Tinta #10222B, Bruma #EEF3F4 */
  --navy: #1B2F4B;
  --navy-deep: #0D1B2D;
  --navy-2: #24405F;
  --navy-3: #2C4A6B;
  --sand: #D9CDB8;
  --sand-light: #EDE4D3;
  --sand-glow: #EDE4D3;
  --ink: #10222B;
  --mist: #EEF3F4;
  --on-dark: #D3DCE5;
  --teal: #4FD1C5;
  --coral: #FF8A65;
  --white: #FFFFFF;
  --muted: #B6C4D2;
  --fh: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fb: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0D1B2D;
  color: var(--white);
  font-family: var(--fb);
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background-color: #0D1B2D;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--navy-deep);
  touch-action: none;
}

/* Desktop elegant mobile-first showcase frame matching wilco.network hero */
@media (min-width: 540px) and (min-height: 640px) {
  .stage {
    padding: 18px;
    background-image:
      radial-gradient(900px 500px at 80% 10%, rgba(44, 74, 107, 0.55) 0%, transparent 60%),
      linear-gradient(170deg, #1B2F4B 0%, #132338 55%, #0D1B2D 100%);
  }
  .game-shell {
    width: min(440px, calc((100dvh - 36px) * 9 / 16.5));
    height: min(820px, calc(100dvh - 36px));
    border-radius: 28px;
    border: 1px solid rgba(217, 205, 184, 0.24);
    box-shadow:
      0 28px 80px rgba(5, 18, 36, 0.65),
      0 0 0 1px rgba(255, 255, 255, 0.06) inset,
      0 0 60px rgba(217, 205, 184, 0.08);
  }
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.hud-left {
  display: flex;
  justify-content: flex-start;
}

.hud-center {
  display: flex;
  justify-content: center;
}

.hud-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(16, 34, 43, 0.78);
  border: 1px solid rgba(217, 205, 184, 0.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(5, 18, 36, 0.38);
}

.score-pill {
  padding: 0 11px 0 10px;
}

.fin-mini {
  width: 15px;
  height: 19px;
  flex-shrink: 0;
}

.score-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.score-value {
  font-family: var(--fh);
  font-weight: 800;
  font-size: 15px;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.score-sub {
  font-size: 10px;
  color: var(--on-dark);
  font-weight: 500;
}

.combo-badge {
  font-family: var(--fh);
  font-weight: 800;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--sand);
  color: var(--navy);
  margin-left: 2px;
  animation: popIn 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.timer-pill {
  font-family: var(--fh);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  padding: 0 14px;
  gap: 6px;
}

.timer-pill.urgent {
  border-color: rgba(255, 138, 101, 0.78);
  color: #FFD1BF;
  box-shadow: 0 0 18px rgba(255, 138, 101, 0.3);
  animation: pulseUrgent 0.9s ease-in-out infinite;
}

.clock-ico {
  width: 15px;
  height: 15px;
  color: var(--sand);
}

.lives-pill {
  padding: 0 10px;
  gap: 5px;
}

.life-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.life-dot.active {
  background: var(--sand);
  border-color: var(--sand-light);
  box-shadow: 0 0 8px rgba(217, 205, 184, 0.65);
}

.icon-btn {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(217, 205, 184, 0.24);
  background: rgba(16, 34, 43, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--sand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  background: rgba(36, 64, 95, 0.9);
  border-color: rgba(217, 205, 184, 0.5);
}

.icon-btn:active {
  transform: scale(0.93);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

/* ---------- Radio Micro-Bar ---------- */
.radio-bar {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(16, 34, 43, 0.78);
  border: 1px solid rgba(217, 205, 184, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  z-index: 9;
}

.radio-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 8px rgba(79, 209, 197, 0.8);
  flex-shrink: 0;
  animation: blinkRadio 2s infinite;
}

.radio-text {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--on-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

/* ---------- Go-Around Banner ---------- */
.alert-banner {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 16px;
  background: rgba(27, 47, 75, 0.94);
  border: 1px solid rgba(255, 169, 98, 0.65);
  box-shadow: 0 12px 32px rgba(5, 18, 36, 0.48), 0 0 24px rgba(255, 138, 101, 0.2);
  backdrop-filter: blur(10px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
  z-index: 15;
  animation: slideDown 0.25s ease;
}

.alert-tag {
  font-family: var(--fh);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--coral);
}

.alert-banner strong {
  font-family: var(--fh);
  font-size: 15px;
  font-weight: 800;
  color: var(--white);
}

.alert-banner span:last-child {
  font-size: 11.5px;
  color: var(--on-dark);
}

/* ---------- Overlays & Cards ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 18px;
  background: radial-gradient(circle at 50% 45%, rgba(27, 47, 75, 0.56), rgba(13, 27, 45, 0.86));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 20;
  transition: opacity 0.3s ease;
}

.card {
  width: 100%;
  max-width: 368px;
  padding: 24px 22px 20px;
  border-radius: 22px;
  background: linear-gradient(168deg, rgba(27, 47, 75, 0.95) 0%, rgba(19, 35, 56, 0.97) 100%);
  border: 1px solid rgba(217, 205, 184, 0.26);
  box-shadow:
    0 24px 64px rgba(5, 18, 36, 0.58),
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
  text-align: center;
}

/* Official wilco lowercase Figtree 500 + Cola (timón) lockup */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.brand-lockup.compact {
  margin-bottom: 10px;
  gap: 8px;
}

.wilco-fin {
  width: 26px;
  height: 32px;
  display: block;
}

.wilco-word {
  font-family: var(--fh);
  font-weight: 500;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--white);
}

.brand-lockup.compact .wilco-fin {
  width: 21px;
  height: 26px;
}

.brand-lockup.compact .wilco-word {
  font-size: 28px;
}

.eyebrow {
  font-family: var(--fh);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--sand);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.headline {
  font-family: var(--fh);
  font-weight: 800;
  font-size: 29px;
  line-height: 1.13;
  letter-spacing: -0.015em;
  color: var(--white);
  margin-bottom: 10px;
}

.headline em {
  font-style: normal;
  color: var(--sand);
}

.lead {
  font-size: 13.5px;
  line-height: 1.52;
  color: var(--on-dark);
  margin-bottom: 16px;
}

.fleet-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 12px 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  margin-bottom: 18px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-item strong {
  display: block;
  font-family: var(--fh);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}

.legend-item span {
  display: block;
  font-size: 11px;
  color: var(--on-dark);
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.swatch-jet {
  background: var(--sand);
  box-shadow: 0 0 10px rgba(217, 205, 184, 0.72);
}

.swatch-prop {
  background: var(--teal);
  box-shadow: 0 0 10px rgba(79, 209, 197, 0.7);
}

.swatch-heli {
  background: var(--coral);
  box-shadow: 0 0 10px rgba(255, 138, 101, 0.7);
}

/* ---------- Buttons (Exact wilco.network Pill Style) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  font-family: var(--fh);
  font-weight: 800;
  font-size: 14.5px;
  text-decoration: none;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.btn:active {
  transform: scale(0.975);
}

.btn-lg {
  min-height: 50px;
  font-size: 15.5px;
}

/* Primary button matches wilco.network .btn.pri: Arena #D9CDB8 bg + Azul Noche #1B2F4B text */
.btn-pri {
  background: var(--sand);
  color: var(--navy);
  box-shadow: 0 10px 26px rgba(5, 18, 36, 0.28);
}

.btn-pri:hover {
  background: var(--sand-light);
}

.btn-sand {
  background: rgba(217, 205, 184, 0.14);
  border-color: rgba(217, 205, 184, 0.42);
  color: var(--sand-light);
}

.btn-sand:hover {
  background: rgba(217, 205, 184, 0.24);
}

.btn-outline-light {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.35);
  color: var(--white);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--white);
}

.best-pill {
  margin-top: 12px;
  font-size: 12px;
  color: var(--sand);
}

.micro-note {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.45;
  color: #A9B7C5;
}

/* ---------- End Card ---------- */
.rank-badge {
  display: inline-block;
  font-family: var(--fh);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.015em;
  color: var(--white);
  margin-bottom: 4px;
}

.end-summary {
  font-size: 13px;
  color: var(--on-dark);
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat-box {
  padding: 11px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(217, 205, 184, 0.16);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--on-dark);
  font-weight: 600;
}

.stat-num {
  font-family: var(--fh);
  font-weight: 800;
  font-size: 21px;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.stat-num.accent {
  color: var(--sand-light);
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.share-toast {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
}

.hidden {
  display: none !important;
}

@keyframes popIn {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulseUrgent {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes blinkRadio {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes slideDown {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}
