.er-shell {
    --er-plum: #24102b;
    --er-plum-2: #4b1d4e;
    --er-pink: #ff5d8f;
    --er-amber: #ffc247;
    --er-mint: #6fe3c4;
    --er-violet: #b18cff;
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 8px 12px 24px;
    color: var(--cg-ink);
    font-family: Inter, Arial, sans-serif;
}

.er-shell,
.er-shell *,
.er-shell *::before,
.er-shell *::after {
    box-sizing: border-box;
}

.er-hidden {
    display: none !important;
}

.er-topbar,
.er-stats,
.er-actions,
.er-entry,
.er-result-actions,
.er-controls,
.er-seg,
.er-diffs,
.er-cardhead,
.er-dots {
    display: flex;
    align-items: center;
}

.er-topbar {
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.er-stats {
    gap: 6px;
    min-width: 0;
}

.er-actions {
    gap: 6px;
    flex: 0 0 auto;
}

.er-stat {
    min-width: 0;
    padding: 5px 9px;
    border: 1px solid var(--cg-line);
    border-radius: 10px;
    background: var(--cg-panel);
    box-shadow: 0 4px 12px rgba(30, 37, 40, 0.07);
    text-align: center;
}

.er-stat span {
    display: block;
    color: var(--cg-muted);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 0.07em;
    line-height: 1.2;
    text-transform: uppercase;
}

.er-stat strong {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 20px;
    margin-top: 1px;
    font-size: 17px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.er-heart {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ff9db8, var(--er-pink));
    box-shadow: 0 0 6px rgba(255, 93, 143, 0.6);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.er-heart-lost {
    background: var(--cg-line);
    box-shadow: none;
    transform: scale(0.7);
}

.er-btn,
.er-close {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid var(--cg-line);
    border-radius: 12px;
    background: var(--cg-panel);
    color: var(--cg-ink);
    font: inherit;
    font-size: 0.94rem;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.1s ease, border-color 0.1s ease, filter 0.1s ease;
}

.er-btn:hover {
    border-color: var(--er-pink);
    transform: translateY(-1px);
}

.er-btn:active {
    transform: scale(0.96);
}

.er-btn:focus-visible,
.er-close:focus-visible,
.er-input:focus-visible,
.er-segbtn:focus-visible,
.er-chip:focus-visible {
    outline: 3px solid rgba(255, 93, 143, 0.45);
    outline-offset: 2px;
}

.er-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.er-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.1rem;
}

.er-icon svg {
    width: 20px;
    height: 20px;
}

.er-primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--er-pink), #ff8a5c);
    color: #fff;
    box-shadow: 0 6px 16px rgba(255, 93, 143, 0.35);
}

.er-primary:hover {
    border-color: transparent;
    filter: brightness(1.06);
}

.er-hint {
    color: #8a5a00;
    background: #fff4d6;
    border-color: #f1d28a;
}

.er-card {
    position: relative;
    padding: 10px;
    border: 1px solid var(--cg-line);
    border-radius: 20px;
    background: var(--cg-panel);
    box-shadow: 0 14px 34px rgba(36, 16, 43, 0.14);
}

.er-cardhead {
    gap: 10px;
    min-height: 26px;
    margin-bottom: 8px;
}

.er-tag {
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--er-plum);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.er-tag-0 { background: #1c7c68; }
.er-tag-1 { background: #7d3fc0; }
.er-tag-2 { background: #c2410c; }
.er-tag-3 { background: #b0225a; }
.er-tag-done { background: #59616a; }

.er-dots {
    gap: 4px;
}

.er-pip {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--cg-line);
}

.er-pip-on {
    background: var(--er-pink);
    box-shadow: 0 0 6px rgba(255, 93, 143, 0.5);
}

.er-counter {
    margin-left: auto;
    color: var(--cg-muted);
    font-size: 12px;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
}

.er-bar-track {
    height: 4px;
    margin: -2px 0 8px;
    border-radius: 4px;
    background: var(--cg-line);
    overflow: hidden;
}

.er-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--er-mint), var(--er-amber), var(--er-pink));
    transition: width 0.4s ease;
}

.er-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: clamp(280px, 44vh, 400px);
    padding: 14px 12px 12px;
    border-radius: 16px;
    background:
        radial-gradient(ellipse at 50% 38%, rgba(255, 194, 71, 0.2), transparent 55%),
        radial-gradient(ellipse at 15% 100%, rgba(255, 93, 143, 0.28), transparent 55%),
        linear-gradient(160deg, #3a1745 0%, var(--er-plum) 60%, #150a1b 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 -30px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.er-stage.er-shake {
    animation: er-shake 0.4s ease;
}

.er-stage.er-shake::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 50px rgba(255, 60, 90, 0.6);
    pointer-events: none;
    animation: er-flash 0.5s ease forwards;
}

.er-stage.er-good::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 60px rgba(255, 210, 100, 0.55);
    pointer-events: none;
    animation: er-flash 0.9s ease forwards;
}

.er-fx {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.er-glow {
    position: absolute;
    left: 50%;
    top: 42%;
    width: 60%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 194, 71, 0.22), transparent 65%);
    pointer-events: none;
    animation: er-pulse 4s ease-in-out infinite;
}

.er-art {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1em;
    width: 100%;
    max-height: calc(100% - 44px);
    min-height: 0;
    font-size: 56px;
}

.er-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.14em;
    max-width: 100%;
    line-height: 1.12;
}

.er-tok,
.er-bracket {
    display: inline-block;
    flex: 0 0 auto;
    animation: er-drop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.er-emoji {
    font-size: 1em;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45));
}

.er-emoji.er-big {
    font-size: 1.35em;
}

.er-emoji.er-sm {
    font-size: 0.5em;
}

.er-word {
    color: #ffd985;
    font-size: 0.72em;
    font-weight: 900;
    letter-spacing: 0.06em;
    background: linear-gradient(180deg, #fff2c2, #ffb03a 70%, #e07a10);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.4));
}

.er-word.er-big {
    font-size: 0.86em;
}

.er-word.er-sm {
    font-size: 0.38em;
}

.er-rot {
    transform: rotate(-90deg);
}

.er-bracket {
    color: var(--er-mint);
    font-size: 1.1em;
    font-weight: 300;
}

.er-rule,
.er-bar {
    display: block;
    flex: 1 1 auto;
    min-width: 2.4em;
    height: 0.07em;
    min-height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, transparent, #fff 15%, #fff 85%, transparent);
}

.er-bar {
    height: 0.16em;
    background: linear-gradient(90deg, #ffb03a, #ff5d8f);
}

.er-shape {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 14px;
    min-height: 26px;
}

.er-sword {
    display: inline-flex;
    gap: 3px;
}

.er-sch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
}

.er-sch.er-on {
    width: 20px;
    height: 24px;
    background: var(--er-amber);
    color: var(--er-plum);
}

.er-sch.er-sp {
    background: none;
    width: auto;
}

.er-reveal {
    position: relative;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    padding: 8px 18px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--er-amber), var(--er-pink));
    color: var(--er-plum);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
    animation: er-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.er-reveal[hidden] {
    display: none;
}

.er-reveal-kicker {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.7;
}

.er-answer {
    font-size: clamp(1rem, 4.4vw, 1.5rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.er-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.er-float {
    position: absolute;
    left: 50%;
    top: 28%;
    z-index: 5;
    pointer-events: none;
}

.er-ft {
    position: absolute;
    left: 0;
    transform: translateX(-50%);
    font-size: 1.8rem;
    font-weight: 900;
    white-space: nowrap;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    animation: er-rise 1.1s ease-out forwards;
}

.er-ft-good { color: #ffe27a; }
.er-ft-bad { color: #ff7b8f; }

.er-entry {
    gap: 8px;
    margin-top: 10px;
}

.er-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 48px;
    padding: 0 14px;
    border: 2px solid var(--cg-line);
    border-radius: 12px;
    background: #fff;
    color: var(--cg-ink);
    font: inherit;
    font-size: 1.05rem;
    font-weight: 700;
}

.er-input:focus {
    border-color: var(--er-pink);
}

.er-hintline,
.er-status {
    margin: 8px 0 0;
    color: var(--cg-muted);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}

.er-hintline {
    color: #8a5a00;
}

.er-explain {
    margin-top: 8px;
    padding: 9px 12px;
    border: 1px solid #bfe8dd;
    border-radius: 12px;
    background: linear-gradient(180deg, #f1fbf8, #e5f6f1);
    text-align: center;
}

.er-explain strong {
    color: #0f6b58;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.er-explain p {
    margin: 2px 0 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--cg-ink);
}

.er-explain-in {
    animation: er-pop 0.4s ease both;
}

.er-next {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
    min-height: 48px;
}

.er-next[hidden] {
    display: none;
}

.er-result {
    margin-top: 10px;
    padding: 12px;
    border-radius: 14px;
    background: linear-gradient(135deg, #fff0f5, #fff7e6);
    border: 1px solid #ffd0df;
    text-align: center;
}

.er-result[hidden] {
    display: none;
}

.er-kicker {
    color: #b0225a;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.er-result strong {
    display: block;
    margin-top: 2px;
    font-size: 1.25rem;
}

.er-result p {
    margin: 2px 0 8px;
    color: var(--cg-muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.er-result-actions {
    gap: 8px;
}

.er-result-actions .er-btn {
    flex: 1;
}

.er-controls {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.er-seg {
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--cg-line);
    border-radius: 14px;
    background: var(--cg-panel);
}

.er-diffs {
    gap: 4px;
}

.er-diffs.er-off {
    display: none;
}

.er-segbtn,
.er-chip {
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--cg-ink);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
}

.er-chip {
    border: 1px solid var(--cg-line);
    background: var(--cg-panel);
}

.er-segbtn[aria-pressed="true"],
.er-chip[aria-pressed="true"] {
    background: var(--er-plum);
    color: #fff;
    border-color: var(--er-plum);
}

.er-progress {
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px solid var(--cg-line);
    border-radius: 14px;
    background: var(--cg-panel);
}

.er-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.er-gridrow {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 4px;
}

.er-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: 6px;
    background: var(--cg-line);
    color: var(--cg-muted);
    font-size: 10px;
    font-weight: 900;
}

.er-cell-locked {
    background: transparent;
    border: 1px dashed var(--cg-line);
}

.er-grid-short .er-gridrow + .er-gridrow,
.er-grid-short .er-cell-locked {
    display: none;
}

.er-grid-short .er-gridrow {
    grid-template-columns: repeat(3, 44px);
    justify-content: center;
}

.er-grid-short .er-cell {
    aspect-ratio: auto;
    height: 26px;
    font-size: 12px;
}

.er-cell-done {
    background: linear-gradient(135deg, #6fe3c4, #12a084);
    color: #fff;
}

.er-cell-missed {
    background: linear-gradient(135deg, #ff9b9b, #d6455d);
    color: #fff;
}

.er-cell-now {
    background: #fff;
    border: 2px solid var(--er-pink);
    color: var(--er-pink);
    animation: er-pulse 1.6s ease-in-out infinite;
}

.er-progress-note {
    margin: 6px 0 0;
    color: var(--cg-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
}

.er-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(21, 10, 27, 0.6);
}

.er-modal[hidden] {
    display: none;
}

.er-modal-card {
    position: relative;
    width: min(100%, 460px);
    max-height: 90vh;
    overflow: auto;
    padding: 20px;
    border-radius: 18px;
    background: var(--cg-panel);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.er-modal-card h2 {
    margin: 0 44px 8px 0;
    font-size: 1.2rem;
}

.er-modal-card p {
    margin: 0 0 8px;
    font-size: 0.95rem;
    line-height: 1.45;
}

.er-close {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 0;
    font-size: 1.5rem;
}

@keyframes er-drop {
    from { opacity: 0; transform: translateY(-0.5em) scale(0.5); }
    to { opacity: 1; transform: none; }
}

@keyframes er-pop {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: none; }
}

@keyframes er-shake {
    0%, 100% { transform: none; }
    20% { transform: translateX(-9px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

@keyframes er-flash {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes er-pulse {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 1; }
}

@keyframes er-rise {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, -60px); }
}

@media (max-width: 520px) {
    .er-shell {
        padding: 6px 8px 20px;
    }

    .er-stat {
        padding: 4px 7px;
    }

    .er-stat strong {
        font-size: 15px;
    }

    .er-btn {
        padding: 8px 12px;
    }

    .er-stage {
        height: clamp(260px, 40vh, 360px);
    }

    .er-controls {
        gap: 6px;
    }

    .er-segbtn,
    .er-chip {
        padding: 0 10px;
        font-size: 0.85rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .er-tok,
    .er-bracket,
    .er-glow,
    .er-cell-now,
    .er-stage.er-shake {
        animation: none;
    }
}

.er-shell p,
.er-shell strong,
.er-shell span {
    font-family: inherit;
}

.er-entry .er-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .er-entry {
        gap: 6px;
    }

    .er-entry .er-btn {
        padding: 8px 10px;
        font-size: 0.86rem;
    }

    .er-input {
        padding: 0 10px;
        font-size: 1rem;
    }
}
