:root {
    --ink: #1b1530;
    --paper: #fff8ea;
    --pink: #ff2bd6;
    --cyan: #19f6ff;
    --yellow: #ffd400;
    --acid: #c6ff00;
    --purple: #2b1a5e;
    --pixel: 'Silkscreen', monospace;
    --sans: 'Montserrat', system-ui, sans-serif;
    --display: 'Unbounded', 'Arial Black', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; background: var(--purple); color: var(--paper); font-family: var(--sans); -webkit-tap-highlight-color: transparent; }
body { user-select: none; -webkit-user-select: none; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
kbd { font-family: var(--pixel); font-size: 11px; padding: 2px 6px; border: 2px solid currentColor; border-bottom-width: 4px; border-radius: 5px; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

/* pixel box, used for every UI card */
.pixel-box, .dialog, .panel, .prompt, .race, .hud-goals, .title-card {
    background: var(--paper);
    color: var(--ink);
    border: 4px solid var(--ink);
    border-radius: 10px;
    box-shadow: 0 6px 0 rgba(27, 21, 48, 0.55), inset 0 -4px 0 rgba(27, 21, 48, 0.08);
}

/* ---------- title ---------- */
.title {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 16px;
    background: radial-gradient(ellipse at 50% 120%, rgba(255, 140, 90, 0.35), transparent 60%), rgba(27, 21, 48, 0.35);
    transition: opacity 0.6s, visibility 0.6s;
}
.title.gone { opacity: 0; visibility: hidden; }
.title-card { width: min(560px, 100%); padding: 28px 28px 22px; text-align: center; }
.title-kicker { font-family: var(--pixel); font-size: 12px; letter-spacing: 0.08em; color: #6b5a8a; }
.title h1 { font-family: var(--display); font-weight: 900; font-size: clamp(44px, 11vw, 76px); line-height: 0.9; margin: 10px 0 14px; letter-spacing: -0.03em; }
.title h1 span { color: var(--pink); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--yellow); }
.title-sub { font-size: 15px; line-height: 1.5; color: #3d3256; margin: 0 auto 16px; max-width: 42ch; }
.title-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; list-style: none; font-size: 13px; font-weight: 600; margin-bottom: 20px; }
.title-touch { display: none; font-size: 13px; font-weight: 600; margin-bottom: 18px; }
.is-touch .title-keys { display: none; }
.is-touch .title-touch { display: block; }
.play {
    font-family: var(--pixel);
    font-weight: 700;
    font-size: 22px;
    padding: 14px 36px;
    color: var(--ink);
    background: var(--yellow);
    border: 4px solid var(--ink);
    border-radius: 10px;
    box-shadow: 0 6px 0 var(--ink);
    transition: transform 0.08s, box-shadow 0.08s;
}
.play:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
.play:not(:disabled):active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.play:disabled { background: #ddd3c2; color: #8a7e6c; cursor: wait; }
.title-back { display: inline-block; margin-top: 16px; font-size: 13px; font-weight: 600; color: #6b5a8a; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0; transition: opacity 0.6s 0.3s; }
body.playing .hud { opacity: 1; }
.hud-tl { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hud-brand { pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; font-family: var(--pixel); font-weight: 700; font-size: 14px; text-decoration: none; color: var(--paper); text-shadow: 0 2px 0 var(--ink); }
.hud-brand img { filter: invert(1) drop-shadow(0 2px 0 var(--ink)); }
.hud-goals { display: flex; gap: 14px; padding: 6px 12px; font-size: 12px; font-weight: 700; }
.hud-goals b { font-family: var(--pixel); }
.hud-sound { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; pointer-events: auto; font-family: var(--pixel); font-size: 12px; padding: 6px 10px; color: var(--ink); background: var(--paper); border: 3px solid var(--ink); border-radius: 8px; }
.hud-sound[aria-pressed="false"] { opacity: 0.6; text-decoration: line-through; }

.compass {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 8px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    background: var(--paper);
    color: var(--ink);
    border: 3px solid var(--ink);
    border-radius: 999px;
    box-shadow: 0 4px 0 rgba(27, 21, 48, 0.55);
}
.compass-arrow { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--pink); color: #fff; font-size: 11px; transition: transform 0.15s; }
@media (max-width: 600px) { .compass { top: auto; bottom: 190px; } }

.prompt {
    pointer-events: auto;
    cursor: pointer;
    touch-action: manipulation;
    position: absolute;
    left: 50%;
    bottom: 26%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    animation: bob 1.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateX(-50%) translateY(-4px); } }

.toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); text-align: center; }
.toast .card {
    padding: 14px 22px;
    font-weight: 800;
    font-size: 15px;
    background: var(--yellow);
    color: var(--ink);
    border: 4px solid var(--ink);
    border-radius: 10px;
    box-shadow: 0 6px 0 var(--ink);
    animation: pop 2.6s cubic-bezier(0.2, 1.5, 0.3, 1) forwards;
}
.toast .card b { display: block; font-family: var(--display); font-size: clamp(22px, 5vw, 34px); line-height: 1; margin-bottom: 4px; }
@keyframes pop {
    0% { transform: scale(0.4) rotate(-6deg); opacity: 0; }
    12% { transform: scale(1) rotate(-2deg); opacity: 1; }
    85% { transform: scale(1) rotate(-2deg); opacity: 1; }
    100% { transform: scale(0.9) translateY(-20px); opacity: 0; }
}

.race { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; margin-top: 44px; padding: 10px 14px; min-width: 170px; font-weight: 700; }
.race-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.race-row b, .race-time { font-family: var(--pixel); }
.race-time { font-size: 26px; margin: 2px 0 4px; }
.race-speed { height: 8px; background: #e6dcc8; border: 2px solid var(--ink); border-radius: 6px; margin-top: 8px; overflow: hidden; }
.race-speed i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); }

/* ---------- dialogue ---------- */
.dialog {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(680px, calc(100% - 24px));
    min-height: 116px;
    padding: 26px 22px 18px;
    z-index: 10;
    cursor: pointer;
}
.dialog-name { position: absolute; top: -18px; left: 18px; font-family: var(--pixel); font-weight: 700; font-size: 14px; padding: 4px 12px; background: var(--pink); color: #fff; border: 3px solid var(--ink); border-radius: 8px; }
.dialog-text { font-size: 17px; line-height: 1.5; font-weight: 600; min-height: 3em; }
.dialog-more { position: absolute; right: 16px; bottom: 10px; font-size: 14px; animation: bob2 0.8s steps(2) infinite; }
@keyframes bob2 { 50% { transform: translateY(3px); } }

/* ---------- panels ---------- */
.panel-wrap { position: fixed; inset: 0; z-index: 12; display: grid; place-items: center; padding: 14px; background: rgba(27, 21, 48, 0.55); }
.panel { position: relative; width: min(860px, 100%); max-height: calc(100vh - 28px); max-height: calc(100svh - 28px); overflow: auto; padding: 26px 26px 22px; user-select: text; -webkit-user-select: text; animation: rise 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes rise { from { transform: translateY(30px) scale(0.96); opacity: 0; } }
.panel-close { position: sticky; top: 0; float: right; margin: -10px -10px 0 0; font-family: var(--pixel); font-size: 13px; padding: 6px 10px; background: var(--ink); color: var(--paper); border-radius: 8px; z-index: 1; }
.p-kicker { font-family: var(--pixel); font-size: 12px; color: #6b5a8a; }
.p-title { font-family: var(--display); font-weight: 900; font-size: clamp(32px, 6vw, 56px); line-height: 0.95; letter-spacing: -0.03em; margin: 8px 0 10px; color: var(--ink); }
.p-title span { color: var(--c, var(--pink)); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--ink); }
.p-line { font-size: 17px; font-weight: 600; line-height: 1.4; color: #3d3256; max-width: 50ch; }
.p-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 14px 0 6px; font-size: 13px; }
.p-meta b { display: block; font-family: var(--pixel); font-size: 11px; color: #6b5a8a; font-weight: 400; }
.p-shots { display: flex; gap: 14px; overflow-x: auto; padding: 14px 2px 18px; margin: 4px 0; }
.p-shots img { flex: 0 0 auto; width: 150px; height: auto; border-radius: 18px; border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); }
.p-body p { font-size: 15px; line-height: 1.6; margin-bottom: 10px; max-width: 70ch; }
.p-tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 10px 0 16px; }
.p-tags li { font-size: 12px; font-weight: 700; padding: 4px 10px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; }
.p-links { display: flex; flex-wrap: wrap; gap: 10px; }
.p-links a { font-family: var(--pixel); font-size: 13px; padding: 8px 12px; text-decoration: none; color: var(--ink); background: var(--yellow); border: 3px solid var(--ink); border-radius: 8px; box-shadow: 0 4px 0 var(--ink); }
.p-links a:hover { background: var(--acid); }
.p-timeline { list-style: none; margin-top: 12px; display: grid; gap: 12px; }
.p-timeline li { padding: 12px 14px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; }
.p-timeline b { font-family: var(--pixel); font-size: 11px; color: #6b5a8a; font-weight: 400; }
.p-timeline h3 { font-family: var(--display); font-size: 20px; margin: 2px 0 4px; }
.p-timeline p { font-size: 14px; line-height: 1.5; }

/* ---------- touch ---------- */
.touch { display: none; }
body.playing.is-touch .touch { display: block; }
.stick { position: fixed; left: 18px; bottom: max(26px, env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%; border: 3px dashed rgba(255, 248, 234, 0.6); background: rgba(27, 21, 48, 0.3); touch-action: none; z-index: 6; }
.stick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: var(--paper); border: 4px solid var(--ink); }
.touch-btns { position: fixed; right: 16px; bottom: max(26px, env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: flex-end; z-index: 6; }
.touch-btns button { width: 72px; height: 72px; border-radius: 50%; font-family: var(--pixel); font-weight: 700; font-size: 22px; color: var(--ink); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink); touch-action: none; }
#btnA { background: var(--yellow); margin-bottom: 30px; }
#btnB { background: var(--pink); color: #fff; }
.touch-btns button.on { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.is-touch .prompt { bottom: 200px; }
.is-touch .dialog { bottom: 170px; }

@media (max-width: 600px) {
    .hud-goals { flex-direction: column; gap: 2px; }
    .race { margin-top: 44px; min-width: 140px; padding: 8px 10px; }
    .race-time { font-size: 20px; }
    .dialog-text { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
    .prompt, .dialog-more { animation: none; }
}

/* ---------- playable demos inside a feature panel ---------- */
.p-demo-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; margin-top: 8px; }
.p-demo { flex: 1 1 300px; min-width: 0; padding: 16px; background: #fff; border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 5px 0 var(--ink); }
.p-demo-row .p-shots { flex: 0 0 auto; padding-top: 0; }
.d-label { font-family: var(--pixel); font-size: 12px; color: #6b5a8a; margin-bottom: 8px; }
.d-clock { font-family: var(--pixel); font-weight: 700; font-size: clamp(44px, 9vw, 68px); line-height: 1; color: var(--ink); }
.d-clock.over { color: #d6362a; }
.d-bar { height: 12px; margin: 12px 0; background: #eee5d6; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; }
.d-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--acid), var(--cyan)); transition: width 0.9s linear; }
.d-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.d-btn { font-family: var(--pixel); font-size: 13px; padding: 8px 12px; color: var(--ink); background: var(--yellow); border: 3px solid var(--ink); border-radius: 8px; box-shadow: 0 3px 0 var(--ink); }
.d-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.d-btn.ghost { background: #fff; }
.d-btn.small { font-size: 11px; padding: 6px 9px; }
.d-note { font-size: 13px; line-height: 1.45; color: #5d5170; margin-top: 8px; }
.d-canvas { width: 100%; height: auto; border-radius: 8px; border: 3px solid var(--ink); display: block; }
.d-slider { width: 100%; margin: 12px 0 6px; accent-color: var(--pink); }
.d-read { font-family: var(--pixel); font-size: 13px; }
.d-input { width: 100%; font: 600 15px var(--sans); padding: 10px 12px; color: var(--ink); background: #fffdf8; border: 3px solid var(--ink); border-radius: 8px; resize: vertical; }
.d-parse { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.d-chip { display: inline-flex; gap: 6px; align-items: baseline; font-size: 14px; font-weight: 700; padding: 6px 10px; background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; }
.d-chip b { font-family: var(--pixel); font-size: 10px; color: #6b5a8a; font-weight: 400; }
.d-receipt { margin-top: 10px; border-top: 2px dashed var(--ink); }
.d-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 2px dashed #d8cebc; font-size: 14px; }
.d-line b { font-family: var(--pixel); font-size: 13px; white-space: nowrap; }

/* Haze's 3D try-on */
.d-try { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.d-try .d-3d { flex: 0 1 260px; width: 260px; max-width: 100%; background: radial-gradient(circle at 50% 40%, #fff3fb, #f1e4ff 70%); cursor: grab; }
.d-try .d-3d:active { cursor: grabbing; }
.d-try-controls { flex: 1 1 200px; min-width: 0; display: grid; gap: 10px; }
.d-try-group { display: grid; gap: 6px; }
.d-try-name { font-family: var(--pixel); font-size: 11px; color: #6b5a8a; }
.d-try-slider { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.d-try-slider .d-slider { margin: 0; }
.d-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.d-sw { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ink); box-shadow: 0 2px 0 var(--ink); cursor: pointer; }
.d-sw[aria-pressed="true"] { outline: 3px solid var(--pink); outline-offset: 2px; }
.d-row.tight { margin: 0; gap: 6px; }
.d-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
