:root {
  --ink: #fbf6ea;
  --dark: #1b1b2f;
  --panel: rgba(27, 27, 47, 0.86);
  --mute: #a9a7c9;
  --accent: #ffcf3f;
  --p0: #ff6b4a;
  --p1: #3fb6ff;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f3b37a; color: var(--ink); }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

button { font: inherit; color: inherit; border: 0; cursor: pointer; }
.big {
  font-size: 20px; font-weight: 800; padding: 16px 26px; border-radius: 14px;
  background: var(--accent); color: var(--dark); box-shadow: 0 5px 0 #b8901a;
  transition: transform 80ms ease-out, box-shadow 80ms ease-out, opacity 150ms;
}
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #b8901a; }
.big:disabled { opacity: 0.4; cursor: default; }
.ghost { padding: 16px 22px; border-radius: 14px; background: transparent; border: 2px solid #4a4a78; font-weight: 700; color: var(--mute); }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at center, rgba(27,27,47,0.25), rgba(27,27,47,0.6)); }
.card { background: var(--panel); backdrop-filter: blur(8px); border-radius: 24px; padding: 28px 32px; width: min(860px, 100%);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35); animation: rise 380ms cubic-bezier(.2,1.3,.4,1); }
.card.small { width: min(460px, 100%); text-align: center; }
@keyframes rise { from { transform: translateY(18px) scale(0.97); opacity: 0; } }

.logo { margin: 0; font-size: 48px; font-weight: 900; letter-spacing: 0.04em; }
.logo span { color: var(--accent); }
.tag { color: var(--mute); margin: 4px 0 20px; }

.cols { display: grid; grid-template-columns: 220px 1fr; gap: 28px; }
.join { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#qr { background: #fff; border-radius: 14px; padding: 8px; width: 200px; height: 200px; }
.code-wrap { font-size: 15px; color: var(--mute); }
.code-wrap b { color: var(--ink); font-size: 26px; letter-spacing: 0.2em; margin-left: 6px; }
.url { font-size: 12px; color: var(--mute); word-break: break-all; text-align: center; }

.setup { display: flex; flex-direction: column; gap: 14px; }
.field .lbl { font-size: 13px; color: var(--mute); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.08em; }
.seg { display: inline-flex; flex-wrap: wrap; background: rgba(255,255,255,0.06); border-radius: 12px; padding: 4px; }
.seg button { padding: 9px 16px; border-radius: 9px; color: var(--mute); font-weight: 700; background: transparent; }
.seg button.on { background: #3a3a66; color: var(--ink); }

#slots { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 8px; }
#slots li { display: grid; grid-template-columns: 14px 38px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,0.05); }
#slots li.off { opacity: 0.35; }
.sw { width: 14px; height: 14px; border-radius: 50%; }
[data-slot="0"] .sw { background: var(--p0); }
[data-slot="1"] .sw { background: var(--p1); }
.who { font-weight: 800; }
.st { color: var(--mute); font-size: 14px; }
.st.ok { color: #7dffa8; }
.kb { font-size: 13px; color: var(--mute); display: flex; gap: 6px; align-items: center; }

.help { margin-top: 18px; color: var(--mute); font-size: 14px; }
.help summary { cursor: pointer; font-weight: 700; }
.help ol { padding-left: 20px; line-height: 1.55; }
kbd { background: #3a3a66; border-radius: 5px; padding: 1px 6px; font-size: 12px; color: var(--ink); }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#scoreboard { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px;
  background: var(--panel); border-radius: 18px; padding: 8px 14px; }
#scoreboard .side { display: flex; align-items: center; gap: 10px; }
#scoreboard .nm { font-weight: 800; font-size: 18px; min-width: 60px; }
.p0 .nm { color: var(--p0); text-align: right; }
.p1 .nm { color: var(--p1); }
.pts { font-size: 40px; font-weight: 900; min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.pts.bump { animation: bump 420ms cubic-bezier(.2,1.6,.4,1); }
@keyframes bump { from { transform: scale(1.6); color: var(--accent); } }
.sv { color: var(--accent); font-size: 12px; opacity: 0; transition: opacity 200ms; }
.sv.on { opacity: 1; }
.to { color: var(--mute); font-size: 12px; }

#callout { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); font-size: 72px; font-weight: 900;
  letter-spacing: 0.02em; text-shadow: 0 6px 0 rgba(27,27,47,0.5); white-space: nowrap; opacity: 0; }
#callout.show { animation: callout 1500ms cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes callout {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.96); }
}
#hint { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--panel); padding: 10px 18px;
  border-radius: 99px; font-size: 18px; font-weight: 700; transition: opacity 200ms; }
#hint:empty { opacity: 0; }
#pauseBanner { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(27,27,47,0.55); font-size: 28px; font-weight: 800; }

#over h2 { font-size: 40px; margin: 0; }
.big-score { font-size: 56px; font-weight: 900; margin: 6px 0; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }

/* online lobby */
.online-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.online-row .ghost { padding: 10px 16px; }
.or { color: var(--mute); font-size: 13px; }
#onCode { font: inherit; font-weight: 800; letter-spacing: 0.25em; text-transform: uppercase; width: 120px; padding: 10px 12px;
  border-radius: 10px; border: 2px solid #4a4a78; background: rgba(255,255,255,0.05); color: var(--ink); outline: none; }
#onCode:focus { border-color: var(--accent); }
.oncode { color: var(--mute); }
.oncode b { color: var(--ink); font-size: 24px; letter-spacing: 0.2em; margin-left: 6px; }
.onstatus { margin: 8px 0 0; color: var(--mute); font-size: 14px; min-height: 1.2em; }
.onstatus.err { color: #ff8f7a; }

/* first-person hit cue: gold glow around the screen edge while the shuttle is in reach */
#fpCue { position: absolute; inset: 0; box-shadow: inset 0 0 90px 18px rgba(255, 207, 63, 0.75); opacity: 0; transition: opacity 90ms ease-out; }
#fpCue.on { opacity: 1; }
#fpCue.near { opacity: 0.25; transition-duration: 200ms; }

/* split screen: divider, per-half edge glow and timing text */
#splitLine { position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; transform: translateX(-50%); background: rgba(27,27,47,0.85); }
#fpCue.half { right: 50%; }
#fpCue2 { position: absolute; inset: 0 0 0 50%; box-shadow: inset 0 0 90px 18px rgba(255, 207, 63, 0.75); opacity: 0; transition: opacity 90ms ease-out; }
#fpCue2.on { opacity: 1; }
#fpCue2.near { opacity: 0.25; transition-duration: 200ms; }
#timing.half { left: 25%; }
#timing2 { position: absolute; bottom: 82px; left: 75%; transform: translateX(-50%); font-size: 30px; font-weight: 900; opacity: 0; white-space: nowrap;
  text-shadow: 0 4px 0 rgba(27,27,47,0.45); }
#timing2.show { animation: timingPop 900ms cubic-bezier(.2,1.5,.4,1) forwards; }
#timing2 small { font-size: 16px; font-weight: 700; opacity: 0.85; margin-left: 8px; }

/* timing feedback */
#timing { position: absolute; bottom: 82px; left: 50%; transform: translateX(-50%); font-size: 30px; font-weight: 900; opacity: 0; white-space: nowrap;
  text-shadow: 0 4px 0 rgba(27,27,47,0.45); }
#timing.show { animation: timingPop 900ms cubic-bezier(.2,1.5,.4,1) forwards; }
#timing small { font-size: 16px; font-weight: 700; opacity: 0.85; margin-left: 8px; }
@keyframes timingPop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -14px); }
}
#practiceStats { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); background: var(--panel); border-radius: 18px;
  padding: 12px 20px; display: flex; gap: 22px; font-weight: 800; font-size: 18px; white-space: nowrap; }
#practiceStats span { color: var(--mute); font-weight: 600; font-size: 13px; display: block; text-transform: uppercase; letter-spacing: 0.06em; }
.row.left { justify-content: flex-start; margin-top: 4px; }

/* cricket scoreboard */
#crHud { position: absolute; top: 18px; left: 18px; background: var(--panel); border-radius: 18px; padding: 12px 18px; min-width: 240px; }
.cr-main { display: flex; align-items: baseline; gap: 12px; }
#crName { font-weight: 800; color: var(--p0); font-size: 18px; }
#crScore { font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; }
#crOvers { color: var(--mute); font-weight: 700; }
.cr-sub { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 4px; }
#crLog { display: flex; gap: 5px; }
#crLog span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: rgba(255,255,255,0.1); }
#crLog span.b { background: var(--accent); color: var(--dark); }
#crLog span.w { background: #ff5a4a; }
#crLog span.z { color: var(--mute); }
#crSpeed { color: var(--mute); font-size: 13px; font-weight: 700; }
#crNeed { margin-top: 6px; color: var(--accent); font-weight: 800; }
#crCalib { position: absolute; top: 104px; left: 50%; transform: translateX(-50%); width: min(520px, 90%); background: var(--panel); border-radius: 18px; padding: 16px 20px; text-align: center; }
#crCalib b { font-size: 22px; color: var(--accent); }
#crCalib p { font-size: 18px; font-weight: 700; margin: 8px 0 10px; }
#crCalib .bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; }
#crCalib .bar i { display: block; height: 100%; width: 0; background: #7dffa8; transition: width 80ms linear; }
#crCalib small { display: block; margin-top: 10px; color: var(--mute); font-size: 13px; line-height: 1.4; }
/* Batting: the bat fills the bottom of the screen, so text moves up out of its way. */
body.cricket #hint { bottom: auto; top: 18px; left: auto; right: 18px; transform: none; }
body.cricket #timing { bottom: auto; top: 46%; }

/* tuning panel */
#tune { position: fixed; top: 16px; right: 16px; width: 320px; max-height: calc(100% - 32px); overflow: auto; background: var(--panel);
  backdrop-filter: blur(8px); border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; z-index: 5;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35); }
#tune header { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
#tune .x { font-size: 24px; line-height: 1; background: none; color: var(--mute); padding: 0 4px; }
#tune label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink); }
#tune label output { color: var(--accent); font-variant-numeric: tabular-nums; margin-left: 6px; }
#tune label.check { flex-direction: row; align-items: center; gap: 8px; }
#tune input[type=range] { width: 100%; accent-color: var(--accent); }
#tune .hint { color: var(--mute); font-size: 12px; margin: -4px 0 2px; }
.readout { font: 12px/1.5 ui-monospace, Menlo, monospace; color: var(--mute); background: rgba(255,255,255,0.05); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; }

@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .card, .pts.bump, #callout.show { animation-duration: 1ms; } #callout.show { opacity: 1; } }
