:root {
    --bg: #061018;
    --panel: rgba(10, 23, 34, 0.86);
    --text: #f3fbff;
    --soft: #c9e9f4;
    --muted: #8fb2bf;
    --cyan: #43e8ff;
    --pink: #ff5ea8;
    --amber: #ffd166;
    --green: #52ffa8;
    --violet: #9b72ff;
    --border: rgba(67, 232, 255, 0.28);
    --shadow: rgba(67, 232, 255, 0.2);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

.sr-only {
    clip: rect(0 0 0 0);
    border: 0;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

body {
    background:
        radial-gradient(circle at 18% 10%, rgba(67, 232, 255, 0.15), transparent 30%),
        radial-gradient(circle at 82% 18%, rgba(255, 94, 168, 0.14), transparent 28%),
        radial-gradient(circle at 50% 86%, rgba(82, 255, 168, 0.11), transparent 34%),
        linear-gradient(180deg, #041018 0%, #0b1824 54%, #061018 100%);
    color: var(--text);
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    margin: 0;
    min-height: 100vh;
}

.game-shell {
    align-items: center;
    display: flex;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    width: 100%;
}

.game-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 0 42px var(--shadow), inset 0 0 36px rgba(2, 6, 23, 0.42);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    margin: 0 auto;
    max-height: 960px;
    max-width: 1120px;
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

.game-topbar {
    align-items: center;
    background:
        linear-gradient(90deg, rgba(67, 232, 255, 0.16), transparent 18%, transparent 82%, rgba(82, 255, 168, 0.12)),
        linear-gradient(180deg, rgba(10, 23, 34, 0.98), rgba(4, 12, 20, 0.9));
    border-bottom: 1px solid var(--border);
    box-shadow: inset 0 -1px 0 rgba(82, 255, 168, 0.12);
    display: grid;
    gap: 16px;
    grid-template-columns: auto 1fr auto;
    min-width: 0;
    padding: 14px 18px;
}

.back-link,
.controls button,
.board-hud button,
.overlay-card button {
    background: rgba(4, 12, 20, 0.78);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--cyan);
    cursor: pointer;
    font: 800 12px/1 Inter, "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0;
    padding: 10px 12px;
    text-decoration: none;
    text-transform: uppercase;
}

.back-link:hover,
.controls button:hover,
.board-hud button:hover,
.overlay-card button:hover,
.back-link:focus-visible,
.controls button:focus-visible,
.board-hud button:focus-visible,
.overlay-card button:focus-visible {
    box-shadow: 0 0 16px var(--shadow);
    outline: 1px solid var(--cyan);
}

.game-title {
    min-width: 0;
    text-align: center;
}

.game-title h1 {
    color: var(--text);
    font-size: 24px;
    line-height: 1.05;
    margin: 0;
    text-shadow: 0 0 16px rgba(67, 232, 255, 0.42), 0 0 22px rgba(82, 255, 168, 0.22);
    text-transform: uppercase;
}

.game-title::before,
.game-title::after {
    background: linear-gradient(90deg, transparent, rgba(67, 232, 255, 0.56), transparent);
    content: "";
    display: block;
    height: 1px;
    margin: 0 auto 6px;
    max-width: 220px;
    width: 64%;
}

.game-title::after {
    margin: 6px auto 0;
    opacity: 0.45;
}

.game-title p {
    color: var(--muted);
    font: 700 12px/1.4 "SFMono-Regular", Consolas, monospace;
    margin: 4px 0 0;
    text-transform: uppercase;
}

.lab-hud {
    background:
        linear-gradient(180deg, rgba(67, 232, 255, 0.08), transparent 52%),
        rgba(4, 12, 20, 0.68);
    border: 1px solid rgba(67, 232, 255, 0.28);
    border-radius: 9px;
    box-shadow: inset 0 0 18px rgba(2, 6, 23, 0.72), 0 0 18px rgba(67, 232, 255, 0.08);
    min-width: 0;
    position: relative;
}

.lab-hud::before {
    background: linear-gradient(90deg, transparent, rgba(82, 255, 168, 0.72), transparent);
    content: "";
    height: 1px;
    left: 12px;
    opacity: 0.72;
    position: absolute;
    right: 12px;
    top: 0;
}

.scoreboard {
    display: grid;
    gap: 0;
    grid-template-columns: minmax(126px, 1.25fr) minmax(104px, 1fr);
}

.hud-cell {
    min-width: 0;
    padding: 9px 11px;
    position: relative;
    text-align: left;
}

.hud-cell + .hud-cell {
    border-left: 1px solid rgba(67, 232, 255, 0.18);
}

.scoreboard span,
.run-stat span {
    color: var(--muted);
    display: block;
    font: 800 10px/1 "SFMono-Regular", Consolas, monospace;
    text-transform: uppercase;
}

.scoreboard strong,
.run-stat strong {
    color: var(--cyan);
    display: block;
    font: 900 22px/1.05 "SFMono-Regular", Consolas, monospace;
    margin-top: 4px;
    text-shadow: 0 0 12px rgba(67, 232, 255, 0.34);
}

.scoreboard strong {
    font-size: 24px;
}

.hud-cell-primary strong {
    color: var(--amber);
    text-shadow: 0 0 14px rgba(255, 209, 102, 0.32);
}

.scoreboard .hud-cell-primary strong {
    font-size: 28px;
}

.scoreboard .hud-cell-primary::after {
    background: linear-gradient(180deg, var(--amber), transparent);
    border-radius: 999px;
    content: "";
    height: 28px;
    opacity: 0.72;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
}

.arena-wrap {
    align-items: center;
    background:
        linear-gradient(rgba(67, 232, 255, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(82, 255, 168, 0.08) 1px, transparent 1px),
        radial-gradient(circle at 50% 48%, rgba(67, 232, 255, 0.14), transparent 40%),
        #041018;
    background-size: 52px 52px, 52px 52px, auto, auto;
    display: flex;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
    padding: clamp(10px, 2vh, 18px);
    position: relative;
}

.arena-wrap::before,
.arena-wrap::after {
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

.arena-wrap::before {
    background:
        radial-gradient(circle at 18% 36%, rgba(67, 232, 255, 0.12) 0 2px, transparent 3px),
        radial-gradient(circle at 76% 24%, rgba(82, 255, 168, 0.1) 0 2px, transparent 3px),
        radial-gradient(circle at 62% 78%, rgba(67, 232, 255, 0.09) 0 1px, transparent 2px);
    background-size: 180px 160px, 220px 190px, 150px 130px;
    opacity: 0.42;
    z-index: 0;
    animation: labParticleDrift 18s linear infinite;
}

.arena-wrap::after {
    background: linear-gradient(180deg, transparent 0%, rgba(67, 232, 255, 0.08) 48%, transparent 56%);
    opacity: 0.46;
    transform: translateY(-100%);
    z-index: 0;
    animation: labScanSweep 8s ease-in-out infinite;
}

.play-layout {
    align-items: stretch;
    display: grid;
    gap: clamp(12px, 2vw, 18px);
    grid-template-columns: minmax(0, auto) minmax(116px, 150px);
    height: 100%;
    justify-content: center;
    max-width: 960px;
    min-width: 0;
    outline: none;
    position: relative;
    width: 100%;
    z-index: 1;
}

.board-column {
    display: grid;
    gap: clamp(8px, 1.5vh, 14px);
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
}

.board-stage {
    display: grid;
    min-height: 0;
    position: relative;
}

.board-hud {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.board-hud span {
    background: rgba(4, 12, 20, 0.72);
    border: 1px solid rgba(67, 232, 255, 0.24);
    border-radius: 999px;
    color: var(--soft);
    font: 900 11px/1 "SFMono-Regular", Consolas, monospace;
    padding: clamp(8px, 1.4vh, 10px) 13px;
    text-transform: uppercase;
}

.board-hud span.status-warning {
    border-color: rgba(255, 94, 168, 0.72);
    box-shadow: 0 0 16px rgba(255, 94, 168, 0.28);
    color: #ff9fc9;
}

.board {
    --cols: 5;
    align-content: center;
    background:
        radial-gradient(circle at 50% 50%, rgba(67, 232, 255, 0.08), transparent 58%),
        rgba(4, 12, 20, 0.84);
    border: 1px solid rgba(67, 232, 255, 0.38);
    border-radius: 10px;
    box-shadow: 0 0 34px rgba(67, 232, 255, 0.16), inset 0 0 28px rgba(2, 6, 23, 0.62);
    display: grid;
    gap: clamp(10px, 1.4vw, 16px);
    grid-template-columns: repeat(var(--cols), minmax(58px, 92px));
    justify-content: center;
    min-height: 0;
    padding: clamp(12px, 2vw, 20px);
    position: relative;
    touch-action: manipulation;
}

.board::before {
    background:
        radial-gradient(circle at 24% 28%, rgba(82, 255, 168, 0.26), transparent 22%),
        radial-gradient(circle at 74% 64%, rgba(67, 232, 255, 0.24), transparent 26%);
    border-radius: inherit;
    content: "";
    inset: 0;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    z-index: 0;
}

.board.start-flow::before {
    animation: labLightPulse 0.9s ease-in-out infinite;
}

.bottle {
    appearance: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    height: clamp(150px, 25vh, 230px);
    min-width: 0;
    padding: 0;
    position: relative;
    z-index: 1;
}

.bottle:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
}

.bottle-shell {
    display: block;
    height: 100%;
    margin: 0 auto;
    max-width: 86px;
    position: relative;
    width: 100%;
}

.bottle-glass {
    background: url("../images/bottle-empty.svg") center / 100% 100% no-repeat;
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 2;
}

.bottle-shell::before,
.bottle-shell::after {
    content: "";
    pointer-events: none;
    position: absolute;
    z-index: 3;
}

.bottle-shell::before {
    background: linear-gradient(90deg, transparent, rgba(243, 251, 255, 0.54), transparent);
    border-radius: 50%;
    height: 5%;
    left: 31%;
    opacity: 0.78;
    top: 8%;
    width: 38%;
}

.bottle-shell::after {
    background: linear-gradient(180deg, rgba(243, 251, 255, 0.4), transparent);
    border-radius: 999px;
    bottom: 18%;
    left: 28%;
    opacity: 0.34;
    top: 18%;
    width: 8%;
}

.liquid-stack {
    border-radius: 8px 8px 18px 18px;
    bottom: 13%;
    clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
    display: flex;
    flex-direction: column;
    left: 22%;
    overflow: hidden;
    position: absolute;
    right: 22%;
    top: 30%;
    z-index: 1;
}

.liquid {
    border-top: 1px solid rgba(255, 255, 255, 0.24);
    display: block;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.liquid:not(.empty)::before,
.liquid:not(.empty)::after {
    background: rgba(243, 251, 255, 0.54);
    border-radius: 50%;
    bottom: 12%;
    content: "";
    height: 4px;
    opacity: 0;
    position: absolute;
    width: 4px;
}

.liquid:not(.empty) {
    animation: liquidIdleShift 4.8s ease-in-out infinite;
    box-shadow: inset 0 7px 0 rgba(255, 255, 255, 0.18), inset 0 -8px 14px rgba(2, 6, 23, 0.12);
}

.liquid:not(.empty)::before {
    box-shadow: 12px -10px 0 -1px rgba(243, 251, 255, 0.3), 22px 4px 0 -2px rgba(243, 251, 255, 0.22);
}

.liquid:not(.empty)::after {
    box-shadow: -14px -8px 0 -1px rgba(243, 251, 255, 0.26), -24px 5px 0 -2px rgba(243, 251, 255, 0.2);
}

.liquid:not(.empty)::before {
    left: 26%;
    opacity: 0.28;
    animation: liquidIdleBubble 5.4s ease-in-out infinite;
}

.liquid:not(.empty)::after {
    animation-delay: 0.34s;
    left: 62%;
    opacity: 0.22;
    animation: liquidIdleBubble 6.2s ease-in-out infinite;
}

.board.start-flow .liquid:not(.empty)::before,
.board.start-flow .liquid:not(.empty)::after {
    animation: liquidStartBubble 1.2s ease-in-out infinite;
}

.liquid.empty {
    opacity: 0;
}

.color-pink { background: linear-gradient(180deg, #ff8dcc, #ff3f9d); }
.color-cyan { background: linear-gradient(180deg, #98f6ff, #22cce6); }
.color-amber { background: linear-gradient(180deg, #ffe49a, #ffb832); }
.color-green { background: linear-gradient(180deg, #9dffc8, #22d978); }
.color-violet { background: linear-gradient(180deg, #c4afff, #7b55ff); }
.color-red { background: linear-gradient(180deg, #ff9a9a, #ff4d5c); }
.color-blue { background: linear-gradient(180deg, #91c5ff, #367bff); }
.color-lime { background: linear-gradient(180deg, #e0ff8a, #a7e629); }
.color-orange { background: linear-gradient(180deg, #ffc68a, #ff8428); }

.bottle.selected .bottle-shell {
    animation: selectedBottleReady 1.4s ease-in-out infinite;
    filter: drop-shadow(0 16px 18px rgba(2, 6, 23, 0.32));
    transform-origin: 50% 18%;
}

.bottle.selected .bottle-glass {
    filter: drop-shadow(0 0 16px rgba(67, 232, 255, 0.52));
}

.bottle.selected::after {
    background: radial-gradient(ellipse at center, rgba(67, 232, 255, 0.34), rgba(82, 255, 168, 0.1) 42%, transparent 70%);
    bottom: -5px;
    content: "";
    height: 18px;
    left: 18%;
    pointer-events: none;
    position: absolute;
    right: 18%;
    z-index: 0;
}

.bottle.hint-source .bottle-shell,
.bottle.hint-target .bottle-shell {
    animation: hintBottlePulse 0.9s ease-in-out infinite;
}

.bottle.hint-source .bottle-glass {
    filter: drop-shadow(0 0 16px rgba(67, 232, 255, 0.54));
}

.bottle.hint-target .bottle-glass {
    filter: drop-shadow(0 0 16px rgba(82, 255, 168, 0.5));
}

.bottle.hint-source::after,
.bottle.hint-target::after {
    border-radius: 50%;
    color: #041018;
    display: grid;
    font: 950 10px/1 "SFMono-Regular", Consolas, monospace;
    height: 24px;
    place-items: center;
    pointer-events: none;
    position: absolute;
    top: 10%;
    width: 24px;
    z-index: 5;
}

.bottle.hint-source::after {
    background: var(--cyan);
    content: "1";
    left: 12%;
}

.bottle.hint-target::after {
    background: var(--green);
    content: "2";
    right: 12%;
}

.bottle.solved .bottle-glass {
    filter: drop-shadow(0 0 10px rgba(82, 255, 168, 0.24));
}

.board.start-flow .bottle-shell {
    animation: bottleStartShimmer 1.1s ease-in-out infinite;
}

.board.start-flow .bottle-glass {
    filter: drop-shadow(0 0 14px rgba(67, 232, 255, 0.28));
}

.bottle.solved::before {
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 77, 92, 0.95), rgba(145, 18, 44, 0.96));
    border: 1px solid rgba(255, 210, 218, 0.58);
    border-radius: 4px;
    box-shadow: 0 0 12px rgba(255, 77, 92, 0.28), inset 0 0 8px rgba(255, 255, 255, 0.12);
    color: #fff0f3;
    content: "SEALED";
    display: flex;
    font: 950 8px/1 "SFMono-Regular", Consolas, monospace;
    height: 18px;
    justify-content: center;
    letter-spacing: 0;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: rotate(-28deg);
    transform-origin: center;
    translate: -50% -50%;
    width: 58px;
    z-index: 4;
}

.bottle.solved:hover .bottle-shell,
.bottle.solved:focus-visible .bottle-shell {
    filter: drop-shadow(0 8px 14px rgba(2, 6, 23, 0.24));
}

.bottle.solved-pulse .bottle-shell {
    animation: bottleLockIn 0.82s cubic-bezier(0.19, 1, 0.22, 1) both;
}

.bottle.solved-pulse::before {
    animation: solvedCheckPop 0.82s ease both;
}

.bottle.solved-pulse::after {
    border: 2px solid rgba(82, 255, 168, 0.8);
    border-radius: 14px;
    box-shadow: 0 0 22px rgba(82, 255, 168, 0.34), inset 0 0 18px rgba(67, 232, 255, 0.16);
    content: "";
    inset: -5px 4px;
    pointer-events: none;
    position: absolute;
    z-index: 1;
    animation: solvedGlowPulse 0.82s ease-out both;
}

.bottle.invalid-pour .bottle-shell {
    animation: invalidBottleShake 0.42s ease both;
}

.bottle.invalid-pour .bottle-glass {
    filter: drop-shadow(0 0 18px rgba(255, 94, 168, 0.7));
}

.bottle.pour-source-real {
    opacity: 0.28;
}

.bottle.pour-target .bottle-shell {
    animation: bottleReceiveSettle 0.76s ease-in-out both;
}

.pour-ghost {
    --ghost-left: 0px;
    --ghost-top: 0px;
    --ghost-width: 80px;
    --ghost-height: 180px;
    --ghost-travel-x: 0px;
    --ghost-lift-y: -44px;
    --ghost-tilt: 18deg;
    height: var(--ghost-height);
    left: var(--ghost-left);
    pointer-events: none;
    position: absolute;
    top: var(--ghost-top);
    transform-origin: 50% 12%;
    width: var(--ghost-width);
    z-index: 5;
    animation: ghostBottlePour 0.76s cubic-bezier(0.19, 1, 0.22, 1) both;
}

.pour-ghost .bottle-shell {
    filter: drop-shadow(0 18px 22px rgba(2, 6, 23, 0.48)) drop-shadow(0 0 16px rgba(67, 232, 255, 0.2));
}

.pour-ghost.undo-ghost .bottle-shell {
    filter: drop-shadow(0 18px 22px rgba(2, 6, 23, 0.48)) drop-shadow(0 0 18px rgba(255, 209, 102, 0.28));
}

.pour-stream {
    --stream-x: 0px;
    --stream-y: 0px;
    --stream-length: 80px;
    --stream-angle: 0deg;
    border-radius: 999px;
    box-shadow: 0 0 14px currentColor, 0 0 22px rgba(255, 255, 255, 0.18);
    height: 8px;
    left: var(--stream-x);
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: var(--stream-y);
    transform: rotate(var(--stream-angle)) scaleX(0);
    transform-origin: left center;
    width: var(--stream-length);
    z-index: 4;
    animation: liquidPourStream 0.76s ease-in-out both;
}

.pour-stream.undo-stream {
    box-shadow: 0 0 14px currentColor, 0 0 24px rgba(255, 209, 102, 0.22);
}

.pour-splash {
    --splash-x: 0px;
    --splash-y: 0px;
    border: 2px solid currentColor;
    border-radius: 50%;
    box-shadow: 0 0 14px currentColor;
    height: 14px;
    left: calc(var(--splash-x) - 7px);
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: calc(var(--splash-y) - 7px);
    width: 14px;
    z-index: 4;
    animation: liquidPourSplash 0.76s ease-out both;
}

.pour-splash.undo-splash {
    border-color: var(--amber);
    box-shadow: 0 0 16px rgba(255, 209, 102, 0.58);
}

.pour-stream.color-pink { color: #ff5ea8; background: linear-gradient(90deg, transparent, #ff8dcc, #ff3f9d); }
.pour-stream.color-cyan { color: #43e8ff; background: linear-gradient(90deg, transparent, #98f6ff, #22cce6); }
.pour-stream.color-amber { color: #ffd166; background: linear-gradient(90deg, transparent, #ffe49a, #ffb832); }
.pour-stream.color-green { color: #52ffa8; background: linear-gradient(90deg, transparent, #9dffc8, #22d978); }
.pour-stream.color-violet { color: #9b72ff; background: linear-gradient(90deg, transparent, #c4afff, #7b55ff); }
.pour-stream.color-red { color: #ff4d5c; background: linear-gradient(90deg, transparent, #ff9a9a, #ff4d5c); }
.pour-stream.color-blue { color: #367bff; background: linear-gradient(90deg, transparent, #91c5ff, #367bff); }
.pour-stream.color-lime { color: #a7e629; background: linear-gradient(90deg, transparent, #e0ff8a, #a7e629); }
.pour-stream.color-orange { color: #ff8428; background: linear-gradient(90deg, transparent, #ffc68a, #ff8428); }

.pour-splash.color-pink { color: #ff5ea8; }
.pour-splash.color-cyan { color: #43e8ff; }
.pour-splash.color-amber { color: #ffd166; }
.pour-splash.color-green { color: #52ffa8; }
.pour-splash.color-violet { color: #9b72ff; }
.pour-splash.color-red { color: #ff4d5c; }
.pour-splash.color-blue { color: #367bff; }
.pour-splash.color-lime { color: #a7e629; }
.pour-splash.color-orange { color: #ff8428; }

.side-panel {
    align-content: start;
    display: grid;
    gap: 0;
    grid-auto-rows: max-content;
    min-width: 0;
}

.run-stat {
    min-height: 68px;
}

.run-stat + .run-stat {
    border-left: 0;
    border-top: 1px solid rgba(67, 232, 255, 0.18);
}

.countdown-overlay {
    align-items: center;
    background: radial-gradient(circle at center, rgba(67, 232, 255, 0.2), transparent 42%), rgba(4, 12, 20, 0.28);
    display: flex;
    flex-direction: column;
    gap: 12px;
    inset: 0;
    justify-content: center;
    pointer-events: none;
    position: absolute;
    z-index: 9;
}

.countdown-overlay.hidden,
.pause-overlay.hidden,
.howto-overlay.hidden,
.overlay.hidden {
    display: none;
}

.countdown-ring {
    --countdown-accent: var(--cyan);
    align-items: center;
    aspect-ratio: 1;
    background: linear-gradient(#061018, #061018) padding-box, conic-gradient(from -90deg, var(--countdown-accent), var(--green), var(--amber), var(--countdown-accent)) border-box;
    border: 4px solid transparent;
    border-radius: 50%;
    box-shadow: 0 0 34px color-mix(in srgb, var(--countdown-accent) 45%, transparent), inset 0 0 24px rgba(2, 6, 23, 0.9);
    display: grid;
    justify-items: center;
    width: clamp(118px, 20vw, 178px);
}

.countdown-ring span {
    color: var(--text);
    font: 950 clamp(48px, 9vw, 86px)/1 "SFMono-Regular", Consolas, monospace;
    text-shadow: 0 0 16px var(--countdown-accent), 0 4px 0 rgba(2, 6, 23, 0.72);
}

.countdown-overlay small {
    background: rgba(4, 12, 20, 0.72);
    border: 1px solid rgba(67, 232, 255, 0.28);
    border-radius: 999px;
    color: var(--soft);
    font: 900 11px/1 "SFMono-Regular", Consolas, monospace;
    padding: 9px 13px;
    text-transform: uppercase;
}

.countdown-overlay.pulse .countdown-ring {
    animation: countdownPop 0.7s ease both;
}

.countdown-overlay.go .countdown-ring {
    --countdown-accent: var(--green);
}

.side-controls {
    align-items: stretch;
    background:
        linear-gradient(180deg, rgba(67, 232, 255, 0.08), transparent),
        rgba(4, 12, 20, 0.78);
    border: 1px solid rgba(67, 232, 255, 0.28);
    border-radius: 9px;
    box-shadow: 0 0 20px rgba(67, 232, 255, 0.12), inset 0 0 18px rgba(2, 6, 23, 0.68);
    display: grid;
    gap: 7px;
    grid-template-columns: 1fr;
    margin: 10px;
    padding: 8px;
}

.side-controls button {
    min-height: 34px;
    padding: 9px 10px;
    width: 100%;
}

.side-controls button:active {
    transform: translateY(1px);
}

.overlay {
    align-items: center;
    background: radial-gradient(circle at 30% 28%, rgba(67, 232, 255, 0.18), transparent 30%), radial-gradient(circle at 72% 64%, rgba(82, 255, 168, 0.16), transparent 28%), linear-gradient(135deg, rgba(4, 12, 20, 0.92), rgba(4, 12, 20, 0.64));
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: absolute;
    z-index: 10;
}

.pause-overlay {
    align-items: center;
    background: radial-gradient(circle at 50% 42%, rgba(67, 232, 255, 0.18), transparent 34%), rgba(4, 12, 20, 0.62);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: absolute;
    z-index: 11;
}

.pause-card {
    background: linear-gradient(135deg, rgba(10, 23, 34, 0.96), rgba(4, 12, 20, 0.9));
    border: 1px solid rgba(67, 232, 255, 0.42);
    border-radius: 10px;
    box-shadow: 0 0 34px rgba(67, 232, 255, 0.24), inset 0 0 28px rgba(2, 6, 23, 0.68);
    max-width: min(420px, calc(100dvw - 36px));
    padding: clamp(18px, 4vw, 28px);
    text-align: center;
}

.pause-card span {
    color: var(--green);
    display: block;
    font: 900 11px/1 "SFMono-Regular", Consolas, monospace;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.pause-card h2 {
    color: var(--cyan);
    font-size: clamp(34px, 7vw, 58px);
    line-height: 1;
    margin: 0 0 10px;
    text-transform: uppercase;
}

.pause-card p {
    color: var(--soft);
    line-height: 1.5;
    margin: 0 auto 18px;
    max-width: 320px;
}

.pause-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pause-actions button {
    background: rgba(4, 12, 20, 0.78);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--cyan);
    cursor: pointer;
    font: 800 12px/1 Inter, "Segoe UI", system-ui, sans-serif;
    min-height: 42px;
    padding: 10px 12px;
    text-transform: uppercase;
}

.pause-actions button:first-child {
    background: linear-gradient(135deg, rgba(82, 255, 168, 0.22), rgba(4, 12, 20, 0.88));
    border-color: rgba(82, 255, 168, 0.46);
    color: var(--green);
}

.pause-actions button:hover,
.pause-actions button:focus-visible {
    box-shadow: 0 0 16px var(--shadow);
    outline: 1px solid var(--cyan);
}

.overlay-card {
    align-items: center;
    background: linear-gradient(135deg, rgba(10, 23, 34, 0.96), rgba(4, 12, 20, 0.88)), radial-gradient(circle at 14% 16%, rgba(67, 232, 255, 0.15), transparent 34%);
    border: 1px solid rgba(67, 232, 255, 0.38);
    border-radius: 10px;
    box-shadow: 0 0 34px rgba(67, 232, 255, 0.2), inset 0 0 28px rgba(2, 6, 23, 0.62);
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(160px, 0.55fr) minmax(300px, 1fr);
    max-height: calc(100dvh - 150px);
    max-width: 820px;
    overflow: hidden;
    padding: 22px;
    position: relative;
    width: min(92vw, 820px);
}

.overlay-preview {
    display: block;
    filter: drop-shadow(0 0 24px rgba(67, 232, 255, 0.28));
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.overlay-visual {
    aspect-ratio: 1;
    min-width: 0;
}

.overlay-content {
    min-width: 0;
}

.overlay-mode {
    color: var(--green);
    display: block;
    font: 900 11px/1.2 "SFMono-Regular", Consolas, monospace;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.overlay-card h2 {
    color: var(--cyan);
    font-size: clamp(30px, 5vw, 52px);
    line-height: 1.05;
    margin: 0 0 10px;
    text-transform: uppercase;
}

.overlay-card p {
    color: var(--soft);
    line-height: 1.55;
    margin: 0 0 18px;
    max-width: 470px;
}

.overlay-stats,
.difficulty-select {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 0 14px;
}

.overlay-stats div,
.difficulty-select span {
    background: rgba(4, 12, 20, 0.62);
    border: 1px solid rgba(67, 232, 255, 0.24);
    border-radius: 7px;
    padding: 10px;
}

.overlay-stats span,
.difficulty-select legend {
    color: var(--muted);
    display: block;
    font: 900 10px/1 "SFMono-Regular", Consolas, monospace;
    text-transform: uppercase;
}

.overlay-stats strong {
    color: var(--amber);
    display: block;
    font: 900 18px/1.1 "SFMono-Regular", Consolas, monospace;
    margin-top: 6px;
}

.completion-summary {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 0 14px;
}

.completion-summary.hidden {
    display: none;
}

.completion-summary div {
    background:
        linear-gradient(180deg, rgba(67, 232, 255, 0.08), transparent),
        rgba(4, 12, 20, 0.64);
    border: 1px solid rgba(67, 232, 255, 0.24);
    border-radius: 7px;
    padding: 9px 10px;
}

.completion-summary span {
    color: var(--muted);
    display: block;
    font: 900 9px/1 "SFMono-Regular", Consolas, monospace;
    text-transform: uppercase;
}

.completion-summary strong {
    color: var(--cyan);
    display: block;
    font: 900 16px/1.1 "SFMono-Regular", Consolas, monospace;
    margin-top: 6px;
    text-transform: uppercase;
}

.completion-summary div:nth-child(6) strong,
.completion-summary div:nth-child(7) strong,
.completion-summary div:nth-child(10) strong {
    color: var(--green);
    text-shadow: 0 0 12px rgba(82, 255, 168, 0.26);
}

.completion-summary div:nth-child(6) strong {
    color: var(--cyan);
    letter-spacing: 1px;
}

.difficulty-select {
    border: 0;
    padding: 0;
}

.difficulty-select legend {
    margin-bottom: 8px;
}

.difficulty-select label {
    cursor: pointer;
}

.difficulty-select input {
    inline-size: 1px;
    opacity: 0;
    position: absolute;
}

.difficulty-select input:checked + span {
    background: linear-gradient(135deg, rgba(82, 255, 168, 0.2), rgba(4, 12, 20, 0.88));
    border-color: rgba(82, 255, 168, 0.56);
    box-shadow: 0 0 18px rgba(82, 255, 168, 0.18);
}

.difficulty-select strong {
    color: var(--text);
    font-size: 13px;
}

.difficulty-select small {
    color: var(--muted);
    font: 800 10px/1.2 "SFMono-Regular", Consolas, monospace;
}

.challenge-toggle {
    cursor: pointer;
    display: block;
    margin: 0 0 14px;
}

.challenge-toggle input {
    inline-size: 1px;
    opacity: 0;
    position: absolute;
}

.challenge-toggle span {
    align-items: center;
    background: rgba(4, 12, 20, 0.62);
    border: 1px solid rgba(67, 232, 255, 0.24);
    border-radius: 7px;
    display: grid;
    gap: 3px;
    min-height: 48px;
    padding: 10px 12px 10px 48px;
    position: relative;
}

.challenge-toggle span::before {
    background: rgba(4, 12, 20, 0.86);
    border: 1px solid rgba(67, 232, 255, 0.36);
    border-radius: 50%;
    content: "";
    height: 24px;
    left: 13px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
}

.challenge-toggle span::after {
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(82, 255, 168, 0.46);
    content: "";
    height: 10px;
    left: 20px;
    opacity: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%) scale(0.4);
    transition: opacity 160ms ease, transform 160ms ease;
    width: 10px;
}

.challenge-toggle input:checked + span {
    background: linear-gradient(135deg, rgba(82, 255, 168, 0.16), rgba(4, 12, 20, 0.84));
    border-color: rgba(82, 255, 168, 0.48);
}

.challenge-toggle input:checked + span::after {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

.challenge-toggle strong {
    color: var(--text);
    font-size: 13px;
    text-transform: uppercase;
}

.challenge-toggle small {
    color: var(--muted);
    font: 800 10px/1.2 "SFMono-Regular", Consolas, monospace;
}

.overlay-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(150px, 1.25fr) minmax(120px, 0.85fr);
    margin: 0;
}

.overlay-card button.start-button {
    background: linear-gradient(135deg, rgba(82, 255, 168, 0.28), rgba(67, 232, 255, 0.12)), rgba(4, 12, 20, 0.88);
    border-color: rgba(82, 255, 168, 0.54);
    color: var(--green);
    min-height: 44px;
}

.overlay-card button.howto-button {
    background: linear-gradient(135deg, rgba(67, 232, 255, 0.16), rgba(4, 12, 20, 0.88));
    border-color: rgba(67, 232, 255, 0.38);
    color: var(--cyan);
}

.overlay-card button {
    background: linear-gradient(135deg, rgba(82, 255, 168, 0.22), rgba(4, 12, 20, 0.88));
    border-color: rgba(82, 255, 168, 0.42);
    min-width: 132px;
}

.howto-overlay {
    align-items: center;
    background:
        radial-gradient(circle at 26% 22%, rgba(67, 232, 255, 0.22), transparent 30%),
        radial-gradient(circle at 76% 70%, rgba(82, 255, 168, 0.14), transparent 30%),
        rgba(2, 6, 12, 0.76);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: absolute;
    z-index: 12;
}

.howto-card {
    background:
        linear-gradient(135deg, rgba(10, 23, 34, 0.98), rgba(4, 12, 20, 0.92)),
        radial-gradient(circle at 18% 12%, rgba(67, 232, 255, 0.18), transparent 32%);
    border: 1px solid rgba(67, 232, 255, 0.42);
    border-radius: 10px;
    box-shadow: 0 0 38px rgba(67, 232, 255, 0.22), inset 0 0 30px rgba(2, 6, 23, 0.7);
    display: grid;
    gap: 16px;
    max-height: calc(100dvh - 96px);
    max-width: 760px;
    overflow: hidden;
    padding: clamp(18px, 3vw, 26px);
    position: relative;
    width: min(92vw, 760px);
}

.howto-close {
    background: rgba(4, 12, 20, 0.74);
    border: 1px solid rgba(67, 232, 255, 0.32);
    border-radius: 7px;
    color: var(--cyan);
    cursor: pointer;
    font: 900 10px/1 "SFMono-Regular", Consolas, monospace;
    padding: 9px 11px;
    position: absolute;
    right: 16px;
    text-transform: uppercase;
    top: 16px;
}

.howto-header span {
    color: var(--green);
    display: block;
    font: 900 11px/1 "SFMono-Regular", Consolas, monospace;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.howto-header h2 {
    color: var(--cyan);
    font-size: clamp(30px, 5vw, 50px);
    line-height: 1;
    margin: 0;
    text-transform: uppercase;
}

.howto-slider {
    min-height: 330px;
    position: relative;
}

.howto-slide {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(240px, 0.9fr) minmax(220px, 1fr);
    inset: 0;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    transform: translateX(18px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.howto-slide.active {
    opacity: 1;
    pointer-events: auto;
    position: relative;
    transform: translateX(0);
}

.howto-visual {
    align-items: end;
    background:
        linear-gradient(rgba(67, 232, 255, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(82, 255, 168, 0.07) 1px, transparent 1px),
        rgba(4, 12, 20, 0.72);
    background-size: 28px 28px;
    border: 1px solid rgba(67, 232, 255, 0.28);
    border-radius: 9px;
    box-shadow: inset 0 0 22px rgba(2, 6, 23, 0.72);
    display: flex;
    gap: 26px;
    justify-content: center;
    min-height: 250px;
    overflow: hidden;
    padding: 28px 18px;
    position: relative;
}

.demo-bottle {
    align-items: stretch;
    background: linear-gradient(180deg, rgba(243, 251, 255, 0.18), rgba(243, 251, 255, 0.04));
    border: 2px solid rgba(201, 233, 244, 0.48);
    border-radius: 14px 14px 22px 22px;
    box-shadow: inset 0 0 18px rgba(243, 251, 255, 0.12), 0 0 18px rgba(67, 232, 255, 0.14);
    display: flex;
    flex-direction: column-reverse;
    height: 170px;
    overflow: hidden;
    padding: 12px 10px 16px;
    position: relative;
    width: 64px;
}

.demo-bottle::before {
    background: rgba(243, 251, 255, 0.18);
    border: 2px solid rgba(201, 233, 244, 0.48);
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    content: "";
    height: 22px;
    left: 18px;
    position: absolute;
    top: -20px;
    width: 28px;
}

.demo-bottle i {
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    display: block;
    flex: 1;
}

.demo-source i { background: linear-gradient(180deg, #98f6ff, #22cce6); }
.demo-source i:nth-child(3),
.demo-source i:nth-child(4) { background: linear-gradient(180deg, #ff8dcc, #ff3f9d); }
.demo-target i,
.demo-target.same i { background: linear-gradient(180deg, #98f6ff, #22cce6); }

.select-demo .demo-source {
    animation: howtoLift 1.4s ease-in-out infinite;
}

.demo-cursor {
    align-self: center;
    border: 2px solid rgba(67, 232, 255, 0.74);
    border-radius: 999px;
    box-shadow: 0 0 18px rgba(67, 232, 255, 0.34);
    height: 32px;
    width: 32px;
    animation: howtoCursor 1.4s ease-in-out infinite;
}

.pour-demo .demo-source {
    animation: howtoTilt 1.8s ease-in-out infinite;
}

.demo-flow {
    align-self: center;
    background: linear-gradient(90deg, transparent, #98f6ff, #22cce6);
    border-radius: 999px;
    box-shadow: 0 0 16px rgba(67, 232, 255, 0.48);
    height: 8px;
    margin-bottom: 78px;
    width: 84px;
    transform-origin: left center;
    animation: howtoFlow 1.8s ease-in-out infinite;
}

.solve-demo {
    align-items: center;
}

.solve-demo .demo-bottle {
    box-shadow: inset 0 0 18px rgba(243, 251, 255, 0.12), 0 0 24px rgba(82, 255, 168, 0.24);
}

.solve-demo .demo-bottle i {
    background: linear-gradient(180deg, #9dffc8, #22d978);
}

.demo-seal {
    align-items: center;
    background: rgba(4, 12, 20, 0.86);
    border: 1px solid rgba(82, 255, 168, 0.72);
    border-radius: 50%;
    color: var(--green);
    display: flex;
    font: 950 12px/1 "SFMono-Regular", Consolas, monospace;
    height: 42px;
    justify-content: center;
    margin-bottom: 84px;
    width: 42px;
    animation: howtoSeal 1.6s ease-in-out infinite;
}

.demo-bonus {
    color: var(--green);
    font: 950 24px/1 "SFMono-Regular", Consolas, monospace;
    margin-bottom: 98px;
    text-shadow: 0 0 16px rgba(82, 255, 168, 0.48);
}

.howto-copy {
    align-self: center;
}

.howto-copy strong {
    color: var(--text);
    display: block;
    font-size: clamp(22px, 3.5vw, 34px);
    line-height: 1.05;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.howto-copy p {
    color: var(--soft);
    font-size: 15px;
    line-height: 1.55;
    margin: 0;
}

.howto-nav {
    align-items: center;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(88px, auto) 1fr minmax(88px, auto);
}

.howto-nav button {
    background: rgba(4, 12, 20, 0.74);
    border: 1px solid rgba(67, 232, 255, 0.32);
    border-radius: 7px;
    color: var(--cyan);
    cursor: pointer;
    font: 900 11px/1 "SFMono-Regular", Consolas, monospace;
    min-height: 40px;
    padding: 10px 12px;
    text-transform: uppercase;
}

.howto-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.howto-dots span {
    background: rgba(143, 178, 191, 0.42);
    border-radius: 999px;
    height: 7px;
    width: 22px;
}

.howto-dots span.active {
    background: var(--green);
    box-shadow: 0 0 12px rgba(82, 255, 168, 0.45);
}

@keyframes countdownPop {
    0% { opacity: 0; transform: scale(0.72) rotate(-5deg); }
    55% { opacity: 1; transform: scale(1.08) rotate(2deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes labLightPulse {
    0%, 100% { opacity: 0.18; transform: scale(0.98); }
    50% { opacity: 0.58; transform: scale(1); }
}

@keyframes bottleStartShimmer {
    0%, 100% { transform: translateY(0); }
    45%, 55% { transform: translateY(-3px); }
}

@keyframes selectedBottleReady {
    0%, 100% { transform: translateY(-12px) rotate(-1.5deg) scale(1.015); }
    50% { transform: translateY(-16px) rotate(1.5deg) scale(1.025); }
}

@keyframes hintBottlePulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.025); }
}

@keyframes liquidStartBubble {
    0% { opacity: 0; transform: translateY(8px) scale(0.72); }
    42% { opacity: 0.72; }
    100% { opacity: 0; transform: translateY(-14px) scale(1.08); }
}

@keyframes liquidIdleShift {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.08); }
}

@keyframes liquidIdleBubble {
    0%, 100% { transform: translateY(8px) scale(0.75); }
    45% { transform: translateY(-8px) scale(1); }
}

@keyframes ghostBottlePour {
    0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
    10% { opacity: 1; transform: translate3d(0, -12px, 0) rotate(0deg) scale(1.015); }
    40% { opacity: 1; transform: translate3d(calc(var(--ghost-travel-x) * 0.76), var(--ghost-lift-y), 0) rotate(0deg) scale(1.02); }
    58% { opacity: 1; transform: translate3d(calc(var(--ghost-travel-x) * 0.86), var(--ghost-lift-y), 0) rotate(var(--ghost-tilt)) scale(1.02); }
    78% { opacity: 1; transform: translate3d(calc(var(--ghost-travel-x) * 0.86), var(--ghost-lift-y), 0) rotate(var(--ghost-tilt)) scale(1.02); }
    100% { opacity: 0; transform: translate3d(var(--ghost-travel-x), var(--ghost-travel-y), 0) rotate(0deg) scale(1); }
}

@keyframes bottleReceiveSettle {
    0% { transform: translateY(0) scale(1); }
    58% { transform: translateY(3px) scale(1.025); }
    76% { transform: translateY(-2px) scale(0.995); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes invalidBottleShake {
    0%, 100% { transform: translateX(0); }
    18% { transform: translateX(-6px) rotate(-1deg); }
    36% { transform: translateX(6px) rotate(1deg); }
    54% { transform: translateX(-4px) rotate(-0.8deg); }
    72% { transform: translateX(4px) rotate(0.8deg); }
}

@keyframes bottleLockIn {
    0% { transform: translateY(-8px) scale(1.02); }
    42% { transform: translateY(3px) scale(0.985); }
    68% { transform: translateY(-2px) scale(1.012); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes solvedCheckPop {
    0% { opacity: 0; transform: scale(0.45) rotate(-18deg); }
    44% { opacity: 1; transform: scale(1.18) rotate(4deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes solvedGlowPulse {
    0% { opacity: 0; transform: scale(0.92); }
    42% { opacity: 1; transform: scale(1.03); }
    100% { opacity: 0; transform: scale(1.12); }
}

@keyframes liquidPourStream {
    0%, 48% { opacity: 0; transform: rotate(var(--stream-angle)) scaleX(0); }
    58% { opacity: 0.92; transform: rotate(var(--stream-angle)) scaleX(0.35); }
    76% { opacity: 1; transform: rotate(var(--stream-angle)) scaleX(1); }
    100% { opacity: 0; transform: rotate(var(--stream-angle)) scaleX(0.78); }
}

@keyframes liquidPourSplash {
    0%, 58% { opacity: 0; transform: scale(0.4); }
    74% { opacity: 0.9; transform: scale(1); }
    100% { opacity: 0; transform: scale(2.1); }
}

@keyframes howtoLift {
    0%, 100% { transform: translateY(0); }
    45%, 55% { transform: translateY(-18px); }
}

@keyframes howtoCursor {
    0%, 100% { opacity: 0.35; transform: scale(0.86); }
    45%, 55% { opacity: 1; transform: scale(1.08); }
}

@keyframes howtoTilt {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    48%, 70% { transform: translateY(-24px) rotate(16deg); }
}

@keyframes howtoFlow {
    0%, 42% { opacity: 0; transform: scaleX(0); }
    58%, 82% { opacity: 1; transform: scaleX(1); }
    100% { opacity: 0; transform: scaleX(0.75); }
}

@keyframes howtoSeal {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(1.12); }
}

@keyframes labParticleDrift {
    0% { background-position: 0 0, 0 0, 0 0; }
    100% { background-position: 180px 160px, -220px 190px, 150px -130px; }
}

@keyframes labScanSweep {
    0%, 34% { transform: translateY(-100%); opacity: 0; }
    48% { opacity: 0.42; }
    66%, 100% { transform: translateY(100%); opacity: 0; }
}

/* The field owns local scrolling; its measured box owns bottle geometry. */
.play-layout { min-height: 0; grid-template-columns: minmax(0, 1fr) 150px; grid-template-rows: minmax(0, 1fr); }
.side-panel { min-height: 0; }
.run-stat { min-height: 54px; padding: 7px 9px; }
.side-controls { margin: 6px; padding: 6px; }
.board-column { min-width: 0; }
.board-stage { display: block; overflow: auto; overscroll-behavior: contain; }
.board { min-height: 100%; height: max-content; gap: 6px; padding: 20px 12px 12px; grid-template-columns: repeat(var(--cols), var(--bottle-width, 44px)); }
.bottle:not(.pour-ghost) { width: var(--bottle-width, 44px); height: var(--bottle-height, 96px); min-width: 44px; }
.bottle.solved::before { width: min(100%, 64px); font-size: 10px; }
.board-hud { min-width: 0; gap: 6px; }
.board-hud span { min-width: 0; line-height: 1.3; padding: 6px 8px; overflow-wrap: anywhere; }
.board-hud button { flex-shrink: 0; }
.back-link, button:not(.bottle) { min-height: 44px; min-width: 44px; line-height: 1.25; touch-action: manipulation; }
.back-link { display: inline-flex; align-items: center; justify-content: center; text-align: center; }
:is(a, button):focus-visible, .play-layout:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }
.bottle.keyboard-focus { box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.45); border-radius: 6px; }
.side-controls button { padding: 8px 4px; }

/* Content scrolls independently of each modal's persistent action row. */
.overlay, .pause-overlay, .howto-overlay { padding: 12px; }
.overlay-card { grid-template-columns: minmax(0, 0.55fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) max-content; max-height: 100%; width: min(100%, 820px); gap: 14px; }
.overlay-content, .pause-content, .howto-content { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 4px; align-self: stretch; }
.overlay-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.overlay-actions > * { flex: 1 1 110px; min-width: 0; min-height: 44px; padding: 10px 6px; white-space: normal; overflow-wrap: anywhere; text-align: center; }
.overlay-actions button { min-width: 0; align-self: start; height: auto; }
.difficulty-select { min-inline-size: 0; }
.difficulty-select label, .challenge-toggle { position: relative; min-width: 0; }
.difficulty-select input, .challenge-toggle input { inset: 0; width: 100%; height: 100%; margin: 0; z-index: 1; cursor: pointer; }
.difficulty-select span { display: grid; gap: 4px; min-height: 54px; padding: 8px; }
.difficulty-select input:focus-visible + span, .challenge-toggle input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: -2px; }
.difficulty-select small, .overlay-stats strong, .completion-summary strong { overflow-wrap: anywhere; }
.overlay-end :is(.difficulty-select, .challenge-toggle, .overlay-stats) { display: none; }
.pause-card { display: grid; grid-template-rows: minmax(0, 1fr) max-content; gap: 12px; width: min(100%, 420px); max-height: 100%; padding: 16px; }
.pause-actions { display: flex; }
.pause-actions > * { flex: 1; min-width: 0; height: auto; align-self: start; }
.howto-card { grid-template-rows: minmax(0, 1fr) max-content; max-height: 100%; width: min(100%, 760px); padding: 16px; }
.howto-slider { min-height: 0; }
.howto-slide { display: none; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr); }
.howto-slide.active { display: grid; }
.howto-header { margin-bottom: 12px; }
.keyboard-help { color: var(--soft); font-size: 13px; line-height: 1.5; }
.howto-close { position: static; order: 0; }
.howto-nav { display: flex; gap: 8px; }
.howto-nav > * { flex: 1; min-width: 0; height: auto; align-self: start; }
.motion-suspended .arena-wrap::before, .motion-suspended .arena-wrap::after,
.motion-suspended .play-layout *, .motion-suspended .play-layout *::before, .motion-suspended .play-layout *::after { animation-play-state: paused !important; }

@media (max-width: 780px), (max-height: 600px) {
    .game-topbar { gap: 4px 8px; grid-template-columns: auto minmax(0, 1fr); padding: 4px 8px; }
    .game-title h1 { font-size: 18px; }
    .game-title p, .game-title::before, .game-title::after { display: none; }
    .scoreboard { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .scoreboard .hud-cell { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding: 4px 8px; }
    .scoreboard strong, .scoreboard .hud-cell-primary strong { font-size: 17px; margin: 0; }
    .scoreboard .hud-cell-primary::after { display: none; }
    .arena-wrap { padding: 6px; }
    .play-layout, .board-column { gap: 6px; }
    .overlay, .pause-overlay, .howto-overlay { position: fixed; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
    .overlay-card { grid-template-columns: minmax(0, 1fr); padding: 12px; max-width: 560px; }
    .overlay-visual { display: none; }
    .overlay-card h2, .howto-header h2 { font-size: 28px; }
    .overlay-card p { font-size: 14px; }
    .overlay-stats strong { font-size: 16px; }
    .completion-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) and (orientation: portrait) {
    .play-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
    .side-panel { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .run-stat { min-height: 0; padding: 6px; }
    .run-stat + .run-stat { border-left: 1px solid rgba(67, 232, 255, 0.18); border-top: 0; }
    .run-stat strong { font-size: 17px; }
    .side-controls { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 5px; gap: 5px; }
    .side-controls button { font-size: 11px; padding: 8px 2px; }
}

@media (max-height: 600px) and (orientation: landscape) {
    .game-topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
    .scoreboard { grid-column: auto; }
    .scoreboard .hud-cell { display: block; padding: 4px; }
    .scoreboard strong { margin-top: 3px; }
    .back-link { padding: 8px; }
    .play-layout { grid-template-columns: minmax(0, 1fr) 112px; }
    .side-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: start; }
    .run-stat { min-height: 0; padding: 6px; }
    .run-stat strong { font-size: 16px; }
    .side-controls { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; padding: 4px; gap: 4px; }
    .side-controls button { font-size: 10px; padding: 6px 2px; }
    .howto-visual { min-height: 180px; padding: 20px 8px; gap: 10px; }
    .demo-bottle { height: 128px; width: 50px; flex-shrink: 0; }
    .demo-flow { width: 44px; }
}

@media (max-width: 480px) {
    .howto-slide { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .howto-visual { min-height: 180px; padding: 20px 8px; gap: 14px; }
    .demo-bottle { height: 128px; width: 50px; }
    .demo-flow { width: 44px; }
    .game-topbar { grid-template-columns: auto minmax(0, 1fr); }
    .scoreboard { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
.puzzle-identity { overflow-wrap: anywhere; font-size: 11px; }
.pause-actions { flex-wrap: wrap; }
.pause-actions > * { flex-basis: 100px; }
