* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--slate-50); color: var(--slate-700); }
button, input { font: inherit; }
.afterimage-page { width: min(calc(100% - 40px), 960px); margin: 0 auto; padding: 34px 0 72px; }
.game-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.game-heading h1 { margin: 5px 0 7px; color: var(--slate-900); font-size: clamp(36px, 6vw, 52px); line-height: 1; letter-spacing: -.05em; }
.game-heading p { max-width: 590px; margin: 0; color: var(--slate-600); }
.heading-actions { display: flex; gap: 8px; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--slate-200); border-radius: var(--radius-md); background: white; color: var(--slate-600); box-shadow: var(--shadow-xs); font-weight: 700; cursor: pointer; }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.memory-card { overflow: hidden; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); background: white; box-shadow: var(--shadow-sm); }
.run-strip { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--slate-200); background: var(--slate-50); }
.run-strip > div { display: flex; justify-content: space-between; gap: 12px; padding: 13px 18px; border-right: 1px solid var(--slate-200); }
.run-strip > div:last-child { border-right: 0; }
.run-strip span { color: var(--slate-500); font-size: 12px; font-weight: 600; }
.run-strip strong { color: var(--slate-800); font-size: 15px; }
.phase[hidden] { display: none; }
.phase { min-height: 500px; padding: 34px; }
.phase-ready { display: grid; place-items: center; align-content: center; text-align: center; background: radial-gradient(circle at 50% 38%, var(--cobalt-50), transparent 40%); }
.phase-ready h2 { margin: 8px 0 10px; color: var(--slate-900); font-size: clamp(28px, 5vw, 42px); }
.phase-ready p { max-width: 520px; margin: 0 0 24px; color: var(--slate-600); }
.phase-number { color: var(--cobalt-700); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.primary-button { min-height: 46px; padding: 10px 18px; border: 1px solid var(--cobalt-600); border-radius: var(--radius-md); background: var(--cobalt-600); color: white; font-weight: 700; cursor: pointer; }
.primary-button:hover { border-color: var(--cobalt-700); background: var(--cobalt-700); }
.phase-label, .mix-heading, .reveal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 16px; }
.phase-label span { color: var(--cobalt-700); font-weight: 700; }
.phase-label strong { color: var(--slate-500); font: 600 14px/1 var(--font-mono); }
.phase-study p, .phase-distraction > p { margin: 16px 0 0; color: var(--slate-500); font-size: 14px; text-align: center; }
.memory-swatch { height: 390px; border: 1px solid rgba(20, 25, 40, .12); border-radius: var(--radius-md); box-shadow: inset 0 1px rgba(255,255,255,.24); }
.distraction-grid { height: 390px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; padding: 8px; border: 1px solid var(--slate-200); border-radius: var(--radius-md); background: var(--slate-50); }
.distraction-grid span { border-radius: var(--radius-sm); animation: distract-pop .45s ease both; }
@keyframes distract-pop { from { opacity: 0; transform: scale(.82); } }
.phase-mix { padding-bottom: 0; }
.mix-heading h2, .reveal-heading h2 { margin: 4px 0 0; color: var(--slate-900); font-size: 28px; }
.mix-heading code { padding: 6px 9px; border: 1px solid var(--slate-200); border-radius: var(--radius-sm); background: var(--slate-50); color: var(--slate-700); font: 600 13px/1.4 var(--font-mono); }
.guess-swatch { height: 190px; border: 1px solid rgba(20, 25, 40, .14); border-radius: var(--radius-md); background: rgb(128,128,128); }
.mixer { display: grid; gap: 17px; margin: 24px -34px 0; padding: 22px 34px; border-top: 1px solid var(--slate-200); background: var(--slate-50); }
.channel-heading { display: grid; grid-template-columns: 1fr 68px; gap: 12px; align-items: center; margin-bottom: 8px; }
.channel-heading label { color: var(--slate-700); font-size: 14px; font-weight: 600; }
.channel-heading input { width: 68px; height: 34px; padding: 4px 7px; border: 1px solid var(--slate-300); border-radius: var(--radius-sm); background: white; color: var(--slate-800); text-align: center; }
.channel > input[type="range"] { width: 100%; height: 8px; margin: 0; border-radius: 99px; appearance: none; cursor: pointer; }
.channel > input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; appearance: none; border: 3px solid white; border-radius: 50%; background: var(--slate-800); box-shadow: 0 1px 5px rgba(20,25,40,.35); }
.red-channel > input[type="range"] { background: linear-gradient(90deg,#202536,#ef4459); }
.green-channel > input[type="range"] { background: linear-gradient(90deg,#202536,#22a06b); }
.blue-channel > input[type="range"] { background: linear-gradient(90deg,#202536,#3767df); }
.phase-action { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 0 -34px; padding: 20px 34px; border-top: 1px solid var(--slate-200); }
.phase-action p { margin: 0; color: var(--slate-500); font-size: 13px; }
.reveal-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.reveal-swatches figure { min-width: 0; margin: 0; }
.reveal-swatches figure > div { height: 280px; border: 1px solid rgba(20,25,40,.14); border-radius: var(--radius-md); }
.reveal-swatches figcaption { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--slate-600); font-size: 13px; }
.reveal-swatches code { color: var(--slate-800); font: 600 12px/1.5 var(--font-mono); }
.accuracy-badge { min-width: 68px; padding: 9px 12px; border: 1px solid var(--cobalt-200); border-radius: var(--radius-md); background: var(--cobalt-50); color: var(--cobalt-700); font-size: 20px; text-align: center; }
.difference-row { display: grid; grid-template-columns: repeat(3,1fr); margin: 18px 0 20px; border-block: 1px solid var(--slate-200); }
.difference-row span { padding: 11px; border-right: 1px solid var(--slate-200); color: var(--slate-500); font-size: 12px; text-align: center; }
.difference-row span:last-child { border-right: 0; }
.difference-row strong { display: block; margin-top: 2px; color: var(--slate-800); font-size: 17px; }
.status-line { margin: 0; padding: 13px 22px; border-top: 1px solid var(--slate-200); background: var(--slate-50); color: var(--slate-500); font-size: 13px; text-align: center; }
.ad-card { height: 92px; display: grid; place-items: center; margin: 20px 0; border: 1px dashed var(--slate-300); border-radius: var(--radius-md); color: var(--slate-400); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.about-card { display: grid; grid-template-columns: .8fr 1.2fr; gap: 32px; padding: 28px; border: 1px solid var(--slate-100); border-radius: var(--radius-lg); background: white; box-shadow: var(--shadow-sm); }
.about-card h2 { margin: 5px 0 0; color: var(--slate-800); font-size: 23px; }
.about-card p { margin: 0; color: var(--slate-600); line-height: 1.65; }
.dialog { width: min(calc(100% - 32px), 490px); padding: 28px; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); background: white; color: var(--slate-600); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(20,25,40,.48); }
.dialog h2 { margin: 6px 0 18px; color: var(--slate-800); }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--slate-500); font-size: 24px; cursor: pointer; }
.steps { margin: 0 0 18px; padding: 0; list-style: none; }
.steps li { display: flex; gap: 13px; padding: 12px 0; border-top: 1px solid var(--slate-200); }
.steps li > span { color: var(--cobalt-600); font-size: 12px; font-weight: 700; }
.steps p { margin: 3px 0 0; color: var(--slate-500); font-size: 13px; }
.result-dialog { text-align: center; }
.result-mark { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 14px; border: 1px solid var(--cobalt-200); border-radius: var(--radius-md); background: var(--cobalt-50); color: var(--cobalt-700); font: 700 17px/1 var(--font-heading); }
.result-grid, .record-grid { display: grid; grid-template-columns: repeat(3,1fr); margin: 20px 0; border-block: 1px solid var(--slate-200); }
.record-grid { grid-template-columns: 1fr 1fr; }
.result-grid div, .record-grid div { padding: 13px 6px; border-right: 1px solid var(--slate-200); }
.result-grid div:last-child, .record-grid div:nth-child(2n) { border-right: 0; }
.record-grid div:nth-child(n+3) { border-top: 1px solid var(--slate-200); }
.result-grid strong, .result-grid span, .record-grid strong, .record-grid span { display: block; }
.result-grid span, .record-grid span { margin-top: 3px; color: var(--slate-500); font-size: 11px; }
.round-pips { display: flex; justify-content: center; gap: 7px; margin-bottom: 18px; }
.round-pips span { min-width: 44px; padding: 6px; border-radius: var(--radius-sm); background: var(--slate-100); color: var(--slate-700); font-size: 12px; font-weight: 700; }
.text-button { width: 100%; margin-top: 8px; padding: 9px; border: 0; background: transparent; color: var(--slate-500); cursor: pointer; }
#snackbar { position: fixed; z-index: var(--global-toast-z); left: 50%; top: var(--global-toast-top); translate: -50% -18px; max-width: calc(100% - 32px); padding: 10px 14px; border: 1px solid var(--slate-200); border-radius: var(--radius-md); background: white; box-shadow: var(--shadow-md); color: var(--slate-700); opacity: 0; pointer-events: none; transition: .2s; }
#snackbar.show { translate: -50% 0; opacity: 1; }
@media (max-width:700px) {
  .afterimage-page { width: min(calc(100% - 16px),960px); padding-top: 22px; }
  .game-heading { align-items: flex-start; }
  .phase { min-height: 440px; padding: 24px 18px; }
  .memory-swatch, .distraction-grid { height: 320px; }
  .distraction-grid { grid-template-columns: repeat(4,1fr); }
  .mixer { margin-inline: -18px; padding-inline: 18px; }
  .phase-action { display: block; margin-inline: -18px; padding-inline: 18px; }
  .phase-action .primary-button { width: 100%; margin-top: 13px; }
  .reveal-swatches figure > div { height: 190px; }
  .reveal-swatches figcaption { display: block; }
  .reveal-swatches code { display: block; margin-top: 2px; }
  .about-card { grid-template-columns: 1fr; gap: 10px; padding: 22px; }
  .dialog { padding: 25px 18px; }
}
@media (max-width:430px) {
  .run-strip > div { display: block; padding: 10px 12px; }
  .run-strip strong { display: block; margin-top: 2px; }
  .phase-label { display: block; }
  .phase-label strong { display: block; margin-top: 4px; }
  .reveal-heading h2 { font-size: 24px; }
  .result-grid span { font-size: 10px; }
}
@media (prefers-reduced-motion:reduce) { .distraction-grid span, #snackbar { animation: none; transition: none; } }
