@font-face {
    font-family: Geist;
    src: url('geist-latin-ext-wght-normal.woff2') format('woff2');
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
    font-family: Geist;
    src: url('geist-latin-wght-normal.woff2') format('woff2');
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
    color-scheme: dark;
    --bg: #15152a;
    --panel: #1d1c35;
    --border: #373452;
    --text: #f8f6ff;
    --muted: #b9b4ce;
    --lime: #daf798;
    --lilac: #b8a8fc;
    --coral: #ffa789;
    font: 15px/1.55 Geist, system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    min-width: 280px;
    min-height: 100dvh;
    background: radial-gradient(ellipse at 35% 0, #26204a 0, transparent 550px), var(--bg);
}
button, a, progress { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, canvas:focus-visible, input:focus-visible {
    outline: 3px solid var(--lime);
    outline-offset: 4px;
}
h1, h2, p { margin: 0; }

.game-header {
    border-bottom: 1px solid #b5a6e524;
    background: #17172eeb;
}
.header-inner, .layout, .page-footer {
    width: min(100% - 64px, 1264px);
    margin-inline: auto;
}
.header-inner {
    display: flex;
    min-height: 74px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
    font-weight: 750;
    font-size: 18px;
    white-space: nowrap;
}
.brand img { display: block; flex-shrink: 0; border-radius: 9px; }
.brand span { overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.icon-button, .identity, .hub-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 37px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #282541;
    font-size: 13px;
    white-space: nowrap;
}
.icon-button { width: 40px; padding: 0; font-size: 21px; color: var(--lilac); }
#settings-toggle { position: relative; z-index: 1; }
.game-settings { position: relative; z-index: 4; }
.menu-icon { width: 17px; height: 12px; border-block: 2px solid; position: relative; border-radius: 1px; }
.menu-icon::after { content: ''; position: absolute; top: 3px; left: 0; width: 100%; border-top: 2px solid; }
#settings-toggle[aria-expanded=true] { background: #383155; color: var(--text); }
.settings-panel { position: absolute; top: calc(100% + 7px); inset-inline-end: 0; width: min(205px, 82vw); display: grid; gap: 3px; padding: 5px; border: 1px solid #706394; border-radius: 12px; background: #211d38; box-shadow: 0 9px 28px #110e25c9; }
.settings-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 7px; font-size: 13px; white-space: normal; text-align: start; }
.settings-item:hover:not(:disabled) { background: #33294d; }
.settings-item:disabled { opacity: .48; }
.settings-item > :first-child { flex: 0 0 17px; color: var(--lilac); text-align: center; }
.restart-icon { font: 650 23px/1 system-ui, sans-serif; }
.info-icon { display: grid; place-items: center; height: 17px; border: 1px solid currentColor; border-radius: 50%; font: 720 12px/1 Geist, sans-serif; }
.identity { font-weight: 600; max-width: 200px; }
.identity.signed-in { padding-left: 6px; }
.identity:focus-visible { overflow: visible; }
.identity .avatar { width: 25px; height: 25px; flex-shrink: 0; font-size: 10px; }
.hub-link { border-color: transparent; background: none; color: var(--muted); }
.hub-link span { color: var(--lilac); }
#favorite[aria-pressed=true] { color: var(--coral); }
.sound-icon { position: relative; width: 17px; height: 15px; }
.sound-icon::before { content: ''; position: absolute; inset: 1px 6px 1px 0; background: currentColor; clip-path: polygon(0 34%, 35% 34%, 100% 0, 100% 100%, 35% 66%, 0 66%); }
.sound-icon::after { content: ''; position: absolute; top: 2px; right: 0; width: 6px; height: 11px; border-right: 2px solid; border-radius: 50%; }
#toggle-sound[aria-pressed=false] .sound-icon { color: var(--muted); }
#toggle-sound[aria-pressed=false] .sound-icon::after { width: 19px; height: 2px; top: 7px; right: -1px; transform: rotate(-43deg); border: 0; border-radius: 0; background: currentColor; box-shadow: 0 1px #282541; }
.header-actions :is(a, button):hover { border-color: #8071b7; }

.layout {
    max-width: 1080px;
    padding-top: clamp(23px, 4vw, 45px);
}
.play-column { min-width: 0; }
.hero {
    position: relative;
    isolation: isolate;
    min-height: 375px;
    display: flex;
    align-items: center;
    overflow: hidden;
    background: #191d63;
    border: 1px solid #6961a1;
    border-radius: 22px;
}
.cover, .hero::after {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}
.cover { object-fit: cover; object-position: center 49%; }
.hero::after {
    content: '';
    background: linear-gradient(90deg, #171638 5%, #171638e8 35%, #1d194b79 59%, #171d6612 89%);
}
.hero-content { padding: 38px clamp(25px, 4.3vw, 54px); max-width: 590px; }
.game-type {
    font-size: 11px;
    font-weight: 740;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: #c9bbff;
}
.hero h1 {
    font-size: clamp(54px, 5.8vw, 82px);
    font-weight: 800;
    letter-spacing: -.076em;
    line-height: .99;
    text-shadow: 0 3px 24px #1615387a;
    margin: 8px 0 11px;
}
.hero h1 span { color: var(--lime); }
.hero-description { font-size: clamp(15px, 1.6vw, 19px); line-height: 1.45; color: #e9e3fb; max-width: 330px; }
.start-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 28px; }
.primary-button, .secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    min-height: 47px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-weight: 720;
    font-size: 14px;
}
.primary-button { color: #222a15; background: var(--lime); }
.primary-button:hover:not(:disabled):not([aria-disabled=true]) { background: #eeffc3; }
.primary-button:disabled { opacity: .49; }
.primary-button[aria-disabled=true] { opacity: .72; cursor: wait; }
.primary-button span, .secondary-button span { font-size: 18px; line-height: 1; }
.secondary-button { background: #282541; border-color: var(--border); color: var(--text); }
.secondary-button:hover:not(:disabled) { background: #3c3559; }
.text-button { border: 0; color: #d8cfff; background: none; padding: 6px 0; font-size: 13px; font-weight: 560; }
.text-button:hover { text-decoration: underline; }
.hero-meta { margin-top: 17px; font-size: 12px; color: #d9d0f1; }
.hero-meta span { padding: 0 4px; }
.hero-error { margin-top: 10px; color: #ffd0bd; max-width: 320px; font-size: 12px; }

.leaderboard {
    width: min(420px, calc(100% - 24px));
    max-height: calc(100dvh - 24px);
    padding: 0 0 6px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(150deg, #262340, #1b1b32 63%);
}
.leader-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--border); }
.leader-header p { color: var(--lilac); font-size: 11px; font-weight: 650; }
.leader-header h2 { font-size: clamp(19px, 2vw, 23px); letter-spacing: -.042em; line-height: 1.25; margin-top: 3px; }
.leader-icon { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 17px; height: 15px; }
.leader-icon i { width: 4px; height: 64%; background: #b9a1ff; border-radius: 1px; }
.leader-icon i:nth-child(2) { height: 100%; background: var(--lime); }
.leader-icon i:nth-child(3) { height: 48%; background: #b9a1ff; }
.player-best { display: flex; justify-content: space-between; gap: 6px; margin: 13px 13px 3px; border: 1px solid #b9a1ff3d; border-radius: 10px; background: #7768b329; padding: 10px; font-size: 12px; }
.player-best strong { color: var(--lime); font-variant-numeric: tabular-nums; }
.player-best small { font-size: 10px; font-weight: 560; color: var(--muted); }
.leader-rows { list-style: none; margin: 0; padding: 5px 10px; }
.leader-rows li { min-height: 34px; display: grid; grid-template-columns: 25px 26px minmax(0, 1fr) max-content; gap: 8px; align-items: center; padding: 3px 5px; border-bottom: 1px solid #bcabdf1a; }
.leader-rows .avatar { width: 25px; height: 25px; }
.leader-rows li.current-player { background: #8176b727; border-radius: 8px; }
.rank { color: var(--muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.rank-1 { color: var(--lime); font-weight: 750; }
.rank-2, .rank-3 { color: var(--lilac); font-weight: 700; }
.avatar { display: inline-grid; width: 30px; height: 30px; place-items: center; overflow: hidden; border-radius: 8px; background: #403352; color: #e5d5f6; font-size: 11px; font-weight: 700; }
.avatar canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.leader-rows strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.list-status { color: var(--muted); padding: 10px 16px; font-size: 11px; }
.list-empty { text-align: center; padding: 27px 16px 24px; }
.list-empty span { display: block; font-size: 28px; color: var(--lilac); line-height: 1.1; margin-bottom: 9px; }
.list-empty strong { font-size: 14px; }
.list-empty p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.standing-pages { display: flex; align-items: center; justify-content: center; padding: 6px 12px 11px; gap: 13px; font-size: 12px; color: var(--muted); }
.standing-pages button { border: 1px solid var(--border); border-radius: 6px; background: #292541; color: var(--text); width: 31px; height: 32px; }
.standing-pages button:disabled { opacity: .4; }

.game-panel {
    position: relative;
    --stage-accent: var(--lilac);
    container-type: inline-size;
    overflow: hidden;
    border: 1px solid #4d456c;
    border-radius: 19px;
    background: linear-gradient(135deg, #25213f, #1e1b33 36%);
}
.playing { display: flex; flex-direction: column; height: 100dvh; min-width: 0; overflow: hidden; }
.playing .game-header { flex: 0 0 auto; }
.playing .header-inner { width: 100%; padding-inline: max(1.5%, env(safe-area-inset-left)) max(1.5%, env(safe-area-inset-right)); min-height: clamp(48px, 7.5dvh, 64px); }
.playing .page-footer { display: none; }
.playing .layout { display: flex; width: 100%; max-width: none; flex: 1; min-height: 0; padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.playing .play-column { display: flex; flex: 1; min-height: 0; }
.playing .game-panel { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; border: 0; border-radius: 0; }
.game-panel[data-level=angle] { --stage-accent: var(--coral); }
.game-panel[data-level=size] { --stage-accent: var(--lime); }
.game-panel[data-level=circle] { --stage-accent: #9ce9e9; }
.game-panel[data-level=balance] { --stage-accent: #ffe0a1; }
.game-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); background: #272248; }
.stage-tabs { display: flex; align-items: center; gap: clamp(7px, 2vw, 18px); }
.stage-tab { display: flex; align-items: center; gap: 6px; color: #c2bad4; white-space: nowrap; font-size: 12px; }
.stage-tab b { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 6px; border: 1px solid #8374aa61; font-size: 11px; }
.stage-tab.current { color: var(--stage-accent); font-weight: 730; }
.stage-tab.current b { color: #241a36; background: var(--stage-accent); border-color: transparent; }
.stage-tab.complete b { color: var(--lime); }
.score-pill { flex-shrink: 0; text-align: right; line-height: 1.25; }
.score-pill small { display: block; font-size: 10px; color: var(--muted); }
.score-pill strong { font-size: 20px; color: var(--lime); font-variant-numeric: tabular-nums; }
.round-progress { display: flex; gap: 14px; align-items: center; padding: 8px 18px 0; color: var(--muted); font-size: 12px; }
.round-progress div { flex: 1; display: flex; gap: 5px; }
.round-progress i { flex: 1; background: #4a4360; height: 3px; border-radius: 3px; }
.round-progress i.complete { background: #b6a4ee80; }
.round-progress i.current { background: var(--stage-accent); }
.turn { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: clamp(10px, 2dvh, 18px) max(1.8%, 12px) clamp(10px, 2.2dvh, 22px); }
.turn h2 { font-size: clamp(24px, 4dvh, 34px); font-weight: 760; letter-spacing: -.05em; line-height: 1.15; }
.turn h2:focus, .summary h2:focus { outline: 0; }
.turn-text { color: var(--muted); font-size: 13px; line-height: 1.4; margin-top: 4px; }
.visual-slot { display: grid; place-items: center; flex: 1 1 0; min-height: 0; min-width: 0; container-type: size; margin-top: 8px; }
.memory-card, .drawing, .circle-board {
    border: 1px solid #5e507b;
    border-radius: 12px;
    background-color: #26213c;
    background-image: linear-gradient(#bcb0e316 1px, transparent 1px), linear-gradient(90deg, #bcb0e316 1px, transparent 1px);
    background-size: 22px 22px;
}
.memory-card { display: grid; place-items: center; width: 100%; height: 100%; background-position: center center; }
.sample {
    width: min(62%, 72cqh);
    aspect-ratio: 1.18;
    border-radius: 10px;
    background: var(--swatch);
    box-shadow: 0 10px 22px #110f2955;
}
.turn-clock { display: flex; align-items: center; gap: 8px; padding: 5px 18px 0; font-size: 11px; color: var(--stage-accent); font-variant-numeric: tabular-nums; }
.turn-clock span { min-width: 32px; text-align: right; }
.turn-clock[data-urgent] { color: var(--coral); --stage-accent: var(--coral); }
progress { accent-color: var(--stage-accent, var(--lilac)); }
.turn-clock progress, .recap progress { width: 100%; height: 5px; appearance: none; border: 0; border-radius: 6px; }
.turn-clock progress::-webkit-progress-bar, .recap progress::-webkit-progress-bar { background: #383050; border-radius: 6px; }
.turn-clock progress::-webkit-progress-value, .recap progress::-webkit-progress-value { background: var(--stage-accent, var(--lilac)); border-radius: 6px; }
.swatch-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; height: 100%; }
.swatch {
    position: relative;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 2px solid #ffffff18;
    border-radius: 10px;
    background: var(--swatch);
}
.swatch:hover:not(:disabled) { border-color: #fff; }
.swatch.correct { border-color: var(--lime); box-shadow: 0 0 0 2px var(--lime); }
.swatch.incorrect { border-color: #ffa4a8; box-shadow: 0 0 0 2px #ffa4a8; }
.swatch b {
    position: absolute;
    bottom: 6px;
    left: 6px;
    display: grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    border-radius: 4px;
    background: #19162ac9;
    color: white;
    font-size: 10px;
    font-weight: 640;
}
.swatch.correct b { color: var(--lime); }
.swatch.incorrect b { color: #ffa4a8; }
.palette {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: clamp(10px, 2%, 26px);
    width: 100%;
    height: 100%;
    padding: clamp(8px, 1.6%, 21px);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #26213c;
}
.palette-surface { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.palette-plane {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: 8px;
    background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(var(--hue, 210) 100% 50%);
    cursor: crosshair;
    touch-action: none;
    user-select: none;
}
.palette-marker {
    position: absolute;
    width: 16px;
    height: 16px;
    transform: translate(-50%, -50%);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #201b2a;
    pointer-events: none;
}
.palette-settings { display: grid; gap: 4px; align-content: center; }
.palette-current { display: flex; gap: 9px; align-items: center; color: var(--text); font-size: 12px; }
.palette-preview { width: 46px; height: 32px; border-radius: 6px; border: 1px solid #ffffff4a; }
.palette-slider { display: grid; grid-template-columns: 1fr max-content; align-items: center; gap: 2px 8px; color: var(--muted); font-size: 12px; }
.palette-slider input { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 23px; margin: 0; accent-color: var(--lilac); cursor: pointer; }
.palette-slider b { font-variant-numeric: tabular-nums; color: var(--text); }
.hue-slider input { appearance: none; border-radius: 6px; background: transparent; }
.hue-slider input::-webkit-slider-runnable-track { height: 10px; border-radius: 6px; background: linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red); }
.hue-slider input::-moz-range-track { height: 10px; border-radius: 6px; background: linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red); }
.hue-slider input::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -3px; border: 2px solid white; border-radius: 50%; background: #27213c; }
.hue-slider input::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid white; border-radius: 50%; background: #27213c; }
.color-comparison { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: clamp(8px, 2%, 24px); width: 100%; height: 100%; }
.color-comparison figure { display: flex; flex-direction: column; margin: 0; }
.color-comparison figure div { flex: 1; border: 1px solid #ffffff32; border-radius: 10px; }
.color-comparison figcaption { margin-top: 5px; color: var(--muted); font-size: 13px; }
.question-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.question-target { flex-shrink: 0; border: 1px solid #a997e754; border-radius: 9px; background: #43365e; padding: 5px 11px; color: var(--stage-accent); font-size: 27px; font-weight: 790; letter-spacing: -.04em; }
.drawing { display: block; width: min(100%, 231.88cqh); height: auto; aspect-ratio: 640 / 276; touch-action: none; cursor: crosshair; }
.angle-quiz { touch-action: auto; cursor: default; }
.angle-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-top: 10px; }
.angle-option { position: relative; min-height: 39px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: #322948; }
.angle-option:hover:not(:disabled) { border-color: var(--lilac); background: #443560; }
.angle-option strong { font-size: 19px; }
.angle-option small, .angle-option span { position: absolute; top: 4px; color: var(--muted); font-size: 10px; }
.angle-option small { left: 6px; }
.angle-option span { right: 6px; }
.angle-option.correct, .angle-option.correct span { color: var(--lime); border-color: var(--lime); }
.angle-option.incorrect, .angle-option.incorrect span { color: #ffa4a8; border-color: #ffa4a8; }
.size-drawing { cursor: nwse-resize; }
.size-labels { display: grid; grid-template-columns: 1fr 1fr; padding: 0 16px; margin-top: 6px; color: #d0baff; font-size: 12px; font-weight: 620; }
.size-labels span:nth-child(2) { color: var(--coral); padding-left: 8px; }
.draw-help { font-size: 12px; margin-top: 8px; }
.circle-board { width: min(100%, 150cqh); aspect-ratio: 3 / 2; overflow: hidden; }
.turn[data-phase=memory] .circle-board, .turn[data-phase=answer] .circle-board { width: min(100%, 150cqh, max(0px, calc(150dvh - 333px))); }
.circle-canvas { display: block; width: 100%; height: 100%; }
.circle-input { cursor: crosshair; touch-action: none; user-select: none; -webkit-touch-callout: none; }
.circle-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; margin-top: 4px; color: var(--muted); font-size: 11px; }
.circle-legend span::before { content: ''; display: inline-block; width: 15px; margin-inline-end: 5px; border-top: 2px solid #c6a9ff; vertical-align: middle; }
.circle-legend span + span::before { border-top: 2px dashed #9ce9e9; }
.balance-canvas { width: min(100%, 162.5cqh); aspect-ratio: 13 / 8; border: 0; box-shadow: inset 0 0 0 1px #79698a; background-position: center; user-select: none; -webkit-touch-callout: none; }
.balance-canvas[role=img] { cursor: default; touch-action: auto; }
.balance-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; margin-block: 6px 0; color: var(--muted); font-size: 12px; }
.balance-legend span { display: inline-flex; align-items: center; gap: 5px; }
.balance-legend span::before { content: ''; width: 9px; height: 9px; border: 1.5px solid #d7b9ff; border-radius: 50%; }
.balance-legend span + span::before { content: '+'; width: 10px; border: 0; color: #b8f9c4; font: bold 16px/9px system-ui, sans-serif; }
.circle-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 6px auto 0; width: min(100%, 560px); }
.circle-metrics[data-position] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.circle-metrics > div { padding: 3px 4px; border: 1px solid var(--border); border-radius: 7px; background: #282541; text-align: center; }
.circle-metrics dt { color: var(--muted); font-size: 11px; }
.circle-metrics dd { margin: 0; font-size: 15px; font-weight: 720; font-variant-numeric: tabular-nums; }
[data-outcome] { --outcome: var(--lilac); --outcome-bg: #282541; }
[data-outcome=correct] { --outcome: var(--lime); --outcome-bg: #2b3733; }
[data-outcome=incorrect] { --outcome: #ffa4a8; --outcome-bg: #382632; }
[data-outcome=timeout] { --outcome: #ffd197; --outcome-bg: #382e32; }
.answer-mark { display: inline-grid; place-items: center; flex: 0 0 auto; width: 21px; height: 21px; padding: 0; border: 1px solid currentColor; border-radius: 50%; color: var(--outcome); font: 740 15px/1 system-ui, sans-serif; }
.feedback { display: flex; align-items: center; gap: 7px; padding: 6px 10px; margin-top: 6px; border: 1px solid color-mix(in srgb, var(--outcome) 29%, var(--border)); border-radius: 9px; background: var(--outcome-bg); font-size: 13px; }
.feedback strong { color: var(--outcome); white-space: nowrap; margin-inline-start: auto; }
.feedback-detail { display: inline-block; margin-inline-start: 6px; color: var(--muted); }
.turn-actions { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 8px; }
.turn-actions :is(button, a) { min-height: 40px; padding-block: 7px; }
.next-overlay { position: absolute; z-index: 2; inset-inline-start: 50%; inset-block-end: clamp(10px, 2.8dvh, 26px); transform: translateX(-50%); width: clamp(166px, 24%, 300px); min-height: 44px; box-shadow: 0 5px 25px #110e25c9; }
.turn[data-phase=feedback], .chapter { padding-bottom: clamp(67px, 11dvh, 104px); }
.circle-spacer { min-height: 40px; }
.retry-action { flex: 0 0 auto; padding: 2px 10px 8px; text-align: center; }
.empty-turn { justify-content: center; align-items: center; text-align: center; }
.chapter { align-items: center; text-align: center; justify-content: center; }
.chapter-art { flex: 0 1 auto; min-height: 0; width: min(94%, 60dvh, 820px, max(0px, calc(150dvh - 315px))); aspect-ratio: 3 / 2; border: 1px solid var(--border); border-radius: 13px; background: #191641 var(--chapter-image) 0 0 / 200% 200% no-repeat; margin-bottom: clamp(8px, 2dvh, 15px); }
.chapter[data-chapter=angle] .chapter-art { background-position: 100% 0; }
.chapter[data-chapter=size] .chapter-art { background-position: 0 100%; }
.chapter[data-chapter=circle] .chapter-art { background-position: 100% 100%; }
.chapter[data-chapter=balance] .chapter-art { background-position: center; background-size: cover; }
.chapter .game-type { color: var(--stage-accent); margin-bottom: 4px; }
.chapter .turn-text { max-width: 46ch; text-wrap: balance; }

.summary { display: flex; flex: 1; flex-direction: column; justify-content: center; width: min(100%, 600px); margin-inline: auto; padding: 14px clamp(12px, 4vw, 32px); }
.summary h2 { font-size: clamp(38px, 9dvh, 70px); line-height: 1; font-weight: 800; letter-spacing: -.06em; margin: 6px 0; color: var(--lime); }
.summary h2 span { color: var(--muted); font-size: .35em; letter-spacing: -.03em; white-space: nowrap; }
.summary > p:not(.game-type) { color: var(--muted); }
.summary-note { display: flex; align-items: center; gap: 7px; }
.recap { margin: 12px 0; padding: 6px 12px; background: #2a2440; border: 1px solid var(--border); border-radius: 12px; }
.recap-row { display: grid; grid-template-columns: 1fr max-content; gap: 4px; padding: 5px 0; font-size: 13px; }
.recap-row progress { grid-column: 1 / -1; }
.recap-row strong { color: #d5c8fe; }
.notice:not(:empty) { margin-top: 10px; padding: 10px 13px; border: 1px solid #7d6092; border-radius: 9px; font-size: 13px; color: #f5dcff; background: #392b48; }
.playing .notice:not(:empty) { position: fixed; z-index: 2; top: 50px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 26px); pointer-events: none; }
dialog { max-width: min(460px, 100% - 30px); color: var(--text); background: var(--panel); border: 1px solid #685b8d; border-radius: 16px; padding: 24px; }
dialog::backdrop { background: #101020b8; }
dialog h2 { font-size: 23px; line-height: 1.2; }
dialog p { color: var(--muted); font-size: 13px; margin: 10px 0 19px; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.summary .dialog-actions { justify-content: center; }
.summary .dialog-actions > * { min-height: 39px; padding-block: 6px; }
.comparison-dialog { width: min(500px, calc(100% - 24px)); padding: 0 0 10px; }
.about-dialog { width: min(460px, calc(100% - 24px)); padding: 0; }
.about-content { padding: 10px 16px 13px; }
.about-content p { margin: 0 0 8px; }
.about-content .about-meta { color: var(--lilac); font-size: 12px; }
.about-hub { display: none; }
#comparison-content { padding-inline: 10px; }
#comparison-content .visual-slot { height: max(0px, min(300px, calc(100dvh - 218px))); }
#comparison-content .visual-slot:has(.balance-canvas) { height: max(0px, min(300px, calc(100dvh - 148px))); }
.page-footer { display: flex; flex-wrap: wrap; gap: 17px; padding: 22px 0 25px; margin-top: 20px; font-size: 12px; color: var(--muted); }
.page-footer a:hover, .page-footer button:hover { color: var(--text); text-decoration: underline; }
.page-footer button { padding: 0; border: 0; color: inherit; background: none; font-size: inherit; }
.syca-consent { position: fixed; z-index: 5; bottom: 16px; left: 16px; width: min(390px, 100% - 32px); background: var(--panel); border: 1px solid #6f6092; border-radius: 13px; padding: 15px; font-size: 13px; }
.syca-consent p { color: var(--muted); margin: 6px 0; }
.syca-consent a { color: var(--lilac); text-decoration: underline; }
.syca-consent div { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.syca-consent button { color: var(--text); padding: 7px 8px; background: #392f54; border: 1px solid var(--border); border-radius: 6px; }

@media (max-width: 1040px) {
    .header-inner, .layout, .page-footer { width: calc(100% - 40px); }
}
@media (max-width: 850px) {
    .hero h1 { font-size: clamp(54px, 10vw, 82px); }
}
@media (max-width: 515px) {
    .header-inner, .layout, .page-footer { width: calc(100% - 26px); }
    .header-inner { min-height: 58px; gap: 6px; }
    .brand { gap: 6px; font-size: 15px; }
    .brand img { width: 28px; height: 28px; border-radius: 7px; }
    .header-actions { gap: 4px; }
    .header-actions > :is(a, button) { min-height: 37px; padding: 0 6px; font-size: 11px; }
    .header-actions .icon-button { width: 37px; height: 37px; font-size: 18px; }
    #settings-toggle { width: 44px; min-height: 44px; }
    .identity { max-width: 102px; overflow: hidden; }
    .hub-link { gap: 3px; }
    .hero { min-height: 310px; border-radius: 15px; }
    .hero-content { padding: 23px 17px; }
    .hero::after { background: linear-gradient(90deg, #171638 1%, #171638e0 30%, #221e50a1 60%, #171d6622); }
    .game-top { padding-inline: 10px; }
    .stage-tab { gap: 4px; font-size: 10px; }
    .stage-tab b { width: 17px; height: 19px; font-size: 9px; }
    .score-pill small { font-size: 9px; }
    .score-pill strong { font-size: 16px; }
    .round-progress { padding-inline: 13px; }
    .turn { padding-inline: 12px; }
    .swatch-grid { gap: 6px; }
    .swatch { border-radius: 7px; }
    .swatch b { bottom: 3px; left: 3px; }
    .palette { grid-template-columns: minmax(0, 1fr) minmax(116px, .76fr); gap: 8px; padding: 8px; }
    .palette-preview { height: 24px; }
    .angle-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .question-target { padding: 3px 7px; font-size: 20px; }
    .feedback { padding: 8px; font-size: 12px; }
    .size-labels { padding-inline: 8px; }
}
@media (min-height: 680px) and (max-width: 515px) {
    .palette { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
}
@media (max-height: 600px) {
    body:not(.playing) .header-inner { min-height: 44px; }
    body:not(.playing) .layout { padding-top: 9px; }
    .hero { min-height: 0; }
    .hero-content { padding-block: 13px; }
    .hero h1 { font-size: clamp(38px, 11dvh, 65px); margin-block: 4px 6px; }
    .start-actions { gap: 8px; margin-top: 12px; }
    .start-actions > * { min-height: 38px; padding-block: 6px; }
    .hero-meta { margin-top: 6px; }
    .page-footer { margin-top: 4px; padding-block: 5px; }
}
@media (max-height: 480px) {
    .hero h1 br { display: none; }
    .hero h1 { font-size: clamp(32px, 8vw, 58px); }
    .hero-description { max-width: 55ch; font-size: 13px; }
    .playing .header-inner { min-height: 42px; }
    .playing .brand img { width: 26px; height: 26px; }
    .game-top { padding-block: 4px; }
    .stage-tab b { width: 19px; height: 19px; }
    .score-pill { display: flex; align-items: baseline; gap: 5px; }
    .score-pill strong { font-size: 16px; }
    .round-progress { padding-top: 3px; font-size: 11px; }
    .turn-clock { padding-top: 3px; line-height: 1.2; }
    .turn { padding-block: 6px 8px; }
    .turn[data-phase=feedback], .chapter { padding-bottom: 53px; }
    .next-overlay { inset-block-end: 8px; min-height: 38px; padding-block: 5px; }
    .turn h2 { font-size: 20px; }
    .turn-text { font-size: 11px; }
    .question-target { font-size: 19px; line-height: 1.2; padding: 4px 7px; }
    .size-labels { margin-top: 3px; font-size: 10px; }
    .draw-help { display: none; }
    .angle-option { min-height: 33px; }
    .turn-actions { margin-top: 5px; }
    .turn-actions :is(button, a) { min-height: 35px; padding-block: 4px; }
    .circle-spacer { min-height: 35px; }
    .palette { padding: 5px; gap: 7px; }
    .palette-settings { gap: 0; }
    .palette-slider { gap: 0 5px; font-size: 10px; }
    .palette-slider input { height: 15px; }
    .summary { padding-block: 8px; }
    .recap { margin-block: 6px; }
    .recap-row { padding-block: 3px; }
    .circle-legend, .balance-legend { font-size: 10px; }
    .feedback { padding: 5px 7px; font-size: 11px; line-height: 1.25; }
    .answer-mark { width: 18px; height: 18px; font-size: 12px; }
    .feedback-detail { margin-inline-start: 4px; }
    .chapter-art { width: min(94%, 85dvh, max(0px, calc(150dvh - 250px))); }
    .turn[data-phase=memory] .circle-board, .turn[data-phase=answer] .circle-board { width: min(100%, 150cqh, max(0px, calc(150dvh - 278px))); }
}
@media (max-height: 410px) and (min-width: 470px) {
    .recap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
    .summary .dialog-actions { gap: 6px; }
    .summary .dialog-actions > * { padding-inline: 12px; }
    .turn[data-phase=answer]:has(.balance-canvas) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(166px, 34%);
        grid-template-rows: auto auto minmax(0, 1fr) auto;
        column-gap: 12px;
    }
    .turn[data-phase=answer]:has(.balance-canvas) .visual-slot { grid-column: 1; grid-row: 1 / -1; margin-top: 0; }
    .turn[data-phase=answer]:has(.balance-canvas) h2 { grid-column: 2; grid-row: 1; }
    .turn[data-phase=answer]:has(.balance-canvas) .turn-text { grid-column: 2; grid-row: 2; }
    .turn[data-phase=answer]:has(.balance-canvas) .turn-actions { grid-column: 2; grid-row: 4; justify-content: start; }
    .chapter[data-chapter=balance] .chapter-art { width: min(94%, 60dvh, max(0px, calc(150dvh - 300px))); }
    .turn[data-phase=feedback]:has(.drawing) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(185px, 34%);
        grid-template-rows: auto auto auto minmax(0, 1fr);
        column-gap: 10px;
    }
    .turn[data-phase=feedback]:has(.drawing) .visual-slot { grid-column: 1; grid-row: 1 / 5; }
    .turn[data-phase=feedback]:has(.drawing) :is(.question-title, h2#turn-title) { grid-column: 2; grid-row: 1; }
    .turn[data-phase=feedback]:has(.drawing) > :is(.turn-text, .size-labels) { grid-column: 2; grid-row: 2; }
    .turn[data-phase=feedback]:has(.balance-canvas) .balance-legend { grid-column: 2; grid-row: 2; justify-content: start; }
    .turn[data-phase=feedback]:has(.drawing) .angle-options { grid-column: 2; grid-row: 3; }
    .turn[data-phase=feedback]:has(.drawing) .feedback { grid-column: 2; grid-row: 4; align-self: end; }
    .turn[data-phase=feedback]:has(.angle-quiz) .angle-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
    .turn[data-phase=feedback]:has(.circle-board) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(188px, 36%);
        grid-template-rows: auto auto auto minmax(0, 1fr);
        column-gap: 10px;
    }
    .turn[data-phase=feedback]:has(.circle-board) .visual-slot { grid-column: 1; grid-row: 1 / 5; }
    .turn[data-phase=feedback]:has(.circle-board) h2 { grid-column: 2; grid-row: 1; }
    .turn[data-phase=feedback]:has(.circle-board) .circle-legend { grid-column: 2; grid-row: 2; justify-content: start; }
    .turn[data-phase=feedback]:has(.circle-board) .circle-metrics { grid-column: 2; grid-row: 3; }
    .turn[data-phase=feedback]:has(.circle-board) .circle-metrics[data-position] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .turn[data-phase=feedback]:has(.circle-board) .circle-metrics dt { font-size: 9px; }
    .turn[data-phase=feedback]:has(.circle-board) .circle-metrics dd { font-size: 14px; }
    .turn[data-phase=feedback]:has(.circle-board) .feedback { grid-column: 2; grid-row: 4; align-self: end; }
}
@container (max-width: 680px) {
    .stage-tab:not(.current) span { display: none; }
}
@media (max-width: 420px) {
    .identity.signed-in { padding-inline: 4px; }
    .identity .player-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .playing .hub-link { display: none; }
    .playing .about-hub { display: inline-flex; margin-inline-end: 10px; }
}
@media (max-width: 365px) {
    .hub-link { display: none; }
    .about-hub { display: inline-flex; margin-inline-end: 10px; }
}
.playing .game-header { padding-block-start: env(safe-area-inset-top); }
