:root {
    --cloze-scale: 1;
    --cloze-token-width: 11.2rem;
    --cloze-token-height: 2.6rem;
    --cloze-primary: #F09E0B;
    --cloze-border: #3d4f63;
    --cloze-text: #e5e7eb;
    --player-max-width: 1280px;
    --player-primary: var(--cloze-primary);
    --player-border: var(--cloze-border);
    --player-text: var(--cloze-text);
}

body {
    background:
        radial-gradient(circle at top, rgba(240, 158, 11, 0.12), rgba(15, 23, 42, 0) 28%),
        linear-gradient(180deg, #0f172a 0%, #152234 100%);
}

.cloze-player-hero,
.cloze-stage,
.cloze-card {
    border: 1px solid var(--cloze-border);
    border-radius: 18px;
    padding: 1.5rem;
    color: var(--cloze-text);
}
.cloze-player-hero p,
.card-head p {
    color: #cbd5e1;
}

.cloze-stage {
    position: relative;
    display: grid;
    gap: 1rem;
    overflow: hidden;
}

.cloze-stage:fullscreen {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    padding: 2rem;
    border-radius: 0;
    overflow-y: auto;
    background:
        radial-gradient(circle at top, rgba(240, 158, 11, 0.12), rgba(15, 23, 42, 0.98) 30%, rgba(10, 15, 25, 1) 100%),
        #111827;
}

.cloze-stage-head {
    display: grid;
    gap: 1rem;
}

.cloze-stage:fullscreen .cloze-stage-head {
    position: sticky;
    top: 0;
    z-index: 20;
    width: min(1500px, 100%);
    margin-left: auto;
    margin-right: auto;
    padding-top: 8px;
    padding-bottom: 12px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(17, 24, 39, 0.84) 70%, rgba(17, 24, 39, 0));
    backdrop-filter: blur(10px);
}

.cloze-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.toolbar-pills,
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar-pill {
    border: 2px solid var(--cloze-border);
    padding: 0.55rem 1rem;
    border-radius: 999px;
    background: rgba(38, 53, 73, 0.72);
    color: var(--cloze-text);
    font-size: 0.95rem;
    font-weight: 700;
}

.cloze-stage .toolbar-actions button {
    appearance: none;
    border: 1px solid var(--cloze-border);
    color: var(--cloze-text);
    background: rgba(38, 53, 73, 0.6);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.cloze-stage .toolbar-actions button:hover {
    background: rgba(240, 158, 11, 0.16);
    border-color: var(--cloze-primary);
}

.cloze-stage .toolbar-actions button.ghost-button,
.cloze-stage .toolbar-actions button.ghost {
    background: transparent;
    border-color: var(--cloze-primary);
    color: var(--cloze-primary);
}

.cloze-stage .toolbar-actions button.action-button {
    border-color: rgba(240, 158, 11, 0.3);
    background: linear-gradient(180deg, rgba(240, 158, 11, 0.26), rgba(240, 158, 11, 0.15));
    color: #fff3d4;
}

body[data-theme="light"] .cloze-stage .toolbar-actions button.action-button {
    border-color: rgba(212, 136, 6, 0.45);
    background: linear-gradient(180deg, #f3b23c, #e59b10);
    color: #1f2937;
}

.fullscreen-toolbar {
    display: flex;
    justify-content: center;
    width: auto;
}

.fullscreen-toolbar.hidden {
    display: none;
}

.fullscreen-toolbar label,
.fullscreen-toolbar span {
    color: #e2e8f0;
    font-weight: 600;
}

.fullscreen-toolbar {
    display: flex;
}

.fullscreen-toolbar label {
    margin: 0;
}

.fullscreen-toolbar {
    width: auto;
}

.fullscreen-toolbar {
    justify-content: center;
}

.fullscreen-toolbar {
    gap: 0;
}

.fullscreen-toolbar {
    text-align: center;
}

.fullscreen-toolbar {
    align-items: stretch;
}

.fullscreen-toolbar::before {
    content: '';
    display: none;
}

.fullscreen-toolbar {
    background: transparent;
}

.fullscreen-toolbar {
    padding: 0;
}

.fullscreen-toolbar {
    border-radius: 0;
}

.fullscreen-toolbar {
    box-sizing: border-box;
}

.fullscreen-toolbar {
    grid-template-columns: none;
}

.fullscreen-toolbar {
    flex-direction: row;
}

.fullscreen-toolbar {
    width: auto;
}

.fullscreen-toolbar {
    margin: 0;
}

.fullscreen-toolbar {
    min-height: auto;
}

.fullscreen-toolbar {
    display: flex;
}

.fullscreen-size-control {
    width: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    border-radius: 12px;
    border: 1px solid rgba(240, 158, 11, 0.24);
    background: rgba(15, 23, 42, 0.45);
}

.fullscreen-size-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.45rem;
    white-space: nowrap;
}

.fullscreen-toolbar input[type="range"] {
    width: 9.5rem;
    accent-color: #f09e0b;
    cursor: pointer;
    min-height: 1rem;
}

.fullscreen-toolbar input[type="range"]::-webkit-slider-runnable-track {
    height: 0.55rem;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(240, 158, 11, 0.88), rgba(93, 208, 255, 0.72));
}

.fullscreen-toolbar input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: -0.34rem;
    border-radius: 50%;
    border: 2px solid #fff7e1;
    background: #f09e0b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.fullscreen-toolbar input[type="range"]::-moz-range-track {
    height: 0.55rem;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(240, 158, 11, 0.88), rgba(93, 208, 255, 0.72));
}

.fullscreen-toolbar input[type="range"]::-moz-range-thumb {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 2px solid #fff7e1;
    background: #f09e0b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.status-banner {
    padding: 0.95rem 1rem;
    border-radius: 12px;
    background: rgba(240, 158, 11, 0.1);
    border: 1px solid rgba(240, 158, 11, 0.28);
    color: #f8d08a;
    font-weight: 600;
    text-align: center;
}

.status-banner.is-success {
    background: rgba(240, 158, 11, 0.16);
    border-color: rgba(240, 158, 11, 0.38);
    color: #ffe4aa;
}

.status-banner.is-error {
    background: rgba(177, 54, 38, 0.18);
    border-color: rgba(239, 68, 68, 0.32);
    color: #fecaca;
}

.cloze-app.hidden,
.success-overlay.hidden {
    display: none;
}

.cloze-app {
    display: grid;
    grid-template-columns: 1fr calc(var(--cloze-token-width) * var(--cloze-scale) + 3rem);
    gap: 1.2rem;
    align-items: start;
}

.cloze-card {
    display: grid;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.28);
    border-color: rgba(240, 158, 11, 0.18);
}

.card-head h3,
.card-head p {
    margin: 0;
}

.card-head p {
    margin-top: 0.35rem;
}

.cloze-text {
    font-size: calc(20px * var(--cloze-scale));
    line-height: 1.9;
    color: #e5edf5;
}

.cloze-text p {
    margin: 0;
    font-size: inherit;
    line-height: inherit;
}

.cloze-text p + p {
    margin-top: 1rem;
}

.cloze-slot {
    width: calc(var(--cloze-token-width) * var(--cloze-scale));
    min-width: calc(var(--cloze-token-width) * var(--cloze-scale));
    height: calc(var(--cloze-token-height) * var(--cloze-scale));
    margin: 0.18rem 0.35rem;
    padding: 0.2rem 0.75rem;
    border: 2px dashed rgba(240, 158, 11, 0.55);
    border-radius: 18px;
    background: rgba(240, 158, 11, 0.08);
    color: #f9cf87;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    font-size: calc(0.88rem * var(--cloze-scale));
    font-weight: 700;
    text-align: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.cloze-slot:hover,
.cloze-slot.is-targeted,
.cloze-slot.is-filled {
    transform: translateY(-2px);
    box-shadow: 0 12px 22px rgba(240, 158, 11, 0.12);
    border-color: rgba(240, 158, 11, 0.88);
}

.cloze-slot.is-locked {
    border-style: solid;
    border-color: rgba(240, 158, 11, 0.94);
    background: rgba(240, 158, 11, 0.16);
}

.slot-token,
.answer-token {
    --token-hue: 28;
    width: 100%;
    height: 100%;
    border: 1px solid hsla(var(--token-hue), 72%, 36%, 0.22);
    border-radius: 15px;
    background:
        linear-gradient(180deg, hsla(var(--token-hue), 100%, 97%, 0.98), hsla(var(--token-hue), 84%, 87%, 0.98));
    box-shadow: 0 14px 24px hsla(var(--token-hue), 76%, 40%, 0.12);
    color: #173040;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.35rem;
    font-size: calc(0.88rem * var(--cloze-scale));
    font-weight: 700;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.answer-bank {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.9rem;
}

.answer-token {
    height: auto;
    min-height: calc(var(--cloze-token-height) * var(--cloze-scale));
    cursor: grab;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.answer-token:hover,
.answer-token.is-selected {
    transform: translateY(-3px) scale(1.01);
    filter: saturate(1.08);
    box-shadow: 0 18px 28px rgba(16, 32, 44, 0.16);
}

.cloze-stage:fullscreen .cloze-toolbar,
.cloze-stage:fullscreen .status-banner,
.cloze-stage:fullscreen .cloze-app {
    width: min(1500px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.cloze-stage:fullscreen .cloze-toolbar,
.cloze-stage:fullscreen .status-banner {
    justify-content: center;
    text-align: center;
}

.cloze-stage:fullscreen .toolbar-pill,
.cloze-stage:fullscreen .toolbar-actions button,
.cloze-stage:fullscreen .fullscreen-size-header,
.cloze-stage:fullscreen .status-banner {
    font-size: 0.8rem;
    line-height: 1.2;
}

.cloze-stage:fullscreen .toolbar-pill,
.cloze-stage:fullscreen .toolbar-actions button {
    padding: 0.62rem 0.84rem;
    min-height: 2.4rem;
    box-sizing: border-box;
}

.cloze-stage:fullscreen .cloze-toolbar {
    gap: 0.6rem;
    margin-bottom: 0;
    min-height: 2.4rem;
    align-items: center;
}

.cloze-stage:fullscreen .fullscreen-toolbar {
    min-height: 2.4rem;
    align-items: center;
}

.cloze-stage:fullscreen .fullscreen-size-control {
    height: 2.4rem;
    box-sizing: border-box;
}

.cloze-stage:fullscreen .fullscreen-toolbar input[type="range"] {
    width: 8.5rem;
}

.cloze-stage:fullscreen .status-banner {
    min-height: 3.625rem;
    box-sizing: border-box;
}

.answer-token.is-selected {
    outline: 3px solid rgba(240, 158, 11, 0.38);
}

.answer-bank.is-drop-target {
    padding: 0.6rem;
    border-radius: 20px;
    background: rgba(240, 158, 11, 0.08);
}

.success-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 55%);
}

.success-badge {
    position: relative;
    max-width: min(38rem, 82vw);
    padding: 1.6rem 1.8rem;
    border-radius: 26px;
    text-align: center;
    background:
        linear-gradient(180deg, rgba(255, 250, 240, 0.98), rgba(255, 238, 201, 0.98));
    border: 2px solid rgba(240, 158, 11, 0.78);
    box-shadow: 0 28px 48px rgba(16, 32, 44, 0.2);
    animation: success-pop 420ms ease-out;
}

.success-badge::before,
.success-badge::after {
    content: '';
    position: absolute;
    width: 9rem;
    height: 9rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240, 158, 11, 0.22), transparent 66%);
    animation: success-burst 1.2s ease-out;
}

.success-badge::before {
    top: -3rem;
    left: -3rem;
}

.success-badge::after {
    right: -3rem;
    bottom: -3rem;
}

.success-kicker {
    margin: 0 0 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.86rem;
    font-weight: 800;
    color: #b56a00;
}

.success-badge h3,
.success-badge p {
    margin: 0;
}

.success-badge p:last-child {
    margin-top: 0.55rem;
    color: rgba(23, 48, 64, 0.78);
}

@keyframes success-pop {
    from {
        opacity: 0;
        transform: scale(0.88) translateY(12px);
    }

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

@keyframes success-burst {
    from {
        opacity: 0;
        transform: scale(0.3);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 900px) {
    .cloze-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-pills,
    .toolbar-actions {
        width: 100%;
        justify-content: stretch;
    }

    .toolbar-pill,
    .cloze-stage .toolbar-actions button {
        width: 100%;
        text-align: center;
    }

    .cloze-stage:fullscreen {
        padding: 1rem;
    }

    .cloze-slot,
    .answer-bank {
        --cloze-token-width: 8.8rem;
        --cloze-token-height: 4.3rem;
    }
}

@media (max-width: 680px) {
    .fullscreen-size-control,
    .fullscreen-size-header {
        align-items: stretch;
    }

    .fullscreen-size-header {
        flex-direction: column;
    }

    .answer-bank {
        grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    }

    .cloze-slot {
        margin-left: 0;
        margin-right: 0;
    }
}