:root {
  --stadium: #07140c;
  --stadium-mid: #102418;
  --gold: #e4c04a;
  --gold-deep: #b8922a;
  --home: #0c2340;
  --away: #8f1d2c;
  --led: #f3e27a;
  --housing: #070907;
  --ink: #e8efe6;
  --ink-soft: #9aaf9c;
  --paper: #f4efe4;
  --panel: #101c14;
  --btn: #e4c04a;
  --btn-ink: #1a1406;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--stadium);
  color: var(--ink);
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
}

body {
  background-image:
    radial-gradient(ellipse at 50% -10%, #1c3d28 0%, transparent 48%),
    repeating-linear-gradient(
      90deg,
      rgba(228, 192, 74, 0.035) 0 2px,
      transparent 2px 18px
    );
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(min-content, 1fr) auto minmax(min-content, 1fr);
  align-items: center;
  gap: 16px;
  padding: 14px 28px 10px;
  background: #06110b;
  border-bottom: 3px solid var(--gold);
}

.brand {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.brand-mark {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  transform: rotate(-16deg) scaleX(-1);
  filter: drop-shadow(0 3px 0 rgba(6, 17, 11, 0.7));
}

.brand-copy .brand-kicker {
  margin-bottom: 2px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-kicker,
.eyebrow,
.meta-label,
.score-role {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.brand h1,
.panel h2 {
  margin: 0;
  font-family: "Anton", "Impact", sans-serif;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand h1 {
  color: #f7f4ea;
  font-size: 30px;
  line-height: 1;
}

.scoreboard {
  display: flex;
  align-items: stretch;
  min-width: 460px;
  background: var(--housing);
  color: #f7f4ea;
  border: 3px solid #1c1c1c;
  outline: 2px solid var(--gold-deep);
}

.score-side {
  padding: 8px 16px 10px;
  min-width: 118px;
  background: var(--home);
}

.score-side.away {
  background: var(--away);
  text-align: right;
}

.score-role {
  display: block;
  margin-bottom: 2px;
}

.score-who {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 16px;
}

.score-side.away .score-who {
  justify-content: flex-end;
}

.score-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.poss-icon {
  width: 13px;
  height: 13px;
  display: none;
  flex-shrink: 0;
}

.score-side.has-ball .poss-icon {
  display: block;
}

.score-num {
  display: block;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700;
  font-size: 40px;
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: var(--led);
}

.score-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0;
  min-width: 148px;
  padding: 8px 12px;
  background: #050605;
}

.score-meta .meta-label {
  margin-bottom: 2px;
}

#clock {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--led);
  line-height: 1;
}

#period {
  margin-top: 4px;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f7f4ea;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: max-content;
}

.text-btn,
.primary-btn,
.fg-btn {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  border: 0;
  cursor: pointer;
}

.text-btn {
  background: transparent;
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 10px;
}

.text-btn:hover,
.primary-btn:hover,
.fg-btn:hover {
  filter: brightness(1.08);
}

.primary-btn {
  background: var(--btn);
  color: var(--btn-ink);
  font-size: 16px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 20px;
}

.stage-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 24px 28px;
}

#stage {
  position: relative;
  width: min(1100px, 100%);
}

#game {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
  cursor: crosshair;
  touch-action: none;
}

.hint {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 16px;
  margin: 0;
  text-align: center;
  color: #f7f4ea;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #06110b;
  pointer-events: none;
}

.play-call {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Anton", "Impact", sans-serif;
  font-size: clamp(44px, 8vw, 88px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(6, 17, 11, 0.32);
  pointer-events: none;
}

.fg-btn {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  background: var(--gold);
  color: var(--btn-ink);
  padding: 10px 16px;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 12, 8, 0.78);
  z-index: 10;
}

#rules-overlay {
  z-index: 12;
}

.overlay[hidden] {
  display: none;
}

.panel {
  width: min(760px, 100%);
  background: var(--panel);
  color: var(--ink);
  padding: 32px 36px 28px;
  border: 2px solid var(--gold-deep);
  outline: 1px solid rgba(228, 192, 74, 0.25);
}

.panel h2 {
  font-size: 48px;
  margin-bottom: 10px;
  color: #f7f4ea;
}

.panel .eyebrow {
  color: var(--gold);
}

.lede {
  margin: 0 0 24px;
  font-size: 20px;
  font-weight: 400;
  max-width: 38em;
  color: #d5ddd4;
}

fieldset {
  border: 1px solid #3a5340;
  margin: 0 0 16px;
  padding: 12px 14px 14px;
}

legend {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
}

input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  border: 2px solid #8a7434;
  border-radius: 50%;
  background: #0c1610;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

input[type="radio"]:hover {
  border-color: var(--gold);
}

input[type="radio"]:checked {
  border-color: var(--gold);
  background:
    radial-gradient(circle at 50% 50%, var(--gold) 0 3.5px, #0c1610 4.5px 100%);
}

input[type="radio"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.menu-panel {
  max-width: 520px;
}

.menu-rules {
  margin: 18px 0 0;
  font-size: 16px;
  color: var(--ink-soft);
}

.text-btn.ink {
  color: var(--gold);
  padding: 0;
}

.rules-panel {
  max-width: 860px;
  max-height: min(90vh, 820px);
  overflow: auto;
}

.rules-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 18px 0 24px;
}

.rules-cols h3 {
  margin: 0 0 8px;
  font-family: "Anton", sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold);
}

.rules-cols ul {
  margin: 0;
  padding-left: 18px;
  color: #d5ddd4;
}

.rules-cols li + li {
  margin-top: 8px;
}

.coin-panel {
  max-width: 420px;
  text-align: center;
}

.coin-stage {
  --coin: 96px;
  --coin-r: 48px;
  --coin-t: 14px;
  width: var(--coin);
  height: var(--coin);
  margin: 28px auto 26px;
  position: relative;
  perspective: 760px;
}

.coin-toss {
  width: var(--coin);
  height: var(--coin);
  position: relative;
  z-index: 1;
  transform-style: preserve-3d;
  transform: rotateX(8deg);
}

.coin {
  width: var(--coin);
  height: var(--coin);
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
}

.coin.is-flipping-heads {
  animation: coin-spin-heads 2.2s cubic-bezier(0.12, 0.55, 0.18, 1) forwards;
}

.coin.is-flipping-tails {
  animation: coin-spin-tails 2.2s cubic-bezier(0.12, 0.55, 0.18, 1) forwards;
}

.coin-stage.is-tossing .coin-toss {
  animation: coin-toss 2.2s linear forwards;
}

.coin-stage.is-tossing .coin-shadow {
  animation: coin-shadow 2.2s cubic-bezier(0.22, 0.72, 0.28, 1) forwards;
}

@keyframes coin-spin-heads {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(1800deg);
  }
}

@keyframes coin-spin-tails {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(1980deg);
  }
}

@keyframes coin-toss {
  0% {
    transform: rotateX(8deg) translateY(0);
    animation-timing-function: cubic-bezier(0.2, 0.75, 0.3, 1);
  }
  42% {
    transform: rotateX(58deg) translateY(-44px);
    animation-timing-function: cubic-bezier(0.55, 0, 0.75, 0.35);
  }
  100% {
    transform: rotateX(8deg) translateY(0);
  }
}

@keyframes coin-shadow {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 0.42;
  }
  22% {
    transform: translateX(-50%) scale(0.55);
    opacity: 0.18;
  }
  68% {
    transform: translateX(-50%) scale(0.88);
    opacity: 0.32;
  }
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Anton", sans-serif;
  font-size: 38px;
  color: #3a2a10;
  z-index: 2;
  backface-visibility: hidden;
  transform: translateZ(8px);
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 248, 220, 0.7), transparent 42%),
    radial-gradient(circle at 72% 78%, rgba(92, 66, 12, 0.32), transparent 48%),
    var(--gold);
  box-shadow:
    inset 0 0 0 7px rgba(184, 146, 42, 0.42),
    inset 0 0 0 9px rgba(255, 236, 170, 0.28),
    inset 0 3px 5px rgba(255, 255, 240, 0.28),
    inset 0 -4px 6px rgba(80, 55, 10, 0.28);
}

.coin-face::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(90, 66, 14, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 236, 180, 0.22);
  pointer-events: none;
}

.coin-face span {
  position: relative;
  line-height: 1;
  text-shadow:
    0 1px 0 rgba(255, 242, 190, 0.7),
    0 -1px 0 rgba(80, 55, 10, 0.4);
}

.coin-face.tails {
  transform: rotateY(180deg) translateZ(8px);
  color: #2a2a2a;
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.55), transparent 42%),
    radial-gradient(circle at 72% 78%, rgba(50, 48, 42, 0.28), transparent 48%),
    #d4cfc0;
  box-shadow:
    inset 0 0 0 7px rgba(120, 114, 98, 0.38),
    inset 0 0 0 9px rgba(236, 232, 220, 0.3),
    inset 0 3px 5px rgba(255, 255, 255, 0.28),
    inset 0 -4px 6px rgba(40, 38, 32, 0.22);
}

.coin-face.tails::after {
  border-color: rgba(70, 66, 56, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.coin-edge {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  pointer-events: none;
}

.coin-edge span {
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  background: #b8922a;
  box-shadow: inset 0 0 0 1px rgba(70, 52, 10, 0.35);
}

.coin-shadow {
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 72px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  filter: blur(5px);
  transform: translateX(-50%);
  opacity: 0.42;
}

.coin-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.coin-result {
  min-height: 1.4em;
  margin: 16px 0 0;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.end-panel {
  max-width: 420px;
  text-align: center;
}

#end-score {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700;
  color: var(--led);
  font-size: 22px;
  letter-spacing: 0.06em;
}

.coin-actions .primary-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .scoreboard {
    min-width: 0;
    width: 100%;
  }

  .top-actions {
    justify-content: center;
  }

  .rules-cols {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 24px 20px;
  }
}
