/* ═══════════════════════════════════════════════════════════════════
   Word Rain — falling-word vocabulary arcade game — styles
   Hero: storm blue #1e40af → #0284c7 (distinct from teal, purple,
   indigo, rose, emerald, amber, violet, cyan, fuchsia used elsewhere)
   Shared by /chs/English/WordRain and /Pinyin/WordRain.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Hero / sidebar header ───────────────────────────────────────── */
.wr-hero {
    background: linear-gradient(135deg, #1e40af 0%, #0284c7 100%);
    border-radius: 0.5rem;
}

.wr-panel-header {
    background: linear-gradient(135deg, #1e40af 0%, #0284c7 100%);
    color: #fff;
    border-radius: 0.375rem 0.375rem 0 0;
}

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

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

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

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

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

@keyframes wr-heart-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.6); }
    100% { transform: scale(0.85); }
}

.wr-heart.popping {
    animation: wr-heart-pop 0.4s ease;
}

.wr-combo-badge {
    display: inline-block;
    min-width: 3.2rem;
    text-align: center;
    background: #f59e0b;
    color: #1f2937;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    font-weight: 800;
}

@keyframes wr-combo-bump {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.wr-combo-badge.bump {
    animation: wr-combo-bump 0.25s ease;
}

/* Wave progress bar */
.wr-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--pl-border, #e2e8f0);
    overflow: hidden;
    margin-bottom: 0.6rem;
}

.wr-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #1e40af, #0284c7);
    transition: width 0.25s ease;
}

/* ── Stage (the sky) ─────────────────────────────────────────────── */
.wr-stage {
    position: relative;
    height: clamp(320px, 48vh, 480px);
    border-radius: 0.75rem;
    border: 1px solid var(--pl-border, #dbeafe);
    background: linear-gradient(180deg, #dbeafe 0%, #eff6ff 55%, #f0f9ff 100%);
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Subtle animated drizzle while a round is running */
.wr-stage::before {
    content: "";
    position: absolute;
    inset: -60px 0 0 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(100deg, transparent 0 22px, rgba(37, 99, 235, 0.10) 22px 24px),
        repeating-linear-gradient(100deg, transparent 0 47px, rgba(37, 99, 235, 0.07) 47px 49px);
    opacity: 0;
    transition: opacity 0.5s;
}

.wr-stage.raining::before {
    opacity: 1;
    animation: wr-drizzle 1.1s linear infinite;
}

@keyframes wr-drizzle {
    from { transform: translateY(-24px); }
    to { transform: translateY(24px); }
}

.wr-ground {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 14px;
    background: linear-gradient(180deg, rgba(2, 132, 199, 0.25), rgba(2, 132, 199, 0.5));
}

@keyframes wr-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(3px); }
}

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

/* ── Falling word tile ───────────────────────────────────────────── */
.wr-word {
    position: absolute;
    top: 0;
    transform: translate(-50%, -70px);
    background: #ffffff;
    border: 2px solid #93c5fd;
    border-radius: 1rem;
    box-shadow: 0 4px 14px rgba(30, 64, 175, 0.18);
    padding: 0.4rem 1.05rem;
    text-align: center;
    max-width: 88%;
    will-change: transform;
    z-index: 2;
}

.wr-word .wr-word-main {
    font-size: clamp(1.15rem, 4.5vw, 1.6rem);
    font-weight: 700;
    color: #1e293b;
    line-height: 1.15;
    word-break: break-word;
}

.wr-word .wr-word-sub {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.1;
}

.wr-stage.hide-sub .wr-word-sub {
    display: none;
}

@keyframes wr-danger-pulse {
    0%, 100% { box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25); border-color: #fca5a5; }
    50% { box-shadow: 0 4px 22px rgba(220, 38, 38, 0.55); border-color: #ef4444; }
}

.wr-word.danger {
    animation: wr-danger-pulse 0.5s ease infinite;
}

@keyframes wr-word-zap {
    to { transform: translate(-50%, var(--wr-y, 0)) scale(0.1) rotate(12deg); opacity: 0; }
}

.wr-word.zapped {
    animation: wr-word-zap 0.28s ease forwards;
}

@keyframes wr-word-splat {
    40% { transform: translate(-50%, var(--wr-y, 0)) scaleY(0.5) scaleX(1.25); }
    to { transform: translate(-50%, var(--wr-y, 0)) scaleY(0.3) scaleX(1.4); opacity: 0; }
}

.wr-word.splat {
    animation: wr-word-splat 0.5s ease forwards;
}

/* ── Answer buttons ──────────────────────────────────────────────── */
.wr-answers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin-top: 0.75rem;
}

@media (min-width: 768px) {
    .wr-answers {
        gap: 0.75rem;
    }
}

.wr-answer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 58px;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--pl-border, #cbd5e1);
    border-radius: 0.65rem;
    background: var(--pl-card-bg, #ffffff);
    color: var(--pl-text, #1e293b);
    font-weight: 600;
    font-size: 1.02rem;
    line-height: 1.25;
    text-align: center;
    word-break: break-word;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s, background-color 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.wr-answer-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: #0284c7;
}

.wr-answer-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.wr-answer-btn .wr-key-hint {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
    border: 1px solid var(--pl-border, #cbd5e1);
    border-radius: 0.3rem;
    padding: 0 0.3rem;
    margin-right: 0.5rem;
    flex: 0 0 auto;
}

.wr-answer-btn.correct {
    background: #d1e7dd;
    border-color: #198754;
    color: #0a3622;
    opacity: 1;
}

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

.wr-answer-btn.wrong {
    background: #f8d7da;
    border-color: #dc3545;
    color: #58151c;
    animation: wr-btn-shake 0.3s ease;
    opacity: 1;
}

/* ── Floating score / particles / confetti ───────────────────────── */
.wr-float {
    position: absolute;
    transform: translate(-50%, 0);
    font-weight: 800;
    font-size: 1.25rem;
    color: #16a34a;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.7);
    pointer-events: none;
    z-index: 4;
    animation: wr-float-up 0.9s ease-out forwards;
}

@keyframes wr-float-up {
    to { transform: translate(-50%, -75px); opacity: 0; }
}

.wr-particle {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 3;
    transition: transform 0.65s ease-out, opacity 0.65s ease-out;
}

.wr-confetti {
    position: absolute;
    top: -14px;
    width: 10px;
    height: 14px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 6;
    animation: wr-confetti-fall linear forwards;
}

@keyframes wr-confetti-fall {
    to { transform: translateY(560px) rotate(660deg); opacity: 0.2; }
}

/* ── Reveal toast (shows the correct pair after a miss) ──────────── */
.wr-reveal {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%);
    background: var(--pl-card-bg, #ffffff);
    border: 2px solid #f59e0b;
    border-radius: 0.75rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    padding: 0.6rem 1.2rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--pl-text, #1e293b);
    text-align: center;
    z-index: 5;
}

.wr-reveal small {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--bs-secondary-color);
}

/* Short status toast (e.g. "level 2 words joined the rain!") */
.wr-toast {
    position: absolute;
    left: 50%;
    top: 12%;
    transform: translateX(-50%);
    background: rgba(30, 64, 175, 0.92);
    color: #fff;
    border-radius: 999px;
    padding: 0.35rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 5;
    animation: wr-toast-in 2.4s ease forwards;
}

@keyframes wr-toast-in {
    0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    12%, 82% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ── Overlays (start / wave clear / game over / paused) ──────────── */
.wr-overlay {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    overflow-y: auto;
}

.wr-overlay h2,
.wr-overlay h3 {
    margin-bottom: 0;
}

.wr-overlay .wr-big-icon {
    font-size: 2.6rem;
    color: #0284c7;
    line-height: 1;
}

.wr-btn-primary {
    background: linear-gradient(135deg, #1e40af 0%, #0284c7 100%);
    border: none;
    color: #fff;
}

.wr-btn-primary:hover,
.wr-btn-primary:focus {
    color: #fff;
    filter: brightness(1.1);
}

.wr-final-score {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
    color: #0284c7;
}

.wr-final-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 1.4rem;
    font-size: 0.95rem;
}

.wr-final-stats strong {
    font-size: 1.15rem;
}

@keyframes wr-newbest-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.wr-newbest {
    animation: wr-newbest-pulse 0.9s ease infinite;
}

/* Missed-word chips (game-over review + sidebar) */
.wr-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    max-width: 100%;
}

.wr-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    background: rgba(2, 132, 199, 0.09);
    border: 1px solid rgba(2, 132, 199, 0.35);
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

.wr-chip .wr-chip-answer {
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
}

/* Sidebar best-score rows */
.wr-best-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--pl-border, #f1f5f9);
    padding: 0.3rem 0;
}

.wr-best-row:last-child {
    border-bottom: none;
}

/* Visually hidden live region for screen readers */
.wr-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── Dark mode ───────────────────────────────────────────────────── */
[data-bs-theme="dark"] .wr-stage {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 70%, #1e3a5f 100%);
    border-color: var(--pl-border, #3a4049);
}

[data-bs-theme="dark"] .wr-stage::before {
    background-image:
        repeating-linear-gradient(100deg, transparent 0 22px, rgba(125, 211, 252, 0.10) 22px 24px),
        repeating-linear-gradient(100deg, transparent 0 47px, rgba(125, 211, 252, 0.06) 47px 49px);
}

[data-bs-theme="dark"] .wr-word {
    background: var(--pl-card-bg, #2b3035);
    border-color: #1e40af;
}

[data-bs-theme="dark"] .wr-word .wr-word-main {
    color: var(--pl-text, #e4e6eb);
}

[data-bs-theme="dark"] .wr-word .wr-word-sub {
    color: #94a3b8;
}

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

[data-bs-theme="dark"] .wr-float {
    color: #4ade80;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

[data-bs-theme="dark"] .wr-answer-btn.correct {
    background: #14532d;
    border-color: #22c55e;
    color: #dcfce7;
}

[data-bs-theme="dark"] .wr-answer-btn.wrong {
    background: #58151c;
    border-color: #ef4444;
    color: #f8d7da;
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .wr-stage.raining::before,
    .wr-stage.shaking,
    .wr-word.danger,
    .wr-combo-badge.bump,
    .wr-newbest,
    .wr-confetti {
        animation: none;
    }
}
