/* 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 input:focus-visible + span {
    outline: 2px solid var(--cat-strategy);
    outline-offset: 3px;
}

/* Bullet / Blitz use text ("1m" / "3m") in the icon slot instead of an
 * emoji — tuck them down a hair so they sit on the same baseline as the
 * emoji icons, and use the sans font so the numeric reads cleanly. */
.op-row .circle-pick > span .op-icon-time {
    font-family: var(--font-sans);
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.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);
}

/* MP room label — click-to-copy invite, with 60-min TTL countdown */
.mp-room-label {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.2;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mp-room-label:hover,
.mp-room-label:focus-visible {
    background: var(--bg);
    color: var(--text);
    border-color: var(--text-muted);
}
.mp-room-label .mp-room-code { color: var(--text); font-weight: 600; }
.mp-room-label-warn {
    background: #fff4e5;
    color: #92400e;
    border-color: #fbbf77;
}
.mp-room-label-copied {
    background: var(--cat-strategy);
    color: #fff;
    border-color: var(--cat-strategy);
}
.mp-room-label-copied::after {
    content: ' — copied';
    font-weight: 600;
}
@media (max-width: 480px) {
    /* On phones the TTL eats too much width — hide the seconds-level detail
       but keep the room code so users can still tap to copy. */
    .mp-room-label .mp-room-sep,
    .mp-room-label .mp-room-ttl { display: none; }
}
.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;
}

/* Recent matches (solo + MP) — base styling lifted to shared/styles.css under
   `MULTIPLAYER — RECENT MATCHES`. Runtime-move overrides for the v6-record-inline
   placement remain below. */

.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: 0.95rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-left: 0.5rem;
    vertical-align: baseline;
    white-space: nowrap;
}
.speed-clock[data-who="opp"] { opacity: 0.65; }
.turn-banner-label { vertical-align: baseline; }
.turn-banner-sep {
    vertical-align: baseline;
    opacity: 0.7;
    margin: 0 0.15rem 0 0.4rem;
}
.speed-clock-urgent {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
    animation: ok-speed-flash 0.6s ease-in-out infinite;
}
@keyframes ok-speed-flash {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.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); }

/* Dead-X tinted by which side vacated the square. Overrides the neutral
 * per-cell colors above so you can tell at a glance whose path carved
 * through each region. Same palette is used in the downloaded image so
 * the two stay visually consistent.
 *   dead-by-mine → player-blue
 *   dead-by-foe  → opponent-orange */
.cell.dead.dead-by-mine .dead-mark { color: #2d7fd6; opacity: 0.95; }
.cell.dead.dead-by-foe  .dead-mark { color: #d65a3a; opacity: 0.95; }
[data-theme="dark"] .cell.dead.dead-by-mine .dead-mark { color: #4ea9ff; }
[data-theme="dark"] .cell.dead.dead-by-foe  .dead-mark { color: #ff7a5a; }
@media (prefers-color-scheme: dark) {
    [data-theme=""] .cell.dead.dead-by-mine .dead-mark { color: #4ea9ff; }
    [data-theme=""] .cell.dead.dead-by-foe  .dead-mark { color: #ff7a5a; }
}

/* 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); }
}

/* play-layout removed — markup now uses shared .play-grid (3-col card
 * frame with ink border + column dividers, defined in shared/styles.css
 * under .game-page .play-grid). Children .history-col / .board-col /
 * .side-col fall into columns 1/2/3 by source order. */

/* Match-result card — v6 idiom (white surface, sharp corners, mono
 * meta labels, serif italic heading). Status is signaled by a 3px
 * LEFT accent border (v6-accent for win, v6-pop for loss) instead of
 * a peach/green wash. Tokens are shared (--v6-ink/-rule/-accent/-pop/
 * -serif/-mono) so a v7 facelift to those values updates this card
 * along with every other v6 surface. */
.match-result {
    width: 100%;
    margin: 0;
    padding: 1.1rem 1.2rem 1.2rem;
    border: 1px solid var(--v6-rule);
    border-left-width: 3px;
    border-radius: 0;
    background: #fff;
    text-align: left;
    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(--v6-serif);
    font-style: italic;
    font-weight: 600;
    font-size: 2rem;
    line-height: 1.05;
    margin: 0 0 0.4rem;
    letter-spacing: -0.01em;
    color: var(--v6-ink);
}
.match-result.win  { border-left-color: var(--v6-accent); }
.match-result.loss { border-left-color: var(--v6-pop); }
[data-theme="dark"] .match-result {
    background: var(--surface);
    border-color: var(--border);
}
[data-theme="dark"] .match-result.win  { border-left-color: var(--v6-accent); }
[data-theme="dark"] .match-result.loss { border-left-color: var(--v6-pop); }
[data-theme="dark"] .match-result h3   { color: var(--text); }

/* Compact MP match-end card — same v6 chrome, tighter rhythm. */
.side-col .match-result.mp-compact { padding: 0.85rem 1rem 0.95rem; }
.match-result.mp-compact .match-result-head {
    font-family: var(--v6-serif);
    font-style: italic;
    font-weight: 600;
    font-size: 1.4rem;
    margin: 0 0 0.25rem;
    line-height: 1.05;
    color: var(--v6-ink);
}
[data-theme="dark"] .match-result.mp-compact .match-result-head { color: var(--text); }
.match-result.mp-compact .match-result-sub,
.match-result.mp-compact .match-result-streak {
    margin: 0 0 0.3rem;
    font-family: var(--v6-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--v6-muted);
}
.match-result.mp-compact .match-result-actions {
    margin-top: 0.7rem;
    display: flex;
    gap: 0.45rem;
    flex-direction: column;
}
.match-result.mp-compact .match-result-actions .btn-primary,
.match-result.mp-compact .match-result-actions .btn-ghost {
    width: 100%;
    padding: 0.5rem 0.9rem;
    font-size: 0.92rem;
}

.match-result .match-reason {
    font-size: 0.95rem;
    margin: 0 0 0.85rem;
    color: var(--v6-ink);
}
[data-theme="dark"] .match-result .match-reason { color: var(--text); }
.match-result .match-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.7rem;
}
.match-result .match-actions .btn-primary,
.match-result .match-actions .btn-ghost {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
}

/* ============================================================
 * 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.
 * ============================================================ */

/* .history-col / .board-col / .side-col base layout lives in
 * shared/styles.css under "MATCH-SHAPE COLUMNS". OK-specific
 * overrides (move-history grid, side-col turn/match banner, etc.)
 * remain below. */
.history-col .move-history-list {
    margin: 0;
    padding: 0;
    max-height: 460px;
    overflow-y: auto;
    overflow-x: hidden;
}
/* Min-width:0 lets the 1fr cells shrink under their content; without
 * it the move buttons (e.g. f3→g1) force the grid wider than the
 * 220px shared track and trigger a horizontal scrollbar. */
.history-col .move-history-list .mh-head,
.history-col .move-history-list .move-pair {
    grid-template-columns: 1.8em minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.25rem;
    padding: 0.2rem 0.1rem;
}
.history-col .mh-move {
    padding: 0.2rem 0.25rem;
    font-size: 0.85rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 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%;
}

/* 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.
 * (.board-col base layout is in shared/styles.css — MATCH-SHAPE COLUMNS.) */
@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 — v6 idiom: thin gold rule above, mono uppercase eyebrow. */
.pb-flag {
    margin: 0 0 0.85rem;
    padding: 0.4rem 0 0;
    border-top: 1px solid var(--v6-gold);
    font-family: var(--v6-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--v6-gold);
    font-weight: 600;
}
.pb-flag-neutral {
    border-top-color: var(--v6-rule);
    color: var(--v6-muted);
}
[data-theme="dark"] .pb-flag { color: var(--v6-gold); }
[data-theme="dark"] .pb-flag-neutral { color: var(--text-secondary); }

/* Run stats — v6 idiom: mono uppercase labels, ink values, hairline
 * rules between rows (no dashed border). */
.run-stats {
    margin: 0 0 0.6rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: 0.88rem;
}
.run-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--v6-rule-soft);
    gap: 0.6rem;
}
.run-stats-row:last-child { border-bottom: 0; }
.run-stats-row dt {
    margin: 0;
    font-family: var(--v6-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--v6-muted);
    font-weight: 500;
}
.run-stats-row dd {
    margin: 0;
    font-weight: 600;
    color: var(--v6-ink);
    font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .run-stats-row dd { 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;
    color: var(--v6-ink);
}
[data-theme="dark"] .run-stats-row .stats-grid { color: var(--text); }

.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 {
    /* inline-grid + auto cols = the frame sizes to content (rank-labels
     * width + board's intrinsic width). Without this, col 2 stretches
     * to fill .board-col and .file-labels (which uses repeat(8, 1fr))
     * spreads its 8 labels across the full column instead of matching
     * the board's actual width — the bottom "h" file ends up far right
     * of the board. .board-col flex centers the frame in its column. */
    display: inline-grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    grid-template-areas:
        "ranks board"
        ".     files";
    gap: 4px;
}
.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 — "Play a friend" button, invite modal, MP match-end card
   ========================================================================== */

.btn-friend {
    background: var(--cat-strategy, #3b4a6b);
    margin-left: 0.5rem;
}
.btn-friend:hover { filter: brightness(1.1); }

.btn-stranger {
    background: var(--cat-strategy, #3b4a6b);
    filter: saturate(0.85) brightness(0.92);
}
.btn-stranger:hover { filter: brightness(1.05); }


.btn-beta-badge {
    display: inline-block;
    margin: 0 0.35em 0 0.25em;
    padding: 0.12em 0.5em;
    font-size: 0.55em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    vertical-align: baseline;
    line-height: 1;
}
/* Stranger-search spinner (Matchmaking screen) */
.mp-stranger-spinner {
    width: 42px;
    height: 42px;
    margin: 0.75rem auto 0.5rem;
    border-radius: 50%;
    border: 3px solid var(--border, #d9dee6);
    border-top-color: var(--cat-strategy, #3b4a6b);
    animation: mp-stranger-spin 0.9s linear infinite;
}
.mp-stranger-countdown {
    font-size: 0.85rem;
    opacity: 0.75;
    margin: 0 0 1rem;
}
@keyframes mp-stranger-spin {
    to { transform: rotate(360deg); }
}
.mp-stranger-spinner-slow {
    animation-duration: 2.2s;
    opacity: 0.7;
}
@media (prefers-reduced-motion: reduce) {
    .mp-stranger-spinner { animation: none; }
}

/* Slim standby banner — shown at the top of the page while notify-me is on.
   Start panel + daily card remain visible beneath, so the user can play
   solo while waiting for a match. */
.mp-standby-banner {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.9rem;
    background: var(--primary, #3a5a78);
    color: #fff;
    font-size: 0.88rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.mp-standby-banner[hidden] { display: none; }
.mp-standby-banner-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #7cc281;
    box-shadow: 0 0 0 0 rgba(124, 194, 129, 0.7);
    animation: mpStandbyPulse 2.4s ease-in-out infinite;
    flex-shrink: 0;
}
.mp-standby-banner-text { flex: 1; line-height: 1.3; }
.mp-standby-banner-stop {
    appearance: none;
    background: transparent;
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    padding: 0.25rem 0.6rem;
    font-size: 0.82rem;
    cursor: pointer;
}
.mp-standby-banner-stop:hover { background: rgba(255, 255, 255, 0.12); }
@keyframes mpStandbyPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(124, 194, 129, 0.7); }
    50%      { box-shadow: 0 0 0 6px rgba(124, 194, 129, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .mp-standby-banner-dot { animation: none; }
}

/* Start panel: legacy layout — keep three Play buttons on one row. */
.start-footer {
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* v6 / .game-page override — shared/styles.css lays start-footer out as a
   2x2 grid and assigns every .btn-primary to grid-area: cta, which causes
   our three Play buttons (Play against the computer / Play a friend /
   Play a stranger) to stack on top of each other in the same cell. OK is
   the only v6 game with multiple CTAs in the footer, so override locally
   to flex-row them and shrink so all three fit beside the legal-moves
   toggle. */
.game-page .start-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 14px 32px 18px;
}

/* OK has 5 mode buttons (Streak / Single / Speed / Bullet / Blitz) — shared
   .op-row uses repeat(4, 1fr) so Blitz wraps to its own row. Override to 5. */
.game-page .start-panel .op-row {
    grid-template-columns: repeat(5, 1fr);
}
.game-page .start-panel .op-row .circle-pick {
    padding: 10px 4px;
}

/* v6-record-inline placement of .recent-matches + multi-CTA start-footer rules
   lifted to shared/styles.css under MULTIPLAYER — RECENT MATCHES. */

/* 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-modal-fine { font-size: 0.88rem; opacity: 0.8; }
.mp-propose-current {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.mp-propose-current span {
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-mono);
}
.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 * {
    box-sizing: border-box;
}

/* Propose-settings modal: wrapper spacing only. The radio rows use the
 * same .circle-row / .circle-pick classes as the start panel so the
 * picks render identically in both places. */
.mp-propose-group {
    margin-bottom: 0.85rem;
}

/* 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; }

/* ---------------------------------------------------------------- */
/* Move history panel (Group G).                                    */
/* ---------------------------------------------------------------- */

.move-history-panel {
    margin-top: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.9rem;
}
.move-history-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    user-select: none;
    font-weight: 600;
}
.move-history-summary::-webkit-details-marker { display: none; }
.move-history-summary::after {
    content: '▸';
    font-size: 0.8rem;
    opacity: 0.6;
    transition: transform 0.15s ease;
}
.move-history-panel[open] .move-history-summary::after {
    transform: rotate(90deg);
}
.mh-title { flex: 1; }
/* .mh-count base styling lives in shared/styles.css under
 * MATCH-SHAPE COLUMNS (.history-col .mh-count). */
.move-history-list {
    list-style: none;
    margin: 0;
    padding: 0 0.5rem 0.5rem;
    max-height: 260px;
    overflow-y: auto;
}
.move-history-list .mh-head,
.move-history-list .move-pair {
    display: grid;
    grid-template-columns: 2.4em 1fr 1fr;
    gap: 0.4rem;
    align-items: center;
    padding: 0.2rem 0.25rem;
    font-variant-numeric: tabular-nums;
}
.move-history-list .mh-head {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.6;
    padding-top: 0.35rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}
.mh-col-label { text-align: center; }
.mh-num {
    text-align: right;
    opacity: 0.6;
    font-size: 0.8rem;
}
.mh-move {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    color: inherit;
    padding: 0.25rem 0.4rem;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.mh-move:hover,
.mh-move:focus-visible {
    background: rgba(224,182,80,0.18);
    border-color: rgba(224,182,80,0.55);
    outline: none;
}
.mh-move.mh-empty {
    cursor: default;
    opacity: 0.3;
    font-weight: 400;
}
.mh-move[data-seat="A"] { color: var(--text-secondary, inherit); font-weight: 500; }

/* ---------------------------------------------------------------- */
/* Sound-effects toggle (Group I).                                  */
/* Mirrors the header .theme-toggle dimensions so the header icons  */
/* sit on a single visual row. Default state shows the speaker-on   */
/* icon; when body.ok-muted is set, shows the muted icon instead.   */
/* ---------------------------------------------------------------- */
.sound-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}
.sound-toggle:hover { color: var(--text); background: var(--bg-soft); }
.sound-toggle svg { width: 18px; height: 18px; display: none; }
.sound-toggle .sound-on-icon  { display: block; }
.sound-toggle .sound-off-icon { display: none; }
body.ok-muted .sound-toggle .sound-on-icon  { display: none; }
body.ok-muted .sound-toggle .sound-off-icon { display: block; }
body.ok-muted .sound-toggle { color: var(--danger, #d93025); }

/* Group H: keyboard focus ring for board cells. Only shows for
 * keyboard focus (not mouse click) via :focus-visible, so it doesn't
 * interfere with the normal click UX. Distinct from .last-move
 * (yellow) and .hinted (yellow/animated) — uses a blue ring. */
.cell:focus-visible {
    outline: none;
    box-shadow:
        inset 0 0 0 3px #4a90e2,
        inset 0 0 0 5px rgba(255,255,255,0.6);
    position: relative;
    z-index: 3;
}
[data-theme="dark"] .cell:focus-visible {
    box-shadow:
        inset 0 0 0 3px #6fb0ff,
        inset 0 0 0 5px rgba(0,0,0,0.5);
}

/* Board overlay when a move-history row is hovered/focused/tapped.
 * Uses a double inset ring so it reads over both light and dark squares
 * without clashing with .last-move, .hinted, or .selected. */
.cell.history-hl {
    box-shadow:
        inset 0 0 0 3px #e0b650,
        inset 0 0 0 5px rgba(0,0,0,0.35);
    position: relative;
    z-index: 2;
}

/* ---------------------------------------------------------------- */
/* Daily puzzle card (Phase 3B).                                    */
/* Sibling below .start-panel. One puzzle per calendar day, same    */
/* for everyone. Hidden while a game is active.                     */
/* ---------------------------------------------------------------- */
.daily-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem 1.1rem;
    margin: 0 0 1.5rem;
    position: relative;
}
.daily-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.daily-card-kicker {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--cat-strategy);
    margin: 0 0 0.15rem;
}
.daily-card-date {
    font-family: var(--font-hand);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}
.daily-card-streak {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--cat-strategy-bg);
    color: var(--cat-strategy);
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    white-space: nowrap;
}
.daily-card-body {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.daily-card-thumb {
    width: 96px;
    height: 96px;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg);
}
.daily-card-thumb svg {
    display: block;
    width: 100%;
    height: 100%;
}
.daily-card-text {
    flex: 1 1 180px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.daily-card-meta {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0;
}
.daily-card-action {
    display: flex;
}
.daily-card-action .btn-primary {
    width: 100%;
    min-height: 44px;
}
.daily-card-result {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.45;
}
.daily-card-result.solved { color: #1e7a47; }
.daily-card-result.partial { color: #b26b1f; }
.daily-card-result.missed { color: #a63333; }
[data-theme="dark"] .daily-card-result.solved { color: #7fdc9d; }
[data-theme="dark"] .daily-card-result.partial { color: #e5ba6b; }
[data-theme="dark"] .daily-card-result.missed { color: #e88a8a; }

@media (max-width: 480px) {
    .daily-card-body { gap: 0.75rem; }
    .daily-card-thumb { width: 72px; height: 72px; }
}

/* Daily puzzle run-over card inside the side-col .match-result element. */
.match-result.daily-card-result-inner { text-align: left; }
.match-result.daily-card-result-inner .daily-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    margin-bottom: 0.4rem;
}
.match-result.daily-card-result-inner .daily-badge.solved { background: #1e7a4722; color: #1e7a47; }
.match-result.daily-card-result-inner .daily-badge.partial { background: #b26b1f22; color: #b26b1f; }
.match-result.daily-card-result-inner .daily-badge.missed { background: #a6333322; color: #a63333; }
[data-theme="dark"] .match-result.daily-card-result-inner .daily-badge.solved { color: #7fdc9d; }
[data-theme="dark"] .match-result.daily-card-result-inner .daily-badge.partial { color: #e5ba6b; }
[data-theme="dark"] .match-result.daily-card-result-inner .daily-badge.missed { color: #e88a8a; }

/* Long inline URLs in the FAQ (invite-link example) must wrap on narrow
 * viewports — otherwise a single <code> exceeds 320px and triggers
 * horizontal scroll. */
.game-content p code,
.game-content li code {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Mode row now has 5 circles (Streak/Single/Speed/Bullet/Blitz) since
 * Phase 3A added Bullet + Blitz. At 64px each they wrapped to a 2nd
 * line on the desktop Mode column (≈310px wide) and pushed the
 * explainer list way below the Difficulty/Ruleset columns. Shrink
 * the op-row specifically so all 5 fit in a single row.
 * 5 × 48 + 4 × 6.4 ≈ 266px — comfortably under the column width. */

/* Align the three panel-col explainers to the same baseline. The Mode
 * row's 48px circles are taller than the Difficulty / Ruleset ovals,
 * so without a shared min-height the three explainer lists below each
 * row start at different Y positions. Pin every picker row to the same
 * reserved height so the lists line up. */
.panel-grid .circle-row {
    min-height: 56px;
    align-items: center;
}
