.kanji-text {
    font-size: 3.9rem;
    font-weight: 600;
    color: #f0a8c0;
    line-height: 1.2;
    font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Noto Sans SC", "PingFang SC", sans-serif;
}

.kanji-text:empty,
.romanization-text:empty,
.english-text:empty,
.path-a-text:empty {
    display: none;
}

/* Glyph face: collapse only when Show glyph is off (no reserve-glyph).
   Inter-card clearDisplay() blanks the glyph for ~40ms — without a reserve
   the 5rem face display:none's and the plate/buttons jump. */
.hangul-text:empty,
.kana-text:empty {
    display: none;
}

/* RSVP width lock: .display-area uses width:min(560px,100%) in style.css so
   the plate does not grow/shrink with glyph length during card cycle. */

/* RSVP stability: when Show reading / Show meaning / Show glyph are on, keep
   the slot height even if the line is temporarily blank (delayed reveal,
   inter-card clear). Avoids glyph + Got it/Nope jumping. Toggle off still
   collapses via :empty { display:none } above. */
.card-display.reserve-reading .romanization-text:empty,
.card-display.reserve-meaning .english-text:empty,
.card-display.reserve-glyph .hangul-text:empty,
.card-display.reserve-glyph .kana-text:empty {
    display: block;
    visibility: hidden;
}

/* Empty block boxes do not form a line box — min-height is what keeps the slot */
.card-display.reserve-glyph .hangul-text:empty,
.card-display.reserve-glyph .kana-text:empty {
    min-height: 1.15em;
}

.card-display {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.kanji-text,
.hangul-text,
.kana-text,
.romanization-text,
.english-text,
.path-a-text {
    white-space: normal;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

/* Dual-path phrase chrome (contract four lines). Distinct from kanji pink. */
.path-a-text {
    font-size: 1.35rem;
    font-weight: 500;
    color: #9db4c8;
    margin-top: 8px;
    margin-bottom: 2px;
    line-height: 1.35;
    font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
    letter-spacing: 0.01em;
}

.card-display.dual-path {
    gap: 2px;
}

/* Contract order: parent → Path A → interpretation (glyph) → parent-letters (reading) */
.card-display.dual-path .english-text {
    order: 1;
    margin-top: 0;
    margin-bottom: 4px;
    font-size: 1.05rem;
    color: var(--text-secondary, #8b949e);
}

.card-display.dual-path .path-a-text {
    order: 2;
    margin-top: 4px;
}

.card-display.dual-path .kana-text,
.card-display.dual-path .hangul-text {
    order: 3;
    margin-top: 6px;
}

.card-display.dual-path .romanization-text {
    order: 4;
}

.card-display.dual-path .kanji-text {
    order: 0;
}

.hidden {
    display: none !important;
}

.editor-link {
    display: block;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    margin: 0 0 16px;
    padding: 6px 12px;
    border-radius: 6px;
}

/* Practice Back — visible control to language landing */
.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    box-sizing: border-box;
    width: 100%;
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    line-height: 1.2;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.back-link::before {
    content: "←";
    font-weight: 700;
    opacity: 0.9;
}

.back-link:hover,
.back-link:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    outline: none;
}

.back-link--bar {
    /* superseded by .close-x in mobile bar */
    display: none;
}

.parent-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.parent-choice {
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.parent-choice[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
}

.parent-choice:disabled {
    opacity: 0.35;
    cursor: default;
}

.checkbox-label input:disabled + span {
    opacity: 0.45;
}

.quiz-instruction {
    margin: 10px 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.4;
}

.quiz-options {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.quiz-input-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.quiz-prompt {
    font-size: 1.1rem;
    color: var(--text-secondary);
    text-align: center;
}

.quiz-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.quiz-answer-input {
    width: 300px;
    max-width: 100%;
    padding: 14px 18px;
    font-size: 1.1rem;
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
}

.quiz-feedback {
    min-height: 60px;
    padding: 12px 20px;
    border-radius: 8px;
    text-align: center;
    max-width: 420px;
}

.quiz-feedback.correct {
    background-color: rgba(35, 134, 54, 0.2);
    border: 1px solid var(--btn-green);
}

.quiz-feedback.incorrect {
    background-color: rgba(218, 54, 51, 0.2);
    border: 1px solid var(--btn-red);
}

@media (max-width: 600px) {
    .quiz-form {
        flex-direction: column;
        width: 100%;
    }

    .quiz-answer-input,
    .quiz-form .btn {
        width: 100%;
        max-width: 300px;
    }
}


/* Phone: keep remaining/score inside the card plate; dual-path needs room */
@media (max-width: 900px) {
    .display-area {
        overflow: hidden;
        box-sizing: border-box;
    }

    .stats-panel {
        position: static;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 8px;
        padding: 0 2px;
        text-align: left;
    }

    .remaining-count {
        align-items: flex-start;
        min-width: 0;
        flex: 0 1 auto;
    }

    #remaining-number {
        font-size: clamp(1.35rem, 6vw, 1.75rem);
    }

    .remaining-label {
        font-size: 0.65rem;
    }

    .session-stats {
        margin-top: 0;
        text-align: right;
        min-width: 0;
        flex: 1 1 auto;
        font-size: 0.75rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 480px) {
    .stats-panel {
        gap: 6px;
        margin-bottom: 6px;
    }

    #remaining-number {
        font-size: 1.25rem;
    }

    .session-stats {
        font-size: 0.7rem;
    }
}

/* Card chrome responsive — keep kanji as target-script scale */
@media (max-width: 900px) {
    .kanji-text {
        font-size: clamp(2.6rem, 10vw, 3.6rem);
    }

    .back-link--bar {
        min-height: 44px;
        min-width: 88px;
    }
}

@media (max-width: 600px) {
    .kanji-text {
        font-size: clamp(2.2rem, 12vw, 3.2rem);
    }
}

/* Exit in practice mobile bar — transparent text (was × / Quit) */
.close-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 3.25rem;
    min-height: 44px;
    margin: 0;
    padding: 0 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #dce6ff;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.2;
    text-decoration: none;
    flex-shrink: 0;
    opacity: 0.95;
    cursor: pointer;
    position: relative;
    z-index: 25;
    pointer-events: auto;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.close-x:hover,
.close-x:focus-visible {
    opacity: 1;
    color: #fff;
    outline: none;
}

/* Don't clip Exit — title stripe used overflow:hidden */
@media (max-width: 900px) {
    .mobile-bar {
        overflow: visible;
    }
}

/* Settings lives with Pause / Stop on phone; hidden on wide layout (side panel always open) */
.control-buttons .settings-toggle {
    display: none;
}

@media (max-width: 900px) {
    .mobile-bar .mobile-bar-spacer {
        display: block;
        width: 44px;
        min-width: 44px;
        flex-shrink: 0;
    }

    /* Transparent, no border; Settings flush left; → shows open direction */
    .control-buttons .settings-toggle.btn-settings {
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.35rem;
        width: 100%;
        min-height: 44px;
        padding: 12px 16px;
        border: none;
        border-radius: 8px;
        background: transparent;
        color: var(--text-primary);
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        order: -1; /* Settings above Pause / Reset when stacked */
        text-align: left;
    }

    .control-buttons .settings-toggle.btn-settings::after {
        content: "→";
        font-weight: 700;
        opacity: 0.9;
        speak: none;
    }

    .control-buttons .settings-toggle.btn-settings[aria-expanded="true"] {
        background: transparent;
        color: var(--accent);
        border: none;
    }

    /* When controls are a row (not yet stacked), keep Settings inline */
    @media (min-width: 481px) {
        .control-buttons {
            flex-wrap: wrap;
        }
        .control-buttons .settings-toggle.btn-settings {
            width: auto;
            flex: 1 1 auto;
            order: 0;
        }
    }
}

/* Settings drawer × — transparent; closes drawer → card (existing JS) */
.side-panel .panel-close {
    background: transparent !important;
    border-color: rgba(220, 230, 255, 0.35);
}

.side-panel .panel-close:hover,
.side-panel .panel-close:focus-visible {
    background: transparent !important;
    border-color: var(--accent, #e0b84a);
    color: #fff;
}

/* Settings drawer: no Back link — panel × returns to practice card */
.side-panel > .back-link {
    display: none !important;
}



/* Desktop Exit — top-right of main chrome (not in sidebar/selection header) */
.exit-main {
    display: none;
}

@media (min-width: 901px) {
    .main-content {
        position: relative;
    }
    .exit-main {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 8px;
        right: 12px;
        z-index: 25;
        pointer-events: auto;
        min-height: 44px;
        padding: 0 12px;
        border: none;
        border-radius: 8px;
        background: transparent;
        color: #dce6ff;
        font-size: 1rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        line-height: 1.2;
        text-decoration: none;
        flex-shrink: 0;
        opacity: 0.95;
        cursor: pointer;
        transition: opacity 0.15s ease, color 0.15s ease;
    }
    .exit-main:hover,
    .exit-main:focus-visible {
        opacity: 1;
        color: #fff;
        outline: none;
    }
    /* Legacy class if any leftover markup */
    .quit-desktop {
        display: none !important;
    }
}

@media (max-width: 900px) {
    .exit-main,
    .quit-desktop {
        display: none !important;
    }
}


/* Numbers handoff under Select Deck (KO/JA) */
.numbers-handoff {
  margin: 0.55rem 0 0.15rem;
}
.numbers-handoff-btn {
  width: 100%;
  justify-content: center;
}
.numbers-handoff-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.35;
}
