/* === Rain game ====================================================
   Companion to js/games/rain.js + games/rain.partial.html.
   Vocabulary tap-to-spell: a target word sits at the top; .rain-char
   tiles drop in columns inside .rain-lane and the user taps the right
   one in order. .rain-form-toggle swaps which side is target vs falling
   (romaji ↔ kana). .rain-celebration overlays for the briefly-shown
   "word complete" flash.
   ==================================================================== */

.rain-game {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 2;
    background: var(--bg);
    border-radius: 12px;
    padding: 12px;
    box-sizing: border-box;
}
.rain-game.active {
    opacity: 1;
    pointer-events: auto;
}
.rain-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.rain-score {
    font-size: 0.9rem;
    color: var(--green);
    font-weight: 700;
    min-width: 24px;
}
.rain-form-toggle {
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}
.rain-form-toggle:hover {
    background: var(--accent);
    color: #fff;
}
.rain-form-arrow { font-size: 0.75rem; opacity: 0.7; }
.rain-close {
    background: var(--close-bg);
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
}
.rain-close:hover { background: var(--close-hover); color: var(--text); }

.rain-target {
    text-align: center;
    margin-bottom: 8px;
}
.rain-target-word {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    min-height: 32px;
    letter-spacing: 0.05em;
}
.rain-target-word .unit {
    display: inline-block;
    transition: color 0.2s, transform 0.2s;
}
.rain-target-word .unit.done {
    color: var(--green);
    opacity: 0.55;
}
.rain-target-word .unit.next {
    color: var(--accent);
    transform: scale(1.1);
}
.rain-target-meaning {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
    min-height: 18px;
}

.rain-lane-wrap {
    position: relative;
    flex: 1;
    min-height: 280px;
    border-radius: 12px;
    background: var(--subtle-bg);
    border: 1px solid var(--divider);
    overflow: hidden;
}
.rain-lane {
    position: absolute;
    inset: 0;
}
.rain-floor {
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-border), var(--accent), var(--accent-border));
    border-radius: 2px;
    opacity: 0.6;
}
.rain-char {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.1s;
    will-change: transform, top;
}
.rain-char:active { transform: scale(0.94); }
.rain-char.correct {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
    animation: rainCharBurst 0.35s ease-out forwards;
    pointer-events: none;
}
.rain-char.wrong {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
    animation: rainCharBurst 0.35s ease-out forwards;
    pointer-events: none;
}
@keyframes rainCharBurst {
    0%   { transform: scale(1); opacity: 1; }
    40%  { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.6); opacity: 0; }
}

.rain-celebration {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--green);
    font-weight: 800;
    background: rgba(0,0,0,0.04);
    pointer-events: none;
    animation: rainCelebrate 0.9s ease-out forwards;
    z-index: 5;
}
@keyframes rainCelebrate {
    0%   { opacity: 0; transform: scale(0.6); }
    30%  { opacity: 1; transform: scale(1.1); }
    70%  { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1); }
}
