:root {
  --bg: #071018;
  --panel: rgba(15, 23, 42, 0.78);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --barca: #a50044;
  --barca-2: #004d98;
  --madrid-2: #febe10;
  --ink: #0f172a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background: #071018;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

.hud {
  position: relative;
  z-index: 1;
  pointer-events: none;
  min-height: 100%;
}

.hud a,
.hud button,
.hud .overlay-card,
.hud .scoreboard,
.hud .actions,
.hud .match-bottom,
.hud .eco-bar {
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

.header {
  text-align: center;
  padding: 0.85rem 1rem 0.35rem;
}

.header h1 {
  margin: 0.2rem 0;
  font-size: clamp(1.5rem, 3.4vw, 2.2rem);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.65);
}

.header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
}

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

.panel {
  max-width: 640px;
  margin: 0 auto;
  padding: 0.75rem 1rem 1.25rem;
  text-align: center;
}

.overlay-card {
  position: fixed;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  width: min(92vw, 480px);
  margin: 0;
  padding: 1.5rem 1.2rem 1.6rem;
  background: rgba(10, 18, 32, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}

.overlay-card h2 {
  margin: 0 0 1.1rem;
}

.team-pick {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.team {
  width: 150px;
  padding: 1.2rem 1rem;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  transition: transform 0.15s ease;
}

.team:hover {
  transform: translateY(-3px);
}

.team--barca {
  background: linear-gradient(145deg, var(--barca), var(--barca-2));
  color: #fff;
}

.team--madrid {
  background: linear-gradient(145deg, #f8fafc, var(--madrid-2));
  color: #111;
}

.team__crest {
  font-family: system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
}

.hint {
  margin-top: 1.2rem;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: 0.92rem;
  line-height: 1.45;
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: start;
  background: var(--panel);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  margin: 0 auto 0.7rem;
  max-width: 520px;
  backdrop-filter: blur(8px);
}

.score__name {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.score__num {
  font-size: 2.1rem;
  font-weight: bold;
  font-family: system-ui, sans-serif;
}

.score--barca .score__num {
  color: #f472b6;
}

.score--madrid .score__num {
  color: var(--madrid-2);
}

.score-mid {
  padding-top: 1.35rem;
  font-family: system-ui, sans-serif;
  color: var(--muted);
  font-size: 0.82rem;
}

.dots {
  display: flex;
  gap: 0.32rem;
  justify-content: center;
  margin-top: 0.45rem;
  min-height: 12px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #334155;
}

.dot--goal {
  background: #22c55e;
}

.dot--miss {
  background: #ef4444;
}

.role {
  font-family: system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 auto 0.4rem;
  max-width: 520px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.flash {
  position: fixed;
  left: 0;
  right: 0;
  top: 42%;
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: clamp(2.8rem, 12vw, 4.6rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.85), 0 0 40px currentColor;
  z-index: 3;
  transform: scale(0.5);
}

.flash.show-goal {
  opacity: 1;
  color: #fde047;
  animation: flash-boom 0.9s ease;
}

.flash.show-save {
  opacity: 1;
  color: #ffffff;
  animation: flash-boom 0.9s ease;
}

@keyframes flash-boom {
  0% {
    transform: scale(0.4) rotate(-8deg);
    opacity: 0;
  }
  25% {
    transform: scale(1.35) rotate(4deg);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.match-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.6rem 1rem 1rem;
  background: linear-gradient(180deg, transparent, rgba(7, 16, 24, 0.82) 35%);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  margin-bottom: 0.55rem;
}

.actions button {
  font-family: system-ui, sans-serif;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.05rem;
  cursor: pointer;
  background: #e2e8f0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
}

.actions button:hover:not(:disabled) {
  filter: brightness(1.05);
}

.actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.log {
  min-height: 1.3rem;
  color: #cbd5e1;
  font-family: system-ui, sans-serif;
  margin: 0 0 0.7rem;
  font-size: 0.9rem;
  text-shadow: 0 1px 8px #000;
}

.reset {
  font-family: system-ui, sans-serif;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.15rem;
  cursor: pointer;
  background: #64748b;
  color: #fff;
}

.reset:hover {
  filter: brightness(1.08);
}

.final-score {
  font-size: 2.4rem;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  margin: 0.4rem 0 1rem;
}

.equipped-now {
  margin: 0 0 0.85rem;
  font-family: system-ui, sans-serif;
  color: #cbd5e1;
  font-size: 0.92rem;
}

.equipped-now strong {
  color: #fbbf24;
}

.webgl-warn {
  position: fixed;
  left: 50%;
  top: 7.6rem;
  bottom: auto;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  max-width: min(92vw, 440px);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  background: rgba(127, 29, 29, 0.85);
  color: #fecaca;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  text-align: center;
  pointer-events: none;
}

.shop-modal {
  position: fixed;
  inset: 0;
  z-index: 8;
  margin: 0;
  max-width: none;
  background: rgba(2, 6, 23, 0.62);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.shop-modal.hidden {
  display: none !important;
}

.shop-modal__box {
  width: min(92vw, 560px);
  max-height: 86vh;
  overflow: auto;
  background: #132337;
  border-radius: 16px;
  padding: 1.1rem 1rem 1.4rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  position: relative;
}

.shop-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  background: #334155;
  color: #fff;
  font-family: system-ui, sans-serif;
  cursor: pointer;
}

@media (max-width: 520px) {
  .header h1 {
    font-size: 1.35rem;
  }

  .score__num {
    font-size: 1.7rem;
  }

  .match-bottom {
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom));
  }
}
