/**
 * NihongoDoya - Particle Rush Stylesheet
 * Watery Neo-Brutalist design for fast Japanese grammar particle mini-game
 */

:root {
    --pr-ink: #111827;
    --pr-bg: #f8fafc;
    --pr-card-bg: #ffffff;
    --pr-yellow: #ffd166;
    --pr-yellow-hover: #fecb52;
    --pr-aqua: #06b6d4;
    --pr-aqua-light: #ccfbf1;
    --pr-aqua-border: #0f766e;
    --pr-coral: #ef4444;
    --pr-coral-light: #fee2e2;
    --pr-coral-border: #dc2626;
    --pr-font-jp: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

/* --------------------------------------------------------------------------
   Container & Global Shell
   -------------------------------------------------------------------------- */
.pr-game-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 16px 40px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--pr-ink);
}

/* Base Card */
.pr-card {
    background: var(--pr-card-bg);
    border: 3px solid var(--pr-ink);
    border-radius: 12px;
    box-shadow: 4px 4px 0px var(--pr-ink);
    padding: 28px 24px;
    margin-bottom: 24px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* --------------------------------------------------------------------------
   Pre-Game Setup Card
   -------------------------------------------------------------------------- */
.pr-setup-header {
    text-align: center;
    margin-bottom: 24px;
}

.pr-setup-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--pr-ink);
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.pr-setup-title i {
    color: #d97706;
}

.pr-setup-subtitle {
    font-size: 1rem;
    color: #4b5563;
    margin: 0;
}

/* Personal Best Banner */
.pr-high-score-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fef3c7;
    border: 2px solid var(--pr-ink);
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #92400e;
}

.pr-high-score-banner strong {
    font-size: 1.15rem;
    font-family: 'Outfit', sans-serif;
    color: var(--pr-ink);
}

/* Option Groups */
.pr-option-group {
    margin-bottom: 20px;
}

.pr-option-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 8px;
}

.pr-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pr-chip {
    flex: 1 1 auto;
    min-width: 90px;
    background: #ffffff;
    border: 2px solid var(--pr-ink);
    border-radius: 8px;
    box-shadow: 2px 2px 0px var(--pr-ink);
    padding: 10px 14px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--pr-ink);
    cursor: pointer;
    text-align: center;
    transition: all 0.1s ease;
    user-select: none;
}

.pr-chip:hover {
    background: #f8fafc;
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0px var(--pr-ink);
}

.pr-chip.active {
    background: var(--pr-yellow);
    border-color: var(--pr-ink);
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px var(--pr-ink);
}

.pr-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e0f2fe;
    border: 2px solid var(--pr-ink);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-weight: 700;
    color: #0369a1;
}

/* --------------------------------------------------------------------------
   In-Game HUD
   -------------------------------------------------------------------------- */
.pr-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--pr-card-bg);
    border: 3px solid var(--pr-ink);
    border-radius: 12px;
    box-shadow: 4px 4px 0px var(--pr-ink);
    padding: 12px 18px;
    margin-bottom: 16px;
}

.pr-hud-item {
    display: flex;
    flex-direction: column;
}

.pr-hud-label {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.pr-hud-val {
    font-family: 'Outfit', sans-serif;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--pr-ink);
    line-height: 1.1;
}

/* Streak Pill */
.pr-streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff7ed;
    border: 2px solid var(--pr-ink);
    border-radius: 20px;
    padding: 6px 14px;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    color: #c2410c;
}

.pr-streak-badge i {
    color: #ea580c;
}

/* Timer Display */
.pr-timer-display {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Outfit', monospace;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--pr-ink);
    background: #f1f5f9;
    border: 2px solid var(--pr-ink);
    border-radius: 8px;
    padding: 6px 12px;
}

.pr-timer-display.is-urgent {
    background: #fee2e2;
    border-color: var(--pr-coral-border);
    color: var(--pr-coral-border);
    animation: prTimerPulse 0.8s infinite alternate ease-in-out;
}

@keyframes prTimerPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

.pr-hud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #ffffff;
    border: 2px solid var(--pr-ink);
    border-radius: 8px;
    box-shadow: 2px 2px 0px var(--pr-ink);
    font-size: 1rem;
    color: var(--pr-ink);
    cursor: pointer;
    transition: all 0.1s ease;
}

.pr-hud-btn:hover {
    background: #f1f5f9;
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0px var(--pr-ink);
}

.pr-hud-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px var(--pr-ink);
}

/* --------------------------------------------------------------------------
   Rush Meter & Rush Mode Indicator
   -------------------------------------------------------------------------- */
.pr-rush-bar-wrap {
    background: #ffffff;
    border: 2.5px solid var(--pr-ink);
    border-radius: 8px;
    box-shadow: 3px 3px 0px var(--pr-ink);
    padding: 8px 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.25s ease;
}

.pr-rush-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pr-ink);
    white-space: nowrap;
}

.pr-rush-label i {
    color: #0284c7;
}

.pr-rush-track {
    flex: 1;
    height: 12px;
    background: #e2e8f0;
    border: 2px solid var(--pr-ink);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.pr-rush-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #38bdf8, #06b6d4);
    border-radius: 4px;
    transition: width 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pr-rush-status {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    color: #0369a1;
    min-width: 52px;
    text-align: right;
}

/* Rush Mode Active State */
.pr-arena.is-rush-active {
    border-color: #0891b2;
    box-shadow: 4px 4px 0px #0891b2, 0 0 16px rgba(6, 182, 212, 0.25);
}

.pr-rush-bar-wrap.is-rush-active {
    background: #ecfeff;
    border-color: #0891b2;
    box-shadow: 3px 3px 0px #0891b2, 0 0 12px rgba(6, 182, 212, 0.25);
}

.pr-rush-bar-wrap.is-rush-active .pr-rush-fill {
    background: linear-gradient(90deg, #06b6d4, #10b981);
}

.pr-rush-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #0891b2;
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 4px;
    animation: prRushPulse 1s infinite alternate ease-in-out;
}

@keyframes prRushPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.06); }
}

/* --------------------------------------------------------------------------
   Arena & Sentence Hero
   -------------------------------------------------------------------------- */
.pr-arena {
    position: relative;
    background: var(--pr-card-bg);
    border: 3px solid var(--pr-ink);
    border-radius: 12px;
    box-shadow: 4px 4px 0px var(--pr-ink);
    padding: 32px 24px;
    margin-bottom: 24px;
    transition: all 0.2s ease;
}

/* Temporary Combo Toast */
.pr-combo-toast {
    position: absolute;
    top: 12px;
    right: 16px;
    background: #fef08a;
    border: 2px solid var(--pr-ink);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    color: #854d0e;
    box-shadow: 2px 2px 0px var(--pr-ink);
    opacity: 0;
    transform: translateY(-8px);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 10;
}

.pr-combo-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Sentence Hero Stage */
.pr-sentence-stage {
    text-align: center;
    margin-bottom: 32px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pr-sentence-text {
    font-family: var(--pr-font-jp);
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--pr-ink);
    line-height: 1.5;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
    word-break: keep-all;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* The Missing Particle Blank */
.pr-blank {
    display: inline-block;
    min-width: 48px;
    padding: 2px 10px;
    margin: 0 4px;
    background: #f1f5f9;
    border-bottom: 3.5px solid #0284c7;
    border-radius: 6px;
    color: #0369a1;
    font-weight: 900;
    letter-spacing: 0;
    text-align: center;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
}

/* Correct Snap Animation */
.pr-blank.snapped {
    background: var(--pr-aqua-light);
    border-color: var(--pr-aqua-border);
    color: var(--pr-aqua-border);
    transform: scale(1.12);
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

/* Wrong State */
.pr-blank.wrong-reveal {
    background: var(--pr-coral-light);
    border-color: var(--pr-coral-border);
    color: var(--pr-coral-border);
    transform: scale(1.05);
}

.pr-sentence-tr {
    font-size: 1rem;
    font-weight: 500;
    color: #64748b;
    margin: 0;
}

/* --------------------------------------------------------------------------
   Answer Buttons (Choices)
   -------------------------------------------------------------------------- */
.pr-choices-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.pr-choice-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 76px;
    background: #ffffff;
    border: 3px solid var(--pr-ink);
    border-radius: 10px;
    box-shadow: 3px 3px 0px var(--pr-ink);
    cursor: pointer;
    user-select: none;
    transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
    padding: 8px 12px;
}

.pr-choice-btn:hover:not(:disabled) {
    background: #f8fafc;
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0px var(--pr-ink);
}

.pr-choice-btn:active:not(:disabled) {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--pr-ink);
}

.pr-choice-key {
    position: absolute;
    top: 6px;
    left: 8px;
    font-family: 'Outfit', monospace;
    font-size: 0.72rem;
    font-weight: 800;
    color: #4b5563;
    background: #f1f5f9;
    border: 1.5px solid var(--pr-ink);
    border-radius: 4px;
    padding: 1px 5px;
    line-height: 1.1;
}

.pr-choice-glyph {
    font-family: var(--pr-font-jp);
    font-size: 1.95rem;
    font-weight: 800;
    color: var(--pr-ink);
    line-height: 1;
}

/* Answer Result States */
.pr-choice-btn.is-correct {
    background: var(--pr-aqua-light) !important;
    border-color: var(--pr-aqua-border) !important;
    color: var(--pr-aqua-border) !important;
    transform: translate(2px, 2px) !important;
    box-shadow: 1px 1px 0px var(--pr-aqua-border) !important;
}

.pr-choice-btn.is-correct .pr-choice-glyph {
    color: var(--pr-aqua-border) !important;
}

.pr-choice-btn.is-wrong {
    background: var(--pr-coral-light) !important;
    border-color: var(--pr-coral-border) !important;
    color: var(--pr-coral-border) !important;
    transform: translate(2px, 2px) !important;
    box-shadow: 1px 1px 0px var(--pr-coral-border) !important;
}

.pr-choice-btn.is-wrong .pr-choice-glyph {
    color: var(--pr-coral-border) !important;
}

.pr-choice-btn.is-dimmed {
    opacity: 0.45;
}

/* --------------------------------------------------------------------------
   Countdown Overlay & Modals
   -------------------------------------------------------------------------- */
.pr-countdown-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(2px);
}

.pr-countdown-number {
    font-family: 'Outfit', sans-serif;
    font-size: 5rem;
    font-weight: 900;
    color: var(--pr-ink);
    line-height: 1;
    animation: prPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pr-countdown-sub {
    font-size: 1.1rem;
    font-weight: 700;
    color: #4b5563;
    margin-top: 10px;
}

@keyframes prPop {
    0% { transform: scale(0.3); opacity: 0; }
    70% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Generic Overlay Modal */
.pr-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.pr-modal {
    background: #ffffff;
    border: 3px solid var(--pr-ink);
    border-radius: 12px;
    box-shadow: 6px 6px 0px var(--pr-ink);
    padding: 28px 24px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    animation: prModalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes prModalIn {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.pr-modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 10px 0;
    color: var(--pr-ink);
}

.pr-modal-text {
    font-size: 0.95rem;
    color: #4b5563;
    margin: 0 0 22px 0;
    line-height: 1.5;
}

.pr-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --------------------------------------------------------------------------
   Results Screen
   -------------------------------------------------------------------------- */
.pr-results-card {
    background: var(--pr-card-bg);
    border: 3px solid var(--pr-ink);
    border-radius: 12px;
    box-shadow: 4px 4px 0px var(--pr-ink);
    padding: 32px 24px;
    margin-bottom: 24px;
    text-align: center;
}

.pr-results-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ecfeff;
    border: 2px solid #0891b2;
    border-radius: 20px;
    padding: 6px 16px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    font-weight: 800;
    color: #0891b2;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.pr-results-title {
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin: 0 0 4px 0;
}

.pr-final-score {
    font-family: 'Outfit', sans-serif;
    font-size: 3.4rem;
    font-weight: 900;
    color: var(--pr-ink);
    line-height: 1;
    margin-bottom: 10px;
}

.pr-new-high-badge {
    display: inline-block;
    background: #fef08a;
    border: 2px solid var(--pr-ink);
    border-radius: 6px;
    padding: 6px 14px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    color: #854d0e;
    box-shadow: 2px 2px 0px var(--pr-ink);
    margin-bottom: 22px;
}

/* Stats Grid */
.pr-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.pr-stat-box {
    background: #f8fafc;
    border: 2px solid var(--pr-ink);
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
}

.pr-stat-box-num {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--pr-ink);
    line-height: 1.2;
}

.pr-stat-box-lbl {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* Weak Particles ("Needs Practice") Section */
.pr-weak-section {
    background: #fffbeb;
    border: 2px solid var(--pr-ink);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
}

.pr-weak-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.pr-weak-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pr-weak-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1.5px solid var(--pr-ink);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--pr-ink);
}

.pr-weak-chip strong {
    font-family: var(--pr-font-jp);
    font-size: 1.15rem;
    color: var(--pr-coral-border);
}

/* Review Mistakes Section */
.pr-review-section {
    background: #ffffff;
    border: 2px solid var(--pr-ink);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 24px;
    text-align: left;
}

.pr-review-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: var(--pr-ink);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.pr-review-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

.pr-review-item {
    background: #f8fafc;
    border: 1.5px solid var(--pr-ink);
    border-radius: 6px;
    padding: 12px 14px;
}

.pr-review-sentence {
    font-family: var(--pr-font-jp);
    font-size: 1.18rem;
    font-weight: 700;
    color: var(--pr-ink);
    margin-bottom: 6px;
}

.pr-review-answers {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.pr-review-wrong {
    color: var(--pr-coral-border);
}

.pr-review-wrong span {
    font-family: var(--pr-font-jp);
    font-weight: 800;
    font-size: 1.05rem;
}

.pr-review-correct {
    color: var(--pr-aqua-border);
}

.pr-review-correct span {
    font-family: var(--pr-font-jp);
    font-weight: 800;
    font-size: 1.05rem;
}

.pr-review-note {
    font-size: 0.84rem;
    color: #475569;
    line-height: 1.45;
    background: #f1f5f9;
    border-radius: 4px;
    padding: 6px 8px;
    margin-top: 4px;
}

/* Results Actions */
.pr-results-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (min-width: 600px) {
    .pr-results-actions {
        flex-direction: row;
        justify-content: center;
    }
    .pr-results-actions > * {
        flex: 1;
    }
}

/* --------------------------------------------------------------------------
   Responsive Layout (Mobile 390px, 430px, Tablet 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .pr-game-container {
        padding: 0 12px 30px;
    }

    .pr-card {
        padding: 20px 16px;
    }

    .pr-setup-title {
        font-size: 1.6rem;
    }

    .pr-sentence-stage {
        margin-bottom: 24px;
        min-height: 90px;
    }

    .pr-sentence-text {
        font-size: 1.45rem;
    }

    .pr-blank {
        min-width: 36px;
        padding: 1px 6px;
    }

    .pr-choices-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .pr-choice-btn {
        height: 64px;
    }

    .pr-choice-glyph {
        font-size: 1.65rem;
    }

    .pr-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pr-final-score {
        font-size: 2.8rem;
    }

    .pr-hud {
        padding: 10px 12px;
    }

    .pr-hud-val {
        font-size: 1.25rem;
    }

    .pr-timer-display {
        font-size: 1.15rem;
        padding: 4px 8px;
    }

    .pr-streak-badge {
        padding: 4px 10px;
        font-size: 0.95rem;
    }
}
