/* === Swipe game ====================================================
   Companion to js/games/swipe.js + games/swipe.partial.html.
   The four directional .swipe-option bubbles ring the .swipe-arena; the
   .swipe-puck (centered character) drags toward whichever romaji matches.
   .swipe-timer-fill drains over each round; .urgent bumps the fill to
   the warning color in the last seconds.

   Slide-in: .swipe-game inactive sits 40px right-of-center; .active
   slides it home, paired with .card-area.hidden translating -40px the
   other way for a cross-slide handoff.
   ==================================================================== */

.swipe-game {
    position: absolute;
    top: 50%;
    left: 50%;
    /* Inactive state sits 40px right of center so it slides into
       place when .active lands — pairs with .card-area.hidden
       translating -40px the other way for a clean cross-slide.
       Ease-out so the new panel decelerates as it arrives
       (settles in) rather than the symmetric ease used by the
       outgoing card-area. */
    transform: translate(calc(-50% + 40px), -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 320px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
    z-index: 2;
}

.swipe-game.active {
    opacity: 1;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.swipe-game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 4px;
}

.swipe-score {
    font-size: 0.85rem;
    color: var(--green);
    font-weight: 600;
}

.swipe-progress {
    font-size: 0.8rem;
    color: var(--text-faint);
}

.swipe-timer {
    width: 100%;
    height: 3px;
    background: var(--timer-bg);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4rem;
}

.swipe-timer-fill {
    height: 100%;
    border-radius: 2px;
    width: 100%;
    transition: width 0.1s linear, background 0.3s;
    background: var(--timer-fill);
}

.swipe-timer-fill.urgent {
    background: var(--timer-urgent);
}

/* Session progress bar — sits below the per-round timer. Subtler color
   so the eye reads the per-round timer first, the session progress
   second. The fill animates over 0.3s so re-queue / rebuild changes
   are perceptible rather than abrupt. */
.swipe-overall-progress {
    width: 100%;
    height: 4px;
    background: var(--subtle-bg);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}
.swipe-overall-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: var(--green);
    opacity: 0.7;
    transition: width 0.3s ease;
}

.swipe-arena {
    position: relative;
    width: 320px;
    height: 340px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Romaji option bubbles around the card */
.swipe-option {
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-hover);
    border: 2px solid var(--accent-border);
    color: var(--accent);
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    font-family: inherit;
    z-index: 2;
}

.swipe-option.top    { top: -32px; left: 50%; transform: translateX(-50%); }
.swipe-option.right  { right: -32px; top: 50%; transform: translateY(-50%); }
.swipe-option.bottom { bottom: -32px; left: 50%; transform: translateX(-50%); }
.swipe-option.left   { left: -32px; top: 50%; transform: translateY(-50%); }

.swipe-option.correct {
    background: var(--green-bg);
    border-color: var(--green);
    color: var(--green);
    transform-origin: center;
}

.swipe-option.wrong {
    background: var(--red-bg);
    border-color: var(--red);
    color: var(--red);
}

/* Character puck in center */
.swipe-puck {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--puck-bg);
    border: 2px solid var(--puck-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 2.2rem;
    color: var(--text);
    z-index: 3;
    transition: top 0.3s ease-out, left 0.3s ease-out, opacity 0.3s;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.swipe-puck:active {
    cursor: grabbing;
}

.swipe-puck.fly {
    transition: top 0.25s ease-in, left 0.25s ease-in, opacity 0.2s;
}

.swipe-feedback {
    font-size: 0.85rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
    margin-top: 8px;
    /* min-height (not height) so the empty-state still reserves a line
       of space, but multi-line completion messages can grow without
       overlapping the Continue button below. */
    min-height: 1.2rem;
    line-height: 1.35;
    padding: 0 8px;
}

/* End-of-session continue button. Hidden during play; revealed when
   the session completes so the user has time to read their score
   before launching Fall. */
.swipe-continue-btn {
    display: block;
    margin: 12px auto 0;
    padding: 10px 22px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.02em;
    transition: background 0.15s, transform 0.1s;
}
.swipe-continue-btn:hover { background: var(--heading); }
.swipe-continue-btn:active { transform: translateY(1px); }
.swipe-continue-btn[hidden] { display: none; }

.swipe-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--close-bg);
    border: 1px solid var(--close-border);
    color: var(--close-color);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: all 0.2s;
}

.swipe-close:hover {
    background: var(--close-hover);
    color: var(--text-muted);
}

/* Game-over / round-complete overlay */
.swipe-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay-bg);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.swipe-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
