:root {
  --bg: #3d22c9;        /* electric violet */
  --bg-2: #2f18a6;
  --ink: #1a1033;
  --paper: #ffffff;
  --cream: #fff7e6;
  --sun: #ffd23f;
  --coral: #ff5c5c;
  --mint: #06d6a0;
  --sky: #3fa9f5;
  --pink: #ff70a6;
  --orange: #ff9f1c;
  --line: 3px solid var(--ink);
  --pop: 5px 5px 0 var(--ink);
  --radius: 18px;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  /* faint dotted-grid "graph paper" */
  background-image: radial-gradient(rgb(255 255 255 / .09) 1.5px, transparent 1.6px);
  background-size: 22px 22px;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
[hidden] { display: none !important; }

.screen {
  max-width: 980px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}
h1, h2, .title, .big-btn, .chip, .final, .board button { font-family: "Fredoka", "Nunito", sans-serif; }

/* Start ----------------------------------------------------------------- */
.home { color: #fff; opacity: .8; text-decoration: none; font-weight: 700; font-size: 15px; }
.home::before { content: "‹ "; }
.home:hover { opacity: 1; text-decoration: underline; }
.title { text-align: center; color: #fff; margin: 18px 0 26px; }
.title h1 {
  font-size: clamp(44px, 9vw, 88px); line-height: .95; margin: 0; font-weight: 700; letter-spacing: -.01em;
  text-shadow: 4px 4px 0 var(--ink);
}
.title .real {
  display: inline-block; background: var(--sun); color: var(--ink); padding: 0 .18em .04em; border-radius: 14px;
  border: var(--line); box-shadow: var(--pop); text-shadow: none; transform: rotate(-3deg);
}
.title p { font-size: 18px; font-weight: 700; max-width: 34ch; margin: 18px auto 0; opacity: .92; }

.card { background: var(--paper); border: var(--line); border-radius: var(--radius); box-shadow: 8px 8px 0 var(--ink); }
.setup { max-width: 620px; margin: 0 auto; padding: 22px 22px 24px; }
.slider-group + .slider-group { margin-top: 22px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.slider-head label { font: 700 20px/1 "Fredoka", sans-serif; }
.slider-head output {
  font: 700 15px/1 "Fredoka", sans-serif; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--mint);
}
.slider-head output[data-level="1"] { background: var(--sun); }
.slider-head output[data-level="2"] { background: var(--coral); color: #fff; }
.hint { margin: 6px 0 0; font-size: 15px; color: #4a3f66; min-height: 1.4em; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 40px; background: transparent; margin: 10px 0 0; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 14px; border-radius: 999px; border: 2px solid var(--ink);
  background: linear-gradient(90deg, var(--mint) 0 33.3%, var(--sun) 33.3% 66.6%, var(--coral) 66.6%);
}
input[type="range"]::-moz-range-track {
  height: 10px; border-radius: 999px; border: 2px solid var(--ink);
  background: linear-gradient(90deg, var(--mint) 0 33.3%, var(--sun) 33.3% 66.6%, var(--coral) 66.6%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 34px; height: 34px; margin-top: -12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
input[type="range"]::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { background: var(--sun); }
.ticks { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; color: #6b6185; padding: 0 2px; }

.board-wrap { margin-top: 24px; }
.board-label { font: 700 16px/1 "Fredoka", sans-serif; margin: 0 0 10px; }
.board-label span { font-family: "Nunito", sans-serif; font-weight: 700; font-size: 13px; color: #6b6185; }
.board { display: grid; grid-template-columns: 52px repeat(3, 1fr); gap: 6px; align-items: stretch; }
.board .axis { font: 800 11px/1.1 "Nunito", sans-serif; color: #6b6185; display: flex; align-items: center; justify-content: center; text-align: center; }
.board button {
  border: 2px solid var(--ink); border-radius: 12px; background: var(--cream); cursor: pointer; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 58px; justify-content: center;
  transition: transform .08s;
}
.board button b { font-size: 18px; font-weight: 700; }
.board button small { font: 700 11px/1 "Nunito", sans-serif; color: #6b6185; }
.board button:hover { transform: translateY(-2px); }
.board button[aria-pressed="true"] { background: var(--sun); box-shadow: 3px 3px 0 var(--ink); }

.big-btn {
  display: block; width: 100%; margin-top: 24px; padding: 16px; border: var(--line); border-radius: 16px;
  background: var(--sun); box-shadow: var(--pop); font-size: 24px; font-weight: 700; cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.big-btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
.big-btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.big-btn:disabled { opacity: .6; cursor: wait; }
.ghost-btn {
  display: block; width: 100%; margin-top: 12px; padding: 12px; border: 3px solid var(--ink); border-radius: 14px;
  background: #fff; font: 700 18px/1 "Fredoka", sans-serif; cursor: pointer;
}

/* Game ----------------------------------------------------------------- */
.hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: #fff; font-weight: 800; }
.quit {
  border: 2px solid #fff; background: transparent; color: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 800;
}
.quit:hover { background: rgb(255 255 255 / .12); }
.chip { background: var(--sun); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; padding: 5px 12px; font-size: 14px; font-weight: 600; }
.stat { margin-left: auto; font-size: 16px; }
.stat + .stat { margin-left: 12px; }
.stat b { font-family: "Fredoka", sans-serif; font-size: 22px; }
.streak b { color: var(--sun); }
.progress { height: 10px; border-radius: 999px; background: rgb(255 255 255 / .18); margin: 14px 0 4px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--mint); border-radius: 999px; transition: width .3s ease; }

.prompt { color: #fff; text-align: center; font-size: clamp(28px, 5vw, 46px); line-height: 1.1; margin: 18px 0 4px; font-weight: 600; }
.prompt strong { color: var(--sun); font-weight: 700; }
.sub { color: #fff; opacity: .8; text-align: center; margin: 0 0 18px; font-weight: 700; }

.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.option {
  position: relative; aspect-ratio: 1; background: var(--paper); border: var(--line); border-radius: var(--radius);
  box-shadow: var(--pop); cursor: pointer; padding: 10px; display: grid; place-items: center;
  transition: transform .1s, box-shadow .1s, background .2s;
}
.option:hover:not(:disabled) { transform: translate(-2px, -3px) rotate(-.6deg); box-shadow: 7px 8px 0 var(--ink); }
.option:disabled { cursor: default; }
.option svg { position: absolute; inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px); overflow: visible; }
.option .shape { stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; fill-rule: evenodd; vector-effect: non-scaling-stroke; }
.option .ghost { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 4; fill-rule: evenodd; opacity: .85; vector-effect: non-scaling-stroke; }
.option .key {
  position: absolute; top: 10px; left: 10px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ink);
  font: 700 15px/24px "Fredoka", sans-serif; text-align: center; background: var(--cream);
}
.option .tag {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font: 700 15px/1 "Fredoka", sans-serif; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--ink);
}
.option.right { background: #dcfff3; }
.option.right .tag { background: var(--mint); }
.option.wrong { background: #ffe3e3; }
.option.wrong .tag { background: var(--coral); color: #fff; }
.option.warped .tag { background: #fff; }
.option.picked { outline: 4px solid var(--sun); outline-offset: 4px; }
.option.shake { animation: shake .35s; }
.option.pop { animation: pop .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes pop { 40% { transform: scale(1.05) rotate(1deg); } }

.feedback { text-align: center; color: #fff; font: 600 22px/1.3 "Fredoka", sans-serif; min-height: 34px; margin-top: 20px; }
.feedback small { display: block; font: 700 15px/1.4 "Nunito", sans-serif; opacity: .85; }
.next { max-width: 420px; margin: 14px auto 0; }

/* Results --------------------------------------------------------------- */
.results-card { max-width: 560px; margin: 24px auto 0; padding: 26px 22px; text-align: center; }
.results-mode { margin: 0; font-weight: 800; color: #6b6185; }
.final { font-size: 110px; font-weight: 700; line-height: 1; margin: 6px 0 0; }
.final small { font-size: 40px; color: #6b6185; }
.verdict { font: 600 24px/1.2 "Fredoka", sans-serif; margin: 6px 0; }
.best { margin: 0 0 16px; font-weight: 700; color: #6b6185; }
.best.new { color: var(--ink); }
.best.new::before { content: "New best! "; background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 8px; margin-right: 4px; }
.recap { list-style: none; margin: 0; padding: 0; text-align: left; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.recap li { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 6px 8px; border-radius: 10px; background: var(--cream); }
.recap li::before {
  content: ""; flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); background: var(--coral);
}
.recap li.ok::before { background: var(--mint); }

/* Confetti --------------------------------------------------------------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i { position: absolute; width: 10px; height: 14px; border-radius: 2px; top: -20px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

/* Phone ------------------------------------------------------------------- */
@media (max-width: 640px) {
  .title { margin: 12px 0 20px; }
  .title p { font-size: 16px; }
  .setup { padding: 18px 16px 20px; box-shadow: 6px 6px 0 var(--ink); }
  .board { grid-template-columns: 40px repeat(3, 1fr); }
  .board button b { font-size: 16px; }
  .hud .chip { order: 5; flex-basis: 100%; text-align: center; }
  .stat { font-size: 14px; }
  .stat b { font-size: 19px; }
  .prompt { margin-top: 12px; }
  .sub { margin-bottom: 12px; }
  /* Three tall-ish cards stacked: big enough to see small warps. */
  .options { grid-template-columns: 1fr; gap: 12px; }
  .option { aspect-ratio: auto; height: clamp(150px, calc((100dvh - 290px) / 3), 260px); box-shadow: 4px 4px 0 var(--ink); }
  .option .tag { bottom: 8px; font-size: 14px; }
  .feedback { margin-top: 14px; font-size: 19px; }
  .next { position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); }
  .final { font-size: 90px; }
  .recap { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
