/* Shared shell styles for layouts/game.blade.php (Quran games: topbar, share modal,
   results modal, toast). The encouragement panel and celebration overlay now live in
   encouragement-v1.css, so pages outside this layout can reuse them. Extracted from an
   inline <style> block so the browser (and the Service Worker's cache-first rule for
   .css files) can cache it once across every Quran game instead of re-downloading it
   with every game page's HTML. */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Tajawal', sans-serif;
    background: #0f0f23;
    color: #fff;
    -webkit-font-smoothing: antialiased;
}

/* Quran text font class - use in any game */
.ayah-text, .quran-text, .stone-text, .balloon-text, .match-card,
.card-back-name, .card-label, .ing-text, .option-btn, .word-option,
.ayah-line, .blank-input, .surah-name, .ayah-bubble {
    font-family: 'Amiri Quran', 'Amiri', 'Tajawal', serif !important;
}

.game-layout {
    width: 100%; height: 100vh;
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
}

/* ========================================
   GAME TOP BAR
   ======================================== */
.game-topbar {
    position: fixed; top: 0; left: 0; right: 0;
    background: rgba(15, 15, 35, .95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,.08);
    padding: 8px 16px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: nowrap;
    min-height: 56px; z-index: 9999;
}
.game-topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.game-topbar-center { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.game-topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.game-stat {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 20px;
    background: rgba(255,255,255,.08);
    font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.game-stat .stat-icon { font-size: 1rem; }
.game-stat .stat-value { color: #a78bfa; font-weight: 800; }

.game-btn {
    width: 38px; height: 38px; border-radius: 50%;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s; font-size: .9rem;
    background: rgba(255,255,255,.1); color: #fff;
}
.game-btn:hover { background: rgba(255,255,255,.2); transform: scale(1.1); }
.game-btn:active { transform: scale(.95); }
.game-btn.btn-danger { background: rgba(239,68,68,.2); color: #f87171; }
.game-btn.btn-danger:hover { background: rgba(239,68,68,.4); }
.game-btn.active { background: rgba(239,68,68,.3); color: #f87171; }

.game-title {
    font-size: .95rem; font-weight: 700;
    color: rgba(255,255,255,.9);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: none;
}

/* ========================================
   GAME CONTENT
   ======================================== */
.game-content {
    flex: 1; margin-top: 56px;
    display: flex; flex-direction: column;
    min-height: 0; overflow: hidden; position: relative;
    padding-bottom: 60px;
}

/* ========================================
   SHARE MODAL
   ======================================== */
.share-modal {
    display: none; position: fixed; inset: 0; z-index: 100000;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,.7); backdrop-filter: blur(8px);
}
.share-modal.show { display: flex; animation: fadeIn .3s ease; }
.share-content {
    background: #1e1e3a; border: 1px solid rgba(255,255,255,.1);
    padding: 32px; border-radius: 20px; text-align: center;
    max-width: 380px; width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.share-title { font-size: 1.2rem; font-weight: bold; color: #fff; margin-bottom: 6px; }
.share-subtitle { color: rgba(255,255,255,.5); margin-bottom: 24px; font-size: .85rem; }
.share-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.share-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,.1);
    background: rgba(255,255,255,.05);
    cursor: pointer; transition: all .2s; color: #fff;
}
.share-btn:hover { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.1); transform: translateY(-2px); }
.share-btn i { font-size: 1.4rem; }
.share-btn.whatsapp i { color: #25d366; }
.share-btn.facebook i { color: #1877f2; }
.share-btn.twitter i { color: #1da1f2; }
.share-btn.copy i { color: #9ca3af; }
.share-btn span { font-size: .75rem; color: rgba(255,255,255,.7); }
.share-link-box { display: flex; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.share-link-input {
    flex: 1; padding: 10px 12px;
    border: 1px solid rgba(255,255,255,.15); border-radius: 8px;
    background: rgba(255,255,255,.05); color: #fff;
    font-size: .8rem; direction: ltr; text-align: left;
}
.share-link-copy {
    padding: 10px 16px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff; border: none; border-radius: 8px;
    cursor: pointer; font-weight: bold; transition: all .2s;
}
.share-link-copy:hover { transform: scale(1.05); }
.share-close {
    margin-top: 16px; padding: 10px 24px;
    background: rgba(255,255,255,.1); color: rgba(255,255,255,.7);
    border: none; border-radius: 20px; cursor: pointer;
    font-weight: 600; transition: all .2s;
}
.share-close:hover { background: rgba(255,255,255,.2); }

/* ========================================
   RESULTS MODAL (Unified Game Over)
   ======================================== */
.results-modal {
    display: none; position: fixed; inset: 0; z-index: 200000;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,.7); backdrop-filter: blur(10px);
}
.results-modal.show { display: flex; animation: fadeIn .4s ease; }
.results-content {
    background: linear-gradient(145deg, #1a1a3e 0%, #2d1b69 50%, #1a1a3e 100%);
    border: 2px solid rgba(251,191,36,.3);
    border-radius: 28px; padding: 40px 36px; text-align: center;
    max-width: 400px; width: 90%;
    box-shadow: 0 25px 80px rgba(139,92,246,.3), 0 0 60px rgba(251,191,36,.15);
    animation: modalPop .5s cubic-bezier(0.34,1.56,0.64,1);
    position: relative;
}
@keyframes modalPop { from{opacity:0;transform:scale(.7) translateY(30px)} to{opacity:1;transform:scale(1) translateY(0)} }
.results-close {
    position: absolute; top: 14px; left: 14px;
    width: 34px; height: 34px; border-radius: 50%;
    border: none; background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.6); font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s; z-index: 2;
}
.results-close:hover { background: rgba(255,255,255,.2); color: #fff; }
.results-trophy {
    font-size: 4.5rem; margin-bottom: 12px;
    animation: trophyBounce 1s ease infinite;
    filter: drop-shadow(0 4px 12px rgba(251,191,36,.5));
}
@keyframes trophyBounce { 0%,100%{transform:translateY(0) scale(1)} 50%{transform:translateY(-8px) scale(1.05)} }
.results-title {
    font-size: 1.6rem; font-weight: 800; color: #fbbf24;
    margin-bottom: 6px; font-family: 'Amiri', serif;
    text-shadow: 0 2px 8px rgba(251,191,36,.3);
}
.results-subtitle {
    color: rgba(255,255,255,.5); margin-bottom: 20px; font-size: .9rem;
}
.results-stars {
    display: flex; justify-content: center; gap: 8px; margin-bottom: 24px;
}
.results-star {
    font-size: 2.2rem;
    animation: starPop .5s cubic-bezier(0.34,1.56,0.64,1) forwards;
    opacity: 0; transform: scale(0);
    filter: drop-shadow(0 2px 6px rgba(251,191,36,.4));
}
.results-star:nth-child(1) { animation-delay: .2s; }
.results-star:nth-child(2) { animation-delay: .4s; }
.results-star:nth-child(3) { animation-delay: .6s; }
@keyframes starPop { to{opacity:1;transform:scale(1)} }
.results-star.empty { filter: grayscale(1) opacity(.3); }
.results-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.results-btn {
    padding: 13px 30px; border-radius: 16px; border: none;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: all .25s; display: flex; align-items: center; gap: 8px;
    font-family: 'Tajawal', sans-serif;
}
.results-btn.primary {
    background: linear-gradient(135deg, #10B981, #059669); color: #fff;
    box-shadow: 0 6px 20px rgba(16,185,129,.3);
}
.results-btn.primary:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(16,185,129,.5); }
.results-btn.secondary {
    background: rgba(255,255,255,.1); color: rgba(255,255,255,.7);
}
.results-btn.secondary:hover { background: rgba(255,255,255,.2); transform: translateY(-2px); }
.results-btn.home {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED); color: #fff;
    box-shadow: 0 6px 20px rgba(139,92,246,.3);
}
.results-btn.home:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(139,92,246,.5); }

@media(max-width:480px) {
    .results-content { padding: 32px 20px; border-radius: 22px; }
    .results-trophy { font-size: 3.5rem; }
    .results-title { font-size: 1.3rem; }
    .results-star { font-size: 1.8rem; }
    .results-actions { flex-direction: column; }
    .results-btn { width: 100%; justify-content: center; }
}

/* ========================================
   TOAST
   ======================================== */
.game-toast {
    position: fixed; bottom: 80px; left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #10b981; color: #fff;
    padding: 12px 24px; border-radius: 30px;
    font-weight: 600; font-size: .9rem;
    box-shadow: 0 8px 25px rgba(16,185,129,.4);
    z-index: 100001; opacity: 0; transition: all .3s;
}
.game-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* ========================================
   FULLSCREEN FIXES
   ======================================== */
.game-layout:fullscreen .share-modal { z-index: 2147483647 !important; }
.game-layout:fullscreen .results-modal { z-index: 2147483647 !important; }
.game-layout:fullscreen .game-toast { z-index: 2147483647 !important; }
.game-layout:fullscreen .game-topbar { top: 0 !important; }

/* ========================================
   RESPONSIVE
   ======================================== */
@media(max-width:768px) {
    .game-topbar { padding: 6px 10px; min-height: 48px; }
    .game-stat { padding: 4px 8px; font-size: .75rem; }
    .game-btn { width: 34px; height: 34px; font-size: .8rem; }
    .game-title { font-size: .85rem; max-width: none; }
    .game-content { margin-top: 48px; }
}
@media(max-width:480px) {
    .game-stat { padding: 3px 6px; font-size: .7rem; gap: 3px; }
}
