/* ::::: GAMES PAGE STYLES ::::: */
body { background-color: #fdfdfb; }

.games-hero {
    text-align: center; padding: 60px 20px 40px;
    background: #bcede8;
    border-bottom-left-radius: 50px; border-bottom-right-radius: 50px;
    margin-bottom: 50px;
}
.games-hero h1 { color: var(--navy); font-size: 2.5rem; margin-bottom: 15px; }
.games-hero p { color: var(--text-light); font-size: 1.1rem; }

/* Grid */
.games-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px; max-width: 1000px; margin: 0 auto 100px; padding: 0 20px;
}
.game-thumb {
    background: white; border-radius: 25px; overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08); cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
}
.game-thumb:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0,40,85,0.15); border-color: var(--gold);
}
.thumb-icon {
    height: 180px; display: flex; align-items: center; justify-content: center; font-size: 5rem;
}
.thumb-content { padding: 20px; text-align: center; }
.thumb-content h3 { color: var(--navy); margin-bottom: 8px; }
.play-btn {
    background: var(--navy); color: white; padding: 8px 25px;
    border-radius: 20px; font-size: 0.9rem; margin-top: 15px; display: inline-block;
}

/* Modal Overlay */
.game-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 40, 85, 0.95); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    padding: 20px;
}
.game-stage {
    background: white; width: 100%; max-width: 800px;
    border-radius: 25px; padding: 30px; position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.5); min-height: 550px;
    display: flex; flex-direction: column;
}

/* Controls Header (Close & Fullscreen) */
.stage-controls {
    position: absolute; top: -60px; right: 0; left: 0;
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 0 10px; pointer-events: none;
}
.close-game, .icon-btn {
    pointer-events: auto;
    background: #e74c3c; color: white; width: 50px; height: 50px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; cursor: pointer; border: 4px solid white; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
.icon-btn { background: var(--blue); }
.icon-btn:hover { background: var(--navy); }
.close-game:hover { background: #c0392b; }

.game-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 15px; border-bottom: 2px dashed #eee;
}
.game-header h2 { margin: 0; color: var(--navy); }
.score-board { font-size: 1.2rem; font-weight: bold; color: var(--blue); }

/* Common Utilities */
.hidden { display: none !important; }
.game-container {
    width: 100%; flex: 1; display: flex; flex-direction: column; min-height: 0;
}
.btn-reset {
    background: var(--gold); border: none; padding: 10px 25px;
    border-radius: 50px; font-weight: bold; cursor: pointer; margin-top: 15px; font-size: 1rem;
}
.win-screen { text-align: center; padding-top: 50px; }
.win-screen h2 { color: #27ae60; font-size: 3rem; }

/* ::::: AUTH OVERLAY (Gatekeeper) ::::: */
.auth-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 40, 85, 0.9); backdrop-filter: blur(8px);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
}
.auth-card {
    background: white; padding: 50px 30px; border-radius: 30px; text-align: center;
    max-width: 400px; width: 90%; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.auth-card i { font-size: 4rem; color: #e74c3c; margin-bottom: 20px; }
.auth-card h2 { color: var(--navy); margin-bottom: 10px; }
.auth-card p { color: #666; margin-bottom: 30px; }
.redirect-counter { font-weight: bold; color: var(--blue); margin-bottom: 20px; }

/* ::::: 1. MEMORY GAME ::::: */
.memory-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px;
    flex-grow: 1; perspective: 1000px;
}
.m-card {
    background: transparent; cursor: pointer; height: 100%; min-height: 100px;
    position: relative; transform-style: preserve-3d; transition: transform 0.5s;
}
.m-card.flip { transform: rotateY(180deg); }
.m-face {
    position: absolute; width: 100%; height: 100%;
    border-radius: 15px; display: flex; align-items: center; justify-content: center;
    backface-visibility: hidden; font-size: 2.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.m-front { background: var(--navy); color: var(--gold); transform: rotateY(0deg); }
.m-back { background: #fff; border: 3px solid var(--blue); transform: rotateY(180deg); }

/* ::::: 2. MATH GAME ::::: */
.question-box {
    text-align: center; font-size: 2.5rem; font-weight: 800;
    color: var(--navy); margin-bottom: 10px;
}
.balloon-stage {
    flex-grow: 1; width: 100%; position: relative; overflow: hidden;
    background: linear-gradient(to bottom, #87CEEB 0%, #E0F7FA 100%);
    border-radius: 15px; border: 4px solid #fff; box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}
.balloon {
    position: absolute; bottom: -120px; width: 70px; height: 90px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: white; font-weight: bold; font-size: 1.8rem;
    cursor: pointer; user-select: none;
    box-shadow: inset -5px -5px 10px rgba(0,0,0,0.2);
    animation: floatUp 4s linear forwards;
}
.balloon::after {
    content: ''; position: absolute; bottom: -15px; left: 50%;
    width: 2px; height: 15px; background: rgba(0,0,0,0.3);
}
@keyframes floatUp { to { bottom: 120%; } }

/* ::::: 3. TASBEEH GAME ::::: */
.tasbeeh-circle {
    width: 200px; height: 200px; border-radius: 50%;
    background: linear-gradient(135deg, #00b894, #00cec9);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 4rem; font-weight: bold; cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 184, 148, 0.4);
    transition: transform 0.1s, box-shadow 0.1s; border: 8px solid rgba(255,255,255,0.3);
}
.tasbeeh-circle:active { transform: scale(0.95); box-shadow: 0 5px 15px rgba(0,0,0,0.2); }

/* ::::: 4. BUNNY GAME ::::: */
.bunny-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 20px; width: 100%; max-width: 600px; margin: auto;
    flex-grow: 1; align-content: center;
}
.hole {
    background: #dfe6e9; border-radius: 50%; position: relative; overflow: hidden;
    height: 120px; cursor: pointer;
    box-shadow: inset 0 10px 30px rgba(0,0,0,0.2), 0 5px 0 #b2bec3;
}
.hole .bunny {
    width: 70%; height: 80%;
    background: url('https://img.icons8.com/color/96/rabbit.png') no-repeat center bottom/contain;
    position: absolute; bottom: -100px; left: 15%;
    transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}
.hole.up .bunny { bottom: 0; }

/* ::::: 5. PIANO GAME ::::: */
.piano-wrapper { display: flex; gap: 10px; }
.piano-key {
    width: 50px; height: 200px; background: white;
    border: 1px solid #ccc; border-radius: 0 0 10px 10px;
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 20px; font-weight: bold; color: white; cursor: pointer;
    box-shadow: 0 5px 10px rgba(0,0,0,0.1); transition: height 0.1s; user-select: none;
}
.piano-key:active, .piano-key.playing { height: 190px; transform: translateY(5px); box-shadow: none; opacity: 0.8; }

/* ::::: 6. ANIMAL QUIZ ::::: */
.animal-options { display: flex; gap: 20px; justify-content: center; width: 100%; }
.animal-card {
    width: 100px; height: 100px; background: #f1f2f6; border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 4rem; cursor: pointer; border: 4px solid transparent; transition: 0.3s;
}
.animal-card:hover { transform: scale(1.1); background: white; border-color: var(--blue); }
.correct-anim { background: #2ecc71 !important; color: white; animation: bounce 0.5s; }
.wrong-anim { background: #e74c3c !important; color: white; animation: shake 0.5s; }
@keyframes bounce { 0%, 100% {transform:scale(1);} 50% {transform:scale(1.2);} }
@keyframes shake { 0%, 100% {transform:translateX(0);} 25% {transform:translateX(-10px);} 75% {transform:translateX(10px);} }

/* ::::: 7. TIC TAC TOE ::::: */
.xo-board {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    background: #002855; padding: 10px; border-radius: 15px;
    width: 300px; height: 300px; margin-top: 20px;
}
.xo-cell {
    background: white; border-radius: 8px; display: flex;
    align-items: center; justify-content: center;
    font-size: 3rem; font-weight: 800; cursor: pointer;
}
.xo-cell.x { color: #e74c3c; }
.xo-cell.o { color: #3498db; }
.xo-status { font-size: 1.5rem; font-weight: bold; color: var(--navy); }

/* ::::: 8. SIMON SAYS ::::: */
.simon-board {
    width: 300px; height: 300px; border-radius: 50%; background: #333;
    position: relative; overflow: hidden; border: 10px solid #333;
}
.simon-btn { width: 50%; height: 50%; position: absolute; cursor: pointer; opacity: 0.6; transition: 0.2s; }
.simon-btn.active { opacity: 1; transform: scale(0.98); }
.simon-btn.red { background: #ff7675; top: 0; left: 0; }
.simon-btn.green { background: #55efc4; top: 0; right: 0; }
.simon-btn.blue { background: #74b9ff; bottom: 0; right: 0; }
.simon-btn.yellow { background: #fdcb6e; bottom: 0; left: 0; }
.simon-center {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 100px; height: 100px; background: white; border-radius: 50%;
    border: 10px solid #333; display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 1.2rem;
}

/* ::::: 9. ISLAMIC QUIZ ::::: */
.islamic-q-card { width: 100%; text-align: center; }
.quiz-options { display: flex; flex-direction: column; gap: 15px; width: 100%; max-width: 500px; margin: 0 auto; }
.quiz-btn {
    padding: 15px 20px; background: white; border: 2px solid #00b894;
    border-radius: 50px; font-size: 1.1rem; color: var(--navy); font-weight: bold;
    cursor: pointer; transition: 0.3s;
}
.quiz-btn:hover { background: #00b894; color: white; }
.quiz-btn.correct { background: #2ecc71; color: white; border-color: #2ecc71; }
.quiz-btn.wrong { background: #e74c3c; color: white; border-color: #e74c3c; }

/* Responsive */
@media (max-width: 600px) {
    .memory-grid { grid-template-columns: repeat(3, 1fr); }
    .thumb-icon { height: 120px; font-size: 3.5rem; }
    .game-stage { padding: 15px; min-height: 450px; margin-top: 50px; }
    .stage-controls { top: -60px; }
    .hole { height: 90px; }
    .piano-key { width: 40px; height: 150px; font-size: 0.8rem; }
    .xo-board { width: 250px; height: 250px; }
    .simon-board { width: 250px; height: 250px; }
}