/* Result, mistakes, and stage records UI extracted from styles.css. */

.result-screen-backdrop {
    background: rgba(15, 23, 42, 0.2) !important;
    /* Very subtle dark tint */
    backdrop-filter: blur(14px) brightness(0.55) contrast(0.9) !important;
    /* Strong blur and dimming */
    -webkit-backdrop-filter: blur(14px) brightness(0.55) contrast(0.9) !important;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.result-modal-glass {
    position: relative;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    max-height: 94dvh;
    isolation: isolate;
    border: 2px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 2rem !important;
    background: rgba(15, 23, 42, 0.75) !important;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.8),
        inset 0 2px 0 rgba(255, 255, 255, 0.25),
        inset 0 -3px 6px rgba(0, 0, 0, 0.35),
        inset 0 0 0 8px rgba(255, 255, 255, 0.02) !important;
    backdrop-filter: blur(32px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(32px) saturate(180%) !important;
}

.result-modal-glass::before,
.result-modal-glass::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    mix-blend-mode: screen;
    pointer-events: none;
}

.result-modal-glass::before {
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.08) 14%, rgba(255, 255, 255, 0.04) 28%, transparent 48%);
}

.result-modal-glass::after {
    background:
        radial-gradient(80% 60% at 0% 0%, rgba(236, 253, 255, 0.12) 0%, transparent 60%),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.04) 22%, transparent 36%),
        linear-gradient(to top, rgba(0, 0, 0, 0.18), transparent 35%);
}

.result-modal-glass>* {
    position: relative;
    z-index: 1;
}

.result-modal-glass button {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.result-spirit-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(42vw, 9.25rem);
    height: min(42vw, 9.25rem);
    margin: -0.35rem auto 0.35rem;
}

.result-spirit-hero::before {
    content: '';
    position: absolute;
    inset: 14%;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.28), rgba(34, 211, 238, 0.1) 48%, transparent 72%);
    filter: blur(10px);
}

.result-spirit-hero img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.46)) drop-shadow(0 0 18px rgba(251, 191, 36, 0.18));
    animation: result-spirit-float 3.4s ease-in-out infinite;
}

.result-spirit-trophy {
    position: relative;
    z-index: 1;
    font-size: 4.4rem;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.55));
}

@keyframes result-spirit-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-0.32rem);
    }
}

.result-star-summary {
    width: 100%;
    margin: -0.1rem 0 1.2rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.result-new-best {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.45rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: #cffafe;
    background: transparent;
    box-shadow: none;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.16em;
}

.result-star-row {
    color: #fde68a;
    font-size: clamp(2.25rem, 10vw, 3.05rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.08em;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.62), 0 2px 8px rgba(0, 0, 0, 0.85);
}

.result-time-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin-top: 0.65rem;
    color: rgba(226, 232, 240, 0.72);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.result-time-row strong {
    color: #67e8f9;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 1.12rem;
    letter-spacing: 0.04em;
    text-shadow: 0 0 10px rgba(34, 211, 238, 0.42);
}

.result-stat-panel {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0.15rem 1.05rem 0.25rem !important;
}

.result-stat-row {
    min-height: 2.35rem;
    padding: 0.28rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

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

.result-stat-label {
    color: rgba(226, 232, 240, 0.72) !important;
    font-size: 1rem !important;
    font-weight: 800 !important;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.38);
}

.result-stat-value {
    font-size: 1.18rem !important;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
}

.result-grade-value {
    font-size: 2.25rem !important;
}

.result-action-row {
    display: flex;
    width: 100%;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    transition: opacity 0.2s ease;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.result-action-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 1rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1.15;
    transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.result-action-btn:active {
    transform: translateY(0.25rem);
    box-shadow: none;
}

.result-action-btn--retry {
    border: 1px solid rgba(251, 191, 36, 0.38);
    background: rgba(251, 191, 36, 0.12);
    color: #fde68a;
}

.result-action-btn--map {
    border: 1px solid rgba(251, 191, 36, 0.65);
    background: #f59e0b;
    color: #0f172a;
    box-shadow: 0 4px 0 #b45309;
}

.result-action-btn:hover {
    filter: brightness(1.08);
}

.mistakes-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    min-height: 2.15rem;
    padding-right: 9.8rem;
    position: relative;
}

.mistakes-voice-hint {
    position: absolute;
    top: 0.15rem;
    right: 0;
    color: rgba(125, 211, 252, 0.82);
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
    white-space: nowrap;
}

.stage-log-list {
    scroll-padding: 0.75rem;
}

.stage-log-card {
    background-color: rgba(15, 23, 42, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.075) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 26px rgba(0, 0, 0, 0.12) !important;
    backdrop-filter: blur(16px) saturate(135%);
    -webkit-backdrop-filter: blur(16px) saturate(135%);
    cursor: pointer;
    outline: none;
    touch-action: manipulation;
}

.stage-log-card:hover {
    border-color: rgba(125, 211, 252, 0.28);
    background-color: rgba(30, 41, 59, 0.2) !important;
}

.stage-log-card:active {
    transform: scale(0.985);
}

.stage-log-card:focus-visible {
    box-shadow: 0 0 0 2px rgba(125, 211, 252, 0.5), 0 10px 28px rgba(0, 0, 0, 0.22);
}

.stage-log-jp {
    font-size: clamp(1.45rem, 6.4vw, 2.15rem) !important;
    line-height: 1.42 !important;
    overflow-wrap: anywhere;
    word-break: normal;
}

.stage-log-kana {
    color: rgba(186, 230, 253, 0.9);
    font-size: clamp(1.05rem, 4.8vw, 1.45rem);
    font-weight: 800;
    line-height: 1.45;
    overflow-wrap: anywhere;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
    word-break: normal;
}

.stage-log-prompt {
    color: rgba(226, 232, 240, 0.82) !important;
    font-size: clamp(1.08rem, 4.6vw, 1.42rem) !important;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: normal;
}

.stage-log-tip {
    color: rgba(203, 213, 225, 0.78) !important;
    font-size: 0.92rem !important;
    line-height: 1.6 !important;
}

@media (max-width: 640px) {
    .mistakes-modal-panel {
        padding: 1.15rem !important;
    }

    .mistakes-header {
        align-items: baseline;
        flex-direction: row;
        gap: 0.5rem;
        min-height: 2.2rem;
        padding-right: 8.7rem;
    }

    .mistakes-voice-hint {
        position: absolute;
        top: 0.12rem;
        right: 0;
        font-size: 0.86rem;
        letter-spacing: 0;
    }

    .stage-log-card {
        padding: 1rem !important;
    }
}

@media (orientation: landscape) and (max-height: 700px) {
    /* ── Result Screen Compression for Landscape Tablets ── */
    .result-modal-glass {
        padding: 1.25rem 1.75rem !important;
        max-width: 420px !important;
    }

    .result-spirit-hero {
        width: 7.5rem !important;
        height: 7.5rem !important;
        margin-top: -0.5rem !important;
        margin-bottom: 0.25rem !important;
    }

    .result-modal-glass h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .result-star-row {
        font-size: 2.25rem !important;
    }

    .result-time-row {
        margin-top: 0.35rem !important;
    }

    .result-stat-panel {
        margin-bottom: 0.75rem !important;
        padding: 0.1rem 1rem !important;
    }

    .result-stat-row {
        min-height: 2rem !important;
    }

    .result-grade-value {
        font-size: 1.85rem !important;
    }

    .result-modal-glass .w-full.py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
        font-size: 1.05rem !important;
    }
}

@media (max-width: 360px) {
    .result-action-row {
        flex-direction: column;
    }
}

/* 全關卡成績一覽 */
.stage-records-modal {
    max-height: min(86vh, 760px);
}

/* 三玻璃面板：主標題旁英文副標（金黃、字級大於 settings.css 預設 .modal-caption） */
.changelog-modal .modal-header-row .modal-caption,
.stage-records-modal .modal-header-row .modal-caption,
.settings-modal .modal-header-row .modal-caption {
    font-size: 0.875rem;
    font-weight: 800;
    letter-spacing: 0.26em;
    margin-left: 0.55rem;
    opacity: 1;
    color: rgba(251, 191, 36, 0.9);
    vertical-align: 0.1em;
}

/* 三玻璃面板內卡：統一霧層（內框線 + 略實霧底，與外層玻璃區隔；不動 confirm-modal-glass） */
.settings-modal .modal-section-card,
.changelog-modal .changelog-entry-card,
.stage-records-modal .stage-record-row {
    border: 1px solid rgba(255, 255, 255, 0.34);
    background:
        radial-gradient(circle at 11% 12%, rgba(125, 211, 252, 0.12), transparent 52%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07)),
        rgba(15, 23, 42, 0.32),
        rgba(255, 255, 255, 0.13);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.26),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 -1px 0 rgba(0, 0, 0, 0.14),
        0 6px 18px rgba(0, 0, 0, 0.26);
}

/* 遊戲設定：三個 section 主題同層級字級／字重／全白 */
.settings-modal .settings-section-label {
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.96);
    text-transform: none;
    margin-bottom: 0.45rem;
}

.settings-modal-footer {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.settings-modal-footer--battle {
    display: grid;
    grid-template-columns: 1fr minmax(7rem, 30%) 1fr;
    align-items: center;
    gap: 0.75rem;
}

.settings-return-btn {
    justify-self: start;
    padding: 0.72rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.78rem;
    font-weight: 900;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.settings-return-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.96);
}

.settings-close {
    margin-top: 0;
    justify-self: center;
}

.changelog-entry-card {
    color: rgba(255, 255, 255, 0.95);
}

/* Changelog 條目內文：偏白（不改變更項目文案，僅色與層級） */
.changelog-modal .changelog-entry-card li,
.changelog-modal .changelog-entry-card .text-slate-300 {
    color: rgba(255, 255, 255, 0.94) !important;
}

.changelog-modal .changelog-entry-card .text-slate-500 {
    color: rgba(255, 255, 255, 0.78) !important;
}

.changelog-footer {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.changelog-close {
    margin-top: 0;
}

.stage-records-summary {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 1rem 0 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.stage-records-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 0;
    max-height: min(58vh, 520px);
    overflow-y: auto;
    padding-right: 0.2rem;
}

.stage-record-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 0.85rem;
    align-items: center;
    padding: 0.78rem 0.95rem;
    border-radius: 1rem;
}

.stage-records-modal .stage-record-row.is-uncleared {
    opacity: 0.8;
    border-color: rgba(255, 255, 255, 0.26);
    background:
        radial-gradient(circle at 11% 12%, rgba(148, 163, 184, 0.16), transparent 52%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.055)),
        rgba(15, 23, 42, 0.34),
        rgba(255, 255, 255, 0.1);
}

.stage-record-main {
    display: flex;
    align-items: center;
    gap: 0.88rem;
    min-width: 0;
}

.stage-record-no {
    flex: 0 0 auto;
    color: rgba(251, 191, 36, 0.88);
    font-size: 0.8125rem;
    font-weight: 900;
    letter-spacing: 0.14em;
}

.stage-record-name {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
}

.stage-record-particle {
    flex: 0 0 auto;
    color: #fef3c7;
    font-size: 1.455rem;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.36), 0 2px 8px rgba(0, 0, 0, 0.56);
}

.stage-record-title {
    min-width: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.96);
    font-size: 1.07rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stage-record-focus {
    margin-top: 0.14rem;
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.97rem;
    font-weight: 800;
}

.stage-record-score {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 10.25rem;
}

.stage-record-rank {
    font-size: 1.36rem;
    font-weight: 1000;
    line-height: 1;
}

.stage-record-stars {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.08rem;
    color: rgba(226, 232, 240, 0.2);
    font-size: 0.86rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.stage-record-stars .is-earned {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.48), 0 2px 8px rgba(0, 0, 0, 0.65);
}

.stage-record-stars.is-empty {
    color: rgba(226, 232, 240, 0.18);
}

.stage-record-time {
    color: #67e8f9;
    font-family: "Courier New", monospace;
    font-size: 0.98rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    white-space: nowrap;
    text-shadow: 0 0 10px rgba(103, 232, 249, 0.35), 0 2px 8px rgba(0, 0, 0, 0.55);
}

.stage-record-status {
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.98rem;
    font-weight: 1000;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.stage-records-close {
    display: block;
    width: 30%;
    min-width: 7rem;
    margin: 1rem auto 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.72rem 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.82rem;
    font-weight: 1000;
    letter-spacing: 0.12em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.stage-records-close:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.98);
}

@media (max-width: 420px) {
    .stage-records-modal {
        padding: 1rem !important;
    }

    .stage-records-modal .modal-header-row h2 {
        font-size: 1.45rem !important;
        letter-spacing: 0.08em;
    }

    .stage-records-modal .modal-header-row .modal-caption {
        font-size: 0.82rem;
        letter-spacing: 0.18em;
        margin-left: 0.42rem;
    }

    .stage-records-summary {
        font-size: 0.82rem;
        letter-spacing: 0.035em;
    }

    .stage-record-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.72rem;
    }

    .stage-record-main {
        display: grid;
        grid-template-columns: 4.6rem minmax(0, 1fr);
        gap: 0.45rem;
    }

    .stage-record-score {
        justify-content: flex-start;
        min-width: 0;
    }

    .stage-record-no {
        font-size: 0.74rem;
        line-height: 1.05;
        letter-spacing: 0.08em;
    }

    .stage-record-name {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 0.32rem;
    }

    .stage-record-particle {
        font-size: 1rem;
    }

    .stage-record-title {
        overflow: visible;
        font-size: 0.92rem;
        line-height: 1.15;
        text-overflow: clip;
        white-space: normal;
    }

    .stage-record-rank {
        font-size: 1.18rem;
    }

    .stage-record-time {
        font-size: 0.9rem;
    }

    .stage-record-stars {
        font-size: 0.82rem;
    }

    .stage-record-status {
        font-size: 0.94rem;
    }

    .stage-records-close {
        width: 52%;
    }

    .settings-modal-footer--battle {
        grid-template-columns: 1fr;
    }

    .settings-return-btn {
        justify-self: center;
        width: 52%;
        min-width: 7rem;
        text-align: center;
    }
}


/* ── 答錯對比教學(戰鬥題目卡下方,答錯後解答窗口內顯示)── */
.battle-wrong-tip {
    margin: 8px auto 0;
    max-width: 92%;
    padding: 6px 14px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fde68a;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.7;
    text-align: center;
    animation: battle-wrong-tip-in 0.25s ease-out;
}

@keyframes battle-wrong-tip-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── 出題本:錯題置頂切換 + 答案對比行 ── */
.mistakes-sort-btn {
    width: 100%;
    margin-bottom: 10px;
    padding: 7px 10px;
    border-radius: 0.7rem;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    transition: all 0.15s ease;
}

.mistakes-sort-btn:active {
    transform: scale(0.98);
}

.mistakes-sort-btn.is-active {
    background: rgba(244, 63, 94, 0.16);
    border-color: rgba(251, 113, 133, 0.45);
    color: #fda4af;
}

.stage-log-ans {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.stage-log-ans__wrong {
    color: #fda4af;
}

.stage-log-ans__correct {
    color: #6ee7b7;
}

/* ── S Rank Result VFX ── */
.result-grade-s-rank {
    display: inline-block;
    transform-origin: center;
    animation:
        result-s-rank-entrance 0.7s cubic-bezier(0.22, 1, 0.36, 1) both,
        result-s-rank-glow 1.6s ease-in-out 0.7s infinite;
}
@keyframes result-s-rank-entrance {
    0%   { opacity: 0; transform: scale(0.3) rotate(-14deg); filter: brightness(3) blur(3px); }
    55%  { opacity: 1; transform: scale(1.6) rotate(5deg); filter: brightness(2) blur(0); }
    78%  { transform: scale(1.18) rotate(-2deg); filter: brightness(1.4); }
    100% { transform: scale(1.35) rotate(0deg); filter: brightness(1.3); }
}
@keyframes result-s-rank-glow {
    0%, 100% {
        transform: scale(1.32);
        text-shadow:
            0 0 10px rgba(255, 215, 90, 0.85),
            0 0 22px rgba(255, 180, 40, 0.55);
    }
    50% {
        transform: scale(1.46);
        text-shadow:
            0 0 24px rgba(255, 238, 150, 1),
            0 0 44px rgba(255, 200, 60, 0.9),
            0 0 66px rgba(255, 170, 30, 0.55);
    }
}
