:root {
  color-scheme: dark;
  font:
    14px/1.45 system-ui,
    sans-serif;
  color: #e6edf0;
  background: #0b1a10;
  --panel: #0d1720e8;
  --line: #2a3a46;
  --muted: #8a9ba6;
  --gold: #ffd666;
  --red: #e5484d;
  --blue: #3e8ef7;
}
[hidden] {
  display: none !important;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
  background: #0b1a10;
}
#game {
  display: block;
  width: 100vw;
  height: 100dvh;
  outline: none;
  touch-action: none;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.muted {
  color: var(--muted);
}
kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid #4a5a66;
  border-bottom-width: 2px;
  border-radius: 4px;
  font:
    600 11px/1.5 ui-monospace,
    Menlo,
    monospace;
  color: #fff;
  background: #1a2630;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px max(12px, env(safe-area-inset-bottom, 0px));
}
.top-left {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 16px;
  display: grid;
  gap: 4px;
}
.scoreboard {
  display: flex;
  align-items: stretch;
  height: 40px;
  font-weight: 900;
  letter-spacing: 0.5px;
  transform: skewX(-8deg);
  box-shadow: 0 4px 18px #0006;
}
.scoreboard > * {
  display: grid;
  place-items: center;
  padding: 0 12px;
}
.team {
  font-size: 18px;
  color: #fff;
}
.team.red {
  background: var(--red);
}
.team.blue {
  background: var(--blue);
}
.score {
  min-width: 78px;
  font-size: 22px;
  color: #0d1720;
  background: #f4f7f5;
}
.clock {
  font-size: 20px;
  background: #0d1720;
}
.half {
  font-size: 11px;
  background: #0d1720;
  color: var(--muted);
  padding-left: 0;
}
.managers {
  display: flex;
  gap: 10px;
  align-items: center;
  width: fit-content;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel);
  border-radius: 4px;
}
.mgr::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
}
.mgr.red {
  color: #ff8a8e;
}
.mgr.blue {
  color: #8dbcff;
}

.live {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: 16px;
  display: flex;
  gap: 6px;
}
.tile {
  display: grid;
  min-width: 84px;
  padding: 5px 10px;
  background: var(--panel);
  border-left: 3px solid var(--gold);
  transform: skewX(-8deg);
}
.tile b {
  font-size: 20px;
  line-height: 1.1;
  color: var(--gold);
}
.tile span {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

/* Super shot meters, one per team, under the managers. */
.meters {
  display: flex;
  gap: 8px;
}
.meter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--panel);
  border-radius: 4px;
}
.meter .label {
  font-size: 9px;
}
.track {
  width: 78px;
  height: 7px;
  overflow: hidden;
  background: #24323c;
  border-radius: 99px;
}
.track div {
  width: 0;
  height: 100%;
  border-radius: 99px;
  transition: width 0.25s;
}
.meter.red .track div {
  background: var(--red);
}
.meter.blue .track div {
  background: var(--blue);
}
.meter .track div.full {
  background: linear-gradient(90deg, #ffd666, #ff8a3d, #ffd666);
  background-size: 200% 100%;
  animation: blaze 0.6s linear infinite;
  box-shadow: 0 0 10px #ff8a3d;
}
@keyframes blaze {
  to {
    background-position: -200% 0;
  }
}
.sinbin {
  width: fit-content;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #ffb3b3;
  background: var(--panel);
  border-left: 3px solid var(--red);
  border-radius: 4px;
}

/* The referee's card. */
.ref-card {
  position: absolute;
  top: 30%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  translate: -50% 0;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 12px 40px #000a;
  animation: card-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.ref-card-face {
  width: 46px;
  height: 64px;
  border-radius: 6px;
  rotate: -8deg;
  box-shadow: 0 4px 12px #0008;
}
.ref-card-face.yellow {
  background: #ffd23f;
}
.ref-card-face.red {
  background: #e5484d;
}
.ref-card-face.none {
  display: none;
}
.ref-card-text {
  display: grid;
}
.ref-card-text strong {
  font-size: 26px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
}
.ref-card-text span {
  color: #c9d4da;
}
@keyframes card-in {
  from {
    opacity: 0;
    scale: 0.6;
  }
}

/* The goal celebration: a band in the scorers' colour swipes across the pitch. */
.celebrate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.celebrate-band {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 140%;
  padding: 18px 0 22px;
  transform: skewY(-6deg);
  background: var(--team, var(--red));
  box-shadow:
    0 0 0 6px #ffffff22,
    0 20px 60px #000a;
  animation: swipe 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.celebrate-band > * {
  transform: skewY(6deg);
}
.celebrate-goal {
  font-size: clamp(56px, 12vw, 140px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.95;
  letter-spacing: -2px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 6px 0 #0004;
  animation: pop 0.5s 0.15s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.celebrate-who {
  display: flex;
  align-items: center;
  gap: 10px;
}
.celebrate-number {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 900;
  color: var(--team, var(--red));
  background: #fff;
}
.celebrate-name {
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 900;
  text-transform: uppercase;
  color: #fff;
}
.celebrate-line {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  opacity: 0.9;
}
.celebrate-score {
  margin-top: 4px;
  padding: 2px 14px;
  font-size: 20px;
  font-weight: 900;
  color: #0d1720;
  background: #fff;
}
@keyframes swipe {
  from {
    translate: -110% 0;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    scale: 1.8;
  }
}

/* The breakaway cut-in: striker and keeper face off in two slanted panels. */
.cutin {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0;
  padding: 16px;
  pointer-events: none;
  background: #050c08b3;
}
.cutin-panel {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 28px 12px;
  color: #fff;
  background: var(--team, #444);
  transform: skewX(-10deg);
  box-shadow: 0 20px 60px #000a;
}
.cutin-panel > * {
  transform: skewX(10deg);
}
.cutin-panel.attacker {
  animation: from-left 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.cutin-panel.keeper {
  animation: from-right 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.cutin-number {
  display: grid;
  place-items: center;
  width: clamp(64px, 12vw, 120px);
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: clamp(30px, 6vw, 60px);
  font-weight: 900;
  color: #10161b;
  background: #fff;
  box-shadow: 0 0 0 6px #ffffff44;
}
.cutin-name {
  font-size: clamp(22px, 5vw, 52px);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
}
.cutin-role {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.85;
}
.cutin-vs {
  padding: 0 14px;
  font-size: clamp(18px, 3.4vw, 34px);
  font-weight: 900;
  font-style: italic;
  text-align: center;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 4px 0 #0008;
  animation: pop 0.4s 0.2s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes from-left {
  from {
    translate: -120% 0;
  }
}
@keyframes from-right {
  from {
    translate: 120% 0;
  }
}

/* Less motion: the cut-in, cards and celebration just appear. */
@media (prefers-reduced-motion: reduce) {
  .celebrate-band,
  .celebrate-goal,
  .cutin-panel,
  .cutin-vs,
  .ref-card,
  .track div.full {
    animation: none;
  }
}

/* The lower-third: one decision, its odds. */
.card {
  position: absolute;
  left: 16px;
  bottom: max(44px, calc(env(safe-area-inset-bottom, 0px) + 36px));
  width: min(440px, calc(100% - 32px));
  background: var(--panel);
  box-shadow: 0 8px 30px #0008;
}
.card-tag {
  position: absolute;
  top: -20px;
  left: 0;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #10161b;
  background: var(--gold);
}
.card-main {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  padding-right: 14px;
}
.card-number {
  display: grid;
  place-items: center;
  height: 52px;
  font-size: 26px;
  font-weight: 900;
  color: #fff;
}
.card-name strong {
  display: block;
  font-size: 20px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-name span {
  font-size: 11px;
  color: var(--muted);
}
.card-call {
  font-size: 22px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  color: var(--gold);
}
.card-options {
  margin: 0;
  padding: 6px 14px 10px;
  list-style: none;
  display: grid;
  gap: 4px;
}
.card-options li {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(60px, 1fr) 40px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: #c9d4da;
}
.card.you .card-options li {
  display: block;
}
.opt {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.opt b {
  font-weight: 700;
}
.opt i {
  margin-left: 6px;
  font-style: normal;
  color: var(--muted);
}
.bar {
  height: 5px;
  background: #24323c;
}
.bar span {
  display: block;
  height: 100%;
  background: #607380;
}
.chosen {
  color: #fff;
}
.chosen .bar span {
  background: var(--gold);
}
.pct {
  text-align: right;
}
.chosen .pct {
  color: var(--gold);
}

.plan-card {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 50%;
  translate: -50% 0;
  width: min(340px, calc(100% - 32px));
  padding: 10px 14px 12px;
  background: var(--panel);
  border-top: 3px solid var(--gold);
  animation: drop 0.3s ease-out;
}
.plan-head {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.plan-shout {
  margin: 2px 0;
  font-size: 18px;
  font-weight: 900;
}
.plan-why {
  font-size: 12px;
  color: #c9d4da;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.chips span {
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  color: #10161b;
  background: var(--gold);
}

.ticker {
  position: absolute;
  left: 50%;
  bottom: max(44px, calc(env(safe-area-inset-bottom, 0px) + 36px));
  transform: translateX(-50%);
  max-width: min(480px, calc(100% - 32px));
  padding: 8px 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--panel);
  border-top: 3px solid var(--gold);
}
.banner {
  position: absolute;
  top: 38%;
  text-align: center;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(32px, 7vw, 84px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow:
    0 4px 0 #0008,
    0 0 40px #0006;
  white-space: nowrap;
}
.keys-hint {
  position: absolute;
  right: 16px;
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 14px;
  max-width: calc(100% - 32px);
  font-size: 11px;
  color: #b9c6cd;
  text-shadow: 0 1px 2px #000;
}

/* Touchline: the manager's panel. */
.tactics {
  position: absolute;
  top: 116px;
  right: 16px;
  bottom: 16px;
  width: 270px;
  overflow-y: auto;
  padding: 12px;
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tactics-head {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}
.speed,
.choices,
.levels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.speed button,
.choices button,
.levels button {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  background: #16222b;
}
.speed button.on,
.choices button.on,
.levels button.on {
  border-color: var(--gold);
  color: #10161b;
  background: var(--gold);
}
.tactic {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}
.tactic-groups {
  margin: 4px 0 8px;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: #050c08a6;
}
#title.overlay {
  background: linear-gradient(180deg, #050c0866, #050c08cc);
}
.dialog {
  display: grid;
  gap: 12px;
  justify-items: center;
  width: min(420px, 100%);
  padding: 24px;
  text-align: center;
  background: #0d1720f2;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 60px #000a;
}
.dialog.wide {
  width: min(620px, 100%);
}
h1 {
  margin: 0;
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -1px;
  line-height: 1;
  text-transform: uppercase;
}
h1 span {
  color: var(--gold);
}
h2,
h3 {
  margin: 0;
}
.lede {
  margin: 0;
  max-width: 46ch;
  color: #c9d4da;
}
.modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  width: 100%;
}
.mode {
  display: grid;
  gap: 4px;
  padding: 14px;
  text-align: left;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #121e27;
}
.mode strong {
  font-size: 20px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
}
.mode span {
  color: #c9d4da;
}
.mode small {
  color: var(--muted);
}
.mode.on {
  border-color: var(--gold);
  background: #1b2730;
}
.mode.on strong {
  color: var(--gold);
}
.levels {
  align-items: center;
}
.primary,
.ghost {
  min-width: 220px;
  padding: 11px 22px;
  border-radius: 8px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.primary {
  border: 0;
  color: #10161b;
  background: var(--gold);
}
.ghost {
  border: 1px solid var(--line);
  background: transparent;
}
.big-score {
  font-size: 48px;
  font-weight: 900;
}
.report {
  margin: 0;
  padding: 0 0 0 18px;
  display: grid;
  gap: 6px;
  text-align: left;
  color: #d6dfe4;
}
.their {
  color: #8dbcff;
}
#halftime .tactic-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 4px 16px;
  width: 100%;
  text-align: left;
}
.stats {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 4px 24px;
  margin: 0;
}
.stats dt {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}
.stats dd {
  margin: 0;
  text-align: right;
}
.stats dd:nth-child(3n + 1) {
  text-align: left;
  font-family: system-ui, sans-serif;
  color: var(--muted);
}

@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* A phone: the tiles and the plan card shrink, and Touchline's panel moves under the pitch. */
@media (max-width: 760px) {
  .live {
    display: none;
  }
  .keys-hint {
    display: none;
  }
  .tactics {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 38dvh;
  }
  .plan-card {
    top: 96px;
  }
  /* On a phone in Touchline the panel has the bottom: the lower-third gives way. */
  #hud[data-mode='touchline'] .card {
    display: none;
  }
  .card {
    bottom: 54px;
  }
}

/* Online: the menu and the lobby. */
.join {
  display: flex;
  gap: 6px;
}
.join input {
  width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font:
    700 16px ui-monospace,
    Menlo,
    monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  background: #16222b;
}
.join .ghost {
  min-width: 0;
}
.error {
  color: #ff8a80;
}
.share {
  display: grid;
  gap: 8px;
  justify-items: center;
  width: 100%;
}
.share code {
  max-width: 100%;
  padding: 8px 10px;
  overflow-wrap: anywhere;
  font-size: 12px;
  border-radius: 6px;
  background: #16222b;
}
.banner small {
  display: block;
  font-size: 0.32em;
  font-style: normal;
  letter-spacing: 0.5px;
  text-transform: none;
}

/* Waiting in a room, over a warm-up match. */
.waitbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  max-width: calc(100% - 32px);
  padding: 7px 12px;
  font-size: 13px;
  white-space: nowrap;
  font-weight: 700;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 14px;
}
.waitbar .ghost {
  min-width: 0;
  padding: 3px 10px;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.waitbar-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  animation: waitbar-pulse 1.2s ease-in-out infinite;
}
@keyframes waitbar-pulse {
  50% {
    opacity: 0.25;
  }
}
@media (prefers-reduced-motion: reduce) {
  .waitbar-dot {
    animation: none;
  }
}
