/* The Isometric Arcade page: its own index.html and the front door (/) both link it. */
:root {
  --ink: #0a0d16; --paper: #f4f6fb; --muted: #9fb0cc; --panel: rgba(10, 14, 26, 0.82);
  --t0: #3d8bff; --t1: #ff5a68; --gold: #ffe14a;
  --display: 'Bungee', 'Impact', sans-serif; --ui: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1322; color: var(--paper); font-family: var(--ui); }
#stage { position: fixed; inset: 0; }
#stage canvas { width: 100%; height: 100%; display: block; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.hud { position: fixed; pointer-events: none; }

/* back link */
#hub { position: fixed; top: 10px; left: 12px; z-index: 30; font: 700 14px var(--ui); letter-spacing: .06em; color: var(--muted);
       text-decoration: none; background: var(--panel); padding: 4px 10px; border-radius: 6px; border: 1px solid #26314a; pointer-events: auto; }
#hub:hover, #hub:focus { color: var(--paper); border-color: var(--gold); outline: none; }

/* scoreboard */
#score { top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 0; filter: drop-shadow(0 4px 0 rgba(0,0,0,.45)); }
.team { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 16px 5px; min-width: 150px; border: 3px solid var(--ink); }
.team.t0 { background: var(--t0); border-radius: 12px 0 0 12px; }
.team.t1 { background: var(--t1); border-radius: 0 12px 12px 0; }
.team .name { font: 800 15px var(--ui); letter-spacing: .12em; text-transform: uppercase; color: var(--ink); display: flex; gap: 6px; align-items: center; }
.serve-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); border: 2px solid var(--ink); visibility: hidden; }
.serve-dot.on { visibility: visible; }
.pips { display: flex; gap: 5px; margin-top: 4px; align-items: center; }
.pip { width: 16px; height: 8px; border-radius: 3px; background: rgba(10,13,22,.45); border: 2px solid var(--ink); transition: background .15s, transform .15s; }
.pip.on { background: var(--gold); }
.pips.max .pip { animation: pipmax .35s ease-in-out infinite alternate; }
.pips .lbl { font: 700 11px var(--ui); letter-spacing: .1em; color: var(--ink); margin-right: 3px; }
@keyframes pipmax { to { transform: scaleY(1.5); background: #fff; } }
.mid { background: var(--ink); color: var(--paper); border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink); display: flex; align-items: center; gap: 14px; padding: 0 16px; }
.mid .pts { font: 28px var(--display); min-width: 46px; text-align: center; }
.mid .games { white-space: nowrap; font: 700 15px var(--ui); color: var(--muted); text-align: center; line-height: 1.1; }
.mid .games b { display: block; font: 22px var(--display); color: var(--paper); }
#golden { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; font: 13px var(--display); color: var(--ink); background: var(--gold); padding: 2px 10px; border-radius: 6px; border: 2px solid var(--ink); display: none; white-space: nowrap; }

/* prompts */
#prompt { bottom: 48px; left: 50%; transform: translateX(-50%); font: 22px var(--display); text-shadow: 0 3px 0 var(--ink); letter-spacing: .02em; white-space: nowrap; }
#prompt kbd, .ov kbd, #menu kbd, #hint kbd, #legend kbd { font: 700 .8em var(--ui); background: var(--paper); color: var(--ink); border-radius: 5px; padding: 0 6px; border-bottom: 3px solid #8b97ad; }
#hint { bottom: 12px; left: 50%; transform: translateX(-50%); font: 600 15px var(--ui); color: var(--muted); letter-spacing: .04em; white-space: nowrap; }
#padhint { bottom: 12px; right: 12px; background: var(--gold); color: var(--ink); font: 700 15px var(--ui); padding: 5px 12px; border-radius: 8px; border: 3px solid var(--ink);
           animation: bob 1.1s ease-in-out infinite; z-index: 25; }
#padhint.off { display: none; }
@keyframes bob { 50% { transform: translateY(3px); } }
#pads { top: 12px; right: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; font: 700 14px var(--ui); }
#pads span { background: var(--panel); padding: 2px 8px; border-radius: 6px; border-left: 6px solid; }
#banner { top: 19%; left: 50%; transform: translate(-50%, -50%) scale(.6); font: 50px var(--display); text-shadow: 0 5px 0 var(--ink), 0 0 30px rgba(0,0,0,.4);
          opacity: 0; transition: opacity .15s, transform .25s cubic-bezier(.2,1.6,.4,1); white-space: nowrap; text-align: center; }
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner small { display: block; font: 800 22px var(--ui); letter-spacing: .2em; color: var(--paper); }
#banner small.mine { font: 800 18px var(--ui); letter-spacing: .12em; margin-top: 2px; }
#score .team.won { animation: teamWon .36s ease-in-out 3; }
@keyframes teamWon { 50% { filter: brightness(1.45); transform: scale(1.06); } }
#score .pts.pop { animation: ptsPop .5s cubic-bezier(.3, 1.9, .5, 1); }
@keyframes ptsPop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
#toast { top: 96px; left: 50%; transform: translateX(-50%); font: 18px var(--display); background: var(--ink); padding: 4px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; white-space: nowrap; }
#toast.show { opacity: 1; }
#servechip { top: 132px; left: 50%; transform: translateX(-50%); font: 800 17px var(--ui); letter-spacing: .06em; background: var(--ink); padding: 4px 14px; border-radius: 999px; border: 3px solid currentColor; white-space: nowrap; opacity: 0; transition: opacity .2s; }
#servechip.show { opacity: 1; }

/* legend */
#legend { left: 12px; bottom: 12px; background: var(--panel); border-radius: 10px; padding: 8px 10px; font: 600 13px var(--ui); display: grid; grid-template-columns: auto auto; gap: 2px 10px; }
#legend i { display: inline-block; width: 22px; height: 6px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }
#legend .title { grid-column: 1 / -1; font: 800 12px var(--ui); letter-spacing: .12em; color: var(--muted); }

/* practice panel */
#practice { left: 12px; top: 50px; width: 230px; background: var(--panel); border-radius: 12px; padding: 10px 12px; border: 2px solid #26314a; display: none; font-size: 15px; }
#practice h3 { margin: 0 0 2px; font: 16px var(--display); color: var(--gold); }
#practice .drill { font: 700 18px var(--ui); text-transform: uppercase; letter-spacing: .06em; }
#practice .row { display: flex; justify-content: space-between; }
#practice .big { font: 24px var(--display); }
#practice .last { margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,.06); }
#practice .res { font: 20px var(--display); }
#practice .res.in { color: #6dff8f; } #practice .res.bad { color: #ff6b6b; }
#practice .shots { margin-top: 6px; font-size: 14px; color: var(--muted); columns: 2; }
#practice .keys { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* labels */
.lab { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; will-change: transform; }
.shot { font: 18px var(--display); text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); }
.shot small { font: 800 14px var(--ui); letter-spacing: .06em; color: var(--paper); margin-left: 4px; }
.smash { font: 30px var(--display); color: var(--gold); }
.smash small { font-size: 18px; color: #fff; }
.wild { animation: wob .12s linear infinite alternate; }
@keyframes wob { from { rotate: -6deg; } to { rotate: 6deg; } }
.bubble { font: 800 17px var(--ui); color: var(--ink); background: #fff; padding: 2px 10px; border-radius: 12px; border: 3px solid var(--ink); }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -9px; border: 6px solid transparent; border-top-color: var(--ink); transform: translateX(-50%); }
.clang { font: 40px var(--display); color: var(--gold); text-shadow: 0 4px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink); animation: shake .06s linear infinite alternate; }
@keyframes shake { from { translate: -3px 0; } to { translate: 3px 1px; } }
.ptag { font: 800 14px var(--ui); color: var(--ink); padding: 0 6px; border-radius: 5px; border: 2px solid var(--ink); }
.ptag::after { content: ''; position: absolute; left: 50%; bottom: -7px; border: 4px solid transparent; border-top-color: var(--ink); transform: translateX(-50%); }
.info { font: 800 18px var(--ui); letter-spacing: .08em; text-shadow: 0 2px 0 var(--ink); }
/* contextual button preview beside the timing ring */
.bprev { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform, opacity; display: flex; gap: 6px;
         font: 700 13px var(--ui); letter-spacing: .03em; color: var(--paper); background: rgba(10, 13, 22, .72); padding: 2px 7px 2px 3px;
         border-radius: 8px; border: 2px solid var(--ink); }
.bprev span { display: inline-flex; align-items: center; gap: 3px; transition: opacity .1s; }
.bprev span.off { opacity: .4; }
.bprev span.on { color: var(--gold); }
.bprev b { font: 800 11px var(--ui); color: var(--ink); min-width: 15px; padding: 0 3px; text-align: center; border-radius: 4px; line-height: 15px; }
.bprev span.on b { box-shadow: 0 0 0 2px var(--gold); }
.qswap { font: 16px var(--display); text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink); animation: qswap .18s ease-out; }
@keyframes qswap { from { filter: brightness(3); letter-spacing: .3em; } }
.qfizz { font: 800 15px var(--ui); letter-spacing: .12em; color: #9aa6bd; text-shadow: 0 2px 0 var(--ink); animation: qfizz .6s ease-in forwards; }
@keyframes qfizz { 30% { filter: none; } to { filter: blur(3px); letter-spacing: .5em; } }

/* overlays */
.ov { position: fixed; inset: 0; background: rgba(6, 9, 18, 0.8); display: none; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.ov.show { display: flex; }
.card { background: #111a2d; border: 3px solid var(--ink); box-shadow: 0 8px 0 #000; border-radius: 16px; padding: 18px 22px; max-width: 880px; width: 100%; max-height: 100%; overflow: auto; }
.card h2 { margin: 0 0 8px; font: 30px var(--display); color: var(--gold); }
.ov table { width: 100%; border-collapse: collapse; font-size: 17px; }
.ov td, .ov th { padding: 4px 8px; border-bottom: 1px solid #243049; text-align: left; }
.ov th { color: var(--muted); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }
.ov td:first-child { font-weight: 700; }
.ov .sec td { color: var(--gold); font: 14px var(--display); padding-top: 10px; }
.ov p { color: var(--muted); font-size: 16px; margin: 10px 0 0; }

#menu .modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 10px 0 14px; }
#menu button.mode { font: inherit; text-align: left; cursor: pointer; background: #1a2540; color: var(--paper); border: 3px solid var(--ink); border-radius: 14px; padding: 16px; box-shadow: 0 5px 0 #000; transition: transform .1s; }
#menu button.mode h3 { margin: 0 0 4px; font: 22px var(--display); }
#menu button.mode p { margin: 0; color: var(--muted); font-size: 16px; }
#menu button.mode.sel { background: var(--gold); color: var(--ink); transform: translateY(-3px); }
#menu button.mode.sel p { color: #3a3000; }
#menu .opts { display: flex; flex-wrap: wrap; gap: 10px 22px; font-size: 17px; align-items: center; }
#menu .opts b { color: var(--gold); }
#menu .opts button { font: 700 15px var(--ui); background: #243049; color: var(--paper); border: 0; border-radius: 6px; padding: 3px 10px; cursor: pointer; }
#menu .players { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
#menu .players span { background: #1a2540; padding: 3px 10px; border-radius: 8px; border-left: 6px solid; font-weight: 700; }
#menu h1 { margin: 0; font: 44px var(--display); line-height: 1; color: var(--paper); text-shadow: 0 4px 0 #000; }
#menu h1 em { color: var(--gold); font-style: normal; }
/* watch (spectator) mode */
#watch { top: 44px; left: 12px; display: none; align-items: center; gap: 8px; font: 700 14px var(--ui); letter-spacing: .08em; }
#watch .tag { font: 14px var(--display); color: var(--ink); background: var(--gold); padding: 2px 10px; border-radius: 6px; border: 2px solid var(--ink); }
#watch .tag::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e0303d; margin-right: 6px; vertical-align: 1px; animation: rec 1s steps(2) infinite; }
@keyframes rec { 50% { opacity: 0; } }
#watch .spd { background: var(--panel); padding: 2px 8px; border-radius: 6px; border: 1px solid #26314a; }
#watch .spd.paused { color: var(--gold); }
body.watch #watch { display: flex; }
body.watch #padhint, body.watch #prompt { display: none !important; }
#controls .watchonly { display: none; }
body.watch #controls .watchonly { display: table-row; }
body.watch #controls p.watchonly { display: block; }
/* tutorial: only Azul's pressure pips (the pressure lesson points at them) */
#score.pipsonly .mid, #score.pipsonly .t1, #score.pipsonly #golden, #score.pipsonly .serve-dot { display: none; }
#score.pipsonly .team.t0 { border-radius: 12px; min-width: 0; }
/* tutorial: the lesson card owns the bottom-left corner, so the key hint moves right */
body.mode-tutorial #hint { left: auto; right: 12px; transform: none; bottom: 52px; }
/* mouse aim: the reticle on the court is the cursor during play */
body.aimcursor #stage canvas { cursor: none; }

/* start screen: practice + first-run prologue callout */
#menu .modes { grid-template-columns: repeat(4, 1fr); }
#menu button.mode.prologue { grid-column: 1 / -1; background: #1f3b2e; border-color: var(--ink); display: flex; align-items: center; gap: 14px; }
#menu button.mode.prologue h3 { color: #4dffb8; }
#menu button.mode.prologue .new { font: 13px var(--display); color: var(--ink); background: #4dffb8; padding: 3px 10px; border-radius: 6px; border: 2px solid var(--ink); animation: bob 1.1s ease-in-out infinite; white-space: nowrap; }
#menu button.mode.prologue.sel { background: #4dffb8; }
#menu button.mode.prologue.sel h3 { color: var(--ink); }
#menu button.mode.prologue.sel .new { background: var(--gold); }
#menu button.mode[hidden] { display: none; }

/* controls overlay: rows come from controlsTable(scheme) */
#controls { z-index: 50; } /* above the shared lesson card (--ptu-z 45) */
#controls .picker { margin: 4px 0 10px; }
#controls .picker .ptu-root { --ptu-position: static; }
#controls .picker .ptu-schemes { font-size: 15px; }
#controls .picker .ptu-schemes .ptu-btn { font: 700 15px var(--ui); padding: 3px 10px; }
#controls .picker .ptu-schemes .ptu-desc { font-size: 15px; }
#controls .picker .who { font: 800 13px var(--ui); letter-spacing: .1em; margin-top: 6px; }

/* shared tutorial / practice / workshop overlays, themed to the arcade look */
#ptu .ptu-root, #controls .ptu-root {
  --ptu-bg: rgba(12, 18, 34, .94); --ptu-fg: var(--paper); --ptu-muted: var(--muted); --ptu-accent: var(--gold); --ptu-good: #6dff8f;
  --ptu-chip-bg: var(--paper); --ptu-chip-fg: var(--ink); --ptu-font: var(--ui); --ptu-radius: 14px; --ptu-z: 45;
  --ptu-gold: #ffe14a; --ptu-silver: #cfd8e6; --ptu-bronze: #d98a45;
  font-family: var(--ui); font-size: 16px;
}
#ptu .ptu-card { border: 3px solid var(--ink); box-shadow: 0 6px 0 #000; }
#ptu .ptu-card h2, #ptu .ptu-title, #ptu .ptu-ws .score, #ptu .ptu-ws .countdown, #ptu .ptu-result .big { font-family: var(--display); font-weight: 400; letter-spacing: .01em; }
#ptu .ptu-card h2 { color: var(--gold); font-size: 30px; }
#ptu .ptu-menu h3 { font: 14px var(--display); color: #4dffb8; letter-spacing: .04em; }
#ptu .ptu-tile { background: #1a2540; border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 #000; }
#ptu .ptu-tile:hover, #ptu .ptu-tile:focus-visible { background: #24335a; transform: translateY(-2px); }
#ptu .ptu-tile:focus-visible { box-shadow: 0 0 0 3px var(--gold), 0 4px 0 #000; }
#ptu .ptu-tile .t { font-size: 17px; font-weight: 800; }
#ptu .ptu-tile .s { font-size: 14px; }
#ptu .ptu-btn, #controls .ptu-btn { font-family: var(--ui); font-weight: 800; letter-spacing: .04em; border: 2px solid var(--ink); background: #243049; color: var(--paper); }
#ptu .ptu-btn.primary { background: var(--gold); color: var(--ink); }
#controls .ptu-schemes .ptu-btn[aria-pressed=true], #ptu .ptu-schemes .ptu-btn[aria-pressed=true] { background: var(--gold); color: var(--ink); }
#ptu .ptu-key { border-bottom: 3px solid #8b97ad; box-shadow: none; }
#ptu .ptu-nice { font-family: var(--display); font-weight: 400; color: #4dffb8; text-shadow: 0 4px 0 var(--ink); }
#ptu .ptu-lesson { font-size: 17px; }
#ptu .ptu-ws .ladder { border: 2px solid var(--ink); height: 12px; }
#controls .ptu-key { display: inline-block; font: 700 .8em var(--ui); background: var(--paper); color: var(--ink); border-radius: 5px; padding: 0 6px; border-bottom: 3px solid #8b97ad; margin: 0 1px; }
#controls .ptu-sep, #controls .ptu-note { color: var(--muted); margin: 0 3px; }

@media (max-width: 640px) { #menu .modes { grid-template-columns: 1fr; } #menu button.mode.prologue { flex-direction: column; align-items: flex-start; } .team { min-width: 96px; padding: 4px 8px; } #legend, #practice { display: none !important; } #prompt { font-size: 16px; } }
