/* ============================================================
   SULAT ARENA — Car Soccer
   Broadcast arena: hard geometric panels, dark metal,
   saturated team colour, punchy motion.
   ============================================================ */
:root {
  --bg: #05070a;
  --metal-0: #0a0d12;
  --metal-1: #11161e;
  --metal-2: #1a212c;
  --metal-3: #26303d;
  --line: #3a4655;
  --ink: #eaf2ff;
  --ink-dim: #9fb0c4;
  --home: #17d1ff;
  --home-deep: #0a86c9;
  --away: #ff7a1a;
  --away-deep: #c94e07;
  --good: #55ff9a;
  --warn: #ffd23f;
  --bad: #ff4d6d;
  --font: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --skew: -9deg;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; overflow: hidden; }
#arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ------------------------- HUD ------------------------- */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.hud button { pointer-events: auto; }

.scoreboard {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: stretch;
  background: linear-gradient(180deg, var(--metal-2), var(--metal-0));
  border: 2px solid var(--line);
  box-shadow: 0 8px 30px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.06);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 100%, 0 100%);
  min-width: min(620px, 94vw);
  height: 62px;
}
.team { display: flex; align-items: center; gap: 8px; padding: 0 14px; min-width: 150px; flex: 1; }
.team-home { justify-content: flex-end; border-right: 1px solid var(--line); }
.team-away { justify-content: flex-start; border-left: 1px solid var(--line); }
.crest {
  width: 34px; height: 34px; display: grid; place-items: center;
  font-weight: 900; font-size: 18px; color: #04121a;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--home);
}
.team-away .crest { background: var(--away); color: #1a0a02; }
.tname {
  font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 17px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.team-home .tname { color: var(--home); }
.team-away .tname { color: var(--away); }

.scorebox { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px 16px; min-width: 130px; }
.scores { display: flex; align-items: baseline; gap: 6px; font-family: var(--mono); font-weight: 700; }
.score { font-size: 26px; line-height: 1; }
.sep { font-size: 18px; color: var(--ink-dim); }
.clock { font-family: var(--mono); font-size: 13px; letter-spacing: .14em; color: var(--ink); margin-top: 2px; }
.phase { font-size: 9px; letter-spacing: .3em; color: var(--ink-dim); margin-top: 1px; }

.topright { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.iconbtn {
  width: 46px; height: 46px; min-width: 46px; min-height: 46px;
  background: linear-gradient(180deg, var(--metal-2), var(--metal-0));
  color: var(--ink); border: 2px solid var(--line); font-family: var(--font);
  font-weight: 800; font-size: 13px; letter-spacing: .05em; cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.iconbtn:hover { border-color: var(--home); color: var(--home); }
.iconbtn:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }

.boostwrap {
  position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
  width: min(280px, 46vw);
}
.boostlabel { font-size: 10px; letter-spacing: .34em; color: var(--ink-dim); margin-bottom: 4px; }
.boostbar { height: 20px; background: var(--metal-0); border: 2px solid var(--line); transform: skewX(var(--skew)); overflow: hidden; }
.boostbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--warn), #fff3b0); transition: width .08s linear; }
.boostnum { position: absolute; right: 2px; top: 16px; font-family: var(--mono); font-size: 12px; color: var(--ink); }

.speedwrap {
  position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  text-align: right;
}
.spdnum { font-family: var(--mono); font-size: 40px; font-weight: 700; line-height: 1; color: var(--ink); }
.spdlabel { font-size: 10px; letter-spacing: .34em; color: var(--ink-dim); }

.lowerthird {
  position: absolute; left: 50%; bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px));
  transform: translateX(-50%);
  display: flex; align-items: stretch; max-width: min(760px, 92vw);
  background: linear-gradient(90deg, rgba(10,13,18,.96), rgba(10,13,18,.72));
  border-left: 5px solid var(--home);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .25s ease, transform .25s ease;
}
.lowerthird.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.lt-tag { background: var(--home); color: #04121a; font-weight: 900; font-size: 12px; letter-spacing: .16em; padding: 8px 10px; display: grid; place-items: center; text-transform: uppercase; }
.lt-text { padding: 8px 14px; font-size: 15px; font-weight: 600; letter-spacing: .02em; }

.minimap { position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(66px, calc(env(safe-area-inset-top) + 66px)); border: 2px solid var(--line); background: rgba(5,7,10,.75); }
.minimap canvas { display: block; width: 150px; height: 85px; }

/* Touch controls */
.touchpad { position: absolute; inset: 0; display: none; }
.touchpad.on { display: block; }
.tstick { position: absolute; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 10px; }
#tstickL { left: max(12px, env(safe-area-inset-left)); }
#tstickR { right: max(12px, env(safe-area-inset-right)); flex-direction: column; align-items: center; }
.tactions { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.tbtn {
  width: 62px; height: 62px; min-width: 62px; min-height: 62px; border-radius: 12px;
  background: rgba(26,33,44,.85); border: 2px solid var(--line); color: var(--ink);
  font-weight: 800; font-size: 18px; pointer-events: auto;
}
.tbtn:active { background: var(--home); color: #04121a; }
.tboost { background: rgba(255,210,63,.25); border-color: var(--warn); width: 76px; }
.tjump { background: rgba(23,209,255,.25); border-color: var(--home); width: 76px; }

/* ------------------------- Overlays ------------------------- */
.overlay { position: absolute; inset: 0; z-index: 40; pointer-events: none; }
.overlay[data-active="false"] { display: none; }
.overlay .panel { pointer-events: auto; }
.panel {
  position: absolute; inset: 0; overflow: auto;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(23,209,255,.10), transparent 60%),
    radial-gradient(900px 600px at 100% 110%, rgba(255,122,26,.10), transparent 60%),
    linear-gradient(180deg, rgba(5,7,10,.92), rgba(5,7,10,.97));
  backdrop-filter: blur(3px);
  display: flex; flex-direction: column; align-items: center;
  padding: clamp(16px, 4vh, 46px) 16px;
}
.panel[hidden] { display: none; }

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: clamp(10px, 2.4vh, 26px); }
.brand-mark {
  width: 58px; height: 58px; display: grid; place-items: center;
  font-size: 30px; color: #04121a; background: linear-gradient(135deg, var(--home), var(--home-deep));
  clip-path: polygon(0 0, 100% 0, 100% 70%, 70% 100%, 0 100%);
}
.brand-text h1 { margin: 0; font-size: clamp(28px, 5vw, 46px); letter-spacing: .04em; font-weight: 900; text-transform: uppercase; }
.brand-text h1 span { color: var(--away); }
.brand-text p { margin: 2px 0 0; color: var(--ink-dim); letter-spacing: .28em; font-size: 11px; text-transform: uppercase; }

.menugrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; width: min(1080px, 96vw); }
.card {
  background: linear-gradient(180deg, rgba(26,33,44,.9), rgba(10,13,18,.9));
  border: 2px solid var(--line); padding: 16px;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}
.card h2 { margin: 0 0 12px; font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: var(--home); }
.card .muted { color: var(--ink-dim); font-size: 13px; line-height: 1.45; }
.card .small { font-size: 11.5px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 10px; letter-spacing: .26em; color: var(--ink-dim); text-transform: uppercase; margin-bottom: 5px; }
.field input[type="text"], .field input {
  width: 100%; background: var(--metal-0); border: 2px solid var(--line); color: var(--ink);
  font-family: var(--font); font-weight: 700; font-size: 16px; letter-spacing: .06em; padding: 10px 12px;
}
.field input:focus-visible { outline: 3px solid var(--warn); outline-offset: 1px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 64px; min-height: 44px; padding: 8px 6px; cursor: pointer;
  background: var(--metal-0); border: 2px solid var(--line); color: var(--ink-dim);
  font-family: var(--font); font-weight: 800; font-size: 13px; letter-spacing: .06em;
}
.seg button.on { background: var(--home); border-color: var(--home); color: #04121a; }
.seg button:hover { border-color: var(--home); color: var(--ink); }
.seg button:focus-visible { outline: 3px solid var(--warn); outline-offset: 1px; }

.controls { display: grid; gap: 6px; }
.controls > div { display: grid; grid-template-columns: auto auto 1fr; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink-dim); }
kbd {
  display: inline-block; min-width: 24px; text-align: center; padding: 3px 6px;
  background: var(--metal-3); border: 1px solid var(--line); border-bottom-width: 3px;
  border-radius: 4px; font-family: var(--mono); font-size: 11px; color: var(--ink);
}
.controls span { padding-left: 4px; }

.season { display: grid; gap: 5px; margin-bottom: 10px; }
.srow { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; padding: 5px 7px; border: 1px solid var(--line); background: rgba(5,7,10,.5); }
.srow .sidx { font-family: var(--mono); color: var(--ink-dim); }
.srow.done-win { border-color: var(--good); }
.srow.done-win .sres { color: var(--good); font-weight: 800; }
.srow.done-loss { border-color: var(--bad); }
.srow.done-loss .sres { color: var(--bad); font-weight: 800; }
.srow.current { border-color: var(--home); box-shadow: 0 0 0 1px var(--home) inset; }
.srow .sres { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
.seasonfoot { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-dim); letter-spacing: .1em; }

.menu-actions { display: flex; gap: 12px; margin-top: clamp(12px, 2.4vh, 26px); flex-wrap: wrap; justify-content: center; }
.bigbtn {
  pointer-events: auto; cursor: pointer; min-height: 52px; padding: 14px 30px;
  background: linear-gradient(180deg, var(--home), var(--home-deep)); color: #04121a;
  border: none; font-family: var(--font); font-weight: 900; font-size: 18px; letter-spacing: .1em;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  box-shadow: 0 8px 24px rgba(23,209,255,.25);
}
.bigbtn:hover { filter: brightness(1.12); }
.bigbtn:focus-visible { outline: 3px solid var(--warn); outline-offset: 3px; }
.bigbtn.ghost { background: var(--metal-2); color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.bigbtn.ghost:hover { border-color: var(--away); color: var(--away); }

.hint { color: var(--ink-dim); font-size: 12px; margin-top: 12px; letter-spacing: .04em; text-align: center; }

.pause { justify-content: center; gap: 18px; }
.pause h2 { font-size: clamp(30px, 6vw, 56px); letter-spacing: .12em; margin: 0; text-transform: uppercase; }
.pause-actions { display: flex; flex-direction: column; gap: 12px; width: min(340px, 90vw); }
.pause-actions .bigbtn { width: 100%; }
.pause-info { color: var(--ink-dim); font-size: 13px; text-align: center; line-height: 1.6; }

.result { justify-content: center; gap: 16px; }
.result-head { text-align: center; }
.res-verdict { font-size: 13px; letter-spacing: .4em; color: var(--warn); text-transform: uppercase; }
.res-score { font-family: var(--mono); font-size: clamp(52px, 12vw, 96px); font-weight: 700; line-height: 1; }
.res-teams { color: var(--ink-dim); letter-spacing: .2em; font-size: 13px; text-transform: uppercase; }
.result-stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 22px; width: min(620px, 94vw); margin: 8px 0; }
.rstat { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 6px 2px; font-size: 13.5px; }
.rstat b { font-family: var(--mono); color: var(--ink); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.banner {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 50;
}
.banner[hidden] { display: none; }
.banner span {
  font-size: clamp(64px, 20vw, 220px); font-weight: 900; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; text-shadow: 0 0 40px rgba(23,209,255,.8), 6px 6px 0 rgba(0,0,0,.4);
  transform: skewX(-8deg); animation: pop .5s cubic-bezier(.2,1.6,.4,1) both;
}
@keyframes pop { from { transform: skewX(-8deg) scale(.5); opacity: 0; } to { transform: skewX(-8deg) scale(1); opacity: 1; } }

@media (max-width: 860px) {
  .menugrid { grid-template-columns: 1fr; }
  .scoreboard { min-width: 96vw; height: 54px; }
  .team { min-width: 0; padding: 0 8px; }
  .tname { font-size: 13px; max-width: 96px; }
  .crest { width: 28px; height: 28px; font-size: 15px; }
  .score { font-size: 22px; }
  .minimap { display: none; }
  .topright { top: max(68px, calc(env(safe-area-inset-top) + 62px)); }
  .iconbtn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 12px; }
  .spdnum { font-size: 28px; }
  .speedwrap { top: max(120px, calc(env(safe-area-inset-top) + 114px)); bottom: auto; right: max(10px, env(safe-area-inset-right)); }
  .lowerthird { bottom: max(170px, calc(env(safe-area-inset-bottom) + 170px)); max-width: 94vw; }
  .lt-text { font-size: 13px; }
  .boostwrap { width: min(180px, 40vw); top: max(120px, calc(env(safe-area-inset-top) + 114px)); bottom: auto; left: max(10px, env(safe-area-inset-left)); }
}
@media (max-width: 560px) {
  .brand-text h1 { font-size: 26px; }
  .result-stats { grid-template-columns: 1fr; }
  .scoreboard { min-width: 0; width: 100vw; height: 50px; }
  .team { flex: 1 1 0; min-width: 0; padding: 0 6px; }
  .tname { font-size: 12px; max-width: 100%; }
  .crest { width: 24px; height: 24px; font-size: 13px; }
  .scorebox { min-width: 78px; padding: 2px 6px; }
  .score { font-size: 20px; }
  .phase { display: none; }
  .topright { top: max(68px, calc(env(safe-area-inset-top) + 62px)); right: max(8px, env(safe-area-inset-right)); }
  .boostwrap { width: min(150px, 42vw); top: max(122px, calc(env(safe-area-inset-top) + 116px)); }
  .tstick { gap: 8px; }
  .tactions { gap: 8px; }
  .tbtn { width: 54px; height: 54px; min-width: 54px; min-height: 54px; font-size: 16px; border-radius: 10px; }
  .tboost, .tjump { width: 64px; }
  #tstickL { left: max(8px, env(safe-area-inset-left)); }
}

@media (prefers-reduced-motion: reduce) {
  .banner span { animation: none; }
  .lowerthird { transition: none; }
}
