.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 20px;
    /* margin-top: 32px;  */
}

body {
    background: var(--theme-bg);
    background-size: cover;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
    overflow-y: hidden;
    font-family: 'Roboto Mono', 'Microsoft YaHei', 'PingFang SC', sans-serif;

}

#article-container {
    background: var(--theme-surface);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-height: 700px;
    transition: height 0.25s ease-out;
    overflow: hidden;
}

#article {
    overflow: hidden;
}

.article-scroll-clip {
    overflow: hidden;
}

/* Instant scroll during live typing; smooth only for intentional layout changes (font size, etc.) */
.article.smooth-article-scroll {
    transition: transform 0.25s ease-out;
}

#article-container-wrapper.replaying #article-container {
    border: 4px solid #00b6ed;
}

#article-container-wrapper.result #article-container {
    height: 700px;
}

#article-container-wrapper.result #article .input-text-area {
    pointer-events: none;
}

.replay-container {
    display: none;
}

#article-container-wrapper.replaying .replay-container {
    display: block;
}

#article-container-wrapper.replaying .article-scroll-clip {
    padding: 2px;
    box-sizing: border-box;
}

#article-container-wrapper.replaying .article.compositor-cursor-active:not(.burst-typing) .typing-cursor-shell,
.typing-record-replay-article-wrap .article.compositor-cursor-active:not(.burst-typing) .typing-cursor-shell {
    animation: none !important;
    opacity: 1 !important;
}

.replay-container {
    position: relative;
}

.replay-container-header {
    background: #00b6ed;
    padding: 6px 20px;
    border-radius: 26px;
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    color: #FFF;
    z-index: 10;
    /* min-width: 560px; */
    width: calc(100% - 71px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.replay-controls {
    display: flex;
    /* align-items: center; */
    align-items: stretch;
    width: calc(100% - 86px);
    gap: 8px;
}

.replay-control-btn {
    border: 1px solid #00b6ed;
    background: #ffffff;
    color: #006f92;
    border-radius: 14px;
    width: 32px;
    height: 28px;
    font-size: 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.replay-control-btn:hover:enabled {
    background: #e8f8fd;
}

.replay-control-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.replay-control-btn-stop {
    border-color: #e15353;
    color: #a83737;
}

.replay-control-btn-stop:hover:enabled {
    background: #fdeeee;
}

.replay-seekbar-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    /* min-width: 290px; */
    width: 100%;
}

.replay-seekbar {
    flex: 1;
    min-width: 180px;
    accent-color: #006f92;
    cursor: pointer;
}

.replay-seekbar:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.replay-seekbar-time {
    color: #ffffff;
    font-size: 12px;
    min-width: 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.timer-container {
    position: relative;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.timer-container.active {
    opacity: 1;
    visibility: visible;
}

.timer-container-text {
    background: #365a92;
    padding: 6px 20px;
    border-radius: 16px;
    color: #FFF;
    font-weight: bold;
    font-size: 16px;
    letter-spacing: 1px;
    z-index: 10;
}

@media (max-width: 834px) {
    #app.container .timer-container-text {
        padding: 4px 12px;
        font-size: 14px;
    }
}

/* ── Result Overlay ── */
#article-container-wrapper {
    position: relative;
}

#article-container {
    position: relative;
}

.result-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #2a4775 0%, #024559 100%);
    border-radius: 8px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    overflow: hidden;
}

.result-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.result-overlay-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 14px 32px 18px;
    box-sizing: border-box;
    position: relative;
}

.result-overlay-header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 12px;
    min-height: 36px;
}

.result-overlay-title-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.result-overlay-title {
    font-size: 28px;
    font-weight: 700;
    color: #FFF;
    text-align: center;
    letter-spacing: 8px;
    margin-bottom: 0;
}

.result-overlay-end-reason {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 220, 160, 0.95);
    text-align: center;
    letter-spacing: 0.5px;
}

.result-submit-indicator-wrap {
    position: absolute;
    top: 0;
    right: 0;
}

.result-submit-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(180, 240, 230, 0.45);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    cursor: default;
}

.result-submit-indicator--failed {
    cursor: pointer;
    border-color: rgba(255, 193, 7, 0.65);
    background: rgba(255, 193, 7, 0.18);
}

.result-submit-indicator--submitted {
    border-color: rgba(25, 135, 84, 0.65);
    background: rgba(25, 135, 84, 0.22);
}

.result-submit-indicator--submitting {
    border-color: rgba(13, 202, 240, 0.65);
    background: rgba(13, 202, 240, 0.18);
}

.result-submit-indicator__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.result-submit-warning-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 193, 7, 0.55);
    background: rgba(255, 193, 7, 0.16);
    color: #fff7da;
    font-size: 13px;
    line-height: 1.4;
}

.result-submit-warning-banner__action {
    flex: 0 0 auto;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.result-submit-dialog-backdrop {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(8, 24, 40, 0.55);
}

.result-submit-dialog {
    width: min(100%, 420px);
    border-radius: 12px;
    border: 1px solid rgba(180, 240, 230, 0.35);
    background: linear-gradient(160deg, #1f3d66 0%, #0f3340 100%);
    color: #fff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.result-submit-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 0;
}

.result-submit-dialog__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.result-submit-dialog__close {
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.result-submit-dialog__body {
    padding: 12px 18px 0;
    font-size: 14px;
    line-height: 1.5;
}

.result-submit-dialog__hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.72);
}

.result-submit-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 18px;
}

.result-submit-dialog__btn-primary {
    background: rgba(255, 193, 7, 0.22);
    border-color: rgba(255, 193, 7, 0.65);
}

.result-submit-dialog__btn-secondary {
    background: rgba(255, 255, 255, 0.08);
}

.result-submit-dialog__btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Two-column body */
.result-overlay-body {
    display: flex;
    gap: 24px;
    flex: 1;
    min-height: 0;
    border-top: 2px solid rgba(160, 230, 220, 0.45);
    border-bottom: 2px solid rgba(160, 230, 220, 0.45);
    padding: 24px 0;
}

.result-left {
    flex: 0 0 380px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-right {
    flex: 1;
    min-width: 0;
    position: relative;
}

.result-right canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Stat boxes */
.result-box {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(180, 230, 225, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
}

.result-box-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 0;
}

.result-box-row-primary {
    padding-bottom: 4px;
}

.result-box-label {
    font-size: 18px;
    color: #ffffff;
    flex: 1;
}

.result-box-value {
    font-size: 18px;
    font-weight: 700;
    color: #FFF;
}

.result-box-row-primary .result-box-value {
    font-size: 26px;
    color: #ffffff;
}

.result-box-unit {
    font-size: 11px;
    color: #FFF;
}

.result-box-row-primary .result-box-unit {
    font-size: 13px;
}

/* Score row */
.result-score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 8px;
}

.result-score-stars {
    font-size: 24px;
    line-height: 1;
}

.result-score-number {
    font-size: 42px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.result-score-label {
    font-size: 18px;
    color: #eee;
    align-self: flex-end;
    margin-bottom: 4px;
}

/* Action buttons */
.result-actions {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin-top: 16px;
    padding-top: 12px;
}



.result-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(180, 240, 230, 0.5);
    color: #ffffff;
    font-family: 'Roboto Mono', monospace;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 2px;
    border-radius: 32px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.result-btn:hover {
    background: #e6f3f1;
    color: #1a6060;
    border-color: #c8f5ed;
}

.result-box-row-primary {
    font-size: 24px;
    font-weight: 700;
    border-bottom: 1px solid rgba(160, 230, 220, 0.45);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.result-box-row-primary .result-box-label {
    font-size: 24px;
}

/* ── Hero Gauges Row ── */
.result-hero {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 36px;
    margin-bottom: 18px;
    flex-shrink: 0;
}

.result-gauge {
    position: relative;
    width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.result-gauge-center {
    width: 180px;
    align-items: center;
}

.gauge-svg {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}

.result-gauge-center .gauge-svg {
    width: 140px;
    height: 140px;
}

.gauge-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 8;
}

.gauge-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 314.16;
    stroke-dashoffset: 314.16;
    transition: stroke-dashoffset 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-fill-accuracy {
    stroke: #f5c842;
}

.gauge-fill-time {
    stroke: rgba(255, 255, 255, 0.7);
}

.gauge-fill-wpm {
    stroke: #7ecfdf;
}

.gauge-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.gauge-value {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
}

.gauge-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 1px;
    margin-top: 2px;
}

.result-stars-row {
    font-size: 26px;
    letter-spacing: 2px;
    line-height: 1;
    display: flex;
    gap: 2px;
}

@keyframes starPop {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-20deg);
    }

    60% {
        opacity: 1;
        transform: scale(1.35) rotate(5deg);
    }

    80% {
        transform: scale(0.9) rotate(-3deg);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.result-stars-row .star {
    display: inline-block;
    opacity: 0;
    animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.result-stars-row .star-filled {
    color: #ffe44d;
    text-shadow: 0 0 10px rgba(255, 220, 60, 0.85);
}

.result-stars-row .star-empty {
    color: rgba(200, 240, 235, 0.3);
}

.result-hero-score {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 6px;
}

.hero-score-number {
    font-size: 42px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 0 20px rgba(100, 240, 210, 0.45);
}

.hero-score-unit {
    font-size: 16px;
    color: #ffffff;
}

.hero-score-label {
    font-size: 11px;
    color: #c0ede5;
    letter-spacing: 1px;
    margin-top: 2px;
    border-top: 1px solid rgba(160, 230, 220, 0.35);
    padding-top: 4px;
    width: 100%;
    text-align: center;
}

/* ── Score tooltip ───────────────────────────── */
.score-unit-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.score-tooltip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.score-tooltip-icon {
    font-size: 0.7em;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
    user-select: none;
    outline: none;
}

.score-tooltip-icon:hover,
.score-tooltip-wrapper:focus-within .score-tooltip-icon {
    color: rgba(255,255,255,0.95);
}

.score-tooltip-popup {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e2229;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 14px 16px;
    z-index: 9999;
    min-width: 480px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.55);
    pointer-events: none;
}

.score-tooltip-wrapper:hover .score-tooltip-popup,
.score-tooltip-wrapper:focus-within .score-tooltip-popup {
    display: block;
    pointer-events: auto;
}

.score-tooltip-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #e0e0e0;
    margin-bottom: 10px;
    letter-spacing: 0.04em;
}

.score-tooltip-row {
    display: flex;
    align-items: self-start;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    font-size: 0.75rem;
    color: #ccc;
}

.score-tooltip-row:last-child {
    border-bottom: none;
}

.score-tooltip-row-header {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 0 4px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 2px;
}

.score-tooltip-label {
    flex: 0 0 72px;
    color: rgba(255,255,255,0.5);
    font-size: 0.72rem;
}

.score-tooltip-value {
    flex: 1;
    color: #e0e0e0;
    line-height: 1.65;
}

.score-tooltip-value .plus  { color: #66bb6a; }
.score-tooltip-value .minus { color: #ef5350; }

/* ── Global loading screen ───────────────────── */
#global-loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #181a1fee;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

#global-loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

/* iPad landscape + docked system keyboard: typing is paused until the combo is gone.
   Geometry (top/left/width/height) is applied from visualViewport in JS. */
#landscape-keyboard-block {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40000;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: rgba(24, 26, 31, 0.72);
    touch-action: none;
}

#landscape-keyboard-block.is-visible {
    display: flex;
}

.landscape-keyboard-block-card {
    max-width: 420px;
    width: 100%;
    max-height: 100%;
    overflow: auto;
    box-sizing: border-box;
    background: #f6f8fa;
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    text-align: center;
}

#landscape-keyboard-block-title {
    margin: 0 0 6px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e2229;
}

#landscape-keyboard-block-text {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #4a5160;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: #6366f1;
    border-radius: 50%;
    animation: loadingSpin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: #e0e0e0;
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 2px;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingSpin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.6; }
    50%       { opacity: 1; }
}

/* ── Global error screen ─────────────────────── */
/* Hidden by default so nothing flashes before Alpine binds; .is-error-visible toggled when hasError. */
#global-error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #181a1fee;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease-out, visibility 0.35s ease-out;
}

#global-error-screen.is-error-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.error-screen-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 20px;
    border-radius: 50%;
    border: 3px solid rgba(239, 83, 80, 0.35);
    background: rgba(239, 83, 80, 0.12);
    position: relative;
    flex-shrink: 0;
}

.error-screen-icon::before,
.error-screen-icon::after {
    content: "";
    position: absolute;
    left: 50%;
    background: #ef5350;
    border-radius: 1px;
    transform: translateX(-50%);
}

.error-screen-icon::before {
    top: 14px;
    width: 4px;
    height: 18px;
}

.error-screen-icon::after {
    bottom: 14px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.error-screen-title {
    color: #e0e0e0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.error-screen-message {
    color: rgba(224, 224, 224, 0.85);
    font-size: 0.95rem;
    line-height: 1.55;
    max-width: 420px;
    margin-bottom: 28px;
    word-break: break-word;
}

.error-screen-retry {
    appearance: none;
    border: none;
    cursor: pointer;
    padding: 12px 28px;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    border-radius: 8px;
    color: #fff;
    background: #6366f1;
    transition: background 0.2s ease, transform 0.15s ease;
}

.error-screen-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.error-screen-continue {
    appearance: none;
    border: 1px solid rgba(224, 224, 224, 0.45);
    cursor: pointer;
    padding: 12px 28px;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    border-radius: 8px;
    color: #e0e0e0;
    background: transparent;
    transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.error-screen-continue:hover {
    background: rgba(224, 224, 224, 0.08);
    border-color: rgba(224, 224, 224, 0.75);
}

.error-screen-continue:active {
    transform: scale(0.98);
}

.error-screen-retry:hover {
    background: #5558e3;
}

.error-screen-retry:active {
    transform: scale(0.98);
}

[x-cloak] {
    display: none !important;
}

.typing-worker-status {
    position: fixed;
    right: 16px;
    bottom: 14px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    color: rgba(30, 41, 59, 0.92);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    pointer-events: none;
    user-select: none;
}

.typing-worker-status__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(100, 116, 139, 0.6);
}

.typing-worker-status__dot--background {
    background: #16a34a;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.22);
}

.typing-worker-status__dot--main {
    background: #d97706;
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.25);
}

.typing-worker-status__text {
    line-height: 1.2;
    white-space: nowrap;
}

.typing-worker-status__reconnect {
    color: rgba(30, 41, 59, 0.55);
    font-variant-numeric: tabular-nums;
}

.typing-worker-status__hash {
    color: rgba(30, 41, 59, 0.55);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}
/* ============================================
   成績頁 UI 優化（統計卡格 / 圖表卡 / 分數動畫）
   ============================================ */
.result-overlay-body {
    border-top: 1px solid rgba(160, 230, 220, 0.28);
    border-bottom: 1px solid rgba(160, 230, 220, 0.28);
    padding: 20px 0;
}

/* 統計卡格 2×3 */
.result-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.result-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px 11px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(180, 230, 225, 0.22);
    border-radius: 12px;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.result-stat-card:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.result-stat-card-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    background: rgba(42, 240, 194, 0.16);
    color: #2af0c2;
}

.result-stat-card-value {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
}

.result-stat-card-value small {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
}

.result-stat-card-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.result-stat-card-correct .result-stat-card-icon {
    background: rgba(57, 199, 22, 0.20);
    color: #6dff7c;
}

.result-stat-card-correct {
    border-color: rgba(57, 199, 22, 0.30);
}

.result-stat-card-wrong .result-stat-card-icon {
    background: rgba(239, 83, 80, 0.20);
    color: #ff9e9c;
}

.result-stat-card-wrong {
    border-color: rgba(239, 83, 80, 0.30);
}

/* 圖表卡 */
.result-right {
    display: flex;
}

.result-chart-card {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(180, 230, 225, 0.22);
    border-radius: 14px;
    padding: 14px 18px 12px;
    box-sizing: border-box;
}

.result-chart-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #cfeee8;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.result-chart-card-header i {
    color: #2af0c2;
    font-size: 13px;
}

.result-chart-card-body {
    flex: 1;
    min-height: 0;
    position: relative;
}

/* Canvas 絕對定位，避免 Chart.js 響應式量測造成高度增生迴圈 */
.result-right .result-chart-card-body canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

/* 最終分數動畫 */
.result-overlay.active .hero-score-number {
    display: inline-block;
    animation: hero-score-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    text-shadow: 0 0 24px rgba(42, 240, 194, 0.35);
}

@keyframes hero-score-pop {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* 主要動作按鈕（重做練習） */
.result-btn-primary {
    background: linear-gradient(135deg, rgba(42, 240, 194, 0.85), rgba(43, 239, 187, 0.65));
    border-color: rgba(42, 240, 194, 0.9);
    color: #06322c;
    box-shadow: 0 4px 16px rgba(42, 240, 194, 0.25);
}

.result-btn-primary:hover {
    background: #2af0c2;
    color: #06322c;
    border-color: #7cf7da;
    box-shadow: 0 6px 20px rgba(42, 240, 194, 0.40);
}

/* ============================================
   目前字詞內的隱藏輸入框不參與排版
   （無樣式的 input 預設約 170px 寬，會把行尾的
   目前字詞擠到下一行；改為絕對定位零佔位）
   ============================================ */
/* Both the <input> (WordAndCharAppMode) and the <textarea> (WordAppMode,
   used by Chinese word-pair articles) get appended inside the current word.
   Unstyled they take ~170px / a 2-row textarea and push the word — and the
   following space — onto the next line. Neutralize both to a zero footprint. */
#article .word {
    position: relative;
}

#article .word .input-text,
#article .word .input-text-area {
    position: absolute;
    top: auto;
    left: 0;
    bottom: 0;
    float: none;
    width: 2px;
    height: 2px;
    min-height: 0;
    opacity: 0;
    border: 0;
    padding: 0;
    margin: 0;
    resize: none;
    overflow: hidden;
    background: transparent;
    pointer-events: none;
}

/* 組字顯示容器同樣脫離排版流，浮在目前字詞下方 */
#article .word .input-text-display-container {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
    z-index: 7;
}
