/* Swishey Five (/demo)
   Phones: the game fills the screen under a slim header, no page scroll.
   Desktop (>= 860px): the game sits in an app window on the golden Swishey sky. */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Pixelify Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("../fonts/pixelify-sans-var.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/inter-500.woff") format("woff"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/inter-600.woff") format("woff"); }

:root {
  --yellow: #ffc800;
  --yellow-2: #ffd84d;
  --yellow-deep: #d9a400;
  --charcoal: #242424;
  --ink: #16122b;
  --navy: #1b1640;
  --navy-2: #221c4f;
  --navy-3: #2c2563;
  --line: #3a3378;
  --text: #f6f3ff;
  --muted: #bdb6e2;
  --good: #63d99a;
  --fair: #d6d1f2;
  --poor: #ff7a66;
  --px: "Press Start 2P", ui-monospace, monospace;
  --pix: "Pixelify Sans", "Inter", ui-sans-serif, system-ui, sans-serif;
  --ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --head-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body.five-page {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  font-family: var(--pix);
  color: var(--text);
  background: #fff8e1;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -80px; z-index: 50; background: var(--charcoal); color: #fff; padding: 10px 14px; border-radius: 10px; font-family: var(--ui); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 10px; }

/* ---------- sky + header ---------------------------------------------- */
.five-sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 108%, #fff 40%, rgba(255, 255, 255, 0) 72%),
    radial-gradient(ellipse 55% 60% at 8% -5%, rgba(255, 244, 205, 0.95), rgba(255, 244, 205, 0) 70%),
    radial-gradient(ellipse 55% 60% at 92% -5%, rgba(255, 214, 92, 0.9), rgba(255, 214, 92, 0) 70%),
    linear-gradient(180deg, #ffd23a 0%, #ffdc66 30%, #ffeeb0 62%, #fffaf0 100%);
}
.five-head {
  flex: none; height: var(--head-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  padding-top: env(safe-area-inset-top);
  height: calc(var(--head-h) + env(safe-area-inset-top));
}
.five-head__logo { display: inline-flex; border-radius: 8px; }
.five-head__logo img { height: 24px; width: auto; }
.five-head__right { display: flex; align-items: center; gap: 8px; }
.five-head__beta {
  display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 999px;
  background: var(--charcoal); color: #fff; font-family: var(--ui); font-weight: 600; font-size: 14px; text-decoration: none;
  transition: transform 160ms var(--ease), background-color 160ms;
}
.five-head__beta:hover { background: #000; transform: translateY(-1px); }
.five-head__beta:active { transform: translateY(0) scale(0.98); }
.five-head :focus-visible { outline-color: var(--charcoal); }

.sound-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 10px;
  border-radius: 999px; border: 1px solid rgba(36, 36, 36, 0.16); background: rgba(255, 255, 255, 0.7);
  color: var(--charcoal); font-family: var(--ui); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background-color 160ms, border-color 160ms, transform 160ms var(--ease);
}
.sound-btn:hover { background: #fff; border-color: rgba(36, 36, 36, 0.3); }
.sound-btn:active { transform: scale(0.97); }
.sound-btn svg { width: 18px; height: 18px; }
.sound-btn__on { display: none; }
.sound-btn.is-on .sound-btn__on { display: block; }
.sound-btn.is-on .sound-btn__off { display: none; }
.sound-btn.is-on { background: var(--charcoal); color: var(--yellow); border-color: var(--charcoal); }
@media (max-width: 420px) { .sound-btn__label { display: none; } .sound-btn { padding: 0 10px; } }

/* ---------- app frame -------------------------------------------------- */
.five { flex: 1; min-height: 0; display: flex; }
.five-app {
  position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--navy);
  background-image: radial-gradient(ellipse 80% 50% at 50% 0%, #2a2266 0%, rgba(42, 34, 102, 0) 70%);
  overflow: hidden;
}
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view--intro, .view--results, .view--error { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

@media (min-width: 860px) {
  body.five-page { padding-bottom: 28px; }
  .five { padding: 4px 28px 0; justify-content: center; }
  .five-app {
    flex: 0 1 1180px; height: 100%; max-height: 820px;
    border-radius: 22px; border: 1px solid rgba(22, 18, 43, 0.6);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 40px 80px -30px rgba(80, 52, 0, 0.55), 0 12px 30px -12px rgba(22, 18, 43, 0.5);
  }
  @media (prefers-reduced-motion: no-preference) {
    .five-app { animation: app-in 700ms var(--ease) both; }
    @keyframes app-in { from { opacity: 0; transform: translateY(18px) scale(0.985); } }
  }
}

/* ---------- loading ---------------------------------------------------- */
.view--load { align-items: center; justify-content: center; gap: 22px; }
.loadmark { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
.loadmark img { width: 56px; filter: drop-shadow(0 0 18px rgba(255, 200, 0, 0.55)); }
.loadmark__floor { position: absolute; left: 30px; right: 30px; bottom: 6px; height: 4px; background: rgba(255, 255, 255, 0.12); border-radius: 2px; }
.pixball {
  position: absolute; left: calc(50% + 34px); bottom: 10px; width: 12px; height: 12px;
  background: #f07b22; box-shadow: 0 0 0 2px var(--ink), inset -3px -3px 0 #c4561a, inset 2px 2px 0 #ffb46b;
  animation: pixbounce 640ms cubic-bezier(0.5, 0, 0.5, 1) infinite alternate;
}
@keyframes pixbounce { from { transform: translateY(0) scaleY(0.82); } 18% { transform: translateY(-4px) scaleY(1); } to { transform: translateY(-46px); } }
.loadmark__text { font-family: var(--px); font-size: 10px; letter-spacing: 0.08em; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .pixball { animation: none; } }

/* ---------- shared pixel UI --------------------------------------------- */
.px-eyebrow { font-family: var(--px); font-size: 10px; line-height: 1.6; letter-spacing: 0.06em; text-transform: uppercase; color: var(--yellow); }
.px-btn {
  --bg: var(--navy-3); --fg: var(--text); --edge: var(--ink);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--bg); color: var(--fg);
  font-family: var(--px); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none;
  box-shadow: 0 0 0 2px var(--edge), 0 5px 0 0 var(--edge);
  transform: translateY(0);
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease), background-color 160ms, filter 160ms;
  touch-action: manipulation;
}
.px-btn svg { width: 14px; height: 14px; flex: none; }
.px-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 0 0 2px var(--edge), 0 6px 0 0 var(--edge); }
.px-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 2px var(--edge), 0 1px 0 0 var(--edge); }
.px-btn:disabled { cursor: not-allowed; opacity: 0.45; }
.px-btn--yellow { --bg: var(--yellow); --fg: var(--charcoal); }
.px-btn--ghost { --bg: transparent; --fg: var(--text); box-shadow: 0 0 0 2px var(--line), 0 5px 0 0 var(--ink); }
.px-btn--ghost:hover:not(:disabled) { --bg: rgba(255, 255, 255, 0.05); box-shadow: 0 0 0 2px #5a52a8, 0 6px 0 0 var(--ink); }
.px-btn--block { width: 100%; }
.px-btn--lg { min-height: 58px; padding: 0 28px; font-size: 12px; }
.px-btn--yellow::after { /* soft pixel shine */
  content: ""; position: absolute; left: 6px; top: 5px; width: 8px; height: 3px; background: rgba(255, 255, 255, 0.6); pointer-events: none;
}

/* ---------- intro -------------------------------------------------------- */
.intro { margin: auto; width: min(100%, 560px); padding: 32px 20px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; }
.intro__title { margin: 0; font-family: var(--px); font-weight: 400; font-size: clamp(28px, 8vw, 46px); line-height: 1.15; letter-spacing: 0.02em; text-transform: uppercase; color: #fff; text-shadow: 0 4px 0 var(--ink); }
.intro__title--sm { font-size: clamp(18px, 4.6vw, 24px); }
.intro__five { display: inline-block; color: var(--yellow); text-shadow: 0 4px 0 var(--ink), 0 0 24px rgba(255, 200, 0, 0.45); }
.intro__tag { font-size: clamp(18px, 4.6vw, 21px); font-weight: 600; color: var(--text); max-width: 26ch; line-height: 1.35; }
.intro__steps { list-style: none; margin: 6px 0 4px; padding: 0; display: grid; gap: 10px; width: 100%; text-align: left; }
.intro__steps li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; padding: 12px 14px; background: var(--navy-2); border: 2px solid var(--line); border-radius: 8px; font-size: 16px; line-height: 1.4; color: var(--muted); }
.intro__steps b { color: var(--text); font-weight: 600; }
.intro__num { display: grid; place-items: center; width: 30px; height: 30px; background: var(--yellow); color: var(--charcoal); font-family: var(--px); font-size: 11px; border-radius: 4px; box-shadow: 0 3px 0 var(--ink); }
.intro .px-btn { margin-top: 6px; width: min(100%, 360px); }
.intro__meta { font-size: 14px; color: var(--muted); }
.intro__best { font-family: var(--px); font-size: 10px; color: var(--yellow); line-height: 1.6; }
@media (prefers-reduced-motion: no-preference) {
  .view--intro:not([hidden]) .intro > * { animation: rise 600ms var(--ease) both; }
  .view--intro:not([hidden]) .intro > :nth-child(2) { animation-delay: 60ms; }
  .view--intro:not([hidden]) .intro > :nth-child(3) { animation-delay: 120ms; }
  .view--intro:not([hidden]) .intro > :nth-child(4) { animation-delay: 180ms; }
  .view--intro:not([hidden]) .intro > :nth-child(n+5) { animation-delay: 240ms; }
  .intro__five { animation: five-glow 2.4s ease-in-out infinite; }
  @keyframes five-glow { 50% { text-shadow: 0 4px 0 var(--ink), 0 0 34px rgba(255, 200, 0, 0.75); } }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- game layout -------------------------------------------------- */
.view--game { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px max(12px, env(safe-area-inset-left)); border-bottom: 2px solid var(--ink); background: rgba(22, 18, 43, 0.35); }
.pips { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.pip {
  display: grid; place-items: center; width: 38px; height: 30px; border-radius: 4px;
  background: var(--navy-2); box-shadow: 0 0 0 2px var(--line); font-family: var(--px); font-size: 9px; color: var(--muted);
  transition: background-color 300ms, box-shadow 300ms, color 300ms;
}
.pip[data-state="current"] { color: var(--charcoal); background: var(--yellow); box-shadow: 0 0 0 2px var(--ink), 0 3px 0 var(--ink); }
.pip[data-state="done"] { font-size: 12px; color: var(--charcoal); box-shadow: 0 0 0 2px var(--ink); }
.pip[data-grade="excellent"] { background: var(--yellow); }
.pip[data-grade="good"] { background: var(--good); }
.pip[data-grade="fair"] { background: var(--fair); }
.pip[data-grade="poor"] { background: var(--poor); }
@media (prefers-reduced-motion: no-preference) {
  .pip[data-state="done"] { animation: flip 520ms var(--ease) both; }
  .pip[data-state="current"] { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes flip { from { transform: rotateX(90deg); } }
  @keyframes pulse { 50% { box-shadow: 0 0 0 2px var(--ink), 0 3px 0 var(--ink), 0 0 16px rgba(255, 200, 0, 0.6); } }
}
.hud__right { display: flex; align-items: center; gap: 8px; }
.hud__score { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.hud__label { font-family: var(--px); font-size: 7px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.hud__num { margin-top: 5px; font-family: var(--px); font-size: 16px; color: var(--yellow); min-width: 3ch; text-align: right; }
@media (prefers-reduced-motion: no-preference) {
  .hud__score.bump .hud__num { animation: bump 500ms var(--spring); }
  @keyframes bump { 40% { transform: scale(1.35); } }
}
.hud__restart { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; transition: color 160ms, background-color 160ms; }
.hud__restart:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.hud__restart svg { width: 20px; height: 20px; }
.hud__restart-confirm { display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; white-space: nowrap; font-family: var(--px); font-size: 8px; padding: 8px 10px; background: var(--poor); color: var(--ink); border-radius: 4px; box-shadow: 0 0 0 2px var(--ink); }
.hud__restart.is-armed { color: var(--poor); }
.hud__restart.is-armed .hud__restart-confirm { display: block; }
@media (max-width: 359px) {
  .pips { gap: 4px; }
  .pip { width: 27px !important; }
  .hud__home, .hud__label { display: none !important; }
  .hud__num { margin-top: 0; }
}

.stage { position: relative; display: grid; place-items: center; padding: 8px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.court { position: relative; width: 100%; aspect-ratio: 216 / 248; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 2px var(--ink), 0 12px 30px -10px rgba(0, 0, 0, 0.6); background: #1d1846; container-type: size; }
.court__prompt { display: none; }
.court canvas { width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.court__layer { position: absolute; inset: 0; pointer-events: none; }

/* labels on the court */
.tag {
  position: absolute; transform: translate(-50%, 0); white-space: nowrap; pointer-events: none;
  font-family: var(--px); font-size: clamp(6px, 2.3cqw, 9px); line-height: 1; letter-spacing: 0.04em;
  padding: 4px 5px 3px; background: rgba(22, 18, 43, 0.82); color: var(--text); border-radius: 3px;
}
.tag--you { background: var(--yellow); color: var(--charcoal); box-shadow: 0 0 0 1px var(--ink); z-index: 2; }
.tag--sub { margin-top: 1.9em; }
.chip {
  --stack: 0;
  position: absolute; pointer-events: auto; cursor: pointer; white-space: nowrap;
  transform: translate(-50%, calc(-100% - var(--stack) * 118%));
  min-height: clamp(22px, 7.4cqw, 30px); padding: 0 clamp(6px, 2.4cqw, 10px); border: 0; border-radius: 3px;
  font-family: var(--px); font-size: clamp(7px, 2.6cqw, 10px); letter-spacing: 0.04em; line-height: clamp(22px, 7.4cqw, 30px);
  background: #fff; color: var(--charcoal); box-shadow: 0 0 0 2px var(--ink), 0 3px 0 var(--ink);
  transition: background-color 140ms, transform 140ms var(--ease);
  touch-action: manipulation;
}
.chip::before, .chip::after { /* reticle corners, like the game */
  content: ""; position: absolute; width: 6px; height: 6px; border: 2px solid #fff; pointer-events: none;
}
.chip::before { left: -7px; top: -7px; border-right: 0; border-bottom: 0; }
.chip::after { right: -7px; bottom: -7px; border-left: 0; border-top: 0; }
.chip--spot { transform: translate(-50%, calc(-50% - var(--stack) * 118%)); }
.chip:hover { background: #fff6cf; }
.chip.is-selected { background: var(--yellow); }
.chip.is-selected::before, .chip.is-selected::after { border-color: var(--yellow); }
@media (prefers-reduced-motion: no-preference) {
  .chip { animation: chip-in 320ms var(--spring) both; }
  .chip:nth-of-type(2) { animation-delay: 60ms; }
  .chip:nth-of-type(3) { animation-delay: 120ms; }
  .chip:nth-of-type(4) { animation-delay: 180ms; }
  @keyframes chip-in { from { opacity: 0; scale: 0.6; } }
}

.court__clock { position: absolute; left: 8px; top: 8px; font-family: var(--px); font-size: clamp(7px, 1.7vmin, 9px); line-height: 1; padding: 6px 7px; background: rgba(22, 18, 43, 0.9); color: #ff9d3a; border-radius: 3px; box-shadow: 0 0 0 1px #000; letter-spacing: 0.04em; }
.court__card {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); display: grid; gap: 10px; justify-items: center; text-align: center;
  padding: 16px 18px; background: rgba(22, 18, 43, 0.92); border-radius: 6px; box-shadow: 0 0 0 2px var(--yellow), 0 6px 0 var(--ink);
  font-family: var(--px); font-size: 9px; color: var(--muted); letter-spacing: 0.06em;
}
.court__card strong { font-weight: 400; font-size: clamp(11px, 2.6vmin, 14px); color: #fff; line-height: 1.3; }
.court__card.is-on { animation: card 1.6s var(--ease) both; }
@keyframes card { 0% { opacity: 0; transform: translate(-50%, -40%); } 15%, 70% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; transform: translate(-50%, -58%); } }
@media (prefers-reduced-motion: reduce) { .court__card.is-on { animation: none; } }

.court__callout {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; white-space: nowrap;
  font-family: var(--px); font-size: clamp(16px, 5vmin, 30px); letter-spacing: 0.02em; color: #fff;
  text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
.court__callout.is-good { color: var(--yellow); }
.court__callout.is-bad { color: #ff8b78; }
.court__callout.is-on { animation: callout 1.4s var(--ease) both; }
@keyframes callout { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); } 14% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); } 24%, 76% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -62%) scale(1); } }
@media (prefers-reduced-motion: reduce) { .court__callout.is-on { animation: callout-still 1.4s linear both; } @keyframes callout-still { 0%, 85% { opacity: 1; } 100% { opacity: 0; } } }

/* ---------- panel -------------------------------------------------------- */
.panel {
  position: relative; background: var(--navy-2); border-top: 2px solid var(--ink);
  padding: 14px max(16px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-height: 56dvh; overflow-y: auto; overscroll-behavior: contain;
}
.phase { display: flex; flex-direction: column; gap: 10px; }
@media (prefers-reduced-motion: no-preference) {
  .phase:not([hidden]) { animation: rise 360ms var(--ease) both; }
}
.phase__meta { display: flex; justify-content: space-between; align-items: center; font-family: var(--px); font-size: 8px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.phase__diff { color: var(--yellow); letter-spacing: 0.2em; font-family: var(--ui); font-size: 11px; }
.phase__eyebrow { font-family: var(--px); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--yellow); }
.phase__prompt { font-size: clamp(16px, 4.2vw, 19px); font-weight: 600; line-height: 1.35; color: #fff; }
.phase__prompt:focus { outline: none; }
.phase__title { font-size: 18px; font-weight: 600; color: #fff; line-height: 1.3; }
.phase__hint, .phase__keys { font-size: 14px; color: var(--muted); }
.phase__keys { display: none; }
@media (hover: hover) and (pointer: fine) { .phase__keys { display: block; font-size: 13px; } }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 2px; }
.actions__lock { min-height: 54px; }
.actions[data-count="2"] .actions__lock, .actions[data-count="4"] .actions__lock { grid-column: 1 / -1; }
.action {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; text-align: left;
  min-height: 54px; padding: 8px 12px 8px 8px; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--navy-3); color: var(--text); font-family: var(--pix); font-size: 15px; font-weight: 500; line-height: 1.2;
  box-shadow: 0 0 0 2px var(--line), 0 4px 0 var(--ink);
  transition: background-color 140ms, box-shadow 140ms, transform 120ms var(--ease);
  touch-action: manipulation;
}
.action:hover { background: #352d74; }
.action:active { transform: translateY(3px); box-shadow: 0 0 0 2px var(--line), 0 1px 0 var(--ink); }
.action[aria-pressed="true"] { background: #3d2f12; color: #fff; box-shadow: 0 0 0 2px var(--yellow), 0 4px 0 var(--ink); }
.action__key { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 4px; background: var(--ink); color: var(--muted); font-family: var(--px); font-size: 9px; }
.action[aria-pressed="true"] .action__key { background: var(--yellow); color: var(--charcoal); }

.dots { display: flex; gap: 6px; padding-top: 4px; }
.dots i { width: 8px; height: 8px; background: var(--yellow); }
@media (prefers-reduced-motion: no-preference) {
  .dots i { animation: dot 900ms ease-in-out infinite; }
  .dots i:nth-child(2) { animation-delay: 150ms; }
  .dots i:nth-child(3) { animation-delay: 300ms; }
  @keyframes dot { 50% { transform: translateY(-5px); opacity: 0.5; } }
}

/* feedback */
.grade { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; background: var(--ink); box-shadow: 0 0 0 2px var(--g, var(--yellow)); }
.grade__icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 4px; background: var(--g, var(--yellow)); color: var(--charcoal); font-size: 17px; font-weight: 700; font-family: var(--ui); }
.grade__title { font-family: var(--px); font-size: clamp(10px, 2.8vw, 12px); line-height: 1.4; color: var(--g, var(--yellow)); letter-spacing: 0.02em; }
.grade__pts { font-family: var(--px); font-size: 13px; color: #fff; }
.phase--feedback[data-grade="excellent"] { --g: var(--yellow); }
.phase--feedback[data-grade="good"] { --g: var(--good); }
.phase--feedback[data-grade="fair"] { --g: var(--fair); }
.phase--feedback[data-grade="poor"] { --g: var(--poor); }
@media (prefers-reduced-motion: no-preference) {
  .phase--feedback:not([hidden]) .grade { animation: stamp 520ms var(--spring) both; }
  @keyframes stamp { from { opacity: 0; transform: scale(1.25); } }
}
.fb__why { font-size: 16px; line-height: 1.45; color: #fff; }
.fb__best { font-size: 15px; color: var(--yellow); font-weight: 600; }
.fb__result { padding: 10px 12px; border-radius: 6px; background: rgba(22, 18, 43, 0.55); border: 1px dashed var(--line); display: grid; gap: 4px; }
.fb__label { font-family: var(--px); font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.fb__result p { font-size: 15px; color: var(--text); line-height: 1.4; }
.fb__result .fb__note { font-size: 14px; color: var(--muted); }
.fb__actions { display: grid; grid-template-columns: auto 1fr; gap: 12px; margin-top: 4px; padding-bottom: 6px; }

/* desktop: court on the left, panel on the right */
@media (min-width: 860px) {
  .view--game { grid-template-columns: minmax(0, 1fr) clamp(340px, 32vw, 400px); grid-template-rows: auto minmax(0, 1fr); }
  .hud { grid-column: 1 / -1; padding: 12px 18px; }
  .stage { grid-row: 2; grid-column: 1; padding: 18px; }
  .panel { grid-row: 2; grid-column: 2; max-height: none; border-top: 0; border-left: 2px solid var(--ink); padding: 22px 22px 24px; display: flex; flex-direction: column; }
  .phase { gap: 14px; }
  .actions { grid-template-columns: 1fr; gap: 10px; }
  .actions__lock { grid-column: 1 / -1; margin-top: 4px; }
  .phase__prompt { font-size: 20px; }
  .pip { width: 44px; height: 32px; font-size: 10px; }
  .hud__home, .hud__sound { display: none; }
}

/* phones and small tablets: the game takes the whole screen */
@media (max-width: 859px) {
  body[data-view="game"] .five-head { display: none; }
  .view--game { grid-template-columns: minmax(0, 1fr); }
  .hud { min-width: 0; }
  body[data-view="game"] .hud { padding-top: calc(8px + env(safe-area-inset-top)); }
  .hud { padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); gap: 8px; }
  .hud__home { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; }
  .hud__home img { width: 24px; height: auto; }
  .hud__sound { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
  .hud__sound svg { width: 20px; height: 20px; }
  .hud__sound.is-on { color: var(--yellow); }
  .hud__sound .sound-btn__on { display: none; }
  .hud__sound.is-on .sound-btn__on { display: block; }
  .hud__sound.is-on .sound-btn__off { display: none; }
  .hud__restart { width: 36px; height: 36px; }
  .pips { flex: 1; justify-content: center; gap: 5px; }
  .pip { width: clamp(28px, 9vw, 40px); height: 28px; font-size: 8px; }
  .hud__right { gap: 2px; }
  .hud__num { font-size: 14px; }
  .stage { padding: 6px 8px; }

  /* the prompt sits over the crowd, like the full game's "Your move" box */
  .court__prompt {
    position: absolute; left: 3%; right: 3%; top: 2.5%; z-index: 3; display: grid; gap: 3px;
    padding: 6px 8px 7px; border-radius: 4px; background: rgba(22, 18, 43, 0.94); box-shadow: 0 0 0 2px var(--yellow);
    font-family: var(--pix); font-weight: 600; font-size: clamp(12px, 4.1cqw, 16px); line-height: 1.25; color: #fff;
  }
  .court__prompt[hidden] { display: none; }
  .court__prompt.is-bottom { top: auto; bottom: 2.5%; }
  .prompt-in-panel .phase--read .phase__eyebrow, .prompt-in-panel .phase--read .phase__prompt { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .prompt-in-panel .phase--read .phase__prompt { font-size: 15px; }
  .court__prompt-eyebrow { font-family: var(--px); font-weight: 400; font-size: clamp(6px, 2.2cqw, 8px); color: var(--yellow); letter-spacing: 0.06em; text-transform: uppercase; }
  @media (prefers-reduced-motion: no-preference) {
    .court__prompt:not([hidden]) { animation: rise 380ms var(--ease) both; }
  }
  .court__clock { top: auto; bottom: 8px; }

  .panel { padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); max-height: 58dvh; }
  .phase { gap: 8px; }
  .phase--read .phase__eyebrow, .phase--read .phase__prompt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .phase--setup .phase__hint { display: none; }
  .action { min-height: 50px; font-size: 14px; padding: 6px 10px 6px 6px; gap: 8px; }
  .action__key { width: 22px; height: 22px; font-size: 8px; }
  .actions__lock { min-height: 50px; font-size: 10px; padding: 0 10px; }
  .fb__why { font-size: 15px; }
  .fb__result { padding: 8px 10px; }
  .fb__result p { font-size: 14px; }
  .fb__result .fb__note { font-size: 13px; }
  .px-btn { min-height: 48px; }
}

/* ---------- results ------------------------------------------------------ */
.results { margin: 0 auto; width: min(100%, 640px); padding: 28px 18px calc(36px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.res-score { display: flex; align-items: baseline; gap: 6px; font-family: var(--px); margin-top: 4px; }
.res-score__num { font-size: clamp(56px, 18vw, 96px); line-height: 1; color: var(--yellow); text-shadow: 0 6px 0 var(--ink), 0 0 40px rgba(255, 200, 0, 0.35); }
.res-score__of { font-size: clamp(14px, 4vw, 20px); color: var(--muted); }
.res-rank { font-family: var(--px); font-size: clamp(16px, 4.6vw, 22px); color: #fff; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.3; }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; width: 100%; }
.ladder li { display: grid; gap: 4px; padding: 8px 2px; background: var(--navy-2); border-radius: 4px; box-shadow: 0 0 0 2px var(--line); }
.ladder b { font-family: var(--px); font-weight: 400; font-size: 7px; line-height: 1.4; color: var(--muted); text-transform: uppercase; }
.ladder span { font-size: 12px; color: var(--muted); }
.ladder li.is-on { background: var(--yellow); box-shadow: 0 0 0 2px var(--ink), 0 4px 0 var(--ink); }
.ladder li.is-on b, .ladder li.is-on span { color: var(--charcoal); }
.res-summary { font-size: 17px; line-height: 1.5; color: var(--text); max-width: 46ch; }
.res-best { font-family: var(--px); font-size: 9px; color: var(--yellow); }
.res-plays { list-style: none; margin: 4px 0 0; padding: 0; width: 100%; display: grid; gap: 8px; text-align: left; }
.res-play { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--navy-2); border-radius: 6px; box-shadow: 0 0 0 2px var(--line); }
.res-play__glyph { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 4px; font-family: var(--ui); font-weight: 700; color: var(--charcoal); background: var(--fair); }
.res-play[data-grade="excellent"] .res-play__glyph { background: var(--yellow); }
.res-play[data-grade="good"] .res-play__glyph { background: var(--good); }
.res-play[data-grade="poor"] .res-play__glyph { background: var(--poor); }
.res-play__body { display: grid; gap: 2px; min-width: 0; }
.res-play__body strong { font-family: var(--px); font-weight: 400; font-size: 8px; line-height: 1.5; color: var(--muted); text-transform: uppercase; }
.res-play__body span { font-size: 15px; color: #fff; }
.res-play__pts { font-family: var(--px); font-size: 8px; color: var(--muted); text-align: right; line-height: 1.6; }
.res-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; margin-top: 6px; }
.res-share-msg { min-height: 1.2em; font-size: 14px; color: var(--good); white-space: pre-line; }
@media (max-width: 400px) { .res-actions { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: no-preference) {
  .results.is-in > * { animation: rise 600ms var(--ease) both; }
  .results.is-in > :nth-child(2) { animation-delay: 60ms; }
  .results.is-in > :nth-child(3) { animation-delay: 120ms; }
  .results.is-in > :nth-child(4) { animation-delay: 300ms; }
  .results.is-in > :nth-child(5) { animation-delay: 380ms; }
  .results.is-in > :nth-child(n+6) { animation-delay: 460ms; }
  .results.is-in .res-play { animation: flip 520ms var(--ease) both; }
  .results.is-in .res-play:nth-child(1) { animation-delay: 500ms; }
  .results.is-in .res-play:nth-child(2) { animation-delay: 600ms; }
  .results.is-in .res-play:nth-child(3) { animation-delay: 700ms; }
  .results.is-in .res-play:nth-child(4) { animation-delay: 800ms; }
  .results.is-in .res-play:nth-child(5) { animation-delay: 900ms; }
}

/* waitlist inside results */
.res-beta {
  width: 100%; margin-top: 14px; padding: 24px 18px; border-radius: 14px; text-align: center; color: var(--charcoal);
  background: radial-gradient(ellipse 90% 80% at 50% 0%, #fff3bf 0%, #ffd84d 60%, #ffc800 100%);
  box-shadow: 0 0 0 2px var(--ink), 0 6px 0 var(--ink);
}
.res-beta__eyebrow { font-family: var(--px); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.res-beta__title { margin: 10px 0 0; font-family: var(--ui); font-weight: 600; font-size: clamp(22px, 6vw, 28px); letter-spacing: -0.02em; }
.res-beta__copy { margin-top: 8px; font-family: var(--ui); font-size: 15px; line-height: 1.5; color: #4a4020; }
.beta-form { margin-top: 16px; text-align: left; font-family: var(--ui); }
.beta-form__row { display: grid; gap: 10px; }
.beta-form input[type="email"] {
  width: 100%; min-height: 52px; padding: 0 16px; border-radius: 6px; border: 0; font: 500 16px var(--ui); color: var(--charcoal); background: #fff;
  box-shadow: 0 0 0 2px var(--ink); -webkit-appearance: none; appearance: none;
}
.beta-form input[type="email"]:focus { outline: none; box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px rgba(36, 36, 36, 0.25); }
.beta-form input[aria-invalid="true"] { box-shadow: 0 0 0 2px #b42318; }
.beta-form .px-btn { --edge: var(--ink); --bg: var(--charcoal); --fg: var(--yellow); }
@media (min-width: 520px) { .beta-form__row { grid-template-columns: 1fr auto; } }
.beta-form__check { margin-top: 12px; display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; font-size: 14px; line-height: 1.45; color: #3a3420; cursor: pointer; }
.beta-form__check input { width: 20px; height: 20px; margin: 0; accent-color: var(--charcoal); }
.beta-form__msg { min-height: 1.3em; margin-top: 8px; font-size: 14px; font-weight: 600; color: #8f1d12; }
.beta-form__success { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 6px 2px; font-size: 15px; line-height: 1.45; }
.beta-form__success strong:focus { outline: none; }
.beta-form__check-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--charcoal); color: var(--yellow); font-weight: 700; }
.beta-form .shake { animation: shake 360ms var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) { .beta-form .shake { animation: none; } }
.beta-form :focus-visible { outline-color: var(--charcoal); }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.res-home { margin-top: 6px; font-size: 15px; color: var(--muted); text-underline-offset: 3px; }
.res-home:hover { color: #fff; }
.noscript { padding: 24px; text-align: center; color: var(--charcoal); font-family: var(--ui); }
