: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%;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  position: relative;
  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;
}

/* Flex + overflow-y auto + margin:auto on the card: centers when it fits,
   scrolls when it doesn't (grid place-items:center clips the top instead). */
.home-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(4, 9, 14, 0.72);
  backdrop-filter: blur(10px);
}

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

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

.home-card h1 {
  margin: 0 0 10px;
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 0.95;
  color: #fff5bb;
}

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

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

.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-hint {
  margin: 0 0 18px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.4;
}

.home-hint p {
  margin: 0;
}

.home-hint p + p {
  margin-top: 6px;
}

.home-hint strong {
  color: var(--text);
}

.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;
}

.home-buttons {
  display: grid;
}

.start-button {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(135deg, #fff5bb, #ffdb57);
  color: #1a1400;
  font: inherit;
  font-family: "Luckiest Guy", cursive;
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.start-button:active {
  transform: scale(0.98);
}

.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;
  aspect-ratio: 1100 / 680;
  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%);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

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;
}

/* ── 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 {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0;
    border: 0;
    aspect-ratio: auto;
  }

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

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

/* Touch devices: the desktop keyboard card is noise */
@media (pointer: coarse) {
  .controls.card {
    display: none;
  }
}

/* Landscape phones — width > 680px but small height */
@media (orientation: landscape) and (max-height: 700px) {
  .page { width: 100%; padding: 0; }
  .hero { display: none; }
  .layout { gap: 0; }
  .panel--left { display: none; }
  .panel--field {
    border-radius: 0; border: 0; padding: 0;
  }
  .match-scoreboard, .field-topbar { display: none; }
  canvas {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0;
    border: 0;
    aspect-ratio: auto;
  }
}

/* Compact home card for short viewports (landscape phones, ~390px tall).
   Budget at 390px: eyebrow 17 + h1 32 + selects 70 + hint 66 + PLAY 43
   = 228 content + 30 card padding/border + 20 screen padding = ~278px. */
@media (max-height: 500px) {
  .home-screen {
    padding: 10px;
  }

  .home-card {
    padding: 14px 18px;
    border-radius: 18px;
  }

  .home-card .eyebrow {
    margin-bottom: 4px;
    font-size: 0.7rem;
  }

  .home-card h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
  }

  .home-copy {
    display: none;
  }

  .team-selects {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 8px 0;
  }

  .team-selects label {
    gap: 4px;
    font-size: 0.85rem;
  }

  .team-selects select {
    padding: 8px 12px;
    border-radius: 12px;
  }

  .home-hint {
    margin-bottom: 10px;
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .start-button {
    padding: 10px 16px;
    font-size: 1.2rem;
  }
}

/* ── Iframe embed — MUST be last to override all media queries ── */
.in-iframe .hero,
.in-iframe .panel--left,
.in-iframe .match-scoreboard,
.in-iframe .field-topbar { display: none !important; }
.in-iframe .page { width: 100% !important; padding: 0 !important; }
.in-iframe .layout { gap: 0 !important; }
.in-iframe .panel--field {
  border-radius: 0 !important; border: 0 !important; padding: 0 !important;
}
.in-iframe canvas {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  border-radius: 0 !important;
  border: 0 !important;
  aspect-ratio: auto !important;
}
