/* Percentages — game-specific styles.
 * Mirrors Quick Math structure; the problem card holds a word-problem
 * question instead of a flat arithmetic expression, so the current-problem
 * row stacks the question above the answer instead of sitting on one line.
 */

.game-page {
    padding: 1.5rem 0 2rem;
    --jump-accent: var(--cat-strategy);
}

.game-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0 0.25rem;
}

.game-head h1 {
    margin: 0;
    font-family: var(--font-hand);
    font-size: 2.6rem;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.05;
}

.game-head .category {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--cat-strategy-bg);
    color: var(--cat-strategy);
}

.game-lede {
    color: var(--text-secondary);
    margin: 0 0 1.25rem;
    font-family: var(--font-hand);
    font-size: 1.25rem;
    line-height: 1.5;
}

/* Start panel */
.start-panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem 1.4rem;
    margin: 1rem 0 1.5rem;
    overflow: hidden;
}

.start-panel h2 {
    font-family: var(--font-hand);
    margin: 0 0 0.25rem;
    font-size: 1.8rem;
    color: var(--cat-strategy);
    transform: rotate(-1deg);
    display: inline-block;
}
.start-panel h2::after { display: none; }

.panel-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem 1.25rem;
    margin: 0.25rem 0 1rem;
    align-items: start;
}
.panel-col { min-width: 0; }
@media (max-width: 640px) {
    .panel-grid { grid-template-columns: 1fr; gap: 0.5rem 1rem; }
}

.start-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}
.start-footer .untimed-row { margin: 0; }

/* Circle pickers */
.circle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.3rem 0 0;
}
.circle-pick { position: relative; cursor: pointer; }
.circle-pick input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.circle-pick > span {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg);
    border: 1.5px dashed var(--border-strong);
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.05;
    color: var(--text);
    transition: all 0.18s ease;
    transform: rotate(var(--rot, 0));
    user-select: none;
    text-align: center;
    padding: 0.1rem 0.2rem;
}
.op-row .circle-pick > span { font-size: 0.95rem; }

.circle-pick:nth-child(1) > span { --rot: -5deg; }
.circle-pick:nth-child(2) > span { --rot: 4deg; }
.circle-pick:nth-child(3) > span { --rot: -3deg; }
.circle-pick:nth-child(4) > span { --rot: 6deg; }

.circle-pick-oval > span {
    width: auto;
    height: auto;
    min-width: 68px;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-family: var(--font-hand);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.circle-pick:hover > span {
    transform: rotate(0) scale(1.06);
    color: var(--cat-strategy);
    border-color: var(--cat-strategy);
}
.circle-pick input:checked + span {
    border-style: solid;
    border-color: var(--cat-strategy);
    background: var(--cat-strategy-bg);
    color: var(--cat-strategy);
    box-shadow: 0 2px 0 rgba(58, 123, 184, 0.12);
}
.circle-pick input:focus-visible + span {
    outline: 2px solid var(--cat-strategy);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .circle-pick > span { transform: none; transition: none; }
    .circle-pick:hover > span { transform: scale(1.06); }
}

/* Length circles */
.length-row .circle-pick > span { font-size: 1.2rem; }
.length-row .circle-pick > span strong {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.25rem;
    line-height: 1;
}
.length-row .circle-pick > span small {
    font-family: var(--font-sans);
    font-size: 0.54rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 0.1rem;
    opacity: 0.7;
}

/* Op circle label + icon stack */
.op-row .circle-pick > span .op-icon {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.3rem;
    line-height: 1;
    margin-bottom: 0.05rem;
}
.op-row .circle-pick > span .op-name {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.75;
    font-family: var(--font-sans);
}
.op-row .circle-pick input:checked + span .op-name { opacity: 1; }

.untimed-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0 1rem;
    font-family: var(--font-hand);
    font-size: 1.05rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1.4rem;
    font-family: var(--font-hand);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: 2px solid var(--cat-strategy);
    border-radius: 999px;
    background: var(--cat-strategy);
    color: #fff;
    cursor: pointer;
    box-shadow: 3px 4px 0 rgba(58, 123, 184, 0.28);
    transform: rotate(-0.8deg);
    transition: transform 0.18s, box-shadow 0.15s, filter 0.15s;
}
.btn-primary:hover {
    filter: brightness(0.96);
    transform: rotate(0) translate(-1px, -1px);
    box-shadow: 4px 5px 0 rgba(58, 123, 184, 0.32);
}
.btn-primary:active {
    transform: rotate(0) translate(2px, 2px);
    box-shadow: 1px 1px 0 rgba(58, 123, 184, 0.25);
}
.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 1rem;
    font-family: var(--font-hand);
    font-size: 1.15rem;
    font-weight: 600;
    border: 1.5px dashed var(--border-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transform: rotate(var(--btn-rot, 0.8deg));
    transition: transform 0.18s, border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-ghost:hover {
    transform: rotate(0) scale(1.03);
    border-style: solid;
    border-color: var(--cat-strategy);
    color: var(--cat-strategy);
    background: var(--cat-strategy-bg);
}
.btn-ghost:focus-visible { outline: 2px solid var(--cat-strategy); outline-offset: 3px; }
.btn-ghost:nth-of-type(odd)  { --btn-rot: -0.8deg; }
.btn-ghost:nth-of-type(even) { --btn-rot: 1deg; }

@media (prefers-reduced-motion: reduce) {
    .btn-primary,
    .btn-ghost { transform: none; }
}

/* Game area */
.game-area {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: transform 0.08s;
}

.play-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
@media (min-width: 720px) {
    .play-grid {
        grid-template-columns: 1fr minmax(260px, 320px);
        gap: 1.75rem;
        align-items: start;
    }
}
.play-col { min-width: 0; }
.play-col-card { display: flex; flex-direction: column; gap: 0.5rem; }
.play-col-pad  { display: flex; flex-direction: column; gap: 1rem; }

.game-area.shake { animation: shake 0.35s; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce) {
    .game-area.shake { animation: none; }
}

/* HUD */
.hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border);
    flex-wrap: wrap;
}
.hud-group {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}
.hud-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}
.hud-value {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
}
.timer-low {
    color: var(--danger);
    animation: pulse 0.8s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
    .timer-low { animation: none; }
}
.score-bump { animation: scoreBump 0.35s ease-out; }
@keyframes scoreBump {
    0%   { transform: scale(1); color: var(--cat-strategy); }
    40%  { transform: scale(1.35); color: var(--cat-strategy); }
    100% { transform: scale(1); color: var(--text); }
}
@media (prefers-reduced-motion: reduce) {
    .score-bump { animation: none; }
}
.score-pop {
    position: absolute;
    top: -0.5em;
    left: 100%;
    margin-left: 0.2em;
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--cat-strategy);
    opacity: 0;
    pointer-events: none;
}
.score-pop.pop-run { animation: popUp 0.9s ease-out forwards; }
@keyframes popUp {
    0%   { opacity: 0; transform: translateY(0); }
    25%  { opacity: 1; transform: translateY(-6px); }
    100% { opacity: 0; transform: translateY(-28px); }
}
@media (prefers-reduced-motion: reduce) {
    .score-pop.pop-run { animation: none; opacity: 0; }
}

.hud-streak .streak-value {
    color: var(--accent);
    font-family: var(--font-hand);
    font-size: 1.5rem;
    line-height: 1;
}
.hud-streak.streak-hot .streak-value {
    color: var(--cat-car);
    text-shadow: 0 0 8px rgba(212, 122, 60, 0.4);
}

.btn-end {
    margin-left: auto;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-end:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--bg-soft);
}
.btn-end:focus-visible { outline: 2px solid var(--danger); outline-offset: 2px; }

/* Problem card */
.problem-wrap {
    display: flex;
    justify-content: center;
    padding: 0.75rem 0.25rem 1.25rem;
}
.problem-card {
    --card-bg: #fdf8ea;
    --card-ink: #1f2a3a;
    --card-rule: #d7cbaa;
    --rule-gap: 2rem;
    position: relative;
    width: min(440px, 100%);
    min-height: calc(var(--rule-gap) * 9);
    max-height: calc(var(--rule-gap) * 11);
    background:
        radial-gradient(circle at 5% 0%, rgba(139, 90, 43, 0.05) 0%, transparent 38%),
        radial-gradient(circle at 95% 100%, rgba(139, 90, 43, 0.05) 0%, transparent 38%),
        radial-gradient(circle at 80% 15%, rgba(0, 0, 0, 0.025) 0%, transparent 25%),
        linear-gradient(135deg, #fdf8ea 0%, #f5ecd4 100%);
    color: var(--card-ink);
    padding: 1.2rem 1.4rem 1.2rem;
    border-radius: 4px;
    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.04),
        0 12px 28px -14px rgba(0, 0, 0, 0.3),
        inset 0 0 0 1px rgba(0, 0, 0, 0.04);
    transform: rotate(-0.6deg);
    transition: transform 0.25s;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.problem-card:hover { transform: rotate(0); }
@media (prefers-reduced-motion: reduce) {
    .problem-card { transform: none; }
    .problem-card:hover { transform: none; }
}

:root[data-theme="dark"] .problem-card {
    --card-bg: #f3ead5;
    --card-ink: #1f2a3a;
    --card-rule: #c7b890;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) .problem-card {
        --card-bg: #f3ead5;
        --card-ink: #1f2a3a;
        --card-rule: #c7b890;
    }
}

/* Tape strip along the top */
.problem-card-tape {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%) rotate(-2deg);
    width: 80px;
    height: 20px;
    background: rgba(113, 166, 208, 0.35);
    border: 1px solid rgba(113, 166, 208, 0.55);
    border-radius: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* History list */
.problem-history {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.15rem;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
    color: var(--card-ink);
    mask-image: linear-gradient(to bottom, transparent 0%, black 35%, black 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 35%, black 100%);
}
.problem-history li {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.3em;
    opacity: 0.6;
    font-family: var(--font-hand);
    font-size: 1.2rem;
    line-height: 1.5;
    animation: historyIn 0.28s ease-out;
    flex-wrap: wrap;
}
@keyframes historyIn {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 0.55; }
}
.problem-history .h-expr  { color: inherit; }
.problem-history .h-eq    { opacity: 0.7; }
.problem-history .h-ans   { font-weight: 700; }
.problem-history li.correct .h-ans { color: #2a7a52; }
.problem-history li.wrong  .h-ans { color: #b04141; text-decoration: line-through; }
.problem-history li.wrong  .h-correct { color: #2a7a52; font-size: 0.9em; margin-left: 0.15em; }
.problem-history li.skip   .h-ans { color: #7a7668; font-style: italic; }
.problem-history li .h-mark { font-size: 0.9em; margin-left: 0.15em; }
@media (prefers-reduced-motion: reduce) {
    .problem-history li { animation: none; }
}

/* Current problem — stacked question over answer row */
.problem-current {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    padding-top: 0.45rem;
    border-top: 1.5px dashed var(--card-rule);
    margin-top: auto;
    min-height: calc(var(--rule-gap) * 3);
}
.problem-label {
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--card-ink);
    opacity: 0.6;
    text-align: center;
}
.problem-question {
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 1.55rem;
    line-height: 1.25;
    color: var(--card-ink);
    text-align: center;
    padding: 0.1rem 0.25rem;
    word-break: normal;
}
.problem-answer-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
    padding-top: 0.2rem;
}
.problem-equals {
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 1.8rem;
    color: var(--card-ink);
    opacity: 0.75;
}
.dollar-prefix {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 2rem;
    color: var(--cat-strategy);
    line-height: 1;
    padding-right: 0.05em;
}
.problem-answer {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 2rem;
    color: var(--cat-strategy);
    min-width: 3ch;
    border-bottom: 2px solid var(--cat-strategy);
    padding: 0 0.25em 0.05em;
    white-space: nowrap;
    position: relative;
    line-height: 1.05;
}
.problem-answer.is-empty::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background: var(--cat-strategy);
    margin-left: 0.1em;
    animation: caretBlink 1s steps(1) infinite;
    opacity: 0.8;
    align-self: center;
}
@keyframes caretBlink {
    50% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .problem-answer.is-empty::after { animation: none; }
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.55rem;
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
}
.key {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.08s, background 0.15s, border-color 0.15s;
    font-family: inherit;
}
.key:hover { background: var(--surface); border-color: var(--cat-strategy); }
.key:active { transform: translateY(1px) scale(0.97); }
.key:focus-visible { outline: 2px solid var(--cat-strategy); outline-offset: 2px; }

.key-back { color: var(--text-muted); font-size: 1.3rem; }
.key-back:hover { color: var(--danger); border-color: var(--danger); }
.key-dot { font-size: 1.6rem; color: var(--cat-strategy); font-weight: 800; }
.key-slash { font-size: 1.8rem; color: var(--cat-strategy); font-weight: 800; }
.key-space { font-size: 1.6rem; color: var(--text-muted); font-weight: 700; }
.key-enter {
    color: #fff;
    background: var(--cat-strategy);
    border-color: var(--cat-strategy);
    font-family: var(--font-hand);
    font-size: 1.6rem;
    font-weight: 700;
}
.key-enter:hover { filter: brightness(0.92); background: var(--cat-strategy); color: #fff; }

/* Action row / feedback */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.25rem 0 0;
    justify-content: center;
}
.feedback {
    min-height: 1.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    margin: 0.25rem 0 0.5rem;
    color: transparent;
    transition: color 0.2s;
}
.feedback-right { color: var(--success); font-size: 1.4rem; }
.feedback-wrong { color: var(--danger); }
.feedback-skip  { color: var(--text-muted); }

/* Countdown */
.countdown {
    text-align: center;
    font-family: var(--font-hand);
    font-size: 4rem;
    font-weight: 600;
    color: var(--cat-strategy);
    padding: 2rem 0;
    line-height: 1;
}

/* Handle dialog */
.handle-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.handle-dialog[hidden] { display: none; }
.handle-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 380px;
    width: 100%;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.4);
}
.handle-card h3 {
    margin: 0 0 0.35rem;
    font-family: var(--font-hand);
    font-size: 1.6rem;
}
.handle-card p {
    margin: 0 0 1rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
}
.handle-card input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    margin-bottom: 0.5rem;
}
.handle-card input:focus { outline: 2px solid var(--cat-strategy); outline-offset: 1px; }
.handle-error {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1.2em;
    margin: 0 0 0.6rem;
}
.handle-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Summary */
.summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}
.summary h2 {
    font-family: var(--font-hand);
    font-size: 2rem;
    margin: 0 0 0.25rem;
    padding: 0;
}
.summary h2::after { display: none; }
.summary-score {
    font-family: var(--font-mono);
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--cat-strategy);
    line-height: 1;
    margin: 0.5rem 0 0.25rem;
}
.summary-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 1rem;
}
.summary-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin: 0.5rem 0 1rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
}
.summary-meta span strong {
    color: var(--text);
    font-family: var(--font-mono);
}
.summary-best-flag {
    color: var(--accent);
    font-family: var(--font-hand);
    font-size: 1.25rem;
    font-weight: 600;
    min-height: 1.5em;
    margin: 0.25rem 0 0.5rem;
}
.summary-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.share-note {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    min-height: 1.2em;
}

/* Leaderboard (local) */
.leaderboard {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.leaderboard-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.local-best-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.local-best-list li {
    display: grid;
    grid-template-columns: 2.5rem 1fr auto auto 3rem;
    gap: 0.75rem;
    align-items: center;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.local-best-list li:last-child { border-bottom: none; }
.local-best-list li.empty {
    display: block;
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
}
.local-best-list .rank {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-weight: 600;
}
.local-best-list .handle { font-weight: 500; }
.local-best-list .diff,
.local-best-list .date {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.local-best-list .score {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--cat-strategy);
    text-align: right;
}

.game-page .section-heading .section-hint {
    font-family: var(--font-hand);
    font-size: 1rem;
}

/* Content sections */
.game-content { margin-top: 2.25rem; }
.game-content section { margin-bottom: 2rem; }
.game-content h2 { margin-top: 0; }

.game-page .section-heading h2 {
    font-family: var(--font-hand);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
}
.game-content h3 {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.7rem;
    line-height: 1.15;
    margin: 1.4em 0 0.3em;
    color: var(--text);
}
.game-content p,
.game-content ul,
.game-content ol.walkthrough + p {
    font-size: 1.02rem;
    line-height: 1.65;
    color: var(--text-secondary);
}
.game-content p strong { color: var(--text); }

.panel-subhead {
    font-family: var(--font-hand);
    font-size: 1.1rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    font-weight: 600;
    margin: 0.9rem 0 0.2rem;
}

/* Knight ⚔ Knight — visualizes the two-knight duel the panel sets up.
 * Unicode only ships a left-facing chess knight (U+265E), so the LEFT
 * glyph is mirrored with scaleX(-1) so the two knights face each other.
 * Split across ::before (left knight, flipped) and ::after (swords +
 * right knight) because you can't selectively transform part of a
 * single CSS content string.
 * \FE0E = text-presentation variation selector — forces monochrome
 * rendering (otherwise many OSes draw ⚔ as a color emoji). */
.start-panel::before,
.start-panel::after {
    position: absolute;
    top: 0.5rem;
    font-family: ui-sans-serif, system-ui, "Segoe UI Symbol", sans-serif;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--cat-strategy);
    opacity: 0.28;
    letter-spacing: 0.15em;
    pointer-events: none;
    font-variant-emoji: text;
}
.start-panel::before {
    content: "\265E\FE0E";
    /* 7rem clears the ~110px-wide ::after (anchored at right:1rem)
     * with a small breathing-room gap. */
    right: 7rem;
    transform: rotate(-4deg) scaleX(-1);
    transform-origin: center;
}
.start-panel::after {
    content: "\2694\FE0E  \265E\FE0E";
    right: 1rem;
    transform: rotate(-4deg);
}
@media (max-width: 560px) {
    .start-panel::before,
    .start-panel::after { display: none; }
}

/* Step walkthroughs */
.walkthrough {
    list-style: none;
    counter-reset: wstep;
    padding: 0;
    margin: 0.5rem 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.walkthrough li {
    counter-increment: wstep;
    position: relative;
    padding: 0.5rem 0.85rem 0.5rem 2.75rem;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    line-height: 1.5;
}
.walkthrough li::before {
    content: counter(wstep);
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.8rem;
    height: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--cat-strategy-bg);
    color: var(--cat-strategy);
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.05rem;
    border: 1.5px dashed var(--cat-strategy);
}
.walkthrough strong {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 1.02em;
}

/* Callout */
.callout {
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin: 1rem 0;
    line-height: 1.55;
}
.callout-gotcha {
    background: #eef4fb;
    border: 1px solid #9ec3e4;
    color: #24456b;
}
:root[data-theme="dark"] .callout-gotcha {
    background: #1f2c3c;
    border-color: #3e5b7c;
    color: #bfd4ea;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) .callout-gotcha {
        background: #1f2c3c;
        border-color: #3e5b7c;
        color: #bfd4ea;
    }
}
.callout strong { font-weight: 700; }

.ftc-disclosure {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem;
    margin: 1rem 0;
    border: 1px solid var(--border);
}

.affiliate-links {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
}
.affiliate-links li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.affiliate-links li:last-child { border-bottom: none; }
.affiliate-links a { font-weight: 500; }
.affiliate-links .blurb {
    display: block;
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 0.15rem;
}

.kb-hints {
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}
.kb-hints kbd {
    font-family: var(--font-mono);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

@media (max-width: 560px) {
    .kb-hints { display: none; }
    .local-best-list li {
        grid-template-columns: 2rem 1fr auto 3rem;
    }
    .local-best-list .date { display: none; }
    .key { font-size: 1.25rem; }
    .problem-question { font-size: 1.35rem; }
}

/* ---------- Fractions-specific additions ---------- */

/* Panel note under the difficulty picker */
.panel-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0.5rem 0 0;
    line-height: 1.35;
    font-family: var(--font-sans);
}

/* Answer input — legacy fractions rule, not used in Memory Sprint. */

/* Feedback flash: full-width green ring on correct, matching Tape Measure */
.game-area.flash-right {
    animation: flashRight 0.7s ease-out;
}
@keyframes flashRight {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); background-color: transparent; }
    20%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.45); background-color: rgba(16, 185, 129, 0.07); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); background-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
    .game-area.flash-right { animation: none; }
}

.feedback-right { font-size: 2.4rem; animation: feedbackPop 0.4s ease-out; }
@keyframes feedbackPop {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .feedback-right { animation: none; }
}

/* Hide surfaces cleanly */
#keypadWrap[hidden], #chipWrap[hidden], #showStage[hidden],
#recallArea[hidden], #digitRecall[hidden], #wordRecall[hidden] {
    display: none !important;
}

/* ---------- Memory Sprint: SHOW PHASE ---------- */

.show-stage {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0.25rem 0 0.75rem;
    position: relative;
    overflow: hidden;
}
.show-label {
    font-family: var(--font-hand);
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    letter-spacing: 0.01em;
    text-align: center;
}
.show-item-wrap {
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 1rem;
}
.show-item {
    font-family: var(--font-mono);
    font-size: 3.6rem;
    font-weight: 600;
    color: var(--cat-strategy);
    letter-spacing: 0.02em;
    padding: 0.25rem 1rem;
    text-align: center;
    opacity: 0;
    line-height: 1;
    display: inline-block;
    transition: none;
    word-break: keep-all;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.show-item.item-pop {
    animation: itemPop 0.35s ease-out forwards;
}
/* Words are typed in the Caveat hand font for a friendlier read */
.show-item:not(:empty):is([data-kind="word"]),
.show-item {
    /* default, overridden by JS via dataset if we add kind later */
}
@keyframes itemPop {
    0%   { opacity: 0; transform: scale(0.7); }
    40%  { opacity: 1; transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .show-item.item-pop { animation: none; opacity: 1; }
}
.show-item.word-item { font-family: var(--font-hand); font-size: 3.2rem; letter-spacing: 0; }

/* Ready-phase "Get ready — Digits · 6 items" text is smaller and muted so it
 * reads as meta-info rather than being mistaken for a real show item. */
.show-item.ready-text {
    font-family: var(--font-hand);
    font-size: 2rem;
    color: var(--text);
    opacity: 0.85;
    letter-spacing: 0.01em;
}

.show-progress {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.progress-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s, transform 0.2s;
}
.progress-dot.done {
    background: var(--cat-strategy);
    transform: scale(1.15);
}

/* ---------- Memory Sprint: RECALL PHASE ---------- */

.recall-area {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1rem 1.25rem;
    margin: 0.25rem 0 0.75rem;
    min-height: 140px;
}
.recall-label {
    font-family: var(--font-hand);
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    text-align: center;
    letter-spacing: 0.01em;
}

/* Digit recall */
.digit-recall {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.digit-slots {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0.25rem 0 0.5rem;
}
.digit-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.9rem;
    font-family: var(--font-mono);
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-soft);
    border: 2px dashed var(--border);
    border-radius: 0.5rem;
    line-height: 1;
}
.digit-slot.filled {
    border-style: solid;
    border-color: var(--cat-strategy);
    background: var(--surface);
}
.digit-slot.cursor {
    border-color: var(--cat-strategy);
    animation: slotBlink 1s ease-in-out infinite;
}
@keyframes slotBlink {
    0%, 100% { border-color: var(--cat-strategy); }
    50%      { border-color: var(--border); }
}
@media (prefers-reduced-motion: reduce) {
    .digit-slot.cursor { animation: none; }
}

/* Word recall */
.picked-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.4rem;
    justify-content: flex-start;
    align-items: center;
    min-height: 2.4rem;
    padding: 0.3rem 0.25rem;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 0.5rem;
}
.picked-hint {
    font-family: var(--font-hand);
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 0 0.25rem;
}
.picked-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem 0.55rem 0.2rem 0.4rem;
    background: var(--cat-strategy-bg);
    color: var(--cat-strategy);
    border-radius: 999px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--cat-strategy);
}
.picked-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3rem;
    height: 1.3rem;
    border-radius: 999px;
    background: var(--cat-strategy);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}
.picked-word {
    letter-spacing: 0.01em;
}

/* Word chip pool (right column) */
.chip-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.word-pool {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    align-content: start;
}
@media (max-width: 480px) {
    .word-pool { grid-template-columns: repeat(2, 1fr); }
}
.word-chip {
    position: relative;
    appearance: none;
    background: var(--bg-soft);
    border: 1.5px dashed var(--border);
    border-radius: 0.6rem;
    padding: 0.55rem 0.4rem;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: transform 0.08s, background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.15;
    text-align: center;
    word-break: break-word;
}
.word-chip:hover:not(.picked) {
    background: var(--surface);
    border-color: var(--cat-strategy);
    color: var(--cat-strategy);
}
.word-chip:active { transform: translateY(1px) scale(0.98); }
.word-chip.picked {
    background: var(--cat-strategy);
    border-color: var(--cat-strategy);
    border-style: solid;
    color: #fff;
    cursor: default;
}
.word-chip .chip-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    height: 1.2rem;
    border-radius: 999px;
    background: #fff;
    color: var(--cat-strategy);
    font-size: 0.7rem;
    font-weight: 800;
    margin-left: 0.2rem;
}
.word-chip:focus-visible {
    outline: 3px solid var(--cat-strategy);
    outline-offset: 2px;
}
.btn-submit-words {
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
}

/* History list tweak: Memory Sprint has a tag prefix (D8 / W6) */
.problem-history .h-tag {
    display: inline-block;
    min-width: 2.2rem;
    padding: 0.1rem 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--cat-strategy);
    background: var(--cat-strategy-bg);
    border-radius: 0.35rem;
    text-align: center;
    margin-right: 0.4rem;
}

/* Summary recap tweaks for Memory Sprint */
.summary-recap-list li .recap-detail {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.6rem;
    margin: 0.3rem 0 0.2rem 1.75rem;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.summary-recap-list li .recap-pair {
    display: contents;
}
.summary-recap-list li .recap-key {
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.72rem;
    align-self: center;
}
.summary-recap-list li .recap-val {
    font-family: var(--font-mono);
    word-break: break-word;
}
/* Theme the op-icon for digits mode (small stacked digits) */
.op-row .circle-pick .op-icon {
    letter-spacing: 0.02em;
    font-family: var(--font-mono);
    font-size: 1rem;
}

/* HUD additions: Length + Best fit cleanly */
.hud-group .hud-value { white-space: nowrap; }

/* ============================================================
 * Only Knights — board & match styling
 * ============================================================ */

/* The board fills available width up to a cap so it stays usable on
 * narrow phones without getting absurdly large on desktop. Uses
 * aspect-ratio to keep squares square regardless of width. */
.board-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem auto 1rem;
    width: 100%;
}

.match-banner {
    font-family: var(--font-hand);
    font-size: 1.15rem;
    color: var(--text-secondary);
    text-align: center;
    min-height: 1.5em;
}

.turn-indicator {
    display: inline-block;
    font-family: var(--font-hand);
    font-size: 1.3rem;
    font-weight: 600;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    border: 1.5px dashed var(--cat-strategy);
    color: var(--cat-strategy);
    background: var(--cat-strategy-bg);
    transform: rotate(-1deg);
}
.turn-indicator[data-turn="A"] { opacity: 0.7; }

.speed-clock {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--border);
    margin-left: 0.5rem;
}

.board {
    display: grid;
    grid-template-columns: repeat(var(--board-size, 8), 1fr);
    grid-auto-rows: 1fr;
    /* Board must fit inside .game-area at every viewport width.
     * .game-page overrides .container's h-padding to 0, so the only
     * subtractions are:
     *   2 × 20px .game-area h-padding
     * +     14px .board-frame rank-labels gutter
     * +      2px buffer
     * = 56px. Capped at 560px on wide screens.
     * Earlier `min(92vw, 560px)` ignored the padding chain and the
     * board overflowed game-area at narrow widths. */
    width: min(100vw - 56px, 560px);
    aspect-ratio: 1 / 1;
    border: 2px solid var(--cat-strategy);
    border-radius: 6px;
    overflow: hidden;
    background: var(--cat-strategy);
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    user-select: none;
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    color: var(--text);
    font: inherit;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.cell:focus-visible {
    outline: 3px solid var(--cat-strategy);
    outline-offset: -3px;
    z-index: 2;
}
.cell.light { background: #f0e8d6; }
.cell.dark  { background: #b58863; }
[data-theme="dark"] .cell.light,
@media (prefers-color-scheme: dark) {
    [data-theme=""] .cell.light { background: #5c5f6a; }
    [data-theme=""] .cell.dark  { background: #2d3038; }
}
[data-theme="dark"] .cell.light { background: #5c5f6a; }
[data-theme="dark"] .cell.dark  { background: #2d3038; }

/* Dead square — faded × mark, not clickable. */
.cell.dead {
    cursor: not-allowed;
    opacity: 0.55;
}
.dead-mark {
    font-family: var(--font-hand);
    font-size: calc(min(92vw, 560px) / 8 * 0.7);
    font-weight: 600;
    color: var(--text-secondary);
    opacity: 0.75;
    pointer-events: none;
}
/* Per-cell-color overrides so the × stays visible on both palettes.
 * Without these, the dead-mark inherits a dark text color and blends
 * into the dark slate cells. Light theme + dark theme handled. */
.cell.light .dead-mark { color: rgba(0, 0, 0, 0.65); }
.cell.dark  .dead-mark { color: rgba(255, 255, 255, 0.85); }
[data-theme="dark"] .cell.light .dead-mark { color: rgba(255, 255, 255, 0.75); }
[data-theme="dark"] .cell.dark  .dead-mark { color: rgba(255, 255, 255, 0.85); }

/* Knight glyphs — use chess unicode, big and centered. */
.knight-glyph {
    font-size: calc(min(92vw, 560px) / 8 * 0.78);
    line-height: 1;
    pointer-events: none;
    transition: transform 0.2s ease;
}
.knight-player .knight-glyph { color: #1a1a1a; text-shadow: 0 0 3px rgba(255,255,255,0.6); }
.knight-ai     .knight-glyph { color: #f6f6f6; text-shadow: 0 0 3px rgba(0,0,0,0.7); }
[data-theme="dark"] .knight-player .knight-glyph { color: #fdfdfd; text-shadow: 0 0 4px rgba(0,0,0,0.8); }
[data-theme="dark"] .knight-ai     .knight-glyph { color: #111; text-shadow: 0 0 4px rgba(255,255,255,0.4); }

.cell.knight-player.selected {
    box-shadow: inset 0 0 0 4px var(--cat-strategy);
}
.cell.knight-player.selected .knight-glyph {
    transform: scale(1.12);
}

/* Legal destinations — ring + soft fill. Pulses to draw the eye. */
.cell.legal-dest::after {
    content: '';
    position: absolute;
    inset: 18%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(74,85,103,0.32) 0%, rgba(74,85,103,0) 70%);
    pointer-events: none;
    animation: ok-legal-pulse 1.4s ease-in-out infinite;
}
[data-theme="dark"] .cell.legal-dest::after {
    background: radial-gradient(circle, rgba(154,164,181,0.45) 0%, rgba(154,164,181,0) 70%);
}
@keyframes ok-legal-pulse {
    0%, 100% { transform: scale(0.85); opacity: 0.85; }
    50%      { transform: scale(1.0);  opacity: 1; }
}

/* Capture target (legal dest that contains the opponent) — red ring. */
.cell.legal-capture {
    box-shadow: inset 0 0 0 4px #c14b4b;
}
.cell.legal-capture::after {
    background: radial-gradient(circle, rgba(193,75,75,0.55) 0%, rgba(193,75,75,0) 72%);
}

/* Ambient hint — softer than legal-dest; shown before the player taps
 * their knight. Small dot only, no pulse, so it's a reminder not a
 * distraction. */
.cell.ambient-hint::after {
    content: '';
    position: absolute;
    width: 18%;
    height: 18%;
    left: 41%;
    top: 41%;
    border-radius: 50%;
    background: rgba(74,85,103,0.35);
    pointer-events: none;
}
[data-theme="dark"] .cell.ambient-hint::after {
    background: rgba(154,164,181,0.45);
}
.cell.ambient-capture::after {
    background: rgba(193,75,75,0.5);
    width: 24%;
    height: 24%;
    left: 38%;
    top: 38%;
}

/* Hinted cell (from the Hint button) — big star-like accent. */
.cell.hinted {
    box-shadow: inset 0 0 0 4px #e0b650;
    animation: ok-hint-flash 1.6s ease-in-out 1;
}
@keyframes ok-hint-flash {
    0%, 100% { box-shadow: inset 0 0 0 4px #e0b650; }
    50%      { box-shadow: inset 0 0 0 4px #ffd770; }
}

/* Last AI move — brief yellow glow so the player sees where the AI
 * went. Fades automatically via the keyframe. */
.cell.last-move {
    animation: ok-last-move 1.6s ease-out 1;
}
@keyframes ok-last-move {
    0%   { box-shadow: inset 0 0 0 4px rgba(224,182,80,0.9); }
    100% { box-shadow: inset 0 0 0 4px rgba(224,182,80,0); }
}

/* Match-end overlay card — sits above the board without hiding it. */
.match-result {
    width: min(92vw, 560px);
    margin: 0.75rem auto 0;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    text-align: center;
}
.match-result h3 {
    font-family: var(--font-hand);
    font-size: 2rem;
    margin: 0 0 0.25rem;
}
.match-result.win  h3 { color: #2e8b5a; }
.match-result.loss h3 { color: #c14b4b; }
.match-result .match-reason {
    margin: 0 0 0.75rem;
    color: var(--text-secondary);
}
.match-result .match-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Action row under the board: Hint + Concede. */
.match-actions-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0.25rem 0 0;
}
.match-actions-row[hidden] { display: none; }
.match-actions-row .btn-ghost {
    font-size: 0.9rem;
}

/* HUD tweaks — the game-area HUD used by memory-sprint is fine as-is,
 * but the labels differ. No override needed; new IDs only. */

/* FAQ — no SVG diagrams in this game, so the faq-diagram rules from
 * the base are unused. Harmless. */

/* Narrow screens: keep board readable; shrink glyphs proportionally. */
@media (max-width: 480px) {
    /* Board width is now handled by the default `.board` rule
     * (`min(100vw - 96px, 560px)`). Just rescale glyph fonts to the
     * actual cell size at narrow widths. */
    .knight-glyph {
        font-size: calc((100vw - 56px) / 8 * 0.78);
    }
    .dead-mark {
        font-size: calc((100vw - 56px) / 8 * 0.7);
    }
}

/* ============================================================
 * Iteration 2 — feedback fixes
 *   1. Split panel-notes → per-option list with spacing
 *   2. Equal-size squares even when content is present
 *   3. Board palette = slate + off-white (site's strategy theme)
 *   4. Prominent on-board "Your move" banner (pulses on turn flip)
 *   5. 2-column play layout — board left, match-result right on desktop
 *   6. Match-result card made visually louder so losses register
 * ============================================================ */

/* Per-option notes under the picker. Each option on its own line with
 * room to breathe. */
.panel-note-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.panel-note-list li {
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--text-secondary);
    padding-left: 0.15rem;
}
.panel-note-list li strong {
    color: var(--cat-strategy);
    font-weight: 700;
}

/* ---- Grid-sizing fix ----------------------------------------------
 * `grid-auto-rows: 1fr` + content with intrinsic size = rows that grow
 * beyond their track. The well-known fix is to set explicit rows with
 * `minmax(0, 1fr)` and add `min-width: 0; min-height: 0` on grid items
 * so they're allowed to shrink below content size. We also clamp the
 * knight glyph font with `max-width/height` so wide characters can't
 * force a cell to expand. */
.board {
    grid-template-columns: repeat(var(--board-size, 8), minmax(0, 1fr));
    grid-template-rows: repeat(var(--board-size, 8), minmax(0, 1fr));
    grid-auto-rows: unset;
}
.cell {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}
.knight-glyph,
.dead-mark {
    max-width: 100%;
    max-height: 100%;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---- Board palette override (replaces the chess-brown defaults) --- */
.cell.light { background: #eef1f4; }   /* warm off-white, tied to site bg */
.cell.dark  { background: #4a5567; }   /* --cat-strategy slate */
[data-theme="dark"] .cell.light { background: #3a4150; }
[data-theme="dark"] .cell.dark  { background: #1f242d; }
@media (prefers-color-scheme: dark) {
    [data-theme=""] .cell.light { background: #3a4150; }
    [data-theme=""] .cell.dark  { background: #1f242d; }
}

/* Re-tune the knight glyphs against the new palette so both pieces
 * stay legible on both square colors. Dark-theme mirrors. */
.knight-player .knight-glyph {
    color: #0f1620;
    text-shadow: 0 0 4px rgba(255,255,255,0.75);
}
.knight-ai .knight-glyph {
    color: #f8fafb;
    text-shadow: 0 0 4px rgba(0,0,0,0.75);
}
[data-theme="dark"] .knight-player .knight-glyph {
    color: #fbfcfe;
    text-shadow: 0 0 4px rgba(0,0,0,0.85);
}
[data-theme="dark"] .knight-ai .knight-glyph {
    color: #0d1017;
    text-shadow: 0 0 4px rgba(255,255,255,0.55);
}

/* Legal-move pulse tuned to the new palette (slate-teal glow, not
 * the muddy grey from before). */
.cell.legal-dest::after {
    background: radial-gradient(circle, rgba(80,130,160,0.42) 0%, rgba(80,130,160,0) 70%);
}
[data-theme="dark"] .cell.legal-dest::after {
    background: radial-gradient(circle, rgba(140,200,230,0.55) 0%, rgba(140,200,230,0) 70%);
}
.cell.ambient-hint::after {
    background: rgba(80,130,160,0.4);
}
[data-theme="dark"] .cell.ambient-hint::after {
    background: rgba(140,200,230,0.5);
}

/* ---- On-board turn banner ---------------------------------------- */
.turn-banner {
    font-family: var(--font-hand);
    font-size: 1.8rem;
    font-weight: 700;
    padding: 0.3rem 1rem;
    border-radius: 999px;
    text-align: center;
    transform: rotate(-1deg);
    transition: background 0.2s ease, color 0.2s ease;
    min-width: min(60vw, 280px);
    user-select: none;
}
.turn-banner[data-turn="P"][data-phase="player"] {
    background: var(--cat-strategy);
    color: #fff;
    box-shadow: 0 2px 10px rgba(74,85,103,0.25);
}
.turn-banner[data-turn="A"][data-phase="ai"] {
    background: var(--cat-strategy-bg);
    color: var(--cat-strategy);
    opacity: 0.85;
}
.turn-banner[data-phase="match-end"],
.turn-banner[hidden] { display: none; }

.turn-banner-pulse {
    animation: ok-turn-pulse 0.7s ease-out 1;
}
@keyframes ok-turn-pulse {
    0%   { transform: rotate(-1deg) scale(1); box-shadow: 0 0 0 0 rgba(74,85,103,0.5); }
    60%  { transform: rotate(-1deg) scale(1.08); box-shadow: 0 0 0 18px rgba(74,85,103,0); }
    100% { transform: rotate(-1deg) scale(1); box-shadow: 0 0 0 0 rgba(74,85,103,0); }
}

/* ---- 2-column play layout ---------------------------------------- */
.play-layout {
    display: grid;
    grid-template-columns: min(92vw, 560px) minmax(280px, 400px);
    gap: 1.5rem;
    justify-content: center;
    align-items: start;
    margin: 0.5rem auto 1rem;
}
@media (max-width: 980px) {
    .play-layout {
        grid-template-columns: 1fr;
        justify-items: center;
    }
}

/* Match-result card — substantially louder than before so losses
 * register. Big result word, colored backdrop, slight lift animation
 * on reveal. On desktop, it sits beside the board; on mobile it
 * appears beneath and scrolls in view. */
.match-result {
    width: 100%;
    max-width: 400px;
    margin: 0;
    padding: 1.5rem 1.5rem;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--surface);
    text-align: center;
    animation: ok-result-in 0.35s ease-out 1;
    position: relative;
}
@keyframes ok-result-in {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}
.match-result h3 {
    font-family: var(--font-hand);
    font-size: 3rem;              /* up from 2rem — unmissable */
    line-height: 1.05;
    margin: 0 0 0.5rem;
    letter-spacing: -0.01em;
}
.match-result.win {
    background: linear-gradient(180deg, #eafaf1 0%, #f4fff8 100%);
    border-color: #7dc098;
}
.match-result.loss {
    background: linear-gradient(180deg, #fdecec 0%, #fff6f6 100%);
    border-color: #d28787;
}
.match-result.win h3  { color: #1e7a47; }
.match-result.loss h3 { color: #a63333; }
[data-theme="dark"] .match-result.win  { background: linear-gradient(180deg, #1e3a2a 0%, #152620 100%); border-color: #3a6b4e; }
[data-theme="dark"] .match-result.loss { background: linear-gradient(180deg, #3a2020 0%, #26181a 100%); border-color: #6b3a3a; }
[data-theme="dark"] .match-result.win h3  { color: #7fdc9d; }
[data-theme="dark"] .match-result.loss h3 { color: #e88a8a; }

.match-result .match-reason {
    font-size: 1rem;
    margin: 0 0 1rem;
    color: var(--text);
}
.match-result .match-actions {
    gap: 0.6rem;
    margin-top: 0.5rem;
}
.match-result .match-actions .btn-primary {
    padding: 0.55rem 1.1rem;
    font-size: 1rem;
}

/* ============================================================
 * Iteration 3 — side-panel layout
 * Board is its own column; EVERYTHING else (turn banner, match
 * banner, hint/concede buttons, win/loss card) lives in the
 * side column on desktop, wrapping above the board on narrow
 * viewports so no match info can ever be below the fold.
 * ============================================================ */

/* Override the iteration-2 `.play-layout` grid with template areas. */
.play-layout {
    display: grid;
    grid-template-columns: min(92vw, 560px) minmax(260px, 340px);
    grid-template-areas: "board side";
    gap: 1.5rem;
    justify-content: center;
    align-items: start;
    margin: 0.5rem auto 1rem;
}
.play-layout .board-col { grid-area: board; }
.play-layout .side-col  { grid-area: side; }

@media (max-width: 980px) {
    .play-layout {
        /* Stack: board first so the game is what you see immediately.
         * Side-col (turn banner + hint/concede + match-result) sits
         * directly under the board. Same order in solo and MP — was
         * previously flipped per-mode which made solo feel different.
         * Track must fit inside .game-area's content area:
         *   100vw − 40px (.game-area's 20px h-padding × 2).
         * Old `min(96vw, 560px)` overflowed game-area below ~640vw. */
        grid-template-columns: min(100vw - 40px, 560px);
        grid-template-areas:
            "board"
            "side";
        gap: 0.75rem;
    }
}

/* The side column is a stacked card of state + actions. Subtle
 * panel styling so the area reads as "this is where match info
 * lives" rather than empty white space. */
.side-col {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 0.75rem 0.85rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    align-self: stretch;
    min-width: 0;
}
[data-theme="dark"] .side-col {
    background: var(--surface);
}

/* Turn banner no longer needs the big min-width — it sizes to
 * the side column. Keep the pulse / colors from iteration 2. */
.side-col .turn-banner {
    margin: 0;
    min-width: 0;
    width: 100%;
    font-size: 1.7rem;
    padding: 0.45rem 0.9rem;
}

/* Match banner sits just below the turn banner as a secondary
 * status line ("Match 3 — AI moves first", "Streak 2 · best 4"). */
.side-col .match-banner {
    margin: 0;
    text-align: center;
    font-size: 1rem;
    line-height: 1.4;
}

/* Buttons row — vertical on the side column so tap targets are
 * full-width and easy to hit. */
.side-col .match-actions-row {
    flex-direction: column;
    gap: 0.45rem;
    margin: 0;
}
.side-col .match-actions-row .btn-ghost {
    width: 100%;
    padding: 0.55rem 0.8rem;
    font-size: 0.95rem;
}

/* Match-result card inside the side column — doesn't need its own
 * width cap anymore, fills the panel. */
.side-col .match-result {
    max-width: none;
    margin: 0.25rem 0 0;
    padding: 1rem 1rem 1.2rem;
}
.side-col .match-result h3 {
    font-size: 2.4rem;
}
.side-col .match-result .match-actions {
    flex-direction: column;
    gap: 0.45rem;
}
.side-col .match-result .match-actions .btn-primary,
.side-col .match-result .match-actions .btn-ghost {
    width: 100%;
}

/* Board column — just centers the board. The old `.board-wrap`
 * rules don't apply (element was renamed/removed). */
.board-col {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-width: 0;
}

/* On desktop, the board is pinned to the top of its column so the
 * side column (which may be taller or shorter) doesn't drag it. */
@media (min-width: 981px) {
    .board-col { align-self: start; }
    .side-col  { align-self: start; position: sticky; top: 1rem; }
}

/* ============================================================
 * Iteration 4 — Fix for unicode ♘/♞ rendering as color emoji
 *
 * Root cause of the "AI knight looks transparent" issue was that
 * some OSes (Windows Segoe UI Emoji in particular) render the
 * chess-piece unicode chars as COLOR emoji, which ignores CSS
 * `color`. Forcing a font stack that has MONOCHROME text glyphs
 * for U+2654-U+265F keeps CSS color in charge.
 * ============================================================ */

.knight-glyph {
    /* Force text-presentation font stack — these have monochrome
     * chess symbols that respect `color`. "Noto Sans Symbols 2"
     * and "DejaVu Sans" are the fallbacks that always work. */
    font-family: "Segoe UI Symbol", "DejaVu Sans", "Arial Unicode MS",
                 "Noto Sans Symbols", "Noto Sans Symbols 2", serif;
    font-variant-emoji: text;
    -webkit-font-feature-settings: "liga" off;
    font-feature-settings: "liga" off;
    display: inline-block;
    line-height: 1;
}

/* ---- Quick how-to card ------------------------------------------- */
.quick-how {
    background: var(--cat-strategy-bg);
    border: 1px dashed var(--cat-strategy);
    border-radius: 10px;
    padding: 0.7rem 0.9rem 0.8rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text);
}
.quick-how-head {
    margin: 0 0 0.35rem;
    font-family: var(--font-hand);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--cat-strategy);
    letter-spacing: -0.01em;
}
.quick-how ol {
    margin: 0;
    padding-left: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.quick-how li { padding-left: 0.1rem; }
.quick-how li strong { color: var(--text); }

/* ============================================================
 * Iteration 5 — Run-over summary inside the match-result card
 * ============================================================ */

.match-result.run-over {
    padding: 1.2rem 1.1rem 1.3rem;
}
.match-result.run-over h3 {
    font-size: 2.2rem;
    margin-bottom: 0.3rem;
}
.match-result.run-over .match-reason {
    margin-bottom: 0.75rem;
}

.pb-flag {
    margin: 0 0 0.9rem;
    font-family: var(--font-hand);
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
}
.pb-flag-win {
    background: #fff1cc;
    color: #7a5b15;
    border: 1px dashed #d4a73a;
}
.pb-flag-neutral {
    color: var(--text-secondary);
    background: transparent;
    font-size: 0.95rem;
    padding: 0.2rem 0;
}
[data-theme="dark"] .pb-flag-win {
    background: #3d2f15;
    color: #ffd66a;
    border-color: #7a5b15;
}

/* Stat rows inside the run-over card — compact <dl> with clear labels. */
.run-stats {
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.9rem;
}
.run-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.28rem 0;
    border-bottom: 1px dashed var(--border);
    gap: 0.6rem;
}
.run-stats-row:last-child { border-bottom: 0; }
.run-stats-row dt {
    margin: 0;
    color: var(--text-secondary);
    font-weight: 500;
}
.run-stats-row dd {
    margin: 0;
    font-weight: 700;
    color: var(--text);
}
.run-stats-row .stats-grid {
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    max-width: 60%;
    text-align: right;
    overflow-wrap: anywhere;
}

.run-actions {
    gap: 0.45rem;
    flex-direction: column;
}
.run-actions .btn-primary,
.run-actions .btn-ghost {
    width: 100%;
}

/* ============================================================
 * Iteration 6 — Brighter legal-move dots + how-to refresh
 * ============================================================ */

/* Legal-move dots — make them obvious. Both the ambient (knight
 * NOT selected) and selected states use the same prominent dot so
 * the player isn't left hunting for the pulse.
 *
 * Bigger base (inset 22% → inset 26% would be smaller; we go
 * bigger by inset 15%), denser gradient, brighter stroke-like
 * outer ring, stronger pulse amplitude. */
.cell.legal-dest::after,
.cell.ambient-hint::after {
    content: '';
    position: absolute;
    /* White dot with dark outline — readable on both the light
     * (#eef1f4 off-white) and dark (#4a5567 slate) squares. */
    top: 40%;
    right: 40%;
    bottom: 40%;
    left: 40%;
    width: auto;
    height: auto;
    border-radius: 50%;
    pointer-events: none;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(20, 25, 35, 0.85);
    animation: ok-legal-pulse 1.2s ease-in-out infinite;
}
[data-theme="dark"] .cell.legal-dest::after,
[data-theme="dark"] .cell.ambient-hint::after {
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.85);
}

/* Strong pulse — scale + brightness swing. */
@keyframes ok-legal-pulse {
    0%, 100% { transform: scale(0.82); opacity: 0.65; }
    50%      { transform: scale(1.05); opacity: 0.85; }
}

/* Capture dot — red flat fill, still just a dot. The cell itself gets
 * the red inner ring so "attack square" reads clearly. */
.cell.legal-capture::after,
.cell.ambient-capture::after {
    background: rgba(195, 65, 65, 0.9);
    box-shadow: none;
}
.cell.legal-capture {
    box-shadow: inset 0 0 0 4px #c14b4b;
}

/* Algebraic coordinate labels — ranks down the left edge, files
 * along the bottom edge. Outside the board so they don't eat
 * cell space. */
.board-frame {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
        "ranks board"
        ".     files";
    gap: 4px;
    width: 100%;
}
.board-frame > .board {
    grid-area: board;
}
.rank-labels {
    grid-area: ranks;
    display: grid;
    grid-template-rows: repeat(8, 1fr);
    align-items: center;
    justify-items: center;
    padding-right: 2px;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary, #4a5567);
    opacity: 0.6;
    user-select: none;
}
.file-labels {
    grid-area: files;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    justify-items: center;
    padding-top: 2px;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary, #4a5567);
    opacity: 0.6;
    user-select: none;
}
[data-theme="dark"] .rank-labels,
[data-theme="dark"] .file-labels {
    color: #c9cfd8;
}

/* Quick how-to — single-paragraph version (replaces the 3-step
 * ordered list). */
.quick-how-body {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--text);
}
.quick-how-body strong { color: var(--cat-strategy); }

/* ==========================================================================
   Multiplayer UI (feature-flagged via ?mp=1 or ?room=<code>)
   ========================================================================== */

.btn-friend {
    background: var(--cat-strategy, #3b4a6b);
    margin-left: 0.5rem;
}
.btn-friend:hover { filter: brightness(1.1); }

/* Start panel: make Play/Play-a-friend sit side by side */
.start-footer {
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Recent multiplayer matches list */
.mp-history-wrap {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border, #e0e4eb);
}
.mp-history-head {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin: 0 0 0.5rem;
}
.mp-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}
.mp-history-list li {
    padding: 0.25rem 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.mp-history-empty { color: var(--text-secondary); font-style: italic; }
.mp-h-outcome[data-outcome="win"]  { color: #2a7a3d; font-weight: 600; }
.mp-h-outcome[data-outcome="loss"] { color: #a5332b; font-weight: 600; }
.mp-h-outcome[data-outcome="left"] { color: var(--text-secondary); }
.mp-h-when { color: var(--text-secondary); font-size: 0.82rem; margin-left: auto; }

/* Modal (invite / proposal / room-full) */
.mp-modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 20, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.mp-modal[hidden] { display: none; }
.mp-modal-card {
    background: var(--card, #fff);
    color: var(--text);
    border-radius: 14px;
    padding: 1.5rem 1.5rem 1.25rem;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.mp-modal-card h3 { margin: 0 0 0.5rem; }
.mp-modal-body { margin: 0 0 0.9rem; color: var(--text-secondary); }
.mp-invite-input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    font-size: 0.88rem;
    border: 1px solid var(--border, #d9dee6);
    border-radius: 8px;
    background: var(--bg, #f5f7fa);
    color: var(--text);
    margin-bottom: 0.75rem;
}
.mp-modal-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.mp-modal-actions .mp-cancel {
    margin-left: auto;
    color: #a5332b;
}
.mp-invite-note {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-height: 1em;
}

/* Waiting screen */
.mp-waiting {
    max-width: 520px;
    margin: 1.5rem auto;
    padding: 1.75rem 1.5rem;
    background: var(--card, #fff);
    border-radius: 14px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}
.mp-waiting h2 { margin: 0 0 0.4rem; }
.mp-waiting-sub { color: var(--text-secondary); margin: 0 0 1rem; }
.mp-waiting-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Match-end card (MP variant — reuses .match-result container) */
.match-result-inner.won  .match-result-head { color: #2a7a3d; }
.match-result-inner.lost .match-result-head { color: #a5332b; }
.match-result-head { font-size: 1.15rem; font-weight: 600; margin: 0 0 0.25rem; }
.match-result-sub,
.match-result-streak { margin: 0.15rem 0; color: var(--text-secondary); }
.match-result-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.mp-play-again-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0.5rem 0 0;
    min-height: 1em;
}

/* Box-sizing safety for all injected MP elements so mobile padding
 * doesn't overflow 100vw. */
.mp-modal, .mp-modal *,
.mp-waiting, .mp-waiting *,
.mp-history-wrap, .mp-history-wrap * {
    box-sizing: border-box;
}

/* Propose-settings modal rows */
.mp-propose-group {
    margin-bottom: 0.85rem;
}
.mp-propose-group > label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}
.mp-propose-row {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}
.mp-propose-row label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.92rem;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    background: var(--bg, #f5f7fa);
    cursor: pointer;
}
.mp-propose-row label:has(input:checked) {
    background: var(--cat-strategy, #3b4a6b);
    color: #fff;
}

/* Mobile: ensure the multiplayer modals and waiting cards
 * don't push the page past 100vw. The board itself is already
 * sized via `.board { width: 96vw }` in the existing mobile
 * media query (~line 1666). */
@media (max-width: 480px) {
    .mp-modal { padding: 0.75rem; }
    .mp-modal-card { padding: 1.15rem; }
    .mp-waiting { margin: 1rem 0.75rem; padding: 1.25rem 1rem; }
    .mp-waiting-actions, .mp-modal-actions { flex-direction: column; }
    .mp-waiting-actions > *, .mp-modal-actions > * { width: 100%; text-align: center; }
    .mp-modal-actions .mp-cancel { margin-left: 0; }
}

/* MP uses solo's board sizing as-is (`.board { width: 96vw }` on
 * mobile). The small horizontal overflow from the rank-labels gutter
 * is already clipped by `.game-area { overflow: hidden }` in solo,
 * so MP doesn't need its own board width rule. An earlier attempt to
 * force `width: 100%` shrunk the board drastically because the
 * aspect-ratio + nested grid combo collapsed its inner cells. */

/* Hide solo-only controls while MP is active. The Hint button relies on
 * a client-side AI search that makes no sense vs a human opponent. */
body.mp-active #hintBtn { display: none !important; }

/* The "How to move" tutorial blurb eats huge vertical space on mobile
 * and pushes the board off-screen during MP. Players who've seen it
 * once don't need it every match. Hide it in MP. */
body.mp-active #quickHow { display: none !important; }

