/* Rally — the screen. A broadcast graphics package over a lit arena. Tokens: tokens.css. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--arena);
  color: var(--line);
  font-family: var(--sans);
  font-size: 16px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ball); outline-offset: 3px; }

#gl { position: fixed; inset: 0; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

.fine { font-size: 13px; line-height: 1.55; color: var(--line-3); margin: 0; max-width: 62ch; }
.fine b { color: var(--line-2); font-weight: 600; }
/* In the menus a small label is a plain word. Mono capitals stay with the match graphics (the HUD). */
.screen .label { font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; }
kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin: 0 1px;
  border-radius: var(--r-1); background: var(--arena-3); box-shadow: inset 0 0 0 1px var(--hair-strong), 0 2px 0 rgba(0, 0, 0, 0.5);
  font: 500 11px/1 var(--mono); color: var(--line);
}

.text-btn { background: none; border: 0; padding: 6px 0; color: var(--line-2); }
.text-btn:hover { color: var(--line); }
.text-btn.back::before { content: '←'; margin-right: 8px; font-family: var(--sans); letter-spacing: 0; }

/* ================================================================== title */

.title {
  position: absolute; inset: 0;
  display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr);
  padding: 20px clamp(24px, 4vw, 56px) clamp(24px, 4.5vh, 48px);
  visibility: hidden; opacity: 0;
  transition: opacity 260ms var(--ease-out), visibility 0s linear 260ms;
}
.title.is-active { visibility: visible; opacity: 1; transition: opacity 200ms var(--ease-out), visibility 0s; }
/* Scrims so the type holds over the live match behind it: the menu owns the left, the hall the right. */
.title::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(6, 9, 20, 0.92) 0%, rgba(6, 9, 20, 0.7) 30%, rgba(6, 9, 20, 0) 56%),
    linear-gradient(0deg, rgba(6, 9, 20, 0.6) 0%, rgba(6, 9, 20, 0) 30%);
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--line-3); }
.topbar-join { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* One column on the left: the name, then the menu. The hall plays on to the right of it. */
.title-main {
  align-self: center; width: min(420px, 100%);
  display: flex; flex-direction: column; gap: clamp(16px, 3.2vh, 32px);
}
.hero { display: flex; flex-direction: column; align-items: flex-start; }
.wordmark {
  margin: 0; position: relative;
  font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 150%;
  font-size: clamp(44px, min(6.4vw, 9.5vh), 108px); line-height: 0.8; letter-spacing: -0.03em;
  text-transform: uppercase; color: var(--line);
}
.wm-word { display: inline-block; padding-right: 0.06em; }
/* The net tape: a white band over the mesh, as wide as the word. */
.tape {
  align-self: stretch; height: 22px; margin: 0.24em 0 0 0.02em;
  background:
    linear-gradient(var(--line), var(--line)) 0 0 / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, var(--hair-strong) 0 1px, transparent 1px 7px) 0 6px / 100% 16px no-repeat,
    repeating-linear-gradient(0deg, var(--hair-strong) 0 1px, transparent 1px 7px) 0 6px / 100% 16px no-repeat;
  -webkit-mask: linear-gradient(#000 30%, transparent);
  mask: linear-gradient(#000 30%, transparent);
  transform-origin: 0 50%;
}
.tagline { margin: 12px 0 0; font-size: clamp(15px, 1.2vw, 18px); line-height: 1.35; color: var(--line-2); }
.tagline em { font-style: normal; color: var(--line); font-weight: 600; }

.title.is-active .wm-word { animation: wm-in 640ms var(--ease-snap) both; }
.title.is-active .tape { animation: tape-in 520ms var(--ease-out) 160ms both, tape-hit 700ms var(--ease-out) 560ms; }
.title.is-active .tagline { animation: rise 500ms var(--ease-out) 300ms both; }
.title.is-active .modes > * { animation: rise 520ms var(--ease-out) both; }
.title.is-active .modes > :nth-child(2) { animation-delay: 60ms; }
.title.is-active .modes > :nth-child(3) { animation-delay: 90ms; }
.title.is-active .modes > :nth-child(4) { animation-delay: 120ms; }
.title.is-active .modes > :nth-child(5) { animation-delay: 150ms; }
.title.is-active .modes > :nth-child(6) { animation-delay: 180ms; }
.title.is-active .modes > :nth-child(7) { animation-delay: 210ms; }
.title.is-active .modes > :nth-child(n+8) { animation-delay: 240ms; }
@keyframes wm-in {
  0% { opacity: 0; transform: translateX(28%) skewX(-18deg) scaleX(1.25); filter: blur(10px); }
  60% { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: none; }
}
@keyframes tape-in { from { transform: scaleX(0); } }
@keyframes tape-hit { 0%, 100% { translate: 0 0; } 20% { translate: 0 3px; } 45% { translate: 0 -1px; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Modes: plain rows in two groups, by where the other player is — at this screen, or online. Each
   group says so in a heading with an icon, so "online" never gets mixed up with "two on one screen".
   The menu ball sits in the gutter left of the chosen row. */
.modes { display: flex; flex-direction: column; gap: 2px; }
.mode-group {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 10px; align-items: center;
  margin: 14px 0 6px; padding: 0 2px;
}
.mode-group:first-child { margin-top: 0; }
.mg-icon { grid-row: 1 / 3; width: 22px; height: 22px; fill: none; stroke: var(--line-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mg-name { font-size: 15px; font-weight: 700; color: var(--line); }
.mg-hint { font-size: 13px; color: var(--line-3); }
.mode-group-shop { display: block; height: 1px; margin: 12px 0 6px; background: var(--hair); }
.mode {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 44px; padding: 0 16px 0 40px;
  background: none; border: 0; border-radius: var(--r-2);
  text-align: left; color: var(--line);
  transition: background-color 160ms, box-shadow 160ms;
}
.mode:hover, .mode:focus-visible, .mode.is-ball { outline: none; background: rgba(242, 245, 255, 0.07); box-shadow: inset 0 0 0 1px var(--hair-strong); }
.mode:active { background: rgba(242, 245, 255, 0.1); }
.mode-name { font-size: 18px; font-weight: 600; line-height: 1.2; }
.mode-desc, .tile-emblem { display: none; }
.mode-need { font-size: 13.5px; color: var(--line-3); text-align: right; white-space: nowrap; }
.mode:hover .mode-need, .mode:focus-visible .mode-need, .mode.is-ball .mode-need { color: var(--line-2); }

/* ================================================================== the menu ball */

/* Moves with keyboard and pointer focus, hopping to whatever is chosen, like a rally. */
.menu-ball { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 20; pointer-events: none !important; opacity: 0; transition: opacity 160ms; }
.menu-ball.on { opacity: 1; }
.mb-ball, .mb-shadow { position: absolute; display: block; border-radius: 50%; }
.mb-ball {
  width: 18px; height: 18px; left: -9px; top: -18px;
  background: radial-gradient(circle at 35% 30%, #FFE2BD 0 12%, var(--ball-hi) 22%, var(--ball) 55%, #C4560A 100%);
  box-shadow: 0 0 14px rgba(255, 138, 31, 0.55);
}
.mb-shadow { width: 16px; height: 5px; left: -8px; top: -2px; background: rgba(0, 0, 0, 0.55); filter: blur(1.5px); }

/* ================================================================== panels */

.panel {
  position: absolute; top: 24px; left: 24px; bottom: 24px; z-index: 10;
  width: min(540px, calc(100vw - 48px));
  display: flex; flex-direction: column;
  --pad-b: 24px;
  padding: 26px 40px var(--pad-b);
  background: var(--arena-2);
  border-radius: var(--r-3);
  box-shadow: inset 0 0 0 1px var(--hair);
  overflow: auto; scrollbar-width: none;
  visibility: hidden; opacity: 0;
  /* A broadcast wipe with a leaning edge. */
  clip-path: polygon(0 0, 0 0, -12% 100%, 0 100%);
  transition: clip-path 300ms var(--ease-in-out), opacity 200ms, visibility 0s linear 300ms;
}
.panel::-webkit-scrollbar { display: none; }
.panel.is-active {
  visibility: visible; opacity: 1;
  clip-path: polygon(0 0, 112% 0, 100% 100%, 0 100%);
  transition: clip-path 460ms var(--ease-out), opacity 120ms, visibility 0s;
}
.panel-wide { width: min(980px, calc(100vw - 48px)); }
.panel-wide.panel-solo { width: min(660px, calc(100vw - 48px)); }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--hair); color: var(--line-3); }
.kicker { color: var(--line-2); }
/* The way on (Start match, Rematch, Play ranked) stays in sight: the foot sticks to the panel's bottom
   edge while the rest scrolls under it. */
.panel-foot {
  position: sticky; bottom: calc(-1 * var(--pad-b)); z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin: auto 0 calc(-1 * var(--pad-b)); padding: 16px 0 var(--pad-b); border-top: 1px solid var(--hair);
  background: var(--arena-2);
}
.panel-foot .btn { margin-left: auto; }
/* Results: "Try Club →" sits beside Rematch, in the ball's colour — the way up is the obvious next step. */
.panel-foot .res-next { margin-left: auto; margin-right: 26px; color: var(--ball); }
.panel-foot .res-next:hover { color: var(--ball-hi); }
.panel-foot .res-next:not([hidden]) + .btn { margin-left: 0; }
.panel-title {
  margin: 26px 0 10px;
  font-weight: 700;
  font-size: clamp(26px, min(2.8vw, 5vh), 36px); line-height: 1.1; letter-spacing: -0.02em;
}
.panel-lede { margin: 0 0 8px; font-size: 16px; line-height: 1.5; color: var(--line-2); max-width: 60ch; }
.panel.is-active .panel-title { animation: title-in 520ms var(--ease-out) 80ms both; }
@keyframes title-in { from { opacity: 0; transform: translateX(-10px); } }

/* ================================================================== controls */

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 30px;
  background: var(--court); color: var(--line);
  border: 0; border-radius: 0;
  clip-path: polygon(var(--lean) 0, 100% 0, calc(100% - var(--lean)) 100%, 0 100%);
  font-family: var(--sans); font-weight: 700;
  font-size: 15px; white-space: nowrap; flex-shrink: 0;
  transition: background-color 140ms, color 140ms, transform 90ms var(--ease-out), opacity 200ms;
}
.btn::before { content: ''; position: absolute; inset: 0; clip-path: inherit; box-shadow: inset 0 0 0 1px var(--hair-strong); pointer-events: none; }
.btn:hover { background: var(--court-hi); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: none; background: var(--line); color: var(--arena); }
.btn-go { background: var(--ball); color: var(--ball-ink); padding: 0 34px; min-height: 56px; font-size: 17px; }
.btn-go::before { box-shadow: none; }
.btn-go span::after {
  content: ''; display: inline-block; width: 18px; height: 12px; margin-left: 12px; vertical-align: -1px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 12'%3E%3Cpath d='M0 6h15M10 1l5 5-5 5' stroke='black' stroke-width='2.4' fill='none'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: transform 200ms var(--ease-out);
}
.btn-go:hover { background: var(--ball-hi); }
.btn-go:hover span::after { transform: translateX(4px); }
.btn[disabled] { background: var(--arena-3); color: var(--line-3); pointer-events: none; }
.btn[disabled]::before { box-shadow: inset 0 0 0 1px var(--hair); }

.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-2); background: var(--arena); box-shadow: inset 0 0 0 1px var(--hair); }
.seg button {
  min-height: 34px; padding: 0 14px;
  background: none; border: 0; border-radius: var(--r-1);
  font-size: 14px; font-weight: 600; color: var(--line-2); white-space: nowrap;
  transition: background-color 140ms var(--ease-out), color 140ms;
}
.seg button:hover { background: var(--arena-3); color: var(--line); }
.seg button[aria-checked='true'] { background: var(--line); color: var(--arena); }

input[type='range'] { -webkit-appearance: none; appearance: none; width: 190px; height: 24px; background: none; }
input[type='range']::-webkit-slider-runnable-track { height: 4px; background: var(--hair-strong); border-radius: 2px; }
input[type='range']::-moz-range-track { height: 4px; background: var(--hair-strong); border-radius: 2px; }
input[type='range']::-moz-range-progress { height: 4px; background: var(--ball); border-radius: 2px; }
/* The thumb is a ball. */
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFE2BD 0 12%, var(--ball-hi) 22%, var(--ball) 55%, #C4560A 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
input[type='range']::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--ball); }

/* ================================================================== lobby */

.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 24px 0 6px; }
.slot {
  position: relative; display: grid; grid-template-columns: 168px 1fr; gap: 8px 22px;
  padding: 0 18px 18px; border-radius: var(--r-3); background: var(--arena-3);
  box-shadow: inset 0 0 0 1px var(--hair);
}
.slot-head {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center;
  margin: 0 -18px 10px; padding: 12px 18px 11px;
  border-radius: var(--r-3) var(--r-3) 0 0;
  background: linear-gradient(90deg, var(--slot-ink, var(--line)) 0 6px, transparent 6px);
  border-bottom: 1px solid var(--hair);
}
.slot-head .pl { font-size: 17px; font-weight: 700; }
.slot-head .label { color: var(--line-3); }
.qr {
  width: 168px; height: 168px; padding: 10px; background: var(--line); border-radius: var(--r-2);
  display: grid; place-items: center; position: relative; overflow: hidden;
  transition: background-color 300ms;
}
.qr img { width: 100%; height: 100%; display: block; image-rendering: pixelated; transition: opacity 300ms; }
.slot.is-paired .qr { background: var(--court); }
.slot.is-paired .qr img { opacity: 0; }
.qr .qr-done {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; text-align: center;
  font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 120%; font-size: 26px; text-transform: uppercase; color: var(--line);
  opacity: 0; transform: scale(0.8); transition: opacity 240ms, transform 420ms var(--ease-snap);
}
.qr .qr-done::before {
  content: ''; justify-self: center; width: 44px; height: 44px; border-radius: 50%; background: var(--ok)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' stroke='%23060914' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/26px no-repeat;
}
.slot.is-paired .qr .qr-done { opacity: 1; transform: none; }
.slot.is-keyboard .qr { background: var(--arena-2); }
.slot.is-keyboard .qr img { opacity: 0.06; }
.slot-info { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.slot-url { font-family: var(--mono); font-size: 11.5px; color: var(--line-3); word-break: break-all; line-height: 1.5; }
.slot-url b { font-weight: 600; color: var(--line); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--line-3); transition: color 200ms; }
.checks li::before {
  content: ''; flex: none; width: 16px; height: 16px; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--hair-strong);
  transition: background-color 200ms, box-shadow 200ms;
}
.checks li.ok { color: var(--line); }
.checks li.ok::before { background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.3 2.3 4.7-5' stroke='%23060914' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; box-shadow: none; }
.checks li.wait { color: var(--line-2); }
.checks li.wait::before { box-shadow: inset 0 0 0 1.5px var(--ball); animation: breathe 1.2s var(--ease-in-out) infinite; }
.checks li.bad { color: var(--p1); }
.checks li.bad::before { box-shadow: inset 0 0 0 2px var(--p1); }
@keyframes breathe { 50% { box-shadow: inset 0 0 0 5px var(--ball); } }
/* What to do about the phone's connection, under the checklist (ui.js connLine). */
.slot-help { margin: -4px 0 0 26px; font-size: 13px; line-height: 1.45; color: var(--line-3); max-width: 34ch; text-wrap: pretty; }
.slot-help.bad { color: var(--warn); }
.slot-alt { margin-top: auto; align-self: flex-start; color: var(--line-2); }
.slot-alt:hover { color: var(--ball); }
/* The hand the player plays with, across the foot of the card: their figure holds the paddle in it.
   A phone that hasn't been told one yet gets a ring and a word in the ball's colour (what to press),
   nothing louder. */
.slot-hand {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--hair);
}
.slot-hand[hidden] { display: none; }
.slot-hand .label { color: var(--line-3); }
.slot-hand.ask .seg { box-shadow: inset 0 0 0 1px var(--ball); }
.slot-hand-ask { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; line-height: 1.35; color: var(--line-2); }
.slot-hand-ask::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ball); }
.slot-hand-ask[hidden] { display: none; }

.options { display: flex; flex-wrap: wrap; gap: 18px 30px; padding: 18px 0 4px; margin-top: 10px; }
.opt { display: flex; flex-direction: column; gap: 8px; }
.opt .label { color: var(--line-3); }
/* Your name, online: the other screen's score bug and calls say it. */
.name-input {
  width: 200px; min-height: 40px; padding: 0 14px; border: 0; border-radius: var(--r-2);
  background: var(--arena); color: var(--line); box-shadow: inset 0 0 0 1px var(--hair-strong);
  font: 600 16px/1 var(--sans);
}
.name-input::placeholder { color: var(--line-3); font-weight: 700; }
.name-input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ball); }
/* Facecam: the switch, a peek at what the camera sees, and a word on where it stands. */
.cam-ctl { display: flex; align-items: center; gap: 12px; min-height: 42px; }
.cam-peek { flex: none; width: 56px; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--r-1); background: var(--arena); box-shadow: 0 0 0 1px var(--hair-strong); }
.cam-peek[hidden] { display: none; }
.cam-peek video { display: block; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-note { font-size: 13px; line-height: 1.35; color: var(--line-3); max-width: 34ch; }
.cam-note.bad { color: var(--warn); }
#online-options { padding-top: 10px; margin-top: 0; }
.lan-warn {
  margin: 16px 0 0; padding: 12px 14px; border-radius: var(--r-2);
  background: rgba(255, 176, 32, 0.1); box-shadow: inset 3px 0 0 var(--warn);
  font-size: 14px; line-height: 1.5; color: var(--line-2); max-width: 72ch;
}
.lan-warn[hidden] { display: none; }
.lan-warn b { color: var(--line); font-weight: 600; }
.lan-warn code { font-family: var(--mono); font-size: 12px; color: var(--warn); }

/* ================================================================== online */

.online-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0 6px; }
.online-col { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 16px 18px 18px; border-radius: var(--r-3); background: var(--arena-3); box-shadow: inset 0 0 0 1px var(--hair); }
.col-label { color: var(--line-3); }
.code-board { display: flex; gap: 6px; font-size: 54px; min-height: 60px; }
.code-input { position: relative; display: block; }
.code-input input { position: absolute; inset: 0; opacity: 0; font-size: 16px; cursor: text; }
.code-cells { display: flex; gap: 6px; }
.code-cells i {
  width: 46px; height: 60px; border-radius: var(--r-2); display: grid; place-items: center;
  font-style: italic; font-family: var(--display); font-weight: 850; font-stretch: 90%; font-size: 36px; color: var(--line);
  box-shadow: inset 0 0 0 1px var(--hair-strong); background: var(--arena);
  transition: box-shadow 140ms;
}
.code-input:focus-within .code-cells i.cur { box-shadow: inset 0 0 0 2px var(--ball); }
.slots-online .slot { grid-template-columns: 168px 1fr; }

/* ================================================================== how to */

.howto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin: 26px 0 12px; }
.howto-grid figure { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.howto-grid svg { width: 100%; height: auto; background: var(--court-deep); border-radius: var(--r-2); box-shadow: inset 0 0 0 2px var(--hair-strong); padding: 6px; }
.howto-grid .label { color: var(--ball); }
.howto-grid p { margin: 6px 0 0; font-size: 15px; line-height: 1.5; color: var(--line-2); }
.hw { fill: none; stroke: var(--line); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hw-p1 { fill: var(--p1); }
.hw-ink { stroke: var(--arena); stroke-width: 2; stroke-linecap: round; }
.hw-ball { fill: var(--ball); }
.hw-dash { fill: none; stroke: var(--line-3); stroke-width: 1.4; stroke-dasharray: 3 5; }
.hw-zone { fill: var(--hair-strong); }
.hw-good { fill: rgba(242, 245, 255, 0.4); }
.hw-perfect { fill: var(--ball); }
.hw-mark { stroke: var(--p1); stroke-width: 4; stroke-linecap: round; }
.hw-t { font: 600 8.5px var(--mono); letter-spacing: 0.08em; fill: var(--line-3); }
.hw-t-hot { fill: var(--ball); }
.hw-t-cool { fill: var(--p2); }
.keys kbd { margin: 0 2px; }

/* ================================================================== settings */

.rows { display: grid; margin-top: 8px; }
.rows-head { margin: 22px 0 0; padding-bottom: 8px; color: var(--line-2); font-weight: 500; border-bottom: 1px solid var(--hair-strong); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 0; border-bottom: 1px solid var(--hair); font-size: 15px; font-weight: 500; }
.row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row-hint { font-size: 12.5px; line-height: 1.4; font-weight: 400; color: var(--line-3); max-width: 44ch; }
.row-val { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.row-num { font-family: var(--mono); font-size: 12px; color: var(--line-2); text-align: right; }
.row-num.is-empty { font-family: var(--sans); font-size: 14px; color: var(--line-3); }

/* ================================================================== tutorial */

/* The lessons down one side (done ones ticked), the chosen one beside them. */
.tut { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 30px; margin-top: 22px; }
.tut-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; align-content: start; }
.tut-list button {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px;
  background: none; border: 0; border-radius: var(--r-1); color: var(--line-2); text-align: left; font-size: 14px;
  transition: background-color 140ms, color 140ms;
}
.tut-list button:hover, .tut-list button:focus-visible { outline: none; background: var(--arena-3); color: var(--line); }
.tut-list button[aria-current='step'] { background: var(--court-deep); color: var(--line); box-shadow: inset 0 0 0 1px var(--hair-strong); }
.tut-list .n { flex: none; width: 20px; font-family: var(--mono); font-size: 11px; color: var(--line-3); }
.tut-list .is-done .n { color: transparent; background: var(--ok); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 14'%3E%3Cpath d='M2 7l5 5 9-10' stroke='black' stroke-width='2.4' fill='none'/%3E%3C/svg%3E") left center / 14px 10px no-repeat; }
.tut-lesson { min-width: 0; }
.tut-kicker { display: flex; gap: 14px; margin: 0; color: var(--ball); }
.tut-done { color: var(--ok); }
.tut-lesson .panel-title { margin-top: 10px; }
.tut-body { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 14px; }
.tut-art { margin: 0; }
.tut-art svg { width: 100%; height: auto; background: var(--court-deep); border-radius: var(--r-2); box-shadow: inset 0 0 0 2px var(--hair-strong); padding: 6px; }
.tut-text p { margin: 0 0 10px; font-size: 15px; line-height: 1.55; color: var(--line-2); max-width: 62ch; }
.tut-text b { color: var(--line); font-weight: 600; }
.tut-goals-box { display: grid; gap: 8px; margin-top: 8px; }
.tut-goals-box > .label { color: var(--ball); }
.tut-goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-width: 520px; }
.tut-goals li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 14px; border-radius: var(--r-1); background: var(--arena-3); box-shadow: inset 0 0 0 1px var(--hair); font-size: 14px; }
.tut-goals b { font-family: var(--mono); font-weight: 500; color: var(--line); }
.tut-keys { margin-top: 12px; }
.tut-keys[hidden], .tut-slot[hidden], .tut-goals-box[hidden] { display: none; }
.tut-slot { margin-top: 18px; }
.tut-links { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 12px; }
.tut-links:empty { display: none; }

@media (max-width: 820px) {
  .tut { grid-template-columns: 1fr; gap: 18px; }
  .tut-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .tut-body { grid-template-columns: 1fr; }
  .tut-art { max-width: 240px; }
}

/* ================================================================== pause */

.list { display: grid; gap: 8px; margin-top: 26px; }
.list-row {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 60px; padding: 0 20px 0 50px;
  background: var(--arena-3); border: 0; border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--hair);
  color: var(--line); text-align: left;
  transition: background-color 160ms, box-shadow 160ms, transform 200ms var(--ease-out);
}
.list-row[hidden] { display: none; }
.list-row .name { font-size: 18px; font-weight: 600; }
.list-row .desc { color: var(--line-3); }
.list-row:hover, .list-row:focus-visible, .list-row.is-ball { outline: none; background: var(--court-deep); box-shadow: inset 0 0 0 2px var(--line); transform: translateX(4px); }
.score-tag { color: var(--line); }

/* ================================================================== split-flap cards */

.flap {
  --flap-bg: #1B2753; --flap-bg-2: #16214A; --flap-ink: var(--line);
  position: relative; display: inline-block;
  width: 0.66em; height: 1.1em;
  font-family: var(--display); font-weight: 850; font-stretch: 78%; line-height: 1;
  perspective: 6em;
  border-radius: 0.08em;
  box-shadow: 0 0.03em 0 rgba(0, 0, 0, 0.6), 0 0.08em 0.18em rgba(0, 0, 0, 0.4);
}
.flap-half { position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; backface-visibility: hidden; }
.flap-half b {
  position: absolute; left: 0; right: 0; height: 1.1em;
  display: flex; align-items: center; justify-content: center;
  color: var(--flap-ink); font-weight: 850;
}
.flap-top { top: 0; background: var(--flap-bg); border-radius: 0.08em 0.08em 0 0; }
.flap-bot { bottom: 0; background: var(--flap-bg-2); border-radius: 0 0 0.08em 0.08em; }
.flap-top b, .flap-leaf-top b { top: 0; }
.flap-bot b, .flap-leaf-bot b { bottom: 0; }
.flap::after { content: ''; position: absolute; left: 0; right: 0; top: calc(50% - 0.5px); height: 1px; background: rgba(0, 0, 0, 0.6); z-index: 3; }
.flap-leaf-top { top: 0; background: var(--flap-bg); border-radius: 0.08em 0.08em 0 0; transform-origin: 50% 100%; z-index: 2; }
.flap-leaf-bot { bottom: 0; background: var(--flap-bg-2); border-radius: 0 0 0.08em 0.08em; transform-origin: 50% 0%; transform: rotateX(90deg); z-index: 2; }
.flipping .flap-leaf-top { animation: leaf-top var(--flip, 120ms) cubic-bezier(0.55, 0, 0.9, 0.4) forwards; }
.flipping .flap-leaf-bot { animation: leaf-bot var(--flip, 120ms) cubic-bezier(0.2, 0.6, 0.35, 1.25) var(--flip, 120ms) forwards; }
@keyframes leaf-top { from { transform: rotateX(0); filter: brightness(1); } to { transform: rotateX(-90deg); filter: brightness(1.5); } }
@keyframes leaf-bot { from { transform: rotateX(90deg); filter: brightness(0.6); } to { transform: rotateX(0); filter: brightness(1); } }

/* ================================================================== HUD */

#hud { position: absolute; inset: 0; pointer-events: none; color: var(--line); }
#hud[hidden] { display: none; }

/* The score bug: two name plates either side of a slab of table, the net line between the scores. */
.bug {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: minmax(170px, auto) auto auto minmax(170px, auto); align-items: stretch;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  z-index: 5;
}
.bug-side {
  display: flex; flex-direction: column; justify-content: center; gap: 7px;
  padding: 10px 22px; background: var(--arena-2);
}
.bug-side[data-p='0'] { --pc: var(--p1); align-items: flex-end; text-align: right; clip-path: polygon(var(--lean) 0, 100% 0, 100% 100%, 0 100%); box-shadow: inset -6px 0 0 var(--pc); padding-right: 18px; }
.bug-side[data-p='1'] { --pc: var(--p2); align-items: flex-start; clip-path: polygon(0 0, 100% 0, calc(100% - var(--lean)) 100%, 0 100%); box-shadow: inset 6px 0 0 var(--pc); padding-left: 18px; }
.bug-name { display: flex; align-items: center; gap: 9px; font-weight: 700; font-stretch: 90%; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.serve-ball {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #FFE2BD 0 12%, var(--ball-hi) 22%, var(--ball) 55%, #C4560A 100%);
  opacity: 0; transform: scale(0.2); transition: opacity 200ms, transform 360ms var(--ease-snap);
}
.bug-side.serving .serve-ball { opacity: 1; transform: none; }
.board-games { display: flex; gap: 4px; min-height: 5px; }
.board-games i { width: 16px; height: 5px; border-radius: 1px; background: var(--hair-strong); transform: skewX(-20deg); }
.board-games i.won { background: var(--pc); }
.board-score { display: flex; gap: 3px; align-items: center; padding: 8px 12px; background: var(--court); font-size: 46px; box-shadow: inset 0 2px 0 var(--line), inset 0 -2px 0 var(--line); }
.board-score[data-p='0'] { box-shadow: inset 0 2px 0 var(--line), inset 0 -2px 0 var(--line), inset -1px 0 0 var(--line); }
.board-score[data-p='1'] { box-shadow: inset 0 2px 0 var(--line), inset 0 -2px 0 var(--line), inset 1px 0 0 var(--line); }
.board-score .flap { --flap-bg: #0E2D7C; --flap-bg-2: #0B2668; }
.board-score.won-point .flap { animation: score-pop 520ms var(--ease-snap); }
@keyframes score-pop { 0% { transform: scale(1); } 30% { transform: scale(1.14); filter: brightness(1.6); } 100% { transform: scale(1); } }

.board-note {
  position: absolute; top: 96px; left: 50%; transform: translate(-50%, -6px);
  padding: 7px 14px 6px; background: var(--ball); color: var(--ball-ink); font-weight: 700;
  clip-path: polygon(var(--lean) 0, calc(100% - var(--lean)) 0, 100% 100%, 0 100%);
  opacity: 0; transition: opacity 240ms, transform 360ms var(--ease-out); z-index: 4;
}
.board-note.show { opacity: 1; transform: translate(-50%, 0); animation: note-pulse 1.4s var(--ease-in-out) infinite; }
@keyframes note-pulse { 50% { background: var(--ball-hi); } }

/* Rally count: heats up as the rally runs. */
.rally-count {
  position: absolute; top: 22px; right: 28px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  opacity: 0; transform: translateX(10px); transition: opacity 300ms, transform 400ms var(--ease-out);
}
.rally-count.show { opacity: 1; transform: none; }
.rally-count .label { color: var(--line-3); }
.rc-n {
  display: block; font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 90%;
  font-size: 50px; line-height: 0.9; color: var(--line); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  transition: color 300ms;
}
.rally-count.bump .rc-n { animation: rc-bump 360ms var(--ease-snap); }
.rally-count[data-heat='1'] .rc-n { color: var(--ball-hi); }
.rally-count[data-heat='2'] .rc-n { color: var(--ball); text-shadow: 0 0 18px rgba(255, 138, 31, 0.7), 0 0 4px rgba(255, 138, 31, 0.9); }
.rally-count[data-heat='2'] .label { color: var(--ball); }
.rally-count[data-heat='3'] .rc-n { color: #FFF1DE; text-shadow: 0 0 24px rgba(255, 90, 31, 0.95), 0 0 8px rgba(255, 138, 31, 1); animation: rc-fire 700ms steps(2, jump-none) infinite; }
.rally-count[data-heat='3'] .label { color: var(--ball); }
.rally-count.is-best .label { color: var(--ball); }
@keyframes rc-bump { 0% { transform: scale(1); } 35% { transform: scale(1.35) skewX(-8deg); } 100% { transform: none; } }
@keyframes rc-fire { 50% { text-shadow: 0 0 30px rgba(255, 60, 31, 1), 0 0 10px rgba(255, 160, 60, 1); } }

/* Match intro: the two names, slammed in from either side. */
.intro { position: absolute; left: 0; right: 0; top: 30%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0 18px; opacity: 0; pointer-events: none; z-index: 6; }
.intro-side { display: flex; }
.intro-side[data-p='0'] { justify-content: flex-end; }
.intro-name {
  padding: 10px 34px 8px; color: var(--arena);
  font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 118%;
  font-size: clamp(34px, 4.6vw, 70px); line-height: 1; text-transform: uppercase; white-space: nowrap;
}
.intro-side[data-p='0'] .intro-name { background: var(--p1); clip-path: polygon(var(--lean) 0, 100% 0, calc(100% - var(--lean)) 100%, 0 100%); }
.intro-side[data-p='1'] .intro-name { background: var(--p2); clip-path: polygon(var(--lean) 0, 100% 0, calc(100% - var(--lean)) 100%, 0 100%); }
.intro-vs { font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 120%; font-size: clamp(28px, 3vw, 44px); color: var(--ball); text-transform: uppercase; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7); }
.intro-rules { grid-column: 1 / -1; justify-self: center; margin-top: 18px; padding: 6px 10px 5px; border-radius: var(--r-1); background: rgba(6, 9, 20, 0.86); color: var(--line); }
.intro.show { animation: fade-hold 2300ms linear forwards; }
.intro.show .intro-side[data-p='0'] { animation: intro-l 2300ms var(--ease-out) forwards; }
.intro.show .intro-side[data-p='1'] { animation: intro-r 2300ms var(--ease-out) forwards; }
.intro.show .intro-vs { animation: vs-in 2300ms var(--ease-snap) forwards; }
@keyframes fade-hold { 0% { opacity: 1; } 84% { opacity: 1; } 100% { opacity: 0; } }
@keyframes intro-l { 0% { transform: translateX(-60vw) skewX(-14deg); } 18% { transform: none; } 84% { transform: none; } 100% { transform: translateX(-12vw); } }
@keyframes intro-r { 0% { transform: translateX(60vw) skewX(-14deg); } 18% { transform: none; } 84% { transform: none; } 100% { transform: translateX(12vw); } }
@keyframes vs-in { 0%, 12% { transform: scale(3); opacity: 0; } 24% { transform: none; opacity: 1; } 100% { transform: none; opacity: 1; } }

.views { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr; }
.views.split { grid-template-columns: 1fr 1fr; }
.view { position: relative; overflow: hidden; }
.views:not(.split) .view[data-v='1'] { display: none; }
/* Doubles: a stable, readable turn badge away from the ball and timing meter. */
.doubles-turn { position: absolute; top: 112px; left: 28px; max-width: calc(100% - 56px); display: grid; gap: 4px; padding: 12px 18px; border-radius: var(--r-2); background: rgba(6, 9, 20, 0.92); box-shadow: inset 4px 0 0 var(--line-3), inset 0 0 0 1px var(--hair-strong); }
.doubles-turn[hidden] { display: none; }
/* Online doubles: the facecam holds the top-left corner, so the turn cue goes to the right. */
body:has(#facecam:not([hidden])) .doubles-turn { left: auto; right: 28px; }
.dt-label { color: var(--line-2); }
.dt-name { font: italic 900 26px/1.1 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.dt-next { color: var(--line-2); font-size: 12px; }
.doubles-turn[data-turn='you'] { box-shadow: inset 4px 0 0 var(--ok), inset 0 0 0 1px var(--ok); }
.doubles-turn[data-turn='you'] .dt-label { color: var(--ok); }
.doubles-turn[data-turn='partner'] { box-shadow: inset 4px 0 0 var(--coin), inset 0 0 0 1px var(--hair-strong); }
.doubles-turn[data-turn='partner'] .dt-label { color: var(--coin); }
@media (max-width: 600px), (max-height: 520px) {
  .doubles-turn { top: 92px; left: 12px; max-width: calc(100% - 24px); padding: 8px 12px; }
  body:has(#facecam:not([hidden])) .doubles-turn { left: auto; right: 12px; max-width: calc(100% - 168px); }
  .dt-name { font-size: 20px; }
}
/* Split screen: the line down the middle is the table's own centre line. */
.divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 6px; margin-left: -3px; background: linear-gradient(90deg, var(--arena) 0 2px, var(--line) 2px 4px, var(--arena) 4px); display: none; }
.divider.show { display: block; }

/* Callouts: the point's one word, slammed onto the screen with a stripe in the winner's colour. */
.callout { --c: var(--line); position: absolute; left: 0; right: 0; top: 30%; display: flex; flex-direction: column; align-items: center; gap: 14px; opacity: 0; }
.callout-word {
  position: relative; padding: 0 0.12em;
  font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 125%;
  font-size: clamp(64px, 8.6vw, 136px); line-height: 0.9; letter-spacing: -0.015em; text-transform: uppercase;
  color: var(--line);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.55);
}
.callout-word::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -0.16em; height: 0.12em;
  background: var(--c); transform: skewX(-24deg) scaleX(0); transform-origin: 0 50%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.views.split .callout-word { font-size: clamp(44px, 5.4vw, 88px); }
.callout-sub { margin-top: 4px; padding: 6px 10px 5px; border-radius: var(--r-1); background: rgba(6, 9, 20, 0.86); color: var(--line); }
.callout.show { animation: callout-in 420ms var(--ease-snap) forwards; }
.callout.show .callout-word::after { animation: stripe-in 300ms var(--ease-out) 90ms forwards; }
.callout.hide { animation: callout-out 300ms var(--ease-in-out) forwards; }
.callout.hide .callout-word::after { transform: skewX(-24deg); }
@keyframes callout-in { from { opacity: 0; transform: scale(1.5) skewX(-12deg); filter: blur(8px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes stripe-in { to { transform: skewX(-24deg) scaleX(1); } }
@keyframes callout-out { from { opacity: 1; } to { opacity: 0; transform: translateX(60px) skewX(-10deg); filter: blur(4px); } }

/* Timing meter: where in the window the swing landed, the grade above it. */
.meter { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); display: grid; justify-items: center; gap: 7px; opacity: 0; transition: opacity 260ms; }
.meter.show { opacity: 1; transition: opacity 60ms; }
.meter-grade {
  font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 115%;
  font-size: 34px; line-height: 1; text-transform: uppercase; color: var(--line);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}
.meter.show .meter-grade { animation: grade-in 360ms var(--ease-snap); }
.meter[data-grade='perfect'] .meter-grade { color: var(--ball); text-shadow: 0 0 20px rgba(255, 138, 31, 0.6), 0 2px 10px rgba(0, 0, 0, 0.7); }
.meter[data-grade='early'] .meter-grade, .meter[data-grade='late'] .meter-grade { color: var(--line-2); }
.meter[data-grade='miss'] .meter-grade { color: var(--p1); }
@keyframes grade-in { from { transform: scale(1.6) skewX(-10deg); opacity: 0; } }
.meter-track {
  position: relative; width: 300px; height: 8px; border-radius: 2px;
  background: rgba(6, 9, 20, 0.7); box-shadow: inset 0 0 0 1px var(--hair-strong), 0 2px 10px rgba(0, 0, 0, 0.5);
}
.meter-track i { position: absolute; top: 0; bottom: 0; display: block; }
/* Good: |d| < 0.55, Perfect: |d| < 0.2; the track spans d −1.09…+1.09 (46% per unit). */
.meter-good { left: calc(50% - 25.3%); width: 50.6%; background: rgba(242, 245, 255, 0.32); }
.meter-perfect { left: calc(50% - 9.2%); width: 18.4%; background: var(--ball); box-shadow: 0 0 10px rgba(255, 138, 31, 0.6); }
.meter-track .meter-mark {
  left: 50%; top: -8px; bottom: -8px; width: 5px; margin-left: -2.5px; border-radius: 2px;
  background: var(--mark, var(--p1)); box-shadow: 0 0 0 2px var(--arena), 0 2px 8px rgba(0, 0, 0, 0.6);
  transition: left 160ms var(--ease-out);
}
.meter-foot { display: flex; justify-content: space-between; width: 300px; color: var(--line-3); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); }
/* Split screen: a smaller grade. */
.meter-grade { white-space: nowrap; }
.views.split .meter-grade { font-size: 28px; }
.meter-speed { color: var(--line); }
/* The read: what the incoming spin did, in a line under the grade. Up ~0.75 s, gone before the meter.
   The dot is the trail colour of the spin it names, so colour and fix get learned together. */
.meter-read {
  --tone: var(--line-3);
  display: inline-flex; align-items: center; gap: 8px; margin-top: -2px;
  padding: 5px 10px 4px 8px; border-radius: var(--r-1);
  background: rgba(6, 9, 20, 0.8); box-shadow: inset 0 0 0 1px var(--hair);
  font: 600 12px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; color: var(--line);
  opacity: 0;
}
.meter-read:empty { display: none; }
.meter-read::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 8px var(--tone); }
.meter-read[data-tone='top'] { --tone: var(--spin-top); }
.meter-read[data-tone='back'] { --tone: var(--spin-back); }
.meter-read[data-tone='warn'] { --tone: var(--warn); }
.meter-read.ok { color: var(--tone); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 45%, transparent); }
.meter.show .meter-read.show { animation: read-life 780ms var(--ease-out) forwards; }
@keyframes read-life {
  0% { opacity: 0; transform: translateY(5px); }
  14% { opacity: 1; transform: none; }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

/* Item slot (power-ups): bottom-left of each player's view. Empty until a mode deals items. */
.item { --ic: var(--line); position: absolute; left: 24px; bottom: 24px; display: grid; grid-template-columns: 56px auto; align-items: center; gap: 12px; }
.item[hidden] { display: none; }
.item-ring { grid-row: 1; grid-column: 1; width: 56px; height: 56px; transform: rotate(-90deg); }
.item-ring circle { fill: rgba(6, 9, 20, 0.75); stroke: var(--hair-strong); stroke-width: 3; }
.item-ring .item-charge { fill: none; stroke: var(--ic); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: calc(1 - var(--charge, 0)); transition: stroke-dashoffset 300ms var(--ease-out); }
.item-icon { grid-row: 1; grid-column: 1; justify-self: center; width: 26px; height: 26px; color: var(--ic); display: grid; place-items: center; font-family: var(--display); font-style: italic; font-weight: 900; font-size: 20px; }
.item-icon svg { width: 100%; height: 100%; }
.item-name { grid-row: 1; grid-column: 2; color: var(--line); white-space: nowrap; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
.item.ready .item-ring { filter: drop-shadow(0 0 8px var(--ic)); animation: item-ready 1.1s var(--ease-in-out) infinite; }
@keyframes item-ready { 50% { filter: drop-shadow(0 0 16px var(--ic)); } }

.hint {
  position: absolute; left: 50%; bottom: 4.5%; transform: translate(-50%, 8px);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px 8px 8px; border-radius: var(--r-2);
  background: rgba(11, 17, 36, 0.92); box-shadow: inset 0 0 0 1px var(--hair-strong), var(--lift-2);
  font-size: 15px; font-weight: 500; color: var(--line);
  /* One line where it fits; wrapped inside the view where it doesn't (half a split screen, a phone). */
  width: max-content; max-width: calc(100% - 32px); text-wrap: balance;
  opacity: 0; transition: opacity 260ms, transform 360ms var(--ease-out);
}
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.hint .k {
  flex: none;
  padding: 6px 9px 5px; border-radius: var(--r-1); background: var(--ball); color: var(--ball-ink);
  font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
}
/* Spin tips wear the trail colour they teach. */
.hint .k.k-top { background: var(--spin-top); }
.hint .k.k-back { background: var(--spin-back); color: var(--arena); }

/* Facecam: the players' cameras, top-left. A plate of the arena with the camera set in it, a name
   plate leaning out of its bottom edge like the score bug's; online, your own camera sits inset in
   the far corner, edged in your colour. Wipes in the way panels do. */
.facecam {
  --self-ink: var(--line);
  position: absolute; top: 18px; left: 18px; z-index: 5;
  width: clamp(176px, 17vw, 260px);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  animation: fc-in 460ms var(--ease-out) both;
}
.facecam[hidden] { display: none; }
@keyframes fc-in { from { clip-path: polygon(0 0, 0 0, -12% 100%, 0 100%); } to { clip-path: polygon(0 0, 112% 0, 100% 100%, 0 100%); } }
.fc-main {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  border-radius: var(--r-2); background: var(--arena-3);
}
.fc-main::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--hair-strong); pointer-events: none; }
.fc-main video, .fc-self video { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--arena); }
.facecam.mirror .fc-main video, .fc-self video { transform: scaleX(-1); }
.facecam[data-main='empty'] .fc-main video { visibility: hidden; }
.fc-empty {
  position: absolute; inset: 0; display: none; place-items: center; align-content: center; gap: 8px;
  background: radial-gradient(120% 90% at 50% 30%, var(--court-deep), var(--arena-2));
  color: var(--line-3);
}
.facecam[data-main='empty'] .fc-empty { display: grid; }
.fc-empty svg { width: 34%; max-width: 72px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fc-plates { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.fc-plate {
  --pc: var(--line);
  display: inline-flex; align-items: center; min-width: 0;
  padding: 5px 16px 4px 12px; background: var(--arena-2);
  box-shadow: inset 4px 0 0 var(--pc);
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--lean)) 100%, 0 100%);
  font-weight: 700; font-stretch: 90%; font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; color: var(--line);
}
.fc-plate span { overflow: hidden; text-overflow: ellipsis; }
/* Two players on one camera: the second plate leans in from the right edge. */
.fc-plate + .fc-plate { padding: 5px 12px 4px 16px; box-shadow: inset -4px 0 0 var(--pc); clip-path: polygon(var(--lean) 0, 100% 0, 100% 100%, 0 100%); }
.fc-self {
  position: absolute; right: 8px; bottom: 8px; width: 32%; aspect-ratio: 4 / 3; overflow: hidden;
  border-radius: var(--r-1); background: var(--arena);
  box-shadow: 0 0 0 2px var(--self-ink), 0 4px 12px rgba(0, 0, 0, 0.5);
  display: none;
}
.facecam[data-self='on'] .fc-self { display: block; }
.fc-self .label { position: absolute; left: 4px; top: 3px; font-size: 8.5px; color: var(--line); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }
/* With the inset there, the name plate keeps clear of it. */
.facecam[data-self='on'] .fc-plates { right: calc(32% + 14px); }

.net-chip { position: absolute; right: 22px; bottom: 20px; padding: 7px 11px; border-radius: var(--r-1); background: rgba(11, 17, 36, 0.9); box-shadow: inset 0 0 0 1px var(--hair); color: var(--line-2); }

.banner {
  position: absolute; top: 112px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; background: var(--warn); color: var(--ball-ink);
  clip-path: polygon(var(--lean) 0, 100% 0, calc(100% - var(--lean)) 100%, 0 100%);
  z-index: 10;
}
.banner[hidden] { display: none; }

.audio-gate { position: absolute; right: 24px; bottom: 22px; color: var(--line-3); transition: opacity 400ms; pointer-events: none; }
.audio-gate.gone { opacity: 0; }
.in-match .audio-gate { display: none; }

/* ================================================================== results */

.result-title {
  margin: 26px 0 4px;
  font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 125%;
  font-size: clamp(56px, 6.6vw, 104px); line-height: 0.9; letter-spacing: -0.02em; text-transform: uppercase;
}
.panel.is-active .result-title { animation: wm-in 640ms var(--ease-snap) 120ms both; }
.result-score { display: flex; align-items: center; gap: 16px; font-size: 64px; margin: 16px 0 20px; }
.result-score .dash { width: 22px; height: 4px; background: var(--line-3); transform: skewX(-20deg); }
.result-score .games { font-family: var(--mono); font-size: 12px; color: var(--line-3); letter-spacing: 0.08em; text-transform: uppercase; margin-left: 10px; }

/* Stats: the broadcast tale of the tape. Bars grow out from the middle. */
.stats { display: grid; gap: 2px; margin-bottom: 16px; }
.stat { display: grid; grid-template-columns: 74px 1fr 150px 1fr 74px; align-items: center; gap: 12px; padding: 7px 0; }
.stat-head { padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--hair); }
.stat-head .sv { font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--line); }
.stat-head .sv::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 1px; background: var(--sc); vertical-align: 1px; }
.stat .sv { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--line-3); white-space: nowrap; }
.stat .sv.a { --sc: var(--p1); text-align: left; }
.stat .sv.b { --sc: var(--p2); text-align: right; }
.stat-head .sv.a { grid-column: 1 / 3; }
.stat-head .sv.b { grid-column: 4 / 6; }
.stat .sv.lead { color: var(--line); }
.stat .sk { text-align: center; color: var(--line-2); }
.stat-foot { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--hair); text-align: center; color: var(--line-3); }
.sbar { height: 8px; background: var(--hair); border-radius: 1px; overflow: hidden; display: flex; }
.sbar.a { justify-content: flex-end; }
.sbar i { display: block; height: 100%; width: calc(var(--w, 0) * 100%); background: var(--sc); transform: scaleX(0); }
.sbar.a i { --sc: var(--p1); transform-origin: 100% 50%; }
.sbar.b i { --sc: var(--p2); transform-origin: 0 50%; }
.panel.is-active .sbar i { animation: bar-grow 700ms var(--ease-out) forwards; animation-delay: calc(400ms + var(--n, 0) * 60ms); }
@keyframes bar-grow { to { transform: scaleX(1); } }

/* ================================================================== small screens */

@media (max-width: 820px) {
  .panel, .panel-wide, .panel-wide.panel-solo { top: 12px; left: 12px; bottom: 12px; width: calc(100vw - 24px); --pad-b: 18px; padding: 22px 20px var(--pad-b); }
  .online-grid { grid-template-columns: 1fr; }
  .slot { grid-template-columns: 128px 1fr; }
  .qr { width: 128px; height: 128px; }
  .bug { transform: translateX(-50%) scale(0.78); transform-origin: top center; }
  .facecam { top: 12px; left: 12px; width: 132px; }
  .fc-plate { font-size: 10.5px; padding: 4px 12px 3px 9px; }
  /* (wide enough for "30 km/h": at 56 px it ran over its bar and out of the panel) */
  .stat { grid-template-columns: 70px 1fr 104px 1fr 70px; gap: 10px; }
  .stat .sv { font-size: 13px; }
  .meter-track, .meter-foot { width: 240px; }
}
@media (max-width: 640px) {
  /* The score bug spans the top here: the camera tucks in under it. */
  .facecam { top: 84px; width: 112px; }
}
@media (max-width: 560px) {
  .title { padding: 16px; }
  .title-main { width: 100%; align-self: start; padding-top: 16px; }
  .wordmark { font-size: 17vw; }
  .tape { height: 16px; }
  .topbar-join { display: none; }
  /* The footer's note over its button: side by side, the note was squeezed to a word a line. */
  .panel-foot { flex-direction: column; align-items: stretch; gap: 12px; }
  .panel-foot .btn { margin-left: 0; }
  /* Settings: the control under its name, not squeezed beside it. */
  .row { flex-direction: column; align-items: stretch; gap: 10px; }
  .row .seg { align-self: flex-start; }
  .title::before { background: rgba(6, 9, 20, 0.78); }
}
/* Short screens (a laptop at 720, a TV at 1280 × 720): the name shrinks and the rows tighten,
   so the whole menu still fits without scrolling. */
@media (max-height: 760px) {
  .tagline { display: none; }
  .mode { min-height: 38px; }
  .mode-group { margin-top: 10px; }
}
@media (max-height: 600px) and (min-width: 561px) {
  .mode { min-height: 32px; }
  .mode-name { font-size: 16px; }
  .mg-hint { display: none; }
  .mode-group { margin: 6px 0 2px; }
}

/* Instant replay: letterboxed, the play's own graphics (hints, meters, callouts, the rally count) put
   away; the score bug stays. A broadcast bug top right: REPLAY with a red dot, a line under it that
   fills as it plays, and how to skip. */
body.replaying #views, body.replaying #rally-count, body.replaying #divider, body.replaying #facecam, body.replaying #board-note { visibility: hidden; }
#hud::before, #hud::after { content: ''; position: absolute; left: 0; right: 0; height: 0; background: #000; pointer-events: none; transition: height 320ms var(--ease-out); z-index: 0; }
#hud::before { top: 0; }
#hud::after { bottom: 0; }
body.replaying #hud::before, body.replaying #hud::after { height: 7vh; }
.replay-bug {
  --p: 0; position: absolute; right: 22px; top: calc(7vh + 14px); display: grid; justify-items: end; gap: 6px; z-index: 2;
  opacity: 0; transform: translateX(40px) skewX(-8deg);
}
.replay-bug.show { animation: rb-in 360ms var(--ease-snap) forwards; }
.rb-word {
  display: inline-flex; align-items: center; gap: 10px; padding: 7px 20px 6px 16px; background: var(--line); color: var(--arena);
  font-family: var(--display); font-style: italic; font-weight: 900; font-stretch: 125%; font-size: clamp(22px, 2.4vw, 34px); line-height: 1; text-transform: uppercase;
  clip-path: polygon(var(--lean) 0, 100% 0, calc(100% - var(--lean)) 100%, 0 100%);
}
.rb-dot { width: 0.42em; height: 0.42em; border-radius: 50%; background: var(--p1); animation: rb-blink 1s steps(2, jump-none) infinite; }
.rb-bar { display: block; width: 100%; height: 3px; background: var(--hair-strong); position: relative; overflow: hidden; }
.rb-bar::after { content: ''; position: absolute; inset: 0; background: var(--ball); transform-origin: 0 50%; transform: scaleX(var(--p)); }
.rb-slow { padding: 4px 8px 3px; border-radius: var(--r-1); background: var(--ball); color: var(--ball-ink); opacity: 0; transition: opacity 200ms; }
body.replay-slow .rb-slow { opacity: 1; }
.rb-skip { color: var(--line-2); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
@keyframes rb-in { to { opacity: 1; transform: none; } }
@keyframes rb-blink { 0% { opacity: 1; } 100% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .replay-bug.show { animation-duration: 1ms; } .rb-dot { animation: none; } }
