:root {
  --bg: #09131a;
  --panel: rgba(9, 18, 26, 0.84);
  --panel-strong: rgba(8, 15, 22, 0.96);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f5f7ec;
  --muted: #c1d0d6;
  --yellow: #ffdb57;
  --blue: #57a8ff;
  --red: #ff5f66;
  --grass: #17974a;
  --grass-deep: #0e6f36;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(87, 168, 255, 0.15), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 95, 102, 0.18), transparent 30%),
    linear-gradient(180deg, #071018 0%, #0b1c24 100%);
  color: var(--text);
  font-family: "Outfit", system-ui, sans-serif;
}

.home-screen,
.goal-flash,
.match-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.home-screen {
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 9, 14, 0.72);
  backdrop-filter: blur(10px);
}

.home-screen.hidden {
  display: none;
}

.home-card {
  width: min(720px, 100%);
  padding: 30px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: rgba(7, 15, 22, 0.96);
  box-shadow: var(--shadow);
}

.home-copy {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.02rem;
}

.team-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 22px 0 18px;
}

.team-selects label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.team-selects select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font: inherit;
}

.home-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  color: var(--muted);
}

.home-controls-card {
  margin-bottom: 22px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.home-controls-card h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.goal-flash {
  display: grid;
  place-items: center;
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(4rem, 12vw, 9rem);
  color: #fff5bb;
  letter-spacing: 0.05em;
  text-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  background: radial-gradient(circle, rgba(255, 219, 87, 0.2), rgba(0, 0, 0, 0));
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.goal-flash.show {
  opacity: 1;
  transform: scale(1);
}

.match-overlay {
  display: grid;
  place-items: center;
  gap: 6px;
  background: rgba(4, 9, 14, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.match-overlay.show {
  opacity: 1;
}

.match-overlay__label {
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
}

.match-overlay__text {
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(4rem, 14vw, 9rem);
  color: #fff5bb;
  line-height: 0.9;
  letter-spacing: 0.04em;
  text-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(24px);
}

.bg-glow--one {
  width: 320px;
  height: 320px;
  top: -100px;
  right: -60px;
  background: rgba(255, 219, 87, 0.18);
}

.bg-glow--two {
  width: 280px;
  height: 280px;
  left: -100px;
  bottom: 12%;
  background: rgba(87, 168, 255, 0.14);
}

.page {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: var(--yellow);
  font-size: 0.8rem;
}

.hero h1 {
  margin: 0;
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(3rem, 7vw, 6rem);
  line-height: 0.95;
  color: #fff5bb;
}

.subtitle {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.15rem);
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel--left {
  padding: 22px;
}

.card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
}

.card__tag {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.card h2,
.card h3,
.card p {
  margin-top: 0;
}

.card p:last-child {
  margin-bottom: 0;
}

.score-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0;
}

.score-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.score-box span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.score-box strong {
  display: block;
  margin-top: 8px;
  font-size: 1.3rem;
}

.controls {
  margin-bottom: 18px;
}

.controls p + p {
  margin-top: 8px;
}

.start-button {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fff5bb, #ffdb57);
  color: #1a1400;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.panel--field {
  padding: 18px;
}

.match-scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding: 14px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.match-scoreboard__team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.match-scoreboard__team strong {
  font-size: 1.5rem;
}

.match-scoreboard__center {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.match-scoreboard__center strong {
  font-size: 1.4rem;
}

.match-scoreboard__center span {
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 4px 2px 14px;
}

#banner {
  color: var(--muted);
}

.player-chip {
  color: var(--muted);
  white-space: nowrap;
}

.player-chip strong {
  color: var(--yellow);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, var(--grass) 0%, var(--grass-deep) 100%);
}

kbd {
  display: inline-flex;
  min-width: 28px;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 700;
  color: #fff;
}

/* ── Touch Controls ─────────────────────────────── */
.touch-controls {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.touch-joystick {
  position: absolute;
  left: 16px;
  bottom: 24px;
  pointer-events: auto;
  touch-action: none;
}

.touch-joystick__base {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  position: relative;
}

.touch-joystick__thumb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 219, 87, 0.5);
  border: 2px solid rgba(255, 219, 87, 0.7);
  position: absolute;
  transition: none;
}

.touch-buttons {
  position: absolute;
  right: 16px;
  bottom: 24px;
  display: grid;
  grid-template-areas:
    "pause  shoot"
    "switch shoot"
    "pass   sprint";
  gap: 10px;
  pointer-events: auto;
  touch-action: none;
}

.touch-btn {
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  font: inherit;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.touch-btn:active {
  transform: scale(0.92);
}

.touch-btn--shoot {
  grid-area: shoot;
  width: 76px;
  height: 76px;
  font-size: 0.7rem;
  background: rgba(255, 95, 102, 0.35);
  border-color: rgba(255, 95, 102, 0.5);
}

.touch-btn--pass {
  grid-area: pass;
  background: rgba(87, 168, 255, 0.3);
  border-color: rgba(87, 168, 255, 0.45);
}

.touch-btn--switch {
  grid-area: switch;
  background: rgba(255, 219, 87, 0.25);
  border-color: rgba(255, 219, 87, 0.4);
}

.touch-btn--sprint {
  grid-area: sprint;
  background: rgba(99, 245, 170, 0.25);
  border-color: rgba(99, 245, 170, 0.4);
}

.touch-btn--pause {
  grid-area: pause;
  width: 42px;
  height: 42px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  justify-self: end;
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .page {
    width: 100%;
    padding: 0;
  }

  .hero {
    padding: 12px 16px 0;
  }

  .hero h1 {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .layout {
    gap: 0;
  }

  .panel--left {
    display: none;
  }

  .panel--field {
    border-radius: 0;
    border: 0;
    padding: 8px;
  }

  .match-scoreboard {
    border-radius: 14px;
    padding: 10px 14px;
    gap: 10px;
    font-size: 0.85rem;
  }

  .match-scoreboard__team strong {
    font-size: 1.2rem;
  }

  .match-scoreboard__center strong {
    font-size: 1.1rem;
  }

  .field-topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 4px 2px 8px;
    font-size: 0.82rem;
  }

  canvas {
    border-radius: 14px;
  }

  .home-card {
    padding: 20px;
    border-radius: 22px;
  }

  .home-controls-card {
    display: none;
  }

  .team-selects {
    grid-template-columns: 1fr;
  }
}

/* Show touch controls on touch devices */
@media (pointer: coarse) {
  .touch-controls {
    display: block;
  }

  .controls.card,
  .home-controls-card {
    display: none;
  }
}
