body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: black;
    font-family: 'Courier New', Courier, monospace;
    touch-action: none; /* Prevent browser zooming/scrolling on tap */
    /* 3.8: إكمال منع السحب-للتحديث والارتداد المطاطي + تحديد النص العرضي
       أثناء التصويب السريع (بعض هذا كان ناقص رغم touch-action أعلاه) */
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none; /* يمنع قائمة الضغط المطوّل بسفاري iOS */
}

/* Webcam feed acting as the AR background */
#webcam-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    /* We don't mirror it, backward facing normally looks right */
}

/* 3.3: خلفية بديلة عند تعذّر إذن الكاميرا — CSS بحت وبدون أي صور/فيديو خارجي،
   عشان اللعبة تبقى قابلة للعب فعلياً بدل شاشة سوداء صامتة */
#camera-fallback-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: none;
    background-color: #050505;
    background-image:
        radial-gradient(circle at 30% 35%, rgba(60, 0, 0, 0.35), transparent 60%),
        radial-gradient(circle at 70% 70%, rgba(15, 0, 25, 0.35), transparent 55%);
    background-size: 220% 220%, 200% 200%;
    animation: fallbackFog 18s ease-in-out infinite;
}

body.no-camera-fallback #webcam-feed { display: none; }
body.no-camera-fallback #camera-fallback-bg { display: block; }

@keyframes fallbackFog {
    0%   { background-position: 0% 0%, 100% 100%; }
    50%  { background-position: 100% 55%, 0% 30%; }
    100% { background-position: 0% 0%, 100% 100%; }
}

/* تفضيل النظام يتجاوز أي شيء داخل اللعبة — حركة أهدأ لمن يطلب تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
    #camera-fallback-bg { animation: none; }
}

/* A-Frame scene overlay */
a-scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

/* UI Layer should sit above the 3D scene but let touches pass through */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none; /* Allows tap through to body/scene */
}

/* Camera Obscura Viewfinder */
#viewfinder {
    position: absolute;
    top: 50%; left: 50%;
    width: 250px; height: 250px;
    margin-top: -125px; margin-left: -125px;
    pointer-events: none;
}
.corner {
    position: absolute; width: 30px; height: 30px; 
    border: 3px solid rgba(255,255,255,0.7); 
    box-shadow: inset 0 0 5px rgba(255,0,0,0.5), 0 0 5px rgba(255,0,0,0.5);
}
.top-left { top: 0; left: 0; border-right: none; border-bottom: none; }
.top-right { top: 0; right: 0; border-left: none; border-bottom: none; }
.bottom-left { bottom: 0; left: 0; border-right: none; border-top: none; }
.bottom-right { bottom: 0; right: 0; border-left: none; border-top: none; }

#capture-circle {
    position: absolute;
    top: 50%; left: 50%;
    width: 80px; height: 80px;
    margin-top: -40px; margin-left: -40px;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transition: all 0.2s;
}

#capture-circle.charging {
    border-color: yellow;
    box-shadow: 0 0 10px yellow;
    transform: scale(0.9);
}

#capture-circle.fatal {
    border: 4px solid red;
    box-shadow: 0 0 20px red;
    background: rgba(255, 0, 0, 0.2);
    transform: scale(1.1);
}

#fatal-frame-alert {
    position: absolute;
    top: -50px; left: 50%;
    transform: translateX(-50%);
    color: red;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 0 15px red, 0 0 5px white;
    opacity: 0;
    white-space: nowrap;
}

#fatal-frame-alert.active {
    opacity: 1;
    animation: flashAlert 0.15s infinite alternate;
}

@keyframes flashAlert {
    from { opacity: 1; } to { opacity: 0.3; }
}

#spirit-filament {
    position: absolute;
    top: 15px; left: 50%;
    width: 20px; height: 20px;
    border-radius: 50%;
    margin-left: -10px;
    background: radial-gradient(circle, #fff 0%, rgba(255,255,255,0) 70%);
    box-shadow: 0 0 10px 5px rgba(0, 100, 255, 0.5);
    transition: all 0.3s;
}
#spirit-filament.red {
    box-shadow: 0 0 20px 10px rgba(255, 0, 0, 0.9);
    background: radial-gradient(circle, #ffaaaa 0%, rgba(255,0,0,0) 70%);
}

/* 3.2: تلميح أول جولة — تحت دائرة التصويب مباشرة، بلا حجب للعب، يختفي بفيد */
#tutorial-hint {
    position: absolute;
    top: calc(50% + 100px);
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 16px;
    text-shadow: 0 0 6px red;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 40;
}
#tutorial-hint.show { opacity: 1; }

/* HUD System */
#hud {
    position: absolute;
    /* 3.8: احترام النوتش/الحواف الآمنة — يضيف مسافة الجهاز فوق الـ 20px الأصلية بلا أي أثر بالأجهزة العادية */
    top: calc(20px + env(safe-area-inset-top));
    left: calc(20px + env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#health-bar-container {
    width: 200px;
    height: 20px;
    background: rgba(50, 0, 0, 0.8);
    border: 2px solid #a00;
}

#health-bar {
    width: 100%;
    height: 100%;
    background: #f00;
    transition: width 0.3s ease;
}

#score {
    color: white;
    font-size: 24px;
    text-shadow: 2px 2px 4px #000;
    font-weight: bold;
}

#ammo-display {
    color: #dfdfdf;
    font-size: 20px;
    text-shadow: 2px 2px 4px #000;
}

#level-display {
    position: absolute;
    /* 3.8: نفس اعتبار النوتش المطبّق بـ #hud */
    top: calc(20px + env(safe-area-inset-top));
    right: calc(20px + env(safe-area-inset-right));
    color: #ffaa00;
    font-size: 30px;
    font-weight: bold;
    text-shadow: 0 0 10px red;
}

/* The Flash */
#flash-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    transition: opacity 0.1s;
    pointer-events: none;
}

.flash-active {
    opacity: 0.9 !important;
}

.flash-red {
    background: red !important;
    opacity: 0.8 !important;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100; /* Ensure it stays above A-Frame canvas */
    background: rgba(0, 0, 0, 0.85);
    color: #e00;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* Buttons need pointer events */
    text-align: center;
}

.screen h1 {
    font-size: 40px;
    margin-bottom: 10px;
    text-shadow: 0 0 10px red;
}

.screen p {
    font-size: 20px;
    color: #aaa;
    max-width: 80%;
}

.hidden {
    display: none !important;
}

button {
    margin-top: 30px;
    padding: 15px 30px;
    font-size: 22px;
    background: #400;
    color: white;
    border: 2px solid red;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    box-shadow: 0 0 10px red;
    transition: all 0.2s ease;
}

button:hover {
    background: red;
    color: white;
    box-shadow: 0 0 20px red;
}

/* =================== V3: Store UI =================== */
#shop-btn {
    margin-top: 10px;
    padding: 5px 10px;
    background: rgba(100, 0, 0, 0.7);
    color: white;
    border: 1px solid #ff4444;
    border-radius: 5px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    pointer-events: auto;
}

.shop-items {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    justify-content: center;
}

.shop-item {
    background: rgba(50, 0, 0, 0.8);
    border: 2px solid #a00;
    padding: 15px;
    border-radius: 8px;
    width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.shop-item h3 { margin: 0 0 10px 0; font-size: 18px; color: #ff8888; }
.shop-item p { font-size: 12px; line-height: 1.4; margin-bottom: 15px; flex-grow: 1; }
.buy-btn {
    background: #000;
    color: #0f0;
    border: 1px solid #0f0;
    padding: 8px;
    border-radius: 5px;
    width: 100%;
    /* 3.8: هدف لمس ≥48dp — كان ~35px بهذا الـ padding/الخط، فلازم توسيط صريح بالفليكس */
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.buy-btn:disabled { color: #555; border-color: #555; cursor: not-allowed; }
#close-shop-btn { margin-top: 20px; background: transparent; color: white; border: 1px solid white; padding: 10px 30px; }

/* =================== V3: Film Selector =================== */
#film-selector {
    position: absolute;
    /* 3.8: نفس اعتبار النوتش المطبّق بـ #hud */
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: calc(20px + env(safe-area-inset-left));
    display: flex;
    gap: 10px;
    z-index: 50;
    pointer-events: auto;
}

.film-slot {
    /* 3.8: هدف لمس ≥48dp (كانت 45px) */
    width: 48px;
    height: 48px;
    background: rgba(0,0,0,0.6);
    border: 2px solid #555;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #888;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 0 5px #000;
    transition: all 0.2s;
}

.film-slot small { font-size: 10px; opacity: 0.8; }
.film-slot.active { border-color: #ffcccc; color: white; box-shadow: 0 0 15px #ff0000; background: rgba(150,0,0,0.5); transform: scale(1.1); }

/* =================== V3: Horror VFX =================== */
#glitch-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 100;
    background: repeating-linear-gradient(0deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 1px, transparent 1px, transparent 2px);
    opacity: 0;
    transition: opacity 0.2s;
    mix-blend-mode: overlay;
}

/* أمان الصرع (WCAG 2.3.1): يجب ألا يتجاوز الوميض 3 ومضات/ثانية.
   النسخة السابقة كانت 0.1s infinite = 10 ومضات/ثانية، مع تأرجح إضاءة
   (0.5→1) ودوران تدرّج ±90° — خطر نوبات حقيقي. الآن 0.5s = ومضتان/ثانية
   مع تأرجح إضاءة وتشبّع أهدأ بكثير. الشعور بالتشويش باقٍ، الخطر لا. */
@keyframes vhsTear {
    0% { transform: translateX(0); filter: hue-rotate(0deg); opacity: 0.75; }
    30% { transform: translateX(-8px) skewY(1deg); filter: hue-rotate(25deg); opacity: 0.9; }
    60% { transform: translateX(6px) skewY(-1deg); filter: hue-rotate(-25deg); opacity: 0.8; }
    100% { transform: translateX(0); filter: hue-rotate(0deg); opacity: 0.75; }
}

#blood-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 150;
    background-image: radial-gradient(circle, transparent 30%, rgba(200, 0, 0, 0.4) 80%, rgba(150, 0, 0, 0.8) 100%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* 3.8: نبضة أجواء بصرية خفيفة جداً — بديل الاهتزاز المحيطي على أجهزة بلا
   Vibration API (سفاري iOS). ومضة ناعمة واحدة فقط لا تكرار سريع، فما فيها
   خطر تحسس ضوئي (راجع تعليق أمان الصرع بأسفل الملف) */
#ambient-pulse-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
    background: radial-gradient(circle, transparent 55%, rgba(120, 0, 0, 0.35) 100%);
    opacity: 0;
}
#ambient-pulse-overlay.pulse {
    animation: ambientPulse 0.5s ease-out;
}
@keyframes ambientPulse {
    0% { opacity: 0; }
    40% { opacity: 1; }
    100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    #ambient-pulse-overlay.pulse { animation: none; opacity: 0; }
}

#glitch-overlay.active {
    opacity: 1;
    animation: vhsTear 0.2s infinite;
}

/* 4.7: إظلام تدريجي أثناء بناء الرعب قبل ظهور البوس — انتقال ناعم بلا وميض
   (transition بحت، لا keyframes متكررة)، فآمن للحساسين للضوء بلا حاجة
   لاستثناء prefers-reduced-motion صريح مثل بقية الطبقات فوق */
#boss-dread-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 15;
    background: radial-gradient(circle, transparent 15%, rgba(0, 0, 0, 0.8) 100%);
    opacity: 0;
    transition: opacity 2.5s ease;
}
#boss-dread-overlay.active { opacity: 1; }

#cracked-glass-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 200;
    background-image: radial-gradient(circle, transparent 20%, rgba(200, 0, 0, 0.8) 80%),
                      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M50,50 L20,10 M50,50 L80,15 M50,50 L10,60 M50,50 L90,70 M50,50 L30,90 M50,50 L70,95 M50,50 L5,35 M50,50 L95,40" stroke="white" stroke-width="0.5" fill="none"/></svg>');
    background-size: cover;
    opacity: 0;
}

#cracked-glass-overlay.active {
    opacity: 1;
    transition: opacity 0.05s ease-out;
}

.jumpscare-flash {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10000;
    pointer-events: none;
    background-color: darkred;
    background-blend-mode: hard-light;
    background-image: url('../assets/logo.png');
    background-position: center;
    background-repeat: no-repeat;
    animation: jumpscareZoom 1.5s cubic-bezier(.17,.67,.83,.67) forwards, vhsTear 0.5s infinite;
}

/* طبقة التهدئة: تُفعَّل افتراضياً (body.reduce-flash) ويستطيع اللاعب إيقافها
   من الإعدادات. تُلغي التمزّق المتكرر تماماً وتستخدم تكبيراً بلا قفزات
   إضاءة حادة — للحساسين للوميض، ولمن يفضّل تجربة أهدأ. */
@keyframes jumpscareZoomCalm {
    0% { transform: scale(1); opacity: 0; }
    12% { transform: scale(2.2); opacity: 1; }
    100% { transform: scale(3.4); opacity: 0; }
}

body.reduce-flash .jumpscare-flash {
    animation: jumpscareZoomCalm 1.5s ease-out forwards;
}

/* احترام تفضيل النظام — يتجاوز أي إعداد داخل اللعبة */
@media (prefers-reduced-motion: reduce) {
    .jumpscare-flash {
        animation: jumpscareZoomCalm 1.2s ease-out forwards !important;
    }
    .flash-red, .flash-active { transition: none !important; }
}

@keyframes jumpscareZoom {
    0% { transform: scale(1); filter: brightness(1) contrast(1); opacity: 0; }
    5% { transform: scale(3) translate(5px, 5px); filter: brightness(5) contrast(3) invert(1); opacity: 1; }
    15% { transform: scale(2.5) translate(-10px, -10px); filter: hue-rotate(90deg) brightness(2); }
    50% { transform: scale(4) translate(10px, 15px); filter: saturate(10) contrast(5); }
    80% { transform: scale(4.5) translate(-5px, 0); opacity: 1; }
    100% { transform: scale(6); opacity: 0; }
}

/* =================== AUTH & LEADERBOARD =================== */
.auth-box {
    background: rgba(30, 0, 0, 0.9);
    border: 2px solid #a00;
    padding: 30px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80%;
    max-width: 320px;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.4);
}

.auth-input {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #550000;
    color: white;
    font-size: 16px;
    box-sizing: border-box;
    border-radius: 5px;
    text-align: center;
}

.auth-input:focus {
    outline: none;
    border-color: red;
    box-shadow: 0 0 10px red;
}

.leaderboard-entry {
    background: rgba(40, 0, 0, 0.8);
    border: 1px solid #ff4444;
    padding: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ffcccc;
}

.leaderboard-entry span.rank {
    font-weight: bold;
    color: #ffaa00;
    font-size: 18px;
    width: 30px;
}
.leaderboard-entry span.name {
    flex-grow: 1;
    text-align: left;
    margin-left: 10px;
    font-weight: bold;
}
.leaderboard-entry span.score {
    color: #88ff88;
}

/* =================== 4.5: تبويبا اللوحة (كل الأوقات / أسبوعي) ===================
   عناصر <button> عادية فتورث تنسيق button{} العام (uppercase/margin-top
   كبير/توهج أحمر) — نعيد ضبطها هنا لتبدو تبويبات ثانوية صغيرة لا CTA رئيسية */
.lb-tabs {
    display: flex;
    gap: 8px;
    margin: 4px 0 10px 0;
}
.lb-tab {
    margin-top: 0;
    padding: 8px 16px;
    font-size: 13px;
    background: transparent;
    color: #999;
    border: 1px solid #663333;
    border-radius: 20px;
    box-shadow: none;
    text-transform: none;
    min-height: 40px;
}
.lb-tab:hover {
    background: rgba(150, 0, 0, 0.25);
    box-shadow: none;
}
.lb-tab.active {
    background: rgba(150, 0, 0, 0.4);
    color: #fff;
    border-color: #ff4444;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.4);
}

.bottom-right-shop {
    position: absolute;
    /* 3.8: نفس اعتبار النوتش المطبّق بـ #hud + هدف لمس ≥48dp */
    bottom: calc(25px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
    min-height: 48px;
    background: rgba(20, 0, 0, 0.9);
    border: 2px solid #880000;
    color: #ffcccc;
    padding: 12px 18px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
    transition: all 0.2s;
    pointer-events: auto;
    z-index: 50;
    text-shadow: 0 0 5px red;
}

.bottom-right-shop:active {
    transform: scale(0.95);
    background: #550000;
}

/* =================== WEAPON FILTERS =================== */
body.film-type-61 #webcam-feed, body.film-type-61 a-scene {
    filter: sepia(100%) hue-rotate(180deg) saturate(200%) brightness(80%);
    transition: filter 0.3s ease;
}

body.film-type-90 #webcam-feed, body.film-type-90 a-scene {
    filter: sepia(100%) hue-rotate(300deg) saturate(300%) contrast(150%) brightness(70%);
    transition: filter 0.3s ease;
}

#webcam-feed, a-scene {
    transition: filter 0.3s ease;
}

@keyframes shakeHard {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(15px, 15px) rotate(3deg); }
    50% { transform: translate(-15px, -15px) rotate(-3deg); }
    75% { transform: translate(15px, -15px) rotate(3deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}
.shake-hard {
    animation: shakeHard 0.2s cubic-bezier(.36,.07,.19,.97) both;
}

/* =================== FEEDBACK EMOJIS =================== */
.feedback-emj {
    filter: grayscale(100%) opacity(60%);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0 5px; /* Larger hit area */
}
.feedback-emj:hover, .feedback-emj.hovered {
    filter: grayscale(0%) opacity(100%);
    transform: scale(1.15);
}
.feedback-emj.selected {
    filter: grayscale(0%) opacity(100%);
    transform: scale(1.25);
    background: radial-gradient(circle, rgba(255,255,0,0.4) 0%, rgba(0,0,0,0) 70%);
}

/* ===== لوحة الإعدادات (وصولية) ===== */
.setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;          /* هدف لمس ≥48dp */
    min-height: 48px;
    background: rgba(255,255,255,0.05);
    border: 1px solid #444;
    border-radius: 10px;
    font-size: 18px;
    color: #eee;
    cursor: pointer;
}
.setting-row input[type="checkbox"] {
    width: 24px; height: 24px;
    accent-color: #c00;
    flex: 0 0 auto;
    cursor: pointer;
}

/* خط أكبر — يكبّر النص الأساسي دون كسر التخطيط */
body.large-text { font-size: 118%; }
body.large-text .setting-row { font-size: 20px; }

/* =================== 4.1: شاشة الذروة — الرقم الشخصي بدل شاشة فشل ===================
   قاعدة الذروة والنهاية: كل جولة تنتهي بالموت، فنعيد تأطير شاشة الموت
   كاحتفاء بالجهد لا كفشل. .pb-new احتفالية (رقم جديد)، .pb-tied محايدة
   (تعادل)، .pb-gap هادئة إخبارية (لسا ما وصلت) — بلا أي لون إنذار/عقاب. */
#pb-hero {
    font-size: 22px;
    font-weight: bold;
    margin: 4px 0 14px 0;
    padding: 10px 18px;
    border-radius: 10px;
    max-width: 90%;
}
#pb-hero.pb-new {
    color: #ffe58a;
    background: rgba(120, 90, 0, 0.25);
    border: 1px solid #ffcc44;
    text-shadow: 0 0 12px #ffaa00;
    animation: pbHeroGlow 1.6s ease-in-out infinite;
}
#pb-hero.pb-tied {
    color: #ffaa00;
    background: rgba(80, 60, 0, 0.2);
    border: 1px solid #aa7700;
}
#pb-hero.pb-gap {
    color: #e0b070;
    background: rgba(40, 30, 10, 0.25);
    border: 1px solid #664400;
    font-size: 18px;
}
@keyframes pbHeroGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 170, 0, 0.3); }
    50% { box-shadow: 0 0 20px rgba(255, 170, 0, 0.7); }
}
@media (prefers-reduced-motion: reduce) {
    #pb-hero.pb-new { animation: none; box-shadow: 0 0 14px rgba(255, 170, 0, 0.5); }
}

#run-summary {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.run-stat-chip {
    background: rgba(40, 0, 0, 0.6);
    border: 1px solid #772222;
    border-radius: 8px;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}
.run-stat-chip strong { font-size: 20px; color: #ffcccc; }
.run-stat-chip span { font-size: 12px; color: #999; margin-top: 2px; }

#run-new-dex-note {
    color: #8fd6ff;
    font-size: 14px;
    margin-bottom: 10px;
    max-width: 85%;
}

/* =================== 4.3: تنبيه فتح إنجاز/لقب جديد ===================
   طبقة عائمة مستقلة فوق كل شيء (حتى فوق jumpscare-flash) — تظهر أعلى
   الشاشة وتختفي تلقائياً وحدها، بلا حجب لأي تفاعل تحتها. */
#achievement-toast {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(-30px);
    z-index: 10001;
    background: rgba(20, 10, 0, 0.95);
    border: 2px solid #ffaa00;
    border-radius: 10px;
    padding: 10px 20px;
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
    max-width: 85%;
}
#achievement-toast p {
    margin: 2px 0;
    color: #ffe58a;
    font-size: 15px;
    font-weight: bold;
    max-width: none;
}
#achievement-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
@media (prefers-reduced-motion: reduce) {
    #achievement-toast, #achievement-toast.show {
        transform: translateX(-50%) !important;
        transition: opacity 0.35s ease !important;
    }
}

/* =================== 4.4: سجل المطاردات (Ghost Dex) ===================
   شبكة بطاقتين بالعرض تناسب الجوال؛ المقفولة تُعتّم بلا حرق تصميم الشبح
   (مجرد علامة استفهام)، والمفتوحة تعرض الإطار الأول من شيت السبرايت
   بنفس تقنية death-killer-sprite بالضبط (خلفية مقصوصة، لا صورة ممطوطة). */
.dex-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 92%;
    max-width: 460px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 6px;
}
.dex-card {
    background: rgba(30, 0, 0, 0.6);
    border: 1px solid #772222;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 150px;
}
.dex-card.locked { opacity: 0.55; }
.dex-card h3 { font-size: 14px; margin: 8px 0 4px 0; color: #ffcccc; }
.dex-card.locked h3 { color: #666; }
.dex-card p { font-size: 11.5px; color: #aaa; line-height: 1.4; margin: 0; max-width: none; }
.dex-sprite {
    width: 60px;
    height: 68px;
    background-repeat: no-repeat;
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
}
.dex-locked-mark {
    width: 60px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    color: #555;
}

/* =================== 4.3: قائمة الإنجازات ===================
   كل بند يُحسب من العدّادات مباشرة (progress.js) — لا حالة "مفتوح" مخزّنة
   منفصلة، فما فيه احتمال انحراف بين المعروض هنا والعدّادات الفعلية. */
.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 92%;
    max-width: 420px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 6px;
}
.achievement-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(30, 0, 0, 0.5);
    border: 1px solid #662222;
    border-radius: 10px;
    padding: 10px 14px;
    text-align: right;
}
.achievement-row.locked { opacity: 0.5; }
.achievement-icon { font-size: 26px; flex: 0 0 auto; width: 34px; text-align: center; }
.achievement-text { flex: 1; }
.achievement-text h4 { margin: 0 0 2px 0; font-size: 15px; color: #ffcccc; }
.achievement-row.locked .achievement-text h4 { color: #888; }
.achievement-text p { margin: 0; font-size: 12.5px; color: #999; max-width: none; }
