/* ═══════════════════════════════════════════════
   ROAD RACE: FUEL RUSH — endless 3-lane driving game
═══════════════════════════════════════════════ */
.rr-page {
    background: linear-gradient(160deg, #dbeafe 0%, #dcfce7 100%);
    min-height: calc(100vh - 250px);
    padding: 40px 0 60px;
}
.rr-shell {
    max-width: 640px;
    margin: 0 auto;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, .12);
    padding: 28px 24px 32px;
}
.rr-title {
    text-align: center;
    font-weight: 800;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    color: #1e293b;
    margin-bottom: 4px;
}
.rr-subtitle {
    text-align: center;
    color: #64748b;
    font-size: 1rem;
    margin-bottom: 24px;
}
.rr-screen { display: none; }
.rr-screen.active { display: block; animation: rr-fade .25s ease; }
@keyframes rr-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Setup screen ── */
.rr-step-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: #334155;
    margin: 18px 0 10px;
}
.rr-category-grid, .rr-class-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.rr-category-btn, .rr-class-btn {
    border: 3px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 18px;
    padding: 22px 10px;
    font-weight: 800;
    font-size: 1.2rem;
    color: #334155;
    cursor: pointer;
    transition: transform .15s, border-color .15s, background .15s;
    text-align: center;
}
.rr-category-btn .rr-category-icon { display: block; font-size: 2rem; margin-bottom: 6px; }
.rr-category-btn:hover, .rr-class-btn:hover { transform: translateY(-2px); }
.rr-category-btn.rr-category-even.selected {
    border-color: #22c55e;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: #15803d;
    transform: translateY(-2px);
}
.rr-category-btn.rr-category-odd.selected {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: #b91c1c;
    transform: translateY(-2px);
}
.rr-class-btn.selected {
    border-color: #6366f1;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #4338ca;
    transform: translateY(-2px);
}
.rr-instruction {
    text-align: center;
    font-weight: 700;
    color: #6366f1;
    margin-top: 14px;
    min-height: 1.4em;
}
.rr-nickname {
    width: 100%;
    border: 3px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
}
.rr-nickname:focus { outline: none; border-color: #a5b4fc; }
.rr-btn-primary {
    width: 100%;
    margin-top: 24px;
    border: none;
    border-radius: 16px;
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 8px 20px rgba(22,163,74,.3);
    cursor: pointer;
    transition: transform .15s, opacity .15s;
}
.rr-btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.rr-btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ── Play screen ── */
.rr-instruction-banner {
    text-align: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: #4338ca;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-radius: 14px;
    padding: 10px 14px;
    margin-bottom: 16px;
}
.rr-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.rr-lives { flex: 1; min-width: 70px; font-size: 1.2rem; letter-spacing: 2px; }
.rr-lives .rr-heart-lost { opacity: .25; }
.rr-stat { text-align: center; flex: 1; min-width: 62px; }
.rr-stat .rr-stat-num { font-weight: 800; font-size: 1.4rem; line-height: 1; }
.rr-stat-unit { font-size: .75rem; font-weight: 700; margin-left: 1px; }
.rr-stat-correct .rr-stat-num { color: #16a34a; }
.rr-stat-incorrect .rr-stat-num { color: #dc2626; }
.rr-stat-distance .rr-stat-num { color: #2563eb; }
.rr-stat .rr-stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; font-weight: 700; }
.rr-timer-wrap { flex: 1.4; min-width: 100px; }
.rr-timer-bar {
    height: 14px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    margin-bottom: 4px;
}
.rr-timer-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    transition: width 1s linear, background .3s;
    width: 100%;
}
.rr-timer-fill.rr-warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.rr-timer-fill.rr-danger { background: linear-gradient(90deg, #dc2626, #f87171); }
.rr-timer-num { text-align: center; font-weight: 800; font-size: 1rem; color: #334155; }

.rr-canvas-wrap {
    position: relative;
    height: min(70vh, 520px);
    min-height: 380px;
    border-radius: 20px;
    overflow: hidden;
    background: #475569;
    box-shadow: inset 0 0 0 3px #e0f2fe;
    touch-action: none;
}
#rr-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.rr-tap-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 14px;
    display: flex;
    justify-content: space-between;
    padding: 0 14px;
    pointer-events: none;
}
.rr-tap-btn {
    pointer-events: auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, .45);
    color: #fff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.rr-tap-btn:active { background: rgba(15, 23, 42, .7); }

/* ── End screen ── */
.rr-stars {
    text-align: center;
    font-size: 2.6rem;
    letter-spacing: 6px;
    margin: 6px 0 18px;
    color: #e2e8f0;
}
.rr-stars .rr-star-on { color: #fbbf24; }
.rr-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 6px;
}
.rr-summary-item {
    text-align: center;
    background: #f8fafc;
    border-radius: 14px;
    padding: 14px 4px;
}
.rr-summary-item .rr-summary-num { font-weight: 800; font-size: 1.3rem; color: #1e293b; }
.rr-summary-item .rr-summary-label { font-size: .68rem; color: #94a3b8; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.rr-log-wrap { margin-top: 18px; }
.rr-log-list {
    max-height: 220px;
    overflow-y: auto;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 6px 10px;
}
.rr-log-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    font-weight: 700;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}
.rr-log-row:last-child { border-bottom: none; }
.rr-log-num { font-size: 1.05rem; }
.rr-log-verdict { font-size: .82rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.rr-log-verdict.rr-log-correct { background: #dcfce7; color: #166534; }
.rr-log-verdict.rr-log-incorrect { background: #fee2e2; color: #991b1b; }
.rr-log-empty { text-align: center; color: #94a3b8; font-weight: 600; padding: 14px 0; }

.rr-leaderboard-link { text-align: center; margin-top: 14px; }
.rr-leaderboard-link a { color: #4f46e5; font-weight: 700; text-decoration: none; }
.rr-leaderboard-link a:hover { text-decoration: underline; }

.rr-error-banner {
    background: #fef2f2;
    border: 2px solid #fecaca;
    color: #991b1b;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 16px;
    display: none;
}
.rr-error-banner.active { display: block; }

/* ── Leaderboard page ── */
.rr-lb-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.rr-lb-filters select {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
    color: #334155;
}
.rr-lb-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.rr-lb-table tr { background: #f8fafc; }
.rr-lb-table td { padding: 12px 14px; font-weight: 600; color: #334155; }
.rr-lb-table td:first-child { border-radius: 12px 0 0 12px; font-weight: 800; color: #6366f1; }
.rr-lb-table td:last-child { border-radius: 0 12px 12px 0; text-align: right; }
.rr-lb-empty { text-align: center; color: #94a3b8; padding: 30px 0; font-weight: 600; }

@media (max-width: 480px) {
    .rr-shell { padding: 22px 16px 26px; border-radius: 18px; }
    .rr-category-btn, .rr-class-btn { padding: 16px 8px; font-size: 1.05rem; }
    .rr-summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Fullscreen mobile play (see base.css body.game-page rules) ── */
@media (max-width: 991.98px) {
    body.game-page .rr-page { min-height: 100dvh; padding: 0; }
    body.game-page .rr-page .container { max-width: none; padding: 0; }
    body.game-page .rr-shell {
        max-width: none;
        min-height: 100dvh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 54px 16px 16px;
        display: flex;
        flex-direction: column;
    }
    body.game-page .rr-subtitle { display: none; }
    body.game-page .rr-screen.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        justify-content: center;
    }
    body.game-page .rr-canvas-wrap { flex: 1; min-height: 0; height: auto; }
}
