:root {
  color-scheme: dark;
  --ink: #f3f7f7;
  --muted: #94a5ad;
  --panel: rgba(4, 13, 20, 0.78);
  --panel-strong: rgba(4, 12, 19, 0.94);
  --line: rgba(255, 255, 255, 0.14);
  --home: #16d6c6;
  --away: #ff365f;
  --gold: #f0c766;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #071019;
  color: var(--ink);
}

button,
canvas { -webkit-tap-highlight-color: transparent; }

button { font: inherit; }

#game-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 480px;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(circle at 50% 30%, #17342c, #071019 64%);
}

#match-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

#game-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.24), transparent 20%, transparent 76%, rgba(0, 0, 0, 0.28)),
    radial-gradient(circle at center, transparent 58%, rgba(0, 5, 10, 0.18));
}

.glass-panel {
  background: linear-gradient(145deg, rgba(10, 24, 32, 0.9), rgba(3, 10, 16, 0.73));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(15px) saturate(1.2);
}

.scoreboard {
  position: absolute;
  z-index: 8;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  display: grid;
  grid-template-columns: minmax(96px, 170px) 46px 86px 46px minmax(96px, 170px);
  align-items: stretch;
  min-height: 52px;
  transform: translateX(-50%);
  background: rgba(3, 11, 17, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.36);
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%);
}

.score-team {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.score-team--away { justify-content: flex-end; }
.team-short { display: none; }

.kit-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 14px currentColor;
}

.kit-dot--home { color: var(--home); background: var(--home); }
.kit-dot--away { color: var(--away); background: var(--away); }

.score-value {
  display: grid;
  place-items: center;
  min-width: 46px;
  background: rgba(255, 255, 255, 0.09);
  font-size: 24px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.match-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: #edf3ee;
  color: #0a1518;
  font-variant-numeric: tabular-nums;
}

.match-clock span { font-size: 8px; font-weight: 900; letter-spacing: 0.16em; }
.match-clock time { font-size: 15px; font-weight: 900; letter-spacing: 0.035em; }

.match-banner {
  position: absolute;
  z-index: 7;
  top: 83px;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 260px;
  padding: 7px 26px 9px;
  transform: translate(-50%, -12px);
  opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(3, 12, 18, 0.92) 16%, rgba(3, 12, 18, 0.92) 84%, transparent);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.match-banner.is-visible { opacity: 1; transform: translate(-50%, 0); }
.match-banner span { color: var(--gold); font-size: 8px; font-weight: 900; letter-spacing: 0.28em; }
.match-banner strong { margin-top: 2px; font-size: 14px; font-weight: 900; letter-spacing: 0.08em; }

.match-info {
  position: absolute;
  z-index: 6;
  top: max(21px, env(safe-area-inset-top));
  left: 20px;
  width: 240px;
  padding: 13px 14px;
  border-radius: 10px;
}

.possession-row {
  display: grid;
  grid-template-columns: auto 32px 1fr 32px;
  gap: 7px;
  align-items: center;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.possession-row strong { color: var(--ink); font-size: 10px; text-align: center; }
.possession-track { height: 4px; overflow: hidden; border-radius: 999px; background: var(--away); }
.possession-track i { display: block; width: 50%; height: 100%; background: var(--home); transition: width 350ms ease; }

.event-feed {
  display: grid;
  gap: 4px;
  max-height: 70px;
  margin: 10px 0 0;
  padding: 9px 0 0;
  overflow: hidden;
  list-style: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.event-feed li {
  overflow: hidden;
  color: #c6d1d5;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-feed li:first-child { color: #fff; }
.event-feed time { margin-right: 7px; color: var(--gold); font-weight: 800; }

.icon-button {
  position: absolute;
  z-index: 9;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(3, 12, 18, 0.78);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.sound-toggle { top: max(21px, env(safe-area-inset-top)); right: 20px; }
.help-toggle { top: max(67px, calc(env(safe-area-inset-top) + 46px)); right: 20px; font-weight: 900; }
.icon-button:hover { border-color: rgba(255, 255, 255, 0.45); background: rgba(12, 27, 35, 0.92); }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.sound-off { display: none; }
.sound-toggle[aria-pressed="true"] .sound-on { display: none; }
.sound-toggle[aria-pressed="true"] .sound-off { display: block; }

.controls-panel {
  position: absolute;
  z-index: 8;
  top: max(113px, calc(env(safe-area-inset-top) + 92px));
  right: 20px;
  width: 220px;
  padding: 14px;
  border-radius: 10px;
  transform: translateX(calc(100% + 30px));
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  pointer-events: none;
}

.controls-panel.is-visible { transform: translateX(0); opacity: 1; pointer-events: auto; }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.panel-heading span { font-size: 10px; font-weight: 900; letter-spacing: 0.16em; }
.panel-heading small { color: var(--muted); font-size: 8px; }
.controls-panel dl { display: grid; gap: 6px; margin: 10px 0 0; }
.controls-panel dl div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.controls-panel dt { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: 0.1em; }
.controls-panel dd { margin: 0; font-size: 9px; font-weight: 700; }

.player-hud {
  position: absolute;
  z-index: 6;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 22px;
  display: grid;
  grid-template-columns: 52px minmax(150px, 220px) auto;
  min-height: 54px;
  overflow: hidden;
  background: linear-gradient(100deg, rgba(4, 15, 21, 0.94), rgba(5, 17, 25, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow);
  clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 50%, calc(100% - 13px) 100%, 0 100%);
}

.player-number { display: grid; place-items: center; background: var(--home); color: #031411; font-size: 23px; font-weight: 950; }
.player-copy { display: grid; align-content: center; gap: 7px; padding: 0 14px; }
.player-copy > div:first-child { display: flex; align-items: baseline; gap: 8px; }
.player-copy strong { font-size: 12px; letter-spacing: 0.06em; }
.player-copy #player-role { color: var(--home); font-size: 9px; font-weight: 900; }
.stamina { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 7px; }
.stamina span { color: var(--muted); font-size: 7px; font-weight: 800; letter-spacing: 0.1em; }
.stamina i { display: block; width: 100%; height: 3px; overflow: hidden; background: rgba(255, 255, 255, 0.12); }
.stamina b { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #f1c260, var(--home)); transition: width 150ms linear; }
.possession-state { display: grid; min-width: 86px; place-items: center; padding: 0 18px 0 10px; border-left: 1px solid var(--line); color: var(--gold); font-size: 8px; font-weight: 900; letter-spacing: 0.09em; }
.possession-state.is-defending { color: #bbc8cd; }

.radar {
  position: absolute;
  z-index: 6;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  width: 228px;
  height: 140px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  box-shadow: var(--shadow);
  opacity: 0.9;
}

.overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  visibility: hidden;
  place-items: center;
  opacity: 0;
  transition: opacity 280ms ease, visibility 280ms;
}

.overlay--visible { visibility: visible; opacity: 1; }
.overlay-backdrop { position: absolute; inset: 0; background: radial-gradient(circle at 50% 42%, rgba(9, 44, 37, 0.58), rgba(2, 8, 12, 0.9)); backdrop-filter: blur(9px); }
.start-card,
.menu-card { position: relative; width: min(680px, calc(100vw - 34px)); text-align: center; }
.start-card { padding: 35px 38px 30px; background: linear-gradient(145deg, rgba(5, 20, 25, 0.84), rgba(3, 9, 15, 0.56)); border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 30px 100px rgba(0, 0, 0, 0.58); }
.eyebrow { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--gold); font-size: 9px; font-weight: 900; letter-spacing: 0.28em; }
.eyebrow span { width: 44px; height: 1px; background: currentColor; }
h1 { margin: 7px 0 0; font-size: clamp(54px, 9vw, 94px); line-height: 0.94; font-weight: 950; letter-spacing: -0.065em; text-shadow: 0 0 45px rgba(22, 214, 198, 0.2); }
.tagline { margin: 10px 0 26px; color: #b5c2c6; font-size: 13px; letter-spacing: 0.055em; }
.fixture { display: grid; grid-template-columns: 1fr 110px 1fr; align-items: center; padding: 22px 10px; border-block: 1px solid rgba(255, 255, 255, 0.11); }
.fixture-team { display: grid; justify-items: center; gap: 7px; }
.fixture-team strong { font-size: 14px; }
.fixture-team small,
.fixture-center span,
.fixture-center small { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: 0.14em; }
.crest { display: grid; width: 58px; height: 67px; place-items: center; clip-path: polygon(50% 0, 93% 18%, 88% 75%, 50% 100%, 12% 75%, 7% 18%); font-size: 16px; font-weight: 950; }
.crest--home { background: var(--home); color: #041914; }
.crest--away { background: var(--away); color: #fff; }
.fixture-center { display: grid; justify-items: center; gap: 5px; }
.fixture-center strong { font-size: 27px; font-style: italic; }
.primary-button,
.secondary-button { min-width: 230px; min-height: 48px; padding: 0 22px; border: 0; font-weight: 950; letter-spacing: 0.1em; cursor: pointer; }
.primary-button { margin-top: 25px; background: var(--home); color: #031411; box-shadow: 0 10px 35px rgba(22, 214, 198, 0.25); }
.primary-button:hover { background: #64f2e3; transform: translateY(-1px); }
.primary-button kbd { margin-left: 18px; padding: 3px 6px; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 3px; font-size: 8px; }
.secondary-button { display: block; margin: 10px auto 0; border: 1px solid rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.05); color: #fff; }
.start-hint { margin: 15px 0 0; color: #879ba2; font-size: 9px; }
.touch-hint { display: none; }
.menu-card { max-width: 480px; padding: 42px; background: var(--panel-strong); border: 1px solid var(--line); box-shadow: var(--shadow); }
.menu-card h2 { margin: 9px 0 4px; font-size: 35px; letter-spacing: -0.04em; }
.final-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 22px; margin: 26px 0 10px; }
.final-score span { color: var(--muted); font-weight: 900; letter-spacing: 0.14em; }
.final-score strong { font-size: 42px; font-variant-numeric: tabular-nums; }
.fulltime-card p { color: var(--muted); font-size: 12px; }

.touch-controls { display: none; }
noscript { position: absolute; z-index: 100; inset: 0; display: grid; place-items: center; background: #071019; }

@media (max-width: 980px) {
  .match-info { top: 82px; }
  .scoreboard { grid-template-columns: 76px 40px 74px 40px 76px; }
  .team-full { display: none; }
  .team-short { display: inline; }
  .radar { width: 190px; height: 116px; }
  .player-hud { grid-template-columns: 46px minmax(128px, 180px); }
  .possession-state { display: none; }
}

@media (max-width: 680px) {
  .scoreboard { top: max(8px, env(safe-area-inset-top)); min-height: 44px; grid-template-columns: 60px 34px 67px 34px 60px; }
  .score-team { gap: 5px; padding: 0 7px; font-size: 10px; }
  .score-value { min-width: 34px; font-size: 19px; }
  .match-clock time { font-size: 12px; }
  .match-info { display: none; }
  .sound-toggle { top: max(60px, calc(env(safe-area-inset-top) + 51px)); right: 10px; }
  .help-toggle { top: max(103px, calc(env(safe-area-inset-top) + 94px)); right: 10px; }
  .controls-panel { top: 147px; right: 10px; }
  .match-banner { top: 60px; }
  .player-hud { bottom: max(12px, env(safe-area-inset-bottom)); left: 10px; min-height: 46px; grid-template-columns: 40px 135px; }
  .player-number { font-size: 18px; }
  .player-copy { padding: 0 9px; }
  .player-copy strong { font-size: 9px; }
  .radar { bottom: max(68px, calc(env(safe-area-inset-bottom) + 56px)); width: 152px; height: 92px; }
  .start-card { padding: 28px 18px 24px; }
  h1 { font-size: clamp(44px, 15vw, 67px); }
  .fixture { grid-template-columns: 1fr 72px 1fr; padding-inline: 0; }
  .crest { width: 48px; height: 55px; }
  .fixture-team strong { font-size: 11px; }
  .start-hint { line-height: 1.5; }
}

@media (hover: none) and (pointer: coarse) {
  .touch-controls { position: absolute; z-index: 12; inset: auto 0 max(14px, env(safe-area-inset-bottom)) 0; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 18px; pointer-events: none; }
  .touch-stick { position: relative; width: 106px; height: 106px; border: 1px solid rgba(255, 255, 255, 0.24); border-radius: 50%; background: rgba(2, 9, 14, 0.42); pointer-events: auto; touch-action: none; }
  .touch-stick::before,
  .touch-stick::after { content: ""; position: absolute; background: rgba(255, 255, 255, 0.09); }
  .touch-stick::before { top: 50%; left: 12px; width: calc(100% - 24px); height: 1px; }
  .touch-stick::after { top: 12px; left: 50%; width: 1px; height: calc(100% - 24px); }
  .touch-stick i { position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); border: 1px solid rgba(255, 255, 255, 0.32); transform: translate(-50%, -50%); }
  .touch-actions { position: relative; width: 148px; height: 126px; pointer-events: auto; }
  .touch-actions button { position: absolute; width: 54px; height: 54px; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 50%; background: rgba(3, 11, 17, 0.7); color: #fff; font-size: 8px; font-weight: 900; touch-action: none; }
  .touch-actions button:nth-child(1) { top: 0; left: 7px; }
  .touch-actions button:nth-child(2) { top: 0; right: 7px; }
  .touch-actions .touch-shoot { bottom: 0; left: 8px; border-color: rgba(255, 54, 95, 0.7); background: rgba(130, 18, 43, 0.75); }
  .touch-actions .touch-pass { right: 8px; bottom: 0; border-color: rgba(22, 214, 198, 0.7); background: rgba(6, 97, 90, 0.78); }
  .player-hud { display: none; }
  .radar { bottom: max(132px, calc(env(safe-area-inset-bottom) + 118px)); }
  .icon-button { width: 44px; height: 44px; }
  .keyboard-hint { display: none; }
  .touch-hint { display: inline; }
  .primary-button kbd { display: none; }
}

@media (max-height: 479px) {
  #game-shell { min-height: 100dvh; }
  .match-info { display: none; }
  .start-card { width: min(620px, calc(100vw - 22px)); padding: 14px 24px 13px; }
  h1 { margin-top: 3px; font-size: clamp(38px, 12vh, 58px); }
  .tagline { margin: 5px 0 10px; }
  .fixture { padding-block: 9px; }
  .crest { width: 38px; height: 44px; }
  .fixture-team { gap: 3px; }
  .primary-button { min-height: 39px; margin-top: 10px; }
  .start-hint { margin-top: 7px; }
  .radar { bottom: max(7px, env(safe-area-inset-bottom)); width: 138px; height: 83px; }
  .touch-stick { width: 88px; height: 88px; }
  .touch-actions { transform: scale(.84); transform-origin: right bottom; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
