:root {
    --bg: #f4f4f1;
    --panel: #f8f8f5;
    --ink: #171917;
    --muted: #686d68;
    --line: #b9bdb7;
    --soft: #e6e7e2;
    --accent: #65458f;
    --focus: #b7a0d3;
    --h: 40px;
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #151715;
    --panel: #1a1d1a;
    --ink: #eeeeea;
    --muted: #a7ada7;
    --line: #454a45;
    --soft: #252925;
    --accent: #c0a0e6;
    --focus: #70538f;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    overflow-x: hidden;
}

button,
select {
    font: inherit;
}

button,
select {
    min-height: var(--h);
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--bg);
    color: var(--ink);
}

button {
    cursor: pointer;
    transition: border-color .12s, background .12s, transform .05s;
}

select {
    min-width: 150px;
    cursor: pointer;
}

button:hover:not(:disabled) {
    border-color: var(--ink);
    background: var(--soft);
}

button:active:not(:disabled) {
    transform: translateY(1px);
}

button:focus-visible,
select:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

button:disabled {
    color: var(--muted);
    border-color: var(--soft);
    cursor: not-allowed;
    opacity: .48;
}

button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--bg);
}

button.primary:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--ink);
}

.bar {
    height: 58px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 0;
    padding: 0;
    min-height: 36px;
    font-weight: 700;
    letter-spacing: .08em;
    background: transparent;
}

.brand:hover:not(:disabled) {
    background: transparent;
}

.brand img {
    width: 25px;
    height: 25px;
}

.tools {
    display: flex;
    gap: 7px;
}

.tool {
    min-width: 70px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
}

.tool i {
    font-size: 17px;
}

.shell {
    width: min(820px, calc(100% - 28px));
    margin: 0 auto;
    padding: 38px 0 54px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: show .12s ease-out;
}

@keyframes show {
    from {
        opacity: .25;
    }

    to {
        opacity: 1;
    }
}

.hero {
    width: min(360px, 100%);
    margin: 10vh auto 0;
    text-align: center;
}

.mark {
    width: 62px;
    height: 62px;
    margin-bottom: 16px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 31px;
    letter-spacing: .12em;
}

h1 span {
    color: var(--accent);
}

h2 {
    margin-bottom: 0;
    font-size: 22px;
    letter-spacing: -.01em;
}

.hero p {
    color: var(--muted);
    line-height: 1.55;
    margin: 0 auto 25px;
    white-space: nowrap;
}

.stack {
    display: grid;
    gap: 8px;
}

.stack button {
    width: 100%;
}

.head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow {
    margin-bottom: 5px;
    color: var(--muted);
    font: 11px/1.2 "IBM Plex Mono", monospace;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.icon {
    width: var(--h);
    min-width: var(--h);
    padding: 0;
    font-size: 18px;
}

.panel,
.results,
.help,
.board,
.stats {
    border: 1px solid var(--line);
    background: var(--panel);
}

.cat,
.setting {
    min-height: 58px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.cat:last-child,
.setting:last-child {
    border-bottom: 0;
}

.cat>span {
    font-weight: 600;
}

.stepper {
    display: grid;
    grid-template-columns: 38px 34px 38px;
    align-items: center;
}

.stepper button {
    min-width: 38px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 18px;
}

.stepper b {
    text-align: center;
    font: 13px "IBM Plex Mono", monospace;
}

.sum {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 2px 0;
    color: var(--muted);
}

.sum strong {
    color: var(--ink);
    font: 13px "IBM Plex Mono", monospace;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 18px;
}

.settings .setting>span:first-child {
    display: grid;
    gap: 4px;
}

.setting small {
    color: var(--muted);
    font-weight: normal;
    line-height: 1.35;
}

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 10px;
}

.stat {
    min-height: 58px;
    padding: 10px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.stat:first-child {
    border-right: 1px solid var(--line);
}

.stat span {
    color: var(--muted);
    font-size: 12px;
}

.stat strong {
    font: 14px "IBM Plex Mono", monospace;
}

.board {
    min-height: 222px;
    padding: 20px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: 16px 10px;
    overflow: hidden;
}

.tube {
    width: 66px;
    height: 174px;
    min-width: 66px;
    min-height: 174px;
    padding: 5px 6px 7px;
    border: 0;
    background: transparent;
    transform: none !important;
}

button.tube:hover:not(:disabled) {
    border: 0;
    background: transparent;
}

.tube:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

.glass {
    position: relative;
    display: block;
    width: 54px;
    height: 160px;
    margin: 0 auto;
    border: 2px solid var(--line);
    border-top: 0;
    border-radius: 0 0 14px 14px;
    overflow: hidden;
    transition: border-color .12s;
}

.tube.selected .glass {
    border-color: var(--accent);
}

.tube.selected:focus-visible {
    outline-color: var(--accent);
}

.unit {
    position: absolute;
    display: block;
    background: var(--color);
}

.liquid .unit {
    left: 0;
    right: 0;
    bottom: calc(var(--slot) * 25%);
    height: 25%;
}

.liquid .unit:first-child {
    border-radius: 0 0 12px 12px;
}

.liquid .unit:last-child {
    box-shadow: inset 0 2px rgba(255, 255, 255, .14);
}

.ball .unit {
    left: 50%;
    bottom: calc(8px + var(--slot) * 36px);
    width: 34px;
    height: 34px;
    border: 1px solid rgba(0, 0, 0, .14);
    border-radius: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .62) 0 8%, var(--color) 30% 100%);
}

.gameactions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.score {
    min-height: 78px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
}

.score:last-child {
    border-bottom: 0;
}

.score b {
    display: block;
}

.score strong {
    font: 22px "IBM Plex Mono", monospace;
}

.score.config {
    min-height: 54px;
}

.score.config strong {
    font-size: 14px;
    color: var(--ink);
    text-align: right;
}

.topic {
    padding: 15px 16px;
    border-bottom: 1px solid var(--line);
}

.topic:last-child {
    border-bottom: 0;
}

.topic h3 {
    font-size: 14px;
    margin: 0 0 5px;
}

.topic p,
.topic ol {
    color: var(--muted);
    line-height: 1.5;
}

.topic p {
    margin: 0;
}

.topic p.gap {
    margin-top: 9px;
}

.topic ol {
    margin: 0 0 10px;
    padding-left: 20px;
}

.topic li+li {
    margin-top: 4px;
}

@media (max-width: 640px) {
    .bar {
        padding: 0 12px;
    }

    .shell {
        width: min(100% - 20px, 820px);
        padding-top: 26px;
    }

    .hero {
        margin-top: 7vh;
    }

    .hero p {
        white-space: normal;
    }

    .board {
        padding: 16px 10px;
        gap: 13px 7px;
    }
}

@media (max-width: 520px) {
    .gameactions {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .brand span {
        display: none;
    }

    .tool {
        min-width: 62px;
    }

    .setting {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .setting select {
        width: 100%;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .stat:first-child {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .tube {
        width: 58px;
        min-width: 58px;
        height: 164px;
        min-height: 164px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .glass {
        width: 50px;
        height: 150px;
    }

    .ball .unit {
        bottom: calc(8px + var(--slot) * 34px);
        width: 32px;
        height: 32px;
    }

    .score {
        min-height: 68px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .page.active {
        animation: none;
    }

    button,
    .glass {
        transition: none;
    }
}