/**
 * Eduplayify Game Mode: Grand Prix / Turbo Racer (سباق السيارات التيربو)
 * أنماط متوافقة مع المتصفحات القديمة والأجهزة الضعيفة (§10 و§12).
 */

.tr-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 6px;
    border-radius: 16px;
    overflow: hidden;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    font-family: inherit;
}

#gamePlayArea:fullscreen .tr-stage,
.gpa-fullscreen .tr-stage {
    max-width: 960px;
    margin: auto;
    padding: 12px 6px;
    justify-content: center;
}

/* ========================================================
   HUD: شريط المعلومات العلوي
   ======================================================== */
.tr-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    margin-bottom: 8px;
    padding: 6px 12px;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    box-sizing: border-box;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    color: #f8fafc;
}

.tr-hud-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tr-hud-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.16);
    white-space: nowrap;
}

.tr-hud-pos {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border-color: #fbbf24;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.tr-hud-pos.is-first {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #34d399;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.tr-hud-nitro-box {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 130px;
}

.tr-hud-nitro-bar {
    flex: 1;
    height: 12px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.tr-hud-nitro-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #06b6d4, #3b82f6, #ec4899);
    border-radius: 5px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
}

.tr-hud-nitro-fill.is-full {
    background: linear-gradient(90deg, #f59e0b, #ef4444, #f43f5e);
    animation: trPulseFull 1s infinite alternate;
}

@keyframes trPulseFull {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.35) drop-shadow(0 0 6px #ef4444); }
}

.tr-speed-toggle {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.tr-speed-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.tr-speed-btn.is-active {
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.5);
}

/* ========================================================
   QUESTION BAR: لافتة السؤال الحالية
   ======================================================== */
.tr-question-banner {
    width: 100%;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #38bdf8;
    border-radius: 14px;
    padding: 10px 16px;
    margin-bottom: 8px;
    text-align: center;
    box-sizing: border-box;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.tr-question-img {
    max-height: 80px;
    max-width: 140px;
    object-fit: contain;
    border-radius: 8px;
    margin: 0 auto 6px auto;
    display: block;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.tr-question-img:hover {
    transform: scale(1.05);
    filter: brightness(1.08);
}

.tr-question-text {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 800;
    color: #ffffff;
    margin: 0;
    line-height: 1.45;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* ========================================================
   TRACK CANVAS / CONTAINER: حلبة السباق
   ======================================================== */
.tr-track-viewport {
    position: relative;
    width: 100%;
    height: 320px;
    background: #1e293b;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.25);
    border: 2px solid #334155;
}

#gamePlayArea:fullscreen .tr-track-viewport,
.gpa-fullscreen .tr-track-viewport {
    height: 380px;
}

.tr-track-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Speed lines overlay */
.tr-speedlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    background-image: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0, transparent 4px, transparent 40px);
}

.tr-speedlines.is-active {
    opacity: 1;
    animation: trSpeedRush 0.15s linear infinite;
}

@keyframes trSpeedRush {
    0% { transform: translateY(-30px); }
    100% { transform: translateY(30px); }
}

/* شارة التنبيه العائمة (Nitro! / Drift!) */
.tr-float-alert {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.6);
    padding: 8px 18px;
    border-radius: 9999px;
    font-size: 1.15rem;
    font-weight: 900;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.tr-float-alert.is-boost {
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    border: 2px solid #67e8f9;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.tr-float-alert.is-super {
    background: linear-gradient(135deg, #ef4444, #f59e0b);
    border: 2px solid #fef08a;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
}

.tr-float-alert.is-drift {
    background: linear-gradient(135deg, #475569, #1e293b);
    border: 2px solid #94a3b8;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
}

/* ========================================================
   CHOICES / LANES BAR: بوابات وأزرار الخيارات السريعة
   ======================================================== */
.tr-choices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
    gap: 8px;
    width: 100%;
    margin-top: 8px;
    box-sizing: border-box;
}

.tr-choice-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    color: #1e293b;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.15s ease;
    text-align: start;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.tr-choice-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: #3b82f6;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.2);
}

.tr-choice-btn:active:not(:disabled) {
    transform: translateY(0);
}

.tr-choice-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 900;
    flex-shrink: 0;
}

.tr-choice-text {
    flex: 1;
    line-height: 1.35;
    word-break: break-word;
}

.tr-choice-btn.is-correct {
    background: #dcfce7;
    border-color: #16a34a;
    color: #14532d;
    animation: trPulseCorrect 0.4s ease;
}

.tr-choice-btn.is-correct .tr-choice-key {
    background: #16a34a;
    color: #ffffff;
}

.tr-choice-btn.is-wrong {
    background: #fee2e2;
    border-color: #dc2626;
    color: #7f1d1d;
    animation: trShake 0.4s ease;
}

.tr-choice-btn.is-wrong .tr-choice-key {
    background: #dc2626;
    color: #ffffff;
}

@keyframes trPulseCorrect {
    0% { transform: scale(0.96); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes trShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* ========================================================
   START SCREEN & GARAGE: شاشة البداية ومرآب السيارات
   ======================================================== */
.tr-start-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    z-index: 30;
    text-align: center;
    color: #fff;
    backdrop-filter: blur(4px);
}

.tr-start-title {
    font-size: clamp(1.4rem, 3.5vw, 1.85rem);
    font-weight: 900;
    margin: 0 0 8px;
    color: #38bdf8;
    text-shadow: 0 2px 10px rgba(56, 189, 248, 0.5);
}

.tr-start-desc {
    max-width: 480px;
    font-size: 0.92rem;
    color: #cbd5e1;
    line-height: 1.6;
    margin: 0 0 16px;
}

.tr-garage-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tr-garage-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.15s ease;
}

.tr-garage-btn:hover {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
}

.tr-garage-btn.is-active {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.25);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
}

.tr-launch-btn {
    padding: 12px 32px;
    border-radius: 9999px;
    background: linear-gradient(135deg, #0284c7, #2563eb);
    color: #fff;
    border: none;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.5);
    transition: all 0.2s ease;
}

.tr-launch-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.7);
}

/* شاشة نهاية الجولة المصغرة */
.tr-victory-banner {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    border-radius: 16px;
    z-index: 25;
    text-align: center;
    color: #fff;
    backdrop-filter: blur(4px);
    box-sizing: border-box;
}

.tr-victory-banner.is-loss {
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.96) 0%, rgba(30, 41, 59, 0.96) 100%);
    border: 2px solid rgba(251, 191, 36, 0.45);
}

.tr-banner-icon {
    font-size: 3.4rem;
    margin-bottom: 10px;
    line-height: 1;
}

.tr-banner-title {
    font-size: clamp(1.25rem, 3vw, 1.55rem);
    font-weight: 900;
    margin: 0 0 8px;
    color: #38bdf8;
}

.tr-banner-title.is-loss {
    color: #fbbf24;
}

.tr-banner-sub {
    max-width: 460px;
    font-size: 0.98rem;
    line-height: 1.65;
    color: #e2e8f0;
    margin: 0 0 18px;
}

.tr-retry-btn {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    box-shadow: 0 4px 18px rgba(245, 158, 11, 0.45);
}

.tr-retry-btn:hover {
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.65);
}
