/* ═══════════════════════════════════════════════════════════════════
   Radical Hunt — find every character containing a given radical (G10)
   Hero: emerald #065f46 → #10b981, distinct from Triple Match's violet,
   Character Builder's indigo, Look-Alike's teal, Tone Pair Arcade's
   rose and Number Dictation's amber.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Hero ────────────────────────────────────────────────────────── */
.rh-hero {
    background: linear-gradient(135deg, #064e3b 0%, #047857 55%, #10b981 100%);
    border-radius: 0.5rem;
}

/* ── HUD row above the stage ─────────────────────────────────────── */
.rh-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}

.rh-hud-item {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.2;
    white-space: nowrap;
}

.rh-hud-item small {
    display: block;
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
}

.rh-heart {
    color: #ef4444;
    font-size: 1.15rem;
    transition: transform 0.15s, color 0.15s;
}

.rh-heart.lost {
    color: #cbd5e1;
    transform: scale(0.85);
}

.rh-combo-badge {
    display: inline-block;
    min-width: 2.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: #047857;
    color: #fff;
    font-size: 0.95rem;
}

.rh-progress {
    height: 5px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.3);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.rh-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #047857, #10b981);
    transition: width 0.3s ease;
}

/* ── The stage ───────────────────────────────────────────────────── */
.rh-stage {
    position: relative;
    /* Only as tall as the game-over overlay needs — grids vary from 16 to 30. */
    min-height: 420px;
    border-radius: 0.75rem;
    background: linear-gradient(180deg, #ecfdf5 0%, #f0fdfa 100%);
    border: 1px solid rgba(4, 120, 87, 0.15);
    padding: 1rem;
    overflow: hidden;
}

/* ── The target prompt ───────────────────────────────────────────── */
.rh-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    text-align: left;
    min-height: 4.2rem;
    padding-bottom: 0.5rem;
}

.rh-prompt-glyph {
    font-size: clamp(2.6rem, 10vw, 3.6rem);
    line-height: 1;
    font-weight: 600;
    color: #047857;
    padding: 0.15rem 0.75rem;
    border: 3px solid rgba(4, 120, 87, 0.35);
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.75);
}

.rh-prompt-text {
    max-width: 22rem;
}

.rh-prompt-reading {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
}

.rh-prompt-meaning {
    font-size: 0.95rem;
    color: var(--bs-secondary-color);
}

.rh-prompt-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: #047857;
    margin-top: 0.15rem;
}

/* Countdown bar */
.rh-timer {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
    margin-bottom: 0.9rem;
}

.rh-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #10b981, #047857);
}

.rh-timer-fill.urgent {
    background: linear-gradient(90deg, #f97316, #ef4444);
    animation: rh-pulse 0.6s ease-in-out infinite;
}

@keyframes rh-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ── The grid ────────────────────────────────────────────────────── */
.rh-grid {
    display: grid;
    gap: 0.4rem;
    justify-content: center;
}

.rh-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    width: 100%;
    padding: 0;
    border: 2px solid rgba(4, 120, 87, 0.2);
    border-radius: 0.6rem;
    background: #fff;
    color: #0f172a;
    font-size: clamp(1.5rem, 6vw, 2.1rem);
    line-height: 1;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, background 0.12s;
}

.rh-cell:hover:not(:disabled) {
    border-color: #047857;
    transform: translateY(-2px);
}

.rh-cell.found {
    border-color: #16a34a;
    background: #dcfce7;
    color: #14532d;
    cursor: default;
    animation: rh-pop 0.35s ease;
}

.rh-cell.wrong {
    border-color: #dc2626;
    background: #fee2e2;
    animation: rh-shake 0.35s ease;
}

/* A hit the player never tapped, revealed when the round ends. */
.rh-cell.missed {
    border-color: #f59e0b;
    background: #fef3c7;
    color: #92400e;
}

.rh-cell.hinted {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

.rh-cell:disabled {
    cursor: default;
}

@keyframes rh-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.09); }
    100% { transform: scale(1); }
}

@keyframes rh-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ── Status line under the grid ──────────────────────────────────── */
.rh-status {
    min-height: 1.5rem;
    margin-top: 0.7rem;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.rh-status.shown { opacity: 1; }
.rh-status.ok { color: #15803d; }
.rh-status.bad { color: #b91c1c; }
.rh-status.hint { color: #b45309; }

.rh-speaker {
    border: none;
    background: transparent;
    color: #047857;
    padding: 0.1rem 0.35rem;
    cursor: pointer;
    border-radius: 0.25rem;
}

.rh-speaker:hover {
    background: rgba(4, 120, 87, 0.12);
}

.rh-speaker.rh-speaker-loading {
    opacity: 0.45;
    cursor: progress;
}

/* Floating score */
.rh-float {
    position: absolute;
    top: 34%;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 800;
    font-size: 1.5rem;
    color: #15803d;
    pointer-events: none;
    z-index: 4;
    animation: rh-float-up 0.9s ease-out forwards;
}

@keyframes rh-float-up {
    0% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -60px); }
}

/* ── Overlays ────────────────────────────────────────────────────── */
.rh-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    text-align: center;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(2px);
    z-index: 5;
    overflow-y: auto;
}

.rh-big-icon {
    font-size: 2.5rem;
    color: #047857;
}

.rh-btn-primary {
    background: linear-gradient(135deg, #047857, #10b981);
    border: none;
    color: #fff;
    font-weight: 600;
}

.rh-btn-primary:hover {
    background: linear-gradient(135deg, #064e3b, #047857);
    color: #fff;
}

.rh-level-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.rh-level-btn {
    border: 2px solid rgba(4, 120, 87, 0.3);
    background: #fff;
    border-radius: 0.5rem;
    padding: 0.4rem 0.9rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.12s;
}

.rh-level-btn:hover { border-color: #047857; }

.rh-level-btn.active {
    background: linear-gradient(135deg, #047857, #10b981);
    border-color: #047857;
    color: #fff;
}

.rh-final-score {
    font-size: 2.75rem;
    font-weight: 800;
    color: #047857;
    line-height: 1;
}

.rh-final-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.1rem;
    justify-content: center;
    font-size: 0.875rem;
    color: var(--bs-secondary-color);
}

.rh-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
}

.rh-chip {
    background: rgba(4, 120, 87, 0.12);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 1.05rem;
}

/* Round-review list: every hit on the board, tapped or missed. */
.rh-review {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.5rem;
    justify-content: center;
    max-width: 34rem;
    font-size: 0.8rem;
}

.rh-review-item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    padding: 0.15rem 0.45rem;
    border-radius: 0.4rem;
    background: rgba(4, 120, 87, 0.1);
}

.rh-review-item.was-missed {
    background: rgba(245, 158, 11, 0.18);
}

.rh-review-char {
    font-size: 1.15rem;
    font-weight: 600;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.rh-side-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.rh-side-row:last-child { border-bottom: none; }

.rh-side-glyph {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1;
    color: #047857;
}

.rh-ref-char {
    font-size: 1.4rem;
    line-height: 1.5;
}

.rh-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .rh-grid { gap: 0.28rem; }
    .rh-cell { border-radius: 0.45rem; border-width: 2px; }
    .rh-stage { padding: 0.6rem; }
    .rh-prompt { gap: 0.6rem; }
}

/* ── Dark mode ───────────────────────────────────────────────────── */
[data-bs-theme="dark"] .rh-stage {
    background: linear-gradient(180deg, #052e26 0%, #04211c 100%);
    border-color: rgba(16, 185, 129, 0.25);
}

[data-bs-theme="dark"] .rh-prompt-glyph {
    color: #6ee7b7;
    background: rgba(6, 78, 59, 0.6);
    border-color: rgba(16, 185, 129, 0.4);
}

[data-bs-theme="dark"] .rh-prompt-count { color: #6ee7b7; }

[data-bs-theme="dark"] .rh-cell {
    background: #06392f;
    border-color: rgba(16, 185, 129, 0.28);
    color: #e2e8f0;
}

[data-bs-theme="dark"] .rh-cell.found {
    background: rgba(22, 163, 74, 0.32);
    border-color: #22c55e;
    color: #bbf7d0;
}

[data-bs-theme="dark"] .rh-cell.wrong {
    background: rgba(220, 38, 38, 0.3);
    border-color: #ef4444;
}

[data-bs-theme="dark"] .rh-cell.missed {
    background: rgba(245, 158, 11, 0.28);
    border-color: #f59e0b;
    color: #fde68a;
}

[data-bs-theme="dark"] .rh-overlay { background: rgba(15, 23, 42, 0.94); }

[data-bs-theme="dark"] .rh-level-btn {
    background: #06392f;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .rh-status.ok { color: #4ade80; }
[data-bs-theme="dark"] .rh-status.bad { color: #f87171; }
[data-bs-theme="dark"] .rh-status.hint { color: #fbbf24; }
[data-bs-theme="dark"] .rh-side-glyph { color: #6ee7b7; }
[data-bs-theme="dark"] .rh-float { color: #4ade80; }
[data-bs-theme="dark"] .rh-heart.lost { color: #475569; }

@media (prefers-reduced-motion: reduce) {
    .rh-cell,
    .rh-timer-fill,
    .rh-float,
    .rh-progress-fill {
        animation: none !important;
        transition: none !important;
    }
}
