:root {
  --home: #35e2ff;
  --away: #ff6a3d;
  --bg-0: #05080c;
  --bg-1: #0a1119;
  --panel: rgba(10, 18, 26, 0.72);
  --panel-line: rgba(120, 170, 205, 0.18);
  --edge: rgba(150, 195, 225, 0.22);
  --ink: #e8f1f7;
  --ink-dim: #9fb6c7;
  --ink-faint: #6b8394;
  --warn: #ffd166;
  --font-head: 'Bahnschrift', 'Oswald', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Mono', 'Consolas', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#grade {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    radial-gradient(118% 86% at 50% 43%, rgba(0, 0, 0, 0) 52%, rgba(1, 4, 8, 0.5) 100%),
    linear-gradient(180deg, rgba(12, 30, 44, 0.14) 0%, rgba(0, 0, 0, 0) 32%);
}

.hidden { display: none !important; }

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  background:
    radial-gradient(120% 90% at 15% 0%, rgba(53, 226, 255, 0.06), transparent 60%),
    linear-gradient(160deg, rgba(5, 9, 13, 0.68), rgba(5, 9, 13, 0.8));
  backdrop-filter: blur(4px);
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  user-select: none;
}

#scoreboard {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  gap: 0;
  background: linear-gradient(180deg, rgba(8, 14, 20, 0.92), rgba(8, 14, 20, 0.78));
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.sb-side {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  min-width: 168px;
}
.sb-home { justify-content: flex-end; }

.sb-team {
  font-family: var(--font-head);
  font-size: 22px;
  letter-spacing: 0.14em;
  font-weight: 700;
}
.sb-away .sb-team { color: var(--away); }
.sb-home .sb-team { color: var(--home); }

.sb-score {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  min-width: 42px;
  text-align: center;
}

.sb-shots {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.sb-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 22px;
  background: rgba(0, 0, 0, 0.35);
  border-left: 1px solid var(--panel-line);
  border-right: 1px solid var(--panel-line);
}
.sb-clock {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  transition: color 0.2s;
}
.sb-clock.urgent { color: var(--warn); animation: pulse 0.9s ease-in-out infinite; }
.sb-period {
  margin-top: 3px;
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--ink-dim);
}

.sb-state {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-head);
  font-size: 13px;
  letter-spacing: 0.22em;
  color: transparent;
  white-space: nowrap;
  padding: 5px 16px;
  border-radius: 6px;
  transition: color 0.25s, background 0.25s;
}
.sb-state.active {
  color: var(--ink);
  background: rgba(8, 14, 20, 0.8);
  border: 1px solid var(--panel-line);
}

/* ---------- telemetry (left) ---------- */
.telemetry {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 268px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.panel-label {
  font-family: var(--font-head);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  margin-bottom: 7px;
}

.meter {
  height: 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 60%;
  border-radius: 5px;
  background: linear-gradient(90deg, #2ea7c7, var(--home));
  transition: width 0.12s linear, background 0.2s;
}
.meter-fill.sprinting { background: linear-gradient(90deg, #35e2ff, #b6f4ff); }

.power-panel { opacity: 0; transition: opacity 0.18s; }
.power-panel.visible { opacity: 1; }
.power-meter .meter-fill {
  width: 0%;
  background: linear-gradient(90deg, var(--home), var(--warn), var(--away));
}

.map-panel canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  background: rgba(3, 8, 12, 0.6);
}

.meta-panel { display: flex; flex-direction: column; gap: 5px; }
.meta-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}
#pad-status span { color: var(--ink-faint); }
#pad-status.on span { color: var(--home); }

/* ---------- hint ---------- */
#hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  background: rgba(6, 11, 16, 0.7);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 8px 16px;
  white-space: nowrap;
}
#hint b { color: var(--ink); font-weight: 600; }

/* ---------- toast ---------- */
#toast {
  --accent: var(--home);
  position: absolute;
  top: 108px;
  left: 50%;
  transform: translate(-50%, -12px);
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  padding: 10px 22px;
  border-left: 3px solid var(--accent);
  background: rgba(8, 14, 20, 0.82);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-title {
  font-family: var(--font-head);
  font-size: 18px;
  letter-spacing: 0.16em;
}
.toast-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  margin-top: 2px;
}

/* ---------- goal banner ---------- */
#goal-banner {
  position: absolute;
  top: 34%;
  left: 0;
  right: 0;
  text-align: center;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.25s, transform 0.25s;
}
#goal-banner.show { opacity: 1; transform: scale(1); }
.goal-cap {
  font-family: var(--font-head);
  font-size: 16px;
  letter-spacing: 0.5em;
  color: var(--warn);
  margin-bottom: 6px;
}
.goal-team {
  font-family: var(--font-head);
  font-size: 54px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.7);
}
.goal-scorer {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.14em;
  color: var(--ink);
  margin-top: 4px;
}
.goal-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  margin-top: 6px;
}

/* ---------- intro ---------- */
.intro-grid {
  display: flex;
  align-items: center;
  gap: 48px;
}
.intro-team {
  font-family: var(--font-head);
  font-size: 40px;
  letter-spacing: 0.06em;
}
.intro-vs {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--ink-faint);
  padding: 6px 14px;
  border: 1px solid var(--edge);
  border-radius: 999px;
}
.intro-note {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--ink-faint);
  animation: pulse 1.6s ease-in-out infinite;
}

/* ---------- replay ---------- */
#replay { flex-direction: column; gap: 12px; }
.replay-badge {
  font-family: var(--font-head);
  font-size: 34px;
  letter-spacing: 0.4em;
  color: var(--warn);
}
.overlay-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
}

/* ---------- dialogs ---------- */
.dialog {
  width: min(440px, 90vw);
  background: linear-gradient(180deg, rgba(12, 20, 28, 0.96), rgba(8, 14, 20, 0.96));
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 30px 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
}
.dialog.wide { width: min(560px, 92vw); }
.dialog h2 {
  font-family: var(--font-head);
  font-size: 30px;
  letter-spacing: 0.08em;
  margin: 6px 0 4px;
}
.dialog-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
  margin: 0 0 20px;
}
.end-cap {
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.34em;
  color: var(--warn);
}
.end-score {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.06em;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  text-align: center;
}
.end-stats { display: flex; flex-direction: column; gap: 6px; margin-bottom: 22px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  padding: 5px 2px;
  border-bottom: 1px dashed rgba(120, 170, 205, 0.14);
}
.stat-row b { color: var(--ink); }
.dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  pointer-events: auto;
  font-family: var(--font-head);
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--edge);
  border-radius: 9px;
  padding: 12px 22px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(150, 195, 225, 0.4); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  color: #04121a;
  background: linear-gradient(180deg, #7ef0ff, var(--home));
  border-color: transparent;
  font-weight: 700;
}
.btn.primary:hover { background: linear-gradient(180deg, #a4f6ff, #4fe6ff); }
.btn.ghost { background: transparent; color: var(--ink-dim); }
.btn.big { padding: 16px 40px; font-size: 17px; letter-spacing: 0.2em; }
.btn:disabled { opacity: 0.55; cursor: wait; }

/* ---------- menu ---------- */
#menu { z-index: 50; padding: 28px; }
.menu-shell {
  width: min(1180px, 96vw);
  height: min(720px, 94vh);
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 26px;
}
.menu-main, .menu-side {
  background: linear-gradient(180deg, rgba(11, 18, 26, 0.9), rgba(7, 12, 18, 0.92));
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.menu-main {
  padding: 38px 40px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: relative;
  overflow: hidden;
}
.menu-main::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(50% 40% at 88% 0%, rgba(53, 226, 255, 0.12), transparent 70%),
    radial-gradient(40% 40% at 0% 100%, rgba(255, 106, 61, 0.1), transparent 70%);
  pointer-events: none;
}
.menu-main > * { position: relative; z-index: 1; }

.brand { display: flex; align-items: center; gap: 18px; }
.brand-mark {
  font-family: var(--font-head);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 14px 14px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: rgba(53, 226, 255, 0.06);
}
.brand-mark span { color: var(--home); }
.brand-text h1 {
  font-family: var(--font-head);
  font-size: 34px;
  letter-spacing: 0.06em;
  margin: 0;
}
.brand-text p {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--ink-faint);
  margin: 4px 0 0;
}

.teams-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.team-card {
  --team: var(--home);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.24);
  border-left: 3px solid var(--team);
}
.team-badge svg { width: 34px; height: 40px; fill: none; stroke: var(--team); stroke-width: 3; }
.team-info { display: flex; flex-direction: column; }
.team-city {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.26em;
  color: var(--ink-faint);
}
.team-name { font-family: var(--font-head); font-size: 20px; letter-spacing: 0.05em; color: var(--team); }
.team-role { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em; color: var(--ink-dim); margin-top: 2px; }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.setting-label {
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
  margin-bottom: 9px;
}
.seg {
  display: grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
}
.seg button {
  pointer-events: auto;
  font-family: var(--font-head);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 10px 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button.active {
  color: #04121a;
  background: linear-gradient(180deg, #7ef0ff, var(--home));
  font-weight: 700;
}

.menu-actions { display: flex; gap: 12px; align-items: center; margin-top: auto; }

.menu-side {
  padding: 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}
.side-block { border-bottom: 1px solid rgba(120, 170, 205, 0.12); padding-bottom: 16px; }
.side-block:last-child { border-bottom: none; }
.side-title {
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
  margin-bottom: 12px;
}
.keys { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.keys li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.keys kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--edge);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
}
.keys span { font-size: 12px; color: var(--ink-dim); }
.side-block.note p { font-size: 12px; line-height: 1.55; color: var(--ink-dim); margin: 0; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (max-width: 940px) {
  .menu-shell { grid-template-columns: 1fr; height: auto; max-height: 96vh; overflow-y: auto; }
  .menu-side { display: none; }
  .teams-row, .settings { grid-template-columns: 1fr; }
  .telemetry { width: 210px; }
}

@media (min-width: 760px) and (max-width: 940px) and (max-height: 650px) {
  .menu-main { padding: 24px 32px; gap: 18px; }
  .teams-row, .settings { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 760px) and (max-width: 940px) and (min-height: 480px) and (max-height: 650px) {
  .telemetry { bottom: 64px; }
}
