/* Games hub — soft warm minimal cards (+ game pages below) */

.games-hub {
    max-width: 800px;
    margin: 40px auto 48px;
    padding: 40px;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.games-hub-title {
    margin: 0 0 10px;
    font-size: 1.75rem;
    font-weight: 650;
    color: #1d1d1f;
}

.games-hub-lead {
    margin: 0 0 28px;
    color: #6e6e73;
    line-height: 1.6;
    font-size: 15px;
}

.games-hub-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.games-hub-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .games-hub-grid {
        grid-template-columns: 1fr 1fr;
        gap: 18px;
    }
}

.games-hub-card {
    display: block;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 16px;
    background: rgba(245, 242, 235, 0.72);
    text-decoration: none;
    color: inherit;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.07);
    -webkit-tap-highlight-color: transparent;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .games-hub-card:not(.is-soon):hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 22px rgba(0, 0, 0, 0.09);
        background: rgba(245, 242, 235, 0.88);
    }

    .games-hub-card:not(.is-soon):hover .games-hub-card-cta {
        opacity: 0.82;
    }
}

.games-hub-card:active:not(.is-soon) {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.games-hub-card.is-soon {
    background: rgba(245, 242, 235, 0.45);
    opacity: 0.78;
    pointer-events: none;
    box-shadow: none;
    border-color: rgba(0, 0, 0, 0.05);
}

.games-hub-card-media {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 88px;
    overflow: hidden;
    background: transparent;
    padding: 10px 16px 0;
    box-sizing: border-box;
}

.games-hub-card-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.games-hub-card-body {
    display: block;
    padding: 14px 16px 16px;
}

@media (min-width: 640px) {
    .games-hub-card-body {
        padding: 18px 22px 22px;
    }

    .games-hub-card-media {
        padding: 14px 22px 0;
    }
}

.games-hub-card-kicker {
    display: block;
    font-size: 12px;
    color: #86868b;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
    font-weight: 500;
}

.games-hub-card-title {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 6px;
}

.games-hub-card-desc {
    display: block;
    font-size: 13px;
    color: #6e6e73;
    line-height: 1.5;
}

.games-hub-card-cta {
    display: inline-block;
    margin-top: 14px;
    font-size: 14px;
    font-weight: 600;
    color: #b8a478;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

/* ---- Word Sprint ---- */
.ws-page {
    max-width: 640px;
    margin: 28px auto 48px;
    padding: 24px 20px 28px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 14px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.ws-back {
    display: inline-block;
    margin-bottom: 10px;
    color: #444;
    text-decoration: none;
    font-size: 14px;
}

.ws-back:hover {
    text-decoration: underline;
}

.ws-title {
    margin: 0 0 6px;
    font-size: 1.65rem;
    color: #111;
}

.ws-lead {
    margin: 0 0 18px;
    color: #555;
    font-size: 14px;
    line-height: 1.5;
}

.ws-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}

.ws-stat {
    text-align: center;
    padding: 10px 6px;
    background: #f5e3a1;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
}

.ws-stat-label {
    display: block;
    font-size: 11px;
    color: #5c4a16;
    margin-bottom: 2px;
}

.ws-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #111;
    font-variant-numeric: tabular-nums;
}

.ws-stage {
    min-height: 220px;
    padding: 18px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    background: #fff;
}

.ws-idle-copy {
    margin: 0 0 16px;
    color: #555;
    line-height: 1.55;
    font-size: 15px;
    text-align: center;
}

.ws-idle,
.ws-end {
    text-align: center;
}

.ws-mode {
    margin: 0 0 8px;
    font-size: 12px;
    color: #8a6a1a;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ws-prompt {
    margin: 0 0 16px;
    font-size: 1.45rem;
    font-weight: 650;
    color: #111;
    text-align: center;
    line-height: 1.35;
    min-height: 2.8em;
    word-break: break-word;
}

.ws-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.ws-input {
    flex: 1 1 180px;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(0, 0, 0, 0.22);
    border-radius: 8px;
    font-size: 16px;
    background: #fffdf5;
}

.ws-input:focus {
    outline: 2px solid rgba(168, 132, 42, 0.45);
    outline-offset: 1px;
}

.ws-input.is-wrong {
    animation: ws-shake 0.35s ease;
    border-color: #c45c4a;
}

.ws-btn {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 16px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: #eee;
    color: #111;
    text-align: center;
    text-decoration: none;
}

a.ws-btn:hover,
a.ws-btn:focus,
a.ws-btn:focus-visible {
    text-decoration: none;
    color: #111;
}

.ws-btn-primary {
    background: #f5e3a1;
}

.ws-btn-primary:hover {
    background: #ffe69c;
}

.ws-feedback {
    margin: 12px 0 0;
    min-height: 1.3em;
    text-align: center;
    font-size: 14px;
    color: #555;
}

.ws-feedback.is-ok {
    color: #1f6b3a;
}

.ws-feedback.is-bad {
    color: #a33b2c;
}

.ws-vkb {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    user-select: none;
    -webkit-user-select: none;
}

.ws-vkb[hidden] {
    display: none !important;
}

.ws-vkb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.ws-vkb-key {
    flex: 1 1 0;
    min-width: 0;
    max-width: 36px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.16);
    border-radius: 8px;
    background: #fffdf5 !important;
    color: #111 !important;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ws-vkb-key.is-wide {
    max-width: 64px;
    flex: 1.6 1 0;
    font-size: 13px;
}

.ws-vkb-key:hover,
.ws-vkb-key:focus,
.ws-vkb-key:focus-visible {
    background: #fffdf5 !important;
    color: #111 !important;
    outline: none;
}

.ws-vkb-key:active {
    transform: scale(0.96);
    opacity: 0.9;
    background: #f3efe3 !important;
}

.ws-end-title {
    margin: 0 0 10px;
    font-size: 1.35rem;
    font-weight: 700;
}

.ws-end-score,
.ws-end-streak,
.ws-end-best {
    margin: 0 0 6px;
    color: #333;
    font-size: 15px;
}

.ws-end .ws-btn {
    margin-top: 16px;
}

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

@keyframes ws-shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

@media (max-width: 560px) {
    .ws-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ws-prompt {
        font-size: 1.25rem;
    }

    .games-hub {
        margin-left: 0;
        margin-right: 0;
    }

    .ws-page {
        margin-left: 10px;
        margin-right: 10px;
    }

    .games-hub {
        padding: 20px 14px 24px;
    }

    .games-hub-card-media {
        height: 84px;
        padding: 8px 14px 0;
    }
}

@media (min-width: 561px) {
    .games-hub-card-media {
        height: 104px;
    }
}

/* ---- Meaning Match choices ---- */
/* Neutral stats on Meaning Match only (keep Sprint gold). */
.mm-page .ws-stat {
    background: #fffdf5;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.mm-page .ws-stat-label {
    color: #666;
}

.mm-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 4px;
}

.mm-choice {
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.16);
    border-radius: 10px;
    background: #fffdf5;
    color: #111;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    line-height: 1.25;
    transition: transform 0.08s ease, opacity 0.08s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mm-choice:disabled {
    cursor: default;
}

/* Beat global style.css `button:hover { background: #a8842a }` (sticky on mobile). */
.mm-choice:hover,
.mm-choice:focus,
.mm-choice:focus-visible {
    background: #fffdf5 !important;
    color: #111 !important;
    outline: none;
}

/* No yellow hover/active — only .is-correct / .is-wrong may recolor */
.mm-choice:active:not(:disabled) {
    transform: scale(0.98);
    opacity: 0.92;
    background: #fffdf5 !important;
}

.mm-choice.is-correct {
    background: #d8f3e0 !important;
    border-color: #1f6b3a !important;
    color: #14532d;
}

.mm-choice.is-wrong {
    background: #fde2de !important;
    border-color: #a33b2c !important;
    color: #7f1d1d;
    animation: ws-shake 0.35s ease;
}

@media (max-width: 420px) {
    .mm-choices {
        grid-template-columns: 1fr;
    }
}

/* Meaning Match — CEFR level picker (Phase 1; soft minimal, MM-scoped) */
.mm-page {
    position: relative;
}

.mm-level-chip {
    margin: 0 0 20px;
    font-size: 13px;
    color: #86868b;
    letter-spacing: 0.02em;
}

.mm-level-chip strong {
    margin-left: 6px;
    color: #1d1d1f;
    font-weight: 650;
}

/* Idle stack: level → copy → Play — comfortable gaps (mobile + desktop) */
.mm-page .ws-idle-copy {
    margin: 0 0 22px;
}

.mm-page .ws-idle .ws-btn {
    margin-top: 2px;
}

.mm-end-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
}

@media (min-width: 768px) {
    .mm-level-chip {
        margin-bottom: 24px;
    }

    .mm-page .ws-idle-copy {
        margin-bottom: 26px;
    }

    .mm-end-actions {
        margin-top: 20px;
        gap: 12px;
    }
}

.mm-level-modal {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(29, 29, 31, 0.28);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.mm-level-modal[hidden] {
    display: none !important;
}

.mm-level-modal-panel {
    width: min(360px, 100%);
    max-height: min(72vh, 540px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px;
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14);
}

.mm-level-modal-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 650;
    color: #1d1d1f;
    text-align: center;
}

.mm-level-modal-tip {
    margin: 0 4px 14px;
    font-size: 12px;
    line-height: 1.45;
    color: #86868b;
    text-align: center;
}

.mm-level-modal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mm-level-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 12px;
    background: rgba(245, 242, 235, 0.55);
    color: #1d1d1f;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.mm-level-option:hover {
    background: rgba(245, 242, 235, 0.9);
}

.mm-level-option.is-active {
    background: rgba(245, 242, 235, 0.95);
    border-color: rgba(184, 164, 120, 0.55);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.mm-level-option-name {
    font-size: 14px;
    font-weight: 650;
}

.mm-level-option-desc {
    font-size: 12px;
    font-weight: 500;
    color: #6e6e73;
    line-height: 1.35;
}

.mm-level-option.is-active .mm-level-option-desc {
    color: #5c5c60;
}

body.games-immersive .mm-page .mm-level-modal {
    position: fixed;
}

/* Meaning Match — mobile: Chinese cue mid-stage; English choices lower for thumbs. */
@media (max-width: 767px) {
    body.games-immersive .mm-page .ws-stage {
        justify-content: flex-start;
        align-items: stretch;
    }

    body.games-immersive .mm-page .ws-play:not([hidden]) {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        min-height: 0;
        height: 100%;
        flex: 1 1 auto;
        padding-bottom: max(16px, env(safe-area-inset-bottom, 0px), 20px);
        box-sizing: border-box;
    }

    /* Equal spacers center mode+prompt above the lower choices cluster */
    body.games-immersive .mm-page .ws-play:not([hidden])::before,
    body.games-immersive .mm-page .ws-play:not([hidden])::after {
        content: "";
        flex: 1 1 0;
        min-height: 0;
        pointer-events: none;
    }

    body.games-immersive .mm-page .ws-play:not([hidden])::before {
        order: 0;
    }

    body.games-immersive .mm-page .ws-play:not([hidden])::after {
        order: 3;
    }

    body.games-immersive .mm-page .ws-play .ws-mode {
        order: 1;
        flex-shrink: 0;
        margin-bottom: 6px;
    }

    body.games-immersive .mm-page .ws-play .ws-prompt {
        order: 2;
        flex-shrink: 0;
        margin-bottom: 0;
    }

    body.games-immersive .mm-page .mm-choices {
        order: 4;
        flex-shrink: 0;
        margin-top: 0;
        width: 100%;
    }

    body.games-immersive .mm-page .ws-play .ws-feedback {
        order: 5;
        flex-shrink: 0;
        margin-top: 10px;
        min-height: 1.2em;
    }
}

/* Meaning Match — desktop composition (Mac/widescreen). */
@media (min-width: 768px) {
    body.games-immersive .mm-page {
        padding-left: max(28px, env(safe-area-inset-left, 0px));
        padding-right: max(28px, env(safe-area-inset-right, 0px));
    }

    body.games-immersive .mm-page .ws-stats {
        width: 100%;
        max-width: 520px;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 16px;
        gap: 10px;
    }

    body.games-immersive .mm-page .ws-stat {
        padding: 10px 8px;
        border-radius: 12px;
    }

    body.games-immersive .mm-page .ws-stage {
        justify-content: center;
        align-items: center;
    }

    body.games-immersive .mm-page .ws-idle:not([hidden]),
    body.games-immersive .mm-page .ws-play:not([hidden]),
    body.games-immersive .mm-page .ws-end:not([hidden]) {
        width: 100%;
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }

    body.games-immersive .mm-page .ws-play:not([hidden]) {
        justify-content: center;
        gap: 2px;
        height: auto;
        flex: 0 1 auto;
    }

    body.games-immersive .mm-page .ws-play .ws-mode {
        margin: 0 0 10px;
        font-size: 12px;
        font-weight: 500;
        letter-spacing: 0.06em;
        color: #86868b;
        text-transform: uppercase;
    }

    body.games-immersive .mm-page .ws-play .ws-prompt {
        margin: 0 0 22px;
        font-size: 2rem;
        font-weight: 650;
        line-height: 1.25;
        letter-spacing: -0.02em;
        color: #1d1d1f;
    }

    body.games-immersive .mm-page .mm-choices {
        width: 100%;
        max-width: 480px;
        gap: 12px;
        margin-top: 0;
        /* Keep 2×2 on desktop even if base mobile rule stacks at 420px */
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.games-immersive .mm-page .mm-choice {
        min-height: 58px;
        padding: 14px 16px;
        border-radius: 12px;
        font-size: 17px;
        font-weight: 600;
        border-color: rgba(0, 0, 0, 0.1);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
        transition:
            transform 0.16s ease,
            opacity 0.16s ease,
            box-shadow 0.16s ease,
            background-color 0.16s ease;
    }

    @media (hover: hover) and (pointer: fine) {
        body.games-immersive .mm-page .mm-choice:not(:disabled):hover {
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
            transform: translateY(-1px);
        }
    }

    body.games-immersive .mm-page .ws-play .ws-feedback {
        margin-top: 14px;
        min-height: 1.35em;
        font-size: 14px;
        color: #6e6e73;
    }

    body.games-immersive .mm-page .ws-idle:not([hidden]),
    body.games-immersive .mm-page .ws-end:not([hidden]) {
        padding: 8px 4px 16px;
    }

    body.games-immersive .mm-page .mm-level-modal-panel {
        width: min(400px, 100%);
    }
}

/* Word Sprint — desktop composition (mirror Meaning Match). */
.ws-sprint-page {
    position: relative;
}

/* Sprint idle: level → copy → Play — comfortable gaps */
.ws-sprint-level-chip {
    margin: 0 0 20px;
    font-size: 13px;
    color: #86868b;
    letter-spacing: 0.02em;
}

.ws-sprint-level-chip strong {
    margin-left: 6px;
    color: #1d1d1f;
    font-weight: 650;
}

.ws-sprint-page .ws-idle-copy {
    margin: 0 0 22px;
}

.ws-sprint-page .ws-idle .ws-btn {
    margin-top: 2px;
}

.ws-sprint-end-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
}

.ws-sprint-page .ws-end .ws-sprint-end-actions .ws-btn {
    margin-top: 0;
}

/* Word Sprint — CEFR level picker (Phase 1; Sprint-scoped soft modal) */
.ws-sprint-level-modal {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(29, 29, 31, 0.28);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.ws-sprint-level-modal[hidden] {
    display: none !important;
}

.ws-sprint-level-modal-panel {
    width: min(360px, 100%);
    max-height: min(72vh, 540px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px;
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14);
}

.ws-sprint-level-modal-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 650;
    color: #1d1d1f;
    text-align: center;
}

.ws-sprint-level-modal-tip {
    margin: 0 4px 14px;
    font-size: 12px;
    line-height: 1.45;
    color: #86868b;
    text-align: center;
}

.ws-sprint-level-modal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ws-sprint-level-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 12px;
    background: rgba(245, 242, 235, 0.55);
    color: #1d1d1f;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.ws-sprint-level-option:hover {
    background: rgba(245, 242, 235, 0.9);
}

.ws-sprint-level-option.is-active {
    background: rgba(245, 242, 235, 0.95);
    border-color: rgba(184, 164, 120, 0.55);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.ws-sprint-level-option-name {
    font-size: 14px;
    font-weight: 650;
}

.ws-sprint-level-option-desc {
    font-size: 12px;
    font-weight: 500;
    color: #6e6e73;
    line-height: 1.35;
}

.ws-sprint-level-option.is-active .ws-sprint-level-option-desc {
    color: #5c5c60;
}

body.games-immersive .ws-sprint-page .ws-sprint-level-modal {
    position: fixed;
}

@media (min-width: 768px) {
    .ws-sprint-level-chip {
        margin-bottom: 24px;
    }

    .ws-sprint-page .ws-idle-copy {
        margin-bottom: 26px;
    }

    .ws-sprint-end-actions {
        margin-top: 20px;
        gap: 12px;
    }

    body.games-immersive .ws-sprint-page .ws-sprint-level-modal-panel {
        width: min(400px, 100%);
    }

    body.games-immersive .ws-sprint-page {
        padding-left: max(28px, env(safe-area-inset-left, 0px));
        padding-right: max(28px, env(safe-area-inset-right, 0px));
    }

    body.games-immersive .ws-sprint-page .ws-stats {
        width: 100%;
        max-width: 520px;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 16px;
        gap: 10px;
    }

    body.games-immersive .ws-sprint-page .ws-stat {
        padding: 10px 8px;
        border-radius: 12px;
    }

    body.games-immersive .ws-sprint-page .ws-stage {
        justify-content: center;
        align-items: center;
    }

    body.games-immersive .ws-sprint-page .ws-idle:not([hidden]),
    body.games-immersive .ws-sprint-page .ws-play:not([hidden]),
    body.games-immersive .ws-sprint-page .ws-end:not([hidden]) {
        width: 100%;
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }

    body.games-immersive .ws-sprint-page .ws-play:not([hidden]) {
        justify-content: center;
        gap: 2px;
        height: auto;
        flex: 0 1 auto;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-mode {
        margin: 0 0 10px;
        font-size: 12px;
        font-weight: 500;
        letter-spacing: 0.06em;
        color: #86868b;
        text-transform: uppercase;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-prompt {
        margin: 0 0 22px;
        font-size: 2rem;
        font-weight: 650;
        line-height: 1.25;
        letter-spacing: -0.02em;
        color: #1d1d1f;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-form {
        width: 100%;
        max-width: 420px;
        margin: 0 auto;
        flex-wrap: nowrap;
        gap: 10px;
        align-items: center;
    }

    body.games-immersive .ws-sprint-page .ws-input {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
        height: 48px;
        padding: 0 14px;
        border-radius: 12px;
        border-color: rgba(0, 0, 0, 0.12);
        background: #fff;
        font-size: 17px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }

    body.games-immersive .ws-sprint-page .ws-input:focus {
        outline: 2px solid rgba(184, 164, 120, 0.45);
        outline-offset: 1px;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-form .ws-btn {
        flex: 0 0 auto;
        height: 48px;
        min-width: 88px;
        padding: 0 18px;
        border-radius: 12px;
        border-color: rgba(0, 0, 0, 0.1);
        background: rgba(245, 242, 235, 0.95);
        color: #1d1d1f;
        transition: background-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-form .ws-btn-primary {
        background: rgba(245, 227, 161, 0.55);
        border-color: rgba(184, 164, 120, 0.45);
        color: #1d1d1f;
    }

    @media (hover: hover) and (pointer: fine) {
        body.games-immersive .ws-sprint-page .ws-play .ws-form .ws-btn-primary:hover,
        body.games-immersive .ws-sprint-page .ws-play .ws-form .ws-btn-primary:focus,
        body.games-immersive .ws-sprint-page .ws-play .ws-form .ws-btn-primary:focus-visible {
            background: rgba(245, 227, 161, 0.75) !important;
            color: #1d1d1f !important;
            box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
            outline: none;
        }
    }

    body.games-immersive .ws-sprint-page .ws-vkb:not([hidden]) {
        width: 100%;
        max-width: 420px;
        margin-left: auto;
        margin-right: auto;
        margin-top: 14px;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-feedback {
        margin-top: 14px;
        min-height: 1.35em;
        font-size: 14px;
        color: #6e6e73;
    }

    body.games-immersive .ws-sprint-page .ws-idle:not([hidden]),
    body.games-immersive .ws-sprint-page .ws-end:not([hidden]) {
        padding: 8px 4px 16px;
    }
}

/* Word Sprint — mobile: cue mid-stage; input/Submit just above letter keyboard. */
@media (max-width: 767px) {
    body.games-immersive .ws-sprint-page .ws-play:not([hidden]) {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        min-height: 0;
        height: 100%;
        flex: 1 1 auto;
        padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }

    /* Equal flex spacers center mode+prompt in the free space above the form cluster */
    body.games-immersive .ws-sprint-page .ws-play:not([hidden])::before,
    body.games-immersive .ws-sprint-page .ws-play:not([hidden])::after {
        content: "";
        flex: 1 1 0;
        min-height: 0;
        pointer-events: none;
    }

    body.games-immersive .ws-sprint-page .ws-play:not([hidden])::before {
        order: 0;
    }

    body.games-immersive .ws-sprint-page .ws-play:not([hidden])::after {
        order: 3;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-mode {
        order: 1;
        flex-shrink: 0;
        margin-bottom: 6px;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-prompt {
        order: 2;
        flex-shrink: 0;
        margin-bottom: 0;
    }

    /* Lower cluster: form → keyboard (Submit stays near keys) */
    body.games-immersive .ws-sprint-page .ws-play .ws-form {
        order: 4;
        margin-top: 0;
        width: 100%;
        flex-shrink: 0;
    }

    body.games-immersive .ws-sprint-page .ws-vkb:not([hidden]) {
        order: 5;
        margin-top: 12px !important; /* override shared games-immersive margin-top: auto */
        margin-bottom: 0;
        max-width: 100%;
        flex-shrink: 0;
    }

    body.games-immersive .ws-sprint-page .ws-play .ws-feedback {
        order: 6;
        margin-top: 8px;
        flex-shrink: 0;
        min-height: 1.2em;
    }
}

/* ---- Word Snake ---- */
.wsnek-page {
    position: relative;
    max-width: 640px;
}

.wsnek-top-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin: 0 0 8px;
}

.wsnek-action-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 12px;
    pointer-events: none;
}

.wsnek-action-overlay[hidden] {
    display: none !important;
}

.wsnek-action-overlay .ws-btn {
    min-width: 148px;
    pointer-events: auto;
}

.wsnek-over-title {
    margin: 0 0 4px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #7f1d1d;
    letter-spacing: 0.02em;
    pointer-events: none;
}

.wsnek-over-title[hidden] {
    display: none !important;
}

.wsnek-start-btn {
    min-width: 148px;
}

.wsnek-settings-modal {
    position: absolute;
    inset: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(20, 16, 8, 0.42);
}

.wsnek-settings-modal[hidden] {
    display: none !important;
}

.wsnek-settings-modal-panel {
    width: min(320px, 100%);
    padding: 14px 14px 12px;
    border-radius: 14px;
    background: #fffdf5;
    border: 1px solid rgba(138, 106, 26, 0.28);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
    text-align: center;
}

.wsnek-settings-modal-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #111;
}

.wsnek-settings-label {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
}

.wsnek-settings-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 12px;
}

.wsnek-settings-option {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid rgba(138, 106, 26, 0.28);
    border-radius: 10px;
    background: #fff;
    color: #5c4a16;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.wsnek-settings-option.is-active {
    background: #f5e3a1;
    border-color: rgba(138, 106, 26, 0.7);
    color: #1a1a1a;
}

.wsnek-page.wsnek-dpad-left .wsnek-dpad {
    margin-left: max(12px, env(safe-area-inset-left, 0px));
    margin-right: auto;
    justify-self: start;
    align-self: flex-start;
}

.wsnek-page.wsnek-dpad-right .wsnek-dpad {
    margin-left: auto;
    margin-right: max(12px, env(safe-area-inset-right, 0px));
    justify-self: end;
    align-self: flex-end;
}

.wsnek-page.wsnek-dpad-center .wsnek-dpad {
    margin-left: auto;
    margin-right: auto;
    align-self: center;
}

.wsnek-level-modal {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(20, 16, 8, 0.42);
}

.wsnek-level-modal[hidden] {
    display: none !important;
}

.wsnek-level-modal-panel {
    width: min(360px, 100%);
    max-height: min(70vh, 520px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px;
    border-radius: 14px;
    background: #fffdf5;
    border: 1px solid rgba(138, 106, 26, 0.28);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
}

.wsnek-level-modal-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #111;
    text-align: center;
}

.wsnek-level-modal-tip {
    margin: 0 4px 12px;
    padding: 0;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    color: #8a8a8e;
    text-align: center;
    overflow-wrap: anywhere;
}

.wsnek-level-modal-tip-link {
    color: #6b4f14;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.wsnek-level-modal-tip-link:hover {
    color: #1d1d1f;
}

.wsnek-level-modal-tip[hidden] {
    display: none;
}

.wsnek-level-modal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wsnek-level-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(138, 106, 26, 0.28);
    border-radius: 10px;
    background: #fff;
    color: #5c4a16;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.wsnek-level-option.is-active {
    background: #f5e3a1;
    border-color: rgba(138, 106, 26, 0.7);
    color: #1a1a1a;
}

.wsnek-level-option.is-locked {
    opacity: 0.55;
    cursor: not-allowed;
    background: #f7f7f7;
    color: #888;
}

.wsnek-level-option.is-locked.is-active {
    background: #f7f7f7;
    border-color: rgba(138, 106, 26, 0.28);
    color: #888;
}

.wsnek-level-option-name {
    font-size: 14px;
    font-weight: 700;
}

.wsnek-level-option-desc {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    line-height: 1.35;
}

.wsnek-level-option-lock {
    font-size: 11px;
    font-weight: 600;
    color: #8a6a1a;
    line-height: 1.3;
    margin-top: 2px;
}

.wsnek-level-option.is-locked .wsnek-level-option-desc {
    color: #999;
}

.wsnek-level-option.is-active .wsnek-level-option-desc {
    color: #444;
}

.wsnek-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0 0 10px;
}

.wsnek-chip {
    display: inline-block;
    min-width: 52px;
    text-align: center;
    padding: 4px 10px;
    border-radius: 8px;
    background: #f5e3a1;
    border: 1px solid rgba(138, 106, 26, 0.4);
    color: #5c4a16;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.wsnek-lives {
    color: #8a6a1a;
    font-size: 15px;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
}

.wsnek-metric {
    font-size: 13px;
    color: #555;
}

.wsnek-metric strong {
    color: #111;
    font-variant-numeric: tabular-nums;
    margin-left: 4px;
}

.wsnek-cue {
    width: 100%;
    max-width: 420px;
    margin: 0 auto 12px;
    padding: 12px 14px;
    border: 1px solid rgba(138, 106, 26, 0.22);
    border-radius: 12px;
    background: #fffdf5;
    text-align: center;
    min-height: 88px;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .wsnek-cue {
        max-width: min(780px, 100%);
    }
}

.wsnek-zh {
    margin: 0 0 4px;
    font-size: 1.35rem;
    font-weight: 650;
    color: #111;
    line-height: 1.3;
    min-height: 1.3em;
}

.wsnek-en {
    margin: 0 0 8px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    min-height: 1.2em;
}

.wsnek-cue.is-idle-tip .wsnek-zh {
    font-size: 1.05rem;
    font-weight: 600;
    color: #5c4a16;
    line-height: 1.35;
}

.wsnek-cue.is-idle-tip .wsnek-en {
    color: #8a7a4a;
}

.wsnek-progress {
    display: none;
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: #8a6a1a;
    font-variant-numeric: tabular-nums;
    min-height: 0;
}

.wsnek-feedback {
    margin: 6px 0 0;
    min-height: 1.2em;
    font-size: 13px;
    font-weight: 600;
    color: #2f5d50;
}

.wsnek-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.wsnek-status {
    font-size: 13px;
    color: #8a6a1a;
    font-weight: 600;
}

.wsnek-board-wrap {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto 14px;
    border: 1px solid rgba(138, 106, 26, 0.28);
    border-radius: 12px;
    overflow: visible;
    background: #fffdf5;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .wsnek-board-wrap {
        max-width: min(780px, 100%);
    }
}

.wsnek-canvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    touch-action: none;
    background: #fffdf5;
    vertical-align: top;
}

.wsnek-dpad {
    display: grid;
    grid-template-columns: repeat(3, 65px);
    grid-template-rows: repeat(3, 65px);
    gap: 8px;
    justify-content: center;
    margin: 0 auto 10px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.wsnek-pad-btn {
    min-width: 65px;
    min-height: 65px;
    border: 1px solid rgba(138, 106, 26, 0.4);
    border-radius: 10px;
    background: #fffdf5;
    color: #8a6a1a;
    font-size: 25px;
    font-weight: 700;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.wsnek-pad-btn:active {
    background: #f5e3a1;
}

.wsnek-pad-up {
    grid-column: 2;
    grid-row: 1;
}

.wsnek-pad-left {
    grid-column: 1;
    grid-row: 2;
}

.wsnek-pad-down {
    grid-column: 2;
    grid-row: 2;
}

.wsnek-pad-right {
    grid-column: 3;
    grid-row: 2;
}

.wsnek-hint {
    margin: 0;
    text-align: center;
    font-size: 12px;
    color: #666;
    line-height: 1.45;
}

@media (min-width: 640px) {
    .wsnek-dpad {
        /* Still available on tablet/desktop; keys work too */
        margin-bottom: 12px;
    }
}

.wsnek-results-modal {
    position: absolute;
    inset: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(20, 16, 8, 0.42);
}

.wsnek-results-modal[hidden] {
    display: none !important;
}

.wsnek-results-modal-panel {
    width: min(340px, 100%);
    max-height: min(70vh, 480px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 16px 14px;
    border-radius: 14px;
    background: #fffdf5;
    border: 1px solid rgba(138, 106, 26, 0.28);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
    text-align: center;
}

.wsnek-results-modal-title {
    margin: 0 0 12px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #111;
}

.wsnek-results-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px 6px;
    margin: 0 0 10px;
    padding: 8px 2px;
    border-radius: 10px;
    background: rgba(138, 106, 26, 0.06);
}

.wsnek-results-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 0;
    text-align: center;
}

.wsnek-results-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: #7a6a3a;
    letter-spacing: 0.01em;
    line-height: 1.2;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.wsnek-results-stat-value {
    font-size: 14px;
    font-weight: 700;
    color: #111;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.wsnek-results-comment {
    margin: 0 0 12px;
    padding: 0 2px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    color: #6b5c2e;
    text-align: center;
}

.wsnek-results-heading {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 650;
    color: #666;
    letter-spacing: 0.02em;
    text-align: left;
}

.wsnek-results-words {
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    max-height: 7.5em;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    text-align: left;
}

.wsnek-results-words li {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-size: 14px;
    line-height: 1.35;
}

.wsnek-results-en {
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #111;
}

.wsnek-results-zh {
    font-size: 12px;
    color: #666;
}

.wsnek-results-empty {
    font-size: 13px;
    color: #888;
}

/* ---- Word Snake immersive (fullscreen play) ---- */
/* html.wsnek-immersive: early boot from ?play=1 before body class is applied */
html.wsnek-immersive {
    overflow: hidden !important;
}

html.wsnek-immersive .navbar,
html.wsnek-immersive .site-footer,
body.wsnek-immersive .navbar,
body.wsnek-immersive .site-footer {
    display: none !important;
}

body.wsnek-immersive {
    overflow: hidden !important;
    position: relative;
    height: 100%;
    width: 100%;
}

body.wsnek-immersive main.container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body.wsnek-immersive .wsnek-page {
    position: fixed;
    inset: 0;
    z-index: 10000;
    box-sizing: border-box;
    max-width: none;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fffdf5;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
}

body.wsnek-immersive .wsnek-page .ws-title,
body.wsnek-immersive .wsnek-page .ws-lead,
body.wsnek-immersive .wsnek-hint {
    display: none;
}

body.wsnek-immersive .wsnek-page .ws-top {
    flex-shrink: 0;
    margin: 0;
}

body.wsnek-immersive .wsnek-top-row {
    margin: 0;
}

body.wsnek-immersive .wsnek-page .ws-back {
    margin: 0;
    font-size: 13px;
}

/* Always hide top nav / HUD / toolbar — actions live on board overlays only. */
body.wsnek-immersive .wsnek-page .ws-top,
body.wsnek-immersive .wsnek-page .wsnek-hud,
body.wsnek-immersive .wsnek-page .wsnek-toolbar {
    display: none !important;
}

body.wsnek-immersive .wsnek-level-modal,
body.wsnek-immersive .wsnek-results-modal,
body.wsnek-immersive .wsnek-settings-modal {
    position: absolute;
    inset: 0;
    z-index: 40;
}

body.wsnek-immersive .wsnek-results-modal {
    z-index: 45;
}

body.wsnek-immersive .wsnek-settings-modal {
    z-index: 45;
}

body.wsnek-immersive .wsnek-dpad {
    flex-shrink: 0;
    margin-top: 2px;
    margin-bottom: 0;
    gap: 5px;
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(3, 55px);
}

body.wsnek-immersive .wsnek-page.wsnek-dpad-center .wsnek-dpad {
    margin-left: auto;
    margin-right: auto;
}

body.wsnek-immersive .wsnek-page.wsnek-dpad-left .wsnek-dpad {
    margin-left: max(12px, env(safe-area-inset-left, 0px));
    margin-right: auto;
}

body.wsnek-immersive .wsnek-page.wsnek-dpad-right .wsnek-dpad {
    margin-left: auto;
    margin-right: max(12px, env(safe-area-inset-right, 0px));
}

body.wsnek-immersive .wsnek-hud {
    flex-shrink: 0;
    margin: 0;
    gap: 8px 10px;
}

/* Cue always visible; same width as board so the column never jumps. */
body.wsnek-immersive .wsnek-cue {
    flex-shrink: 0;
    width: 100%;
    max-width: min(480px, 100%);
    margin: 0 auto;
    min-height: 52px;
    padding: 6px 8px;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    body.wsnek-immersive .wsnek-cue {
        max-width: min(780px, 100%);
    }
}

body.wsnek-immersive .wsnek-zh {
    margin: 0;
    font-size: 1.15rem;
    min-height: 1.3em;
}

body.wsnek-immersive .wsnek-en {
    margin: 2px 0 0;
    font-size: 12px;
    min-height: 1.2em;
}

body.wsnek-immersive .wsnek-cue.is-idle-tip .wsnek-zh {
    font-size: 0.95rem;
    font-weight: 600;
    color: #5c4a16;
    line-height: 1.35;
}

body.wsnek-immersive .wsnek-cue.is-idle-tip .wsnek-en {
    color: #8a7a4a;
}

body.wsnek-immersive .wsnek-progress {
    display: none;
}

body.wsnek-immersive .wsnek-feedback {
    display: none;
}

body.wsnek-immersive .wsnek-toolbar {
    flex-shrink: 0;
    margin: 0;
    gap: 6px;
}

body.wsnek-immersive .wsnek-toolbar .ws-btn {
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

body.wsnek-immersive .wsnek-status {
    font-size: 12px;
}

body.wsnek-immersive .wsnek-board-wrap {
    position: relative;
    box-sizing: border-box;
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    max-width: min(480px, 100%);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 10px;
}

@media (min-width: 640px) {
    body.wsnek-immersive .wsnek-board-wrap {
        max-width: min(780px, 100%);
    }
}

body.wsnek-immersive .wsnek-canvas {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

body.wsnek-immersive .wsnek-pad-btn {
    min-width: 60px;
    min-height: 55px;
    font-size: 23px;
}

/* ---- Shared immersive shell (Word Sprint / Meaning Match) ---- */
/* Does not replace Word Snake's wsnek-immersive. */
html.games-immersive {
    overflow: hidden !important;
}

html.games-immersive .navbar,
html.games-immersive .site-footer,
body.games-immersive .navbar,
body.games-immersive .site-footer {
    display: none !important;
}

body.games-immersive {
    overflow: hidden !important;
    position: relative;
    height: 100%;
    width: 100%;
}

body.games-immersive main.container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body.games-immersive .ws-page {
    position: fixed;
    inset: 0;
    z-index: 1;
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: max(10px, env(safe-area-inset-top, 0px)) 14px max(14px, env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    box-shadow: none;
    background: #fffdf5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.games-immersive .ws-page .ws-title,
body.games-immersive .ws-page .ws-lead {
    display: none !important;
}

body.games-immersive .ws-page .ws-top {
    flex-shrink: 0;
    margin: 0;
}

body.games-immersive .ws-page .ws-back {
    margin-bottom: 8px;
}

body.games-immersive .ws-stats {
    flex-shrink: 0;
    margin-bottom: 10px;
    gap: 6px;
}

body.games-immersive .ws-stat {
    padding: 8px 4px;
}

body.games-immersive .ws-stat-value {
    font-size: 1.1rem;
}

body.games-immersive .ws-stage {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Immersive `display:flex` must not override the hidden attribute. */
body.games-immersive .ws-idle[hidden],
body.games-immersive .ws-play[hidden],
body.games-immersive .ws-end[hidden] {
    display: none !important;
}

body.games-immersive .ws-idle,
body.games-immersive .ws-play,
body.games-immersive .ws-end {
    width: 100%;
}

body.games-immersive .ws-play:not([hidden]) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

body.games-immersive .ws-end:not([hidden]),
body.games-immersive .ws-idle:not([hidden]) {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body.games-immersive .ws-play .ws-mode {
    flex-shrink: 0;
    margin: 0 0 4px;
}

body.games-immersive .ws-play .ws-prompt {
    flex-shrink: 0;
    min-height: 0;
    margin: 0 0 8px;
    font-size: 1.2rem;
}

body.games-immersive .ws-play .ws-form {
    flex-shrink: 0;
    margin: 0;
}

body.games-immersive .ws-play .ws-feedback {
    flex-shrink: 0;
    margin: 8px 0 0;
    min-height: 1.2em;
}

body.games-immersive .ws-vkb:not([hidden]) {
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: 0;
    max-width: min(420px, 100%);
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
}

body.games-immersive .ws-vkb-key {
    height: 40px;
    font-size: 13px;
}

/* ---- Word Snake Rankings (Apple polish — scoped) ---- */
.ws-rankings {
    padding: 32px 18px 60px;
    max-width: 640px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "PingFang SC", "Noto Sans SC", sans-serif;
}

.ws-rankings-panel {
    padding: 30px 28px 26px;
    background: rgba(255, 255, 255, 0.94);
    border: none;
    border-radius: 22px;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .ws-rankings-panel {
        background: rgba(255, 255, 255, 0.86);
        -webkit-backdrop-filter: saturate(180%) blur(18px);
        backdrop-filter: saturate(180%) blur(18px);
    }
}

.ws-rankings-back {
    margin-bottom: 20px;
    color: #6e6e73;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: color 0.22s ease;
}

.ws-rankings-back::before {
    content: "‹";
    margin-right: 4px;
    font-size: 1.15em;
    font-weight: 400;
}

.ws-rankings-back:hover {
    color: #1d1d1f;
    text-decoration: none;
}

.ws-rankings-back:focus-visible {
    outline: 2px solid rgba(138, 106, 26, 0.45);
    outline-offset: 3px;
    border-radius: 4px;
}

.ws-rankings-hero {
    margin: 0 0 22px;
}

.ws-rankings-title {
    display: block;
    margin: 0 0 14px;
    padding: 0;
    background: none;
    border-radius: 0;
    font-size: clamp(1.7rem, 4vw, 2.05rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    color: #1d1d1f;
    line-height: 1.15;
}

.ws-rankings-board-subtitle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.ws-rankings-board-badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    background: rgba(245, 227, 161, 0.4);
    border: none;
    font-size: 11px;
    font-weight: 500;
    color: #6b5a28;
    letter-spacing: 0.01em;
}

.ws-rankings-board-level {
    font-size: 12px;
    font-weight: 500;
    color: #aeaeb2;
    letter-spacing: 0.02em;
}

.ws-rankings-levels {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    margin: 0 0 20px;
    padding: 3px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #f5f5f7;
    border-radius: 12px;
}

.ws-rankings-levels::-webkit-scrollbar {
    display: none;
}

.ws-rankings-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 13px;
    box-sizing: border-box;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: #6e6e73;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

@media (min-width: 561px) {
    .ws-rankings-level {
        flex: 1 0 auto;
    }
}

.ws-rankings-level:hover {
    text-decoration: none;
    color: #1d1d1f;
}

.ws-rankings-level:focus-visible {
    outline: 2px solid rgba(138, 106, 26, 0.45);
    outline-offset: 1px;
    color: #1d1d1f;
}

.ws-rankings-level.is-active {
    background: #fff;
    color: #1d1d1f;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 1px rgba(0, 0, 0, 0.04);
}

.ws-rankings-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    margin: 0 0 24px;
}

.ws-rankings-actions .ws-btn {
    margin: 0;
    text-decoration: none;
    border-radius: 10px;
    border-color: transparent;
    transition: background-color 0.22s ease, opacity 0.22s ease, box-shadow 0.22s ease;
}

.ws-rankings-actions .ws-btn:focus-visible {
    outline: 2px solid rgba(138, 106, 26, 0.45);
    outline-offset: 2px;
}

.ws-rankings-actions .ws-btn-primary:hover {
    background: #ffe9a8;
}

.ws-rankings-secondary {
    font-size: 14px;
    font-weight: 500;
    color: #6e6e73;
    text-decoration: none;
    background: none;
    border: none;
    transition: color 0.22s ease, opacity 0.22s ease;
}

.ws-rankings-secondary:hover {
    color: #1d1d1f;
    opacity: 0.85;
}

.ws-rankings-secondary:focus-visible {
    outline: 2px solid rgba(138, 106, 26, 0.45);
    outline-offset: 3px;
    border-radius: 4px;
}

.ws-rankings-you {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr) auto auto;
    gap: 10px 12px;
    align-items: center;
    margin: 0 0 22px;
    padding: 14px 16px;
    background: rgba(245, 227, 161, 0.22);
    border: none;
    border-radius: 14px;
    box-shadow: inset 0 0 0 1px rgba(138, 106, 26, 0.08);
}

.ws-rankings-you-rank {
    font-size: 15px;
    font-weight: 600;
    color: #8a6a1a;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.ws-rankings-you-play {
    margin: 0;
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
    text-decoration: none;
    border-radius: 10px;
    border-color: transparent;
    transition: background-color 0.22s ease, opacity 0.22s ease;
}

.ws-rankings-you-play:focus-visible {
    outline: 2px solid rgba(138, 106, 26, 0.45);
    outline-offset: 2px;
}

.ws-rankings-you-none {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0;
    font-size: 14px;
    color: #aeaeb2;
}

.ws-rankings-status {
    margin: 0;
    flex: 1 1 auto;
    font-size: 14px;
    color: #6e6e73;
    line-height: 1.4;
}

.ws-rankings-status strong {
    color: #1d1d1f;
    font-weight: 600;
}

.ws-rankings-status-score {
    margin-left: 8px;
    color: #aeaeb2;
}

.ws-rankings-board {
    margin: 0;
}

.ws-rankings-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ws-rankings-row {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    gap: 10px 12px;
    align-items: center;
    padding: 14px 10px;
    border: none;
    border-radius: 12px;
}

.ws-rankings-row.is-top {
    background: rgba(230, 216, 190, 0.08);
}

.ws-rankings-row.is-me {
    background: rgba(245, 227, 161, 0.28);
}

.ws-rankings-rank {
    font-size: 16px;
    font-weight: 500;
    color: #aeaeb2;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.ws-rankings-row.is-top .ws-rankings-rank {
    color: #8a6a1a;
    font-weight: 600;
}

.ws-rankings-player {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ws-rankings-name {
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ws-rankings-meta {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    color: #aeaeb2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ws-rankings-row-title {
    font-size: inherit;
    font-weight: 500;
    color: #8a6a1a;
}

.ws-rankings-row.is-top .ws-rankings-row-title {
    color: #6b4f14;
}

.ws-rankings-meta-sep {
    color: #c7c7cc;
    font-weight: 400;
}

.ws-rankings-region {
    font-size: inherit;
    font-weight: 400;
    color: #aeaeb2;
}

.ws-rankings-score {
    font-size: 17px;
    font-weight: 600;
    color: #1d1d1f;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.ws-rankings-row.is-top .ws-rankings-score {
    color: #5c4a16;
}

.ws-rankings-empty {
    margin: 0;
    padding: 32px 8px;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: #aeaeb2;
}

.ws-rankings-footnote {
    margin: 26px 0 0;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 11px;
    line-height: 1.5;
    color: #aeaeb2;
}

@media (max-width: 560px) {
    .ws-rankings {
        padding: 18px 12px 44px;
    }

    .ws-rankings-panel {
        padding: 24px 18px 20px;
        border-radius: 20px;
    }

    .ws-rankings-title {
        font-size: 1.55rem;
        margin-bottom: 12px;
    }

    .ws-rankings-actions {
        margin-bottom: 20px;
    }

    .ws-rankings-you {
        grid-template-columns: 2rem minmax(0, 1fr) auto;
        padding: 12px 12px;
    }

    .ws-rankings-you-play {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .ws-rankings-row {
        padding: 12px 8px;
        gap: 10px;
    }

    .ws-rankings-footnote {
        margin-top: 22px;
    }
}
