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

html[data-theme="dark"] {
    --bg: #151715;
    --panel: #1a1d1a;
    --ink: #eeeeea;
    --muted: #a7ada7;
    --line: #454a45;
    --soft: #252925;
    --accent: #8fc5cd;
    --focus: #4b777d;
    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,
.stats,
.memory,
.answer,
.choices,
.compare {
    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;
}

.notice {
    min-height: 18px;
    margin: 11px 2px 0;
    color: var(--muted);
    font-size: 12px;
}

.notice.error {
    color: #a13a33;
}

.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;
}

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

.progress {
    height: 5px;
    border: 1px solid var(--line);
    margin: -7px 0 14px;
}

.progress span {
    display: block;
    height: 100%;
    width: 100%;
    background: var(--accent);
    transform-origin: left center;
}

.lead {
    color: var(--muted);
    line-height: 1.5;
}

.memory {
    overflow: hidden;
}

.entry {
    min-height: 48px;
    padding: 9px 13px;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    gap: 8px;
}

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

.entry span:first-child {
    color: var(--muted);
    font: 12px "IBM Plex Mono", monospace;
}

.entry strong {
    letter-spacing: .04em;
    text-transform: uppercase;
}

.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;
}

.answer {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-bottom: 10px;
    background: var(--line);
}

.slot {
    min-height: 58px;
    padding: 8px 9px;
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;
    gap: 5px;
    min-width: 0;
    background: var(--panel);
}

.slot span:first-child {
    color: var(--muted);
    font: 10px "IBM Plex Mono", monospace;
}

.slot strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 12px;
}

.slot.empty strong {
    color: var(--muted);
    font-weight: normal;
}

.choices {
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.word {
    width: 100%;
    min-width: 0;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 12px;
}

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

.compare {
    margin-bottom: 10px;
}

.caption {
    padding: 11px 13px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font: 11px "IBM Plex Mono", monospace;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.row {
    padding: 12px 13px;
    border-bottom: 1px solid var(--line);
}

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

.row>b {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
}

.sequence {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
}

.token {
    min-height: 38px;
    padding: 5px 7px;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.token.correct {
    border-color: var(--accent);
}

.token i {
    flex: 0 0 auto;
    color: var(--muted);
}

.token.correct i {
    color: var(--accent);
}

.token span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 11px;
}

.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 ol {
    margin: 0;
    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;
    }

    .answer,
    .choices,
    .sequence {
        grid-template-columns: repeat(3, minmax(0, 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);
    }

    .answer,
    .choices,
    .sequence {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }


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

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

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

    button {
        transition: none;
    }
}