@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --field: #ff3e8e;          /* hot pink: not a palette colour, so it never reads as an answer */
  --field-deep: #c8135f;
  --field-deeper: #8f0b44;
  --ink: #1d0b25;
  --paper: #fff6fa;
  --btn: #19e3ff;            /* electric cyan: the one "act here" colour */
  --btn-ink: #1d0b25;
  --right: #2fe06b;
  --wrong: #ff2a2a;
  --edge: 3px;
  --app-h: 100dvh;
  --ground: var(--field);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--ground); color: var(--paper);
  font-family: "Space Grotesk", system-ui, sans-serif; font-weight: 500;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  transition: background-color .25s;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }
#app { position: fixed; inset: 0 0 auto 0; height: var(--app-h); overflow: hidden; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
kbd { font: 700 .62em/1 "Space Grotesk", sans-serif; padding: .28em .45em; border: 2px solid currentColor; border-radius: 5px; opacity: .75; }
.no-keys kbd { display: none; }

/* --- buttons ---------------------------------------------------------------- */
.btn {
  min-height: 56px; padding: 0 26px; border: var(--edge) solid var(--ink); border-radius: 14px;
  background: rgba(29, 11, 37, .28); color: var(--paper); font-size: 20px; font-weight: 700; cursor: pointer;
  box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--btn); color: var(--btn-ink); }
.btn.big { min-height: 76px; font-size: 30px; padding: 0 52px; border-radius: 18px; box-shadow: 0 7px 0 var(--ink); }
.link { background: none; border: 0; color: var(--paper); font-size: 17px; font-weight: 700; padding: 12px 10px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

/* --- home --------------------------------------------------------------------- */
#home { background: var(--field); align-items: center; justify-content: center; }
.home-scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.home-scene .drift { animation: drift var(--t, 18s) ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(calc(var(--dx) * -1), calc(var(--dy) * -1)); } to { transform: translate(var(--dx), var(--dy)); } }
.home-scene .pop { transform-box: fill-box; transform-origin: center; animation: pop .7s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: var(--d, 0s); }
.home-front {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 28px 16px; width: 100%;
}
.home-front::before {
  content: ""; position: absolute; inset: -10px 0; z-index: -1;
  background: var(--field); clip-path: polygon(0 12%, 100% 0, 100% 88%, 0 100%);
  border-block: var(--edge) solid var(--ink);
}
.title { margin: 0; position: relative; z-index: 0; display: block; font-size: clamp(64px, 21vw, 168px); line-height: .9; font-weight: 700; letter-spacing: -.02em; }
.title { color: var(--paper); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.title::before, .title::after { content: attr(data-t); position: absolute; left: 0; top: 0; z-index: -1; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.title::before { color: #2f6bff; left: .13em; top: .12em; animation: lift 3.2s ease-in-out infinite; z-index: -2; }
.title::after { color: #ffd919; left: .065em; top: .06em; animation: lift 3.2s ease-in-out .15s infinite; }
@keyframes lift { 50% { translate: -.025em -.022em; } }
.home-day { margin: 0; font-size: 18px; font-weight: 700; color: var(--ink); }
.home-buttons { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 8px; }
.home-links { display: flex; gap: 10px; }
.home-links .link { color: var(--ink); }

/* --- play ----------------------------------------------------------------------- */
#play { --ground-local: var(--ground); }
.hud {
  position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: max(8px, env(safe-area-inset-top)) 16px 12px; min-height: 66px; color: var(--ink);
}
.hud-level, .hud-q { display: flex; align-items: baseline; gap: 7px; font-weight: 700; }
.hud-level span, .hud-q span { font-size: 15px; }
.hud-level b, .hud-q b { font-size: 30px; line-height: 1; }
.hud-q { justify-content: flex-end; }
.pips { display: flex; gap: 10px; }
.pips i { width: 22px; height: 22px; border-radius: 50%; border: var(--edge) solid var(--ink); background: var(--paper); transition: background .2s, transform .2s; }
.pips i.on { background: var(--wrong); transform: scale(1.12); }
.pips i.hit { animation: hit .5s; }
@keyframes hit { 30% { transform: scale(1.6); } }
.timer { position: absolute; left: 16px; right: 16px; bottom: 2px; height: 7px; border-radius: 4px; background: rgba(29, 11, 37, .2); overflow: hidden; opacity: 0; transition: opacity .15s; }
.timer.on { opacity: 1; }
.timer-fill { height: 100%; width: 100%; background: var(--ink); transform-origin: left; }

.stage { flex: 1; min-height: 0; container-type: size; display: grid; place-items: center; padding: 0 16px; }
.scene-box { position: relative; width: min(100cqw - 32px, 75cqh); aspect-ratio: 3 / 4; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.scene .pop { transform-box: fill-box; transform-origin: center; animation: pop .55s cubic-bezier(.2, 1.5, .4, 1) both; animation-delay: var(--d, 0s); }
@keyframes pop { from { transform: scale(.2); opacity: 0; } }
.scene .layer-in { animation: layerin .7s ease-out both; }
@keyframes layerin { from { opacity: 0; transform: translateY(-14px); } }
.scene.gone { visibility: hidden; }

.curtain {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 6%;
  background: var(--field-deep); border: var(--edge) solid var(--ink); border-radius: 18px;
  box-shadow: 0 8px 0 var(--ink); color: var(--paper);
}
.curtain.off { display: none; }
.card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.card .q { font-size: clamp(26px, 8.6cqw, 54px); line-height: 1.08; font-weight: 700; margin: 0; overflow-wrap: break-word; }
.card .q-n { font-size: 16px; font-weight: 700; opacity: .8; margin: 0; }
.card .big { font-size: clamp(44px, 15cqw, 96px); font-weight: 700; line-height: 1; margin: 0; }
.card .line { font-size: clamp(18px, 5cqw, 26px); font-weight: 700; margin: 0; line-height: 1.2; }
.card .verdict { font-size: clamp(40px, 13cqw, 84px); font-weight: 700; margin: 0; line-height: 1; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.card .verdict.right { color: var(--right); }
.card .verdict.wrong { color: var(--wrong); }
.card .swatch-show { width: 84px; height: 84px; border-radius: 50%; border: var(--edge) solid var(--ink); }
.card .ic-show { width: 120px; height: 120px; }
.card.flash { animation: flash .25s; }
@keyframes flash { from { transform: scale(.92); } }

.quad { position: absolute; inset: 0; display: grid; grid-template: 1fr 1fr / 1fr 1fr; gap: 0; border-radius: 18px; overflow: hidden; }
.quad button { border: 0; background: transparent; cursor: pointer; display: grid; place-items: start; padding: 12px; outline: 2px dashed rgba(255, 246, 250, .45); outline-offset: -1px; color: var(--paper); font-size: 20px; }
.quad button:nth-child(2), .quad button:nth-child(4) { place-items: start end; }
.quad button:active, .quad button.pick { background: rgba(255, 246, 250, .18); }
.quad button.good { background: var(--right); }
.quad button.bad { background: var(--wrong); }
.quad-q { position: relative; z-index: 2; pointer-events: none; text-shadow: 0 2px 0 var(--ink); }

.pad {
  height: 176px; flex: none; padding: 14px 16px max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
}
.keys { display: grid; gap: 10px; width: 100%; max-width: 560px; margin: 0 auto; }
.keys.n10 { grid-template-columns: repeat(5, 1fr); }
.keys.n2 { grid-template-columns: 1fr 1fr; }
.keys.n6 { grid-template-columns: repeat(6, 1fr); }
.key {
  position: relative; min-height: 58px; border: var(--edge) solid var(--ink); border-radius: 14px; cursor: pointer;
  background: var(--paper); color: var(--ink); font-size: 28px; font-weight: 700; box-shadow: 0 5px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.keys.n2 .key { min-height: 128px; font-size: 34px; }
.keys.n6 .key { min-height: 0; aspect-ratio: 1; border-radius: 50%; max-height: 72px; justify-self: center; width: 100%; max-width: 72px; }
.key:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.key kbd { position: absolute; top: 4px; right: 5px; font-size: 11px; }
.keys.n6 .key kbd { top: auto; right: auto; bottom: -22px; left: 50%; transform: translateX(-50%); color: var(--ink); }
.keys.n2 .key kbd { font-size: 14px; top: 8px; right: 10px; }
.key.good { background: var(--right); }
.key.bad { background: var(--wrong); color: var(--paper); }
.key.good, .key.bad { transform: scale(1.08); z-index: 2; }
.keys.n6 .key.good, .keys.n6 .key.bad { outline: 5px solid var(--paper); }
.keys.locked .key { pointer-events: none; }
.pad .go { align-self: center; min-width: 220px; }
.pad .hint { text-align: center; font-weight: 700; color: var(--ink); margin: 0; font-size: 17px; }
#lookLeft { font-size: 54px; line-height: 1; }

/* the play screen takes the scene's colour while you look */
body.looking { --ground: var(--scene-bg, var(--field)); }
body.looking .curtain { display: none; }

/* --- results ---------------------------------------------------------------------- */
#results { background: var(--field); padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); gap: 12px; color: var(--ink); }
.res-top { text-align: center; }
.res-kicker { margin: 0; font-weight: 700; font-size: 17px; }
.res-level { margin: 0; font-size: clamp(54px, 17vw, 110px); line-height: 1; font-weight: 700; color: var(--paper); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.res-stats div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.res-stats b { font-size: 30px; line-height: 1.05; }
.res-stats span { font-size: 14px; font-weight: 700; line-height: 1.2; }
.res-mid { flex: 1; min-height: 0; display: flex; gap: 14px; align-items: stretch; justify-content: center; }
.res-scene { height: 100%; max-width: 52%; aspect-ratio: 3 / 4; border: var(--edge) solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 var(--ink); }
.res-rows { display: flex; flex-direction: column; gap: 4px; justify-content: center; overflow: hidden; }
.res-rows div { display: flex; gap: 4px; }
.res-rows i { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 4px; background: var(--right); }
.res-rows i.x { background: var(--wrong); }
.res-buttons { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.res-buttons .btn { padding: 0 10px; }
.toast { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); margin: 0; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 10px; font-weight: 700; white-space: nowrap; }

/* --- sheets ----------------------------------------------------------------------- */
.sheet { background: var(--field); padding: max(18px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); color: var(--ink); overflow-y: auto; }
.sheet h2 { margin: 0 0 12px; font-size: 40px; line-height: 1; color: var(--paper); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.how-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; flex: 1; justify-content: center; }
.how-steps li { display: flex; gap: 14px; align-items: center; }
.how-steps svg { width: 84px; flex: none; aspect-ratio: 3 / 4; border: var(--edge) solid var(--ink); border-radius: 10px; box-shadow: 0 4px 0 var(--ink); }
.how-steps p { margin: 0; font-size: 20px; line-height: 1.3; }
.sheet-buttons { display: flex; justify-content: center; padding-top: 14px; }
.sheet-buttons .btn { min-width: 200px; }
.credits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; flex: 1; font-size: 17px; line-height: 1.35; }
.credits b { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.credits a { color: var(--ink); font-weight: 700; }

/* --- tweaks ----------------------------------------------------------------------- */
.tweaks { position: fixed; right: 8px; bottom: 8px; z-index: 50; background: var(--ink); color: var(--paper); padding: 10px 12px; border-radius: 10px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.tweaks label { display: flex; gap: 8px; align-items: center; justify-content: space-between; }

/* --- desktop ------------------------------------------------------------------------ */
@media (min-width: 900px) and (min-height: 600px) {
  .pad { height: 196px; }
  .res-mid { max-height: 52vh; }
  #results { align-items: center; }
  #results > * { width: min(720px, 100%); }
  .how-steps, .credits { width: min(640px, 100%); margin-inline: auto; }
  .sheet h2 { text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}

/* landscape desktop: the answer pad goes beside the picture, not under it */
@media (min-width: 820px) and (min-aspect-ratio: 1/1) {
  #play { display: grid; grid-template: auto 1fr / 1fr minmax(360px, 34vw); }
  #play .hud { grid-column: 1 / -1; padding-inline: 32px; }
  #play .stage { grid-column: 1; padding-bottom: 24px; }
  #play .pad { grid-column: 2; height: auto; padding: 0 32px 24px 0; justify-content: center; }
  .keys.n2 .key { min-height: 150px; }
  .keys.n6 { grid-template-columns: repeat(3, 1fr); row-gap: 34px; }
  .keys.n6 .key { max-width: 96px; max-height: 96px; }
}
.title { padding: 0 .12em .12em 0; }
@media (min-width: 900px) and (min-height: 600px) {
  .hud { min-height: 84px; }
  .hud-level b, .hud-q b { font-size: 42px; }
  .hud-level span, .hud-q span { font-size: 19px; }
  .pips i { width: 30px; height: 30px; }
  .title { font-size: clamp(120px, 14vw, 240px); }
  .home-day { font-size: 24px; }
  .btn.big { min-height: 92px; font-size: 38px; padding: 0 72px; }
  .link { font-size: 20px; }
}
