/* ============================================
   GRAPE Ramadan Games - Design System
   ============================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1e2d4d;
    --accent-grape: #EC008C;
    --accent-grape-light: #ff3dab;
    --accent-grape-dark: #b8006e;
    --gold: #f4c430;
    --gold-light: #ffd966;
    --gold-dark: #c9a020;
    --green-ramadan: #2d6a4f;
    --green-light: #40916c;
    --red: #e63946;
    --text-primary: #ffffff;
    --text-secondary: #b8c4d0;
    --text-muted: #6b7b8d;
    --border-color: rgba(255,255,255,0.08);
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --nav-height: 70px;
    --header-height: 60px;
    --font-ui: 'Poppins', sans-serif;
    --font-arabic: 'Tajawal', sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    height: 100%;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
}

.hidden { display: none !important; }

/* --- Splash Screen --- */
.splash-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    position: relative;
}

/* Lanterns */
.splash-lanterns {
    display: flex;
    justify-content: center;
    gap: 50px;
    margin-bottom: 30px;
}

.lantern {
    width: 30px;
    height: 50px;
    background: linear-gradient(180deg, var(--gold) 0%, #e6a817 50%, var(--gold-dark) 100%);
    border-radius: 50% 50% 5px 5px;
    position: relative;
    animation: lanternSwing 3s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(244,196,48,0.4);
}

.lantern::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 15px;
    background: var(--gold-dark);
}

.lantern::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 6px;
    background: var(--gold);
    border-radius: 3px 3px 0 0;
}

.lantern-1 { animation-delay: 0s; }
.lantern-2 { animation-delay: 0.5s; transform: scale(1.2); }
.lantern-3 { animation-delay: 1s; }

@keyframes lanternSwing {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.lantern-2 {
    animation: lanternSwing2 3s ease-in-out infinite;
}

@keyframes lanternSwing2 {
    0%, 100% { transform: scale(1.2) rotate(-5deg); }
    50% { transform: scale(1.2) rotate(5deg); }
}

/* Crescent Moon */
.crescent-moon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    box-shadow: 15px -10px 0 0 var(--gold);
    margin: 0 auto 15px;
    animation: moonGlow 4s ease-in-out infinite;
}

@keyframes moonGlow {
    0%, 100% { box-shadow: 15px -10px 0 0 var(--gold), 15px -10px 30px rgba(244,196,48,0.3); }
    50% { box-shadow: 15px -10px 0 0 var(--gold-light), 15px -10px 50px rgba(244,196,48,0.5); }
}

.splash-logo-img {
    width: 200px;
    height: auto;
    object-fit: contain;
    background: rgba(255,255,255,0.9);
    padding: 15px 25px;
    border-radius: 16px;
    animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(244,196,48,0.3); }
    50% { box-shadow: 0 0 40px rgba(244,196,48,0.6); }
}

.splash-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 8px;
    background: linear-gradient(135deg, var(--accent-grape), var(--accent-grape-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.splash-subtitle {
    font-family: var(--font-arabic);
    font-size: 1.4rem;
    color: var(--gold);
    margin-top: 10px;
    letter-spacing: 3px;
}

/* Stars */
.splash-stars {
    margin-top: 30px;
    position: relative;
    height: 40px;
}

.star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--gold);
    border-radius: 50%;
    animation: twinkle 2s ease-in-out infinite;
}

.star:nth-child(1) { left: 10%; top: 10%; animation-delay: 0s; }
.star:nth-child(2) { left: 25%; top: 70%; animation-delay: 0.3s; }
.star:nth-child(3) { left: 40%; top: 20%; animation-delay: 0.6s; }
.star:nth-child(4) { left: 55%; top: 60%; animation-delay: 0.9s; }
.star:nth-child(5) { left: 70%; top: 30%; animation-delay: 1.2s; }
.star:nth-child(6) { left: 85%; top: 50%; animation-delay: 1.5s; }
.star:nth-child(7) { left: 15%; top: 45%; animation-delay: 0.4s; }
.star:nth-child(8) { left: 60%; top: 5%; animation-delay: 0.8s; }
.star:nth-child(9) { left: 90%; top: 15%; animation-delay: 1.1s; }

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.8); }
}

/* Loader */
.splash-loader {
    margin-top: 40px;
    width: 200px;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-inline: auto;
    overflow: hidden;
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-grape), var(--gold));
    border-radius: 2px;
    animation: loading 2s ease forwards;
}

@keyframes loading {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* --- App Layout --- */
.app {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
.app-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.header-left, .header-right {
    width: 60px;
    display: flex;
    align-items: center;
}

.header-right { justify-content: flex-end; }

.header-title {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-grape), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-logo-img {
    height: 30px;
    width: auto;
    object-fit: contain;
    background: rgba(255,255,255,0.85);
    padding: 4px 14px;
    border-radius: 8px;
}

.header-score {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold);
}

/* Page Content */
.page-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 16px;
    padding-bottom: calc(var(--nav-height) + 20px);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 8px 16px;
    position: relative;
}

.nav-item.active {
    color: var(--accent-grape);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: var(--accent-grape);
    border-radius: 0 0 3px 3px;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.active svg { stroke: var(--accent-grape); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-grape), var(--accent-grape-light));
    color: white;
    box-shadow: 0 4px 15px rgba(236,0,140,0.3);
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(236,0,140,0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:active { transform: scale(0.96); }

.btn-gold {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #1a1a2e;
    box-shadow: 0 4px 15px rgba(244,196,48,0.3);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.btn-icon:active { background: rgba(255,255,255,0.1); }

.btn-block { width: 100%; }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:active {
    transform: scale(0.98);
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.form-input:focus {
    border-color: var(--accent-grape);
    box-shadow: 0 0 0 3px rgba(236,0,140,0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.pin-input-group {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.pin-digit {
    width: 55px;
    height: 60px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-ui);
    outline: none;
    transition: border-color 0.3s ease;
}

.pin-digit:focus {
    border-color: var(--accent-grape);
    box-shadow: 0 0 0 3px rgba(236,0,140,0.15);
}

.otp-input-group {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.otp-digit {
    width: 42px;
    height: 50px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-ui);
    outline: none;
    transition: border-color 0.3s ease;
}

.otp-digit:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(244,196,48,0.15);
}

/* --- Login Page --- */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height) - var(--nav-height) - 40px);
    text-align: center;
}

.login-logo {
    margin-bottom: 30px;
}

.login-logo-img {
    width: 160px;
    height: auto;
    object-fit: contain;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.9);
    padding: 12px 20px;
    border-radius: 14px;
}

.login-logo .crescent-moon {
    width: 50px;
    height: 50px;
}

.login-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
    background: linear-gradient(135deg, var(--accent-grape), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 35px;
}

.login-form {
    width: 100%;
    max-width: 350px;
}

.login-tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 25px;
}

.login-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all 0.3s ease;
}

.login-tab.active {
    background: var(--accent-grape);
    color: white;
}

.form-error {
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 5px;
    display: none;
}

.form-error.show { display: block; }

/* --- Home Page --- */
.home-welcome {
    text-align: center;
    margin-bottom: 30px;
}

.home-welcome h2 {
    font-family: var(--font-arabic);
    font-size: 1.6rem;
    color: var(--gold);
    margin-bottom: 5px;
}

.home-welcome p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.home-promo {
    background: linear-gradient(135deg, var(--accent-grape-dark), var(--accent-grape));
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 25px;
    position: relative;
    overflow: hidden;
}

.home-promo::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.home-promo::after {
    content: '';
    position: absolute;
    bottom: -40px;
    right: 30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
}

.promo-badge {
    display: inline-block;
    background: var(--gold);
    color: var(--bg-primary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.home-promo h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 5px;
    position: relative;
    z-index: 1;
}

.home-promo p {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.85);
    position: relative;
    z-index: 1;
}

/* Games Grid */
.games-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.games-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 20px;
}

.game-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.game-card:active {
    transform: scale(0.96);
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.game-card[data-game="quiz"]::before { background: linear-gradient(90deg, var(--accent-grape), var(--gold)); }
.game-card[data-game="memory"]::before { background: linear-gradient(90deg, var(--green-light), var(--gold)); }
.game-card[data-game="catch"]::before { background: linear-gradient(90deg, var(--gold), #ff6b35); }
.game-card[data-game="puzzle"]::before { background: linear-gradient(90deg, #6c5ce7, var(--accent-grape)); }
.game-card[data-game="breaker"]::before { background: linear-gradient(90deg, var(--red), var(--gold)); }
.game-card[data-game="twenty48"]::before { background: linear-gradient(90deg, #f4c430, #ff6b35); }
.game-card[data-game="colorswitch"]::before { background: linear-gradient(90deg, #EC008C, #6c5ce7); }
.game-card[data-game="flappy"]::before { background: linear-gradient(90deg, #f4c430, #EC008C); }
.game-card[data-game="snake"]::before { background: linear-gradient(90deg, #40916c, #f4c430); }
.game-card[data-game="blockblast"]::before { background: linear-gradient(90deg, #6c5ce7, #ff6b35); }
.game-card[data-game="wordscramble"]::before { background: linear-gradient(90deg, #6c5ce7, #a29bfe); }
.game-card[data-game="mosque"]::before { background: linear-gradient(90deg, #2d6a4f, #40916c); }
.game-card[data-game="tasbih"]::before { background: linear-gradient(90deg, #f4c430, #40916c); }
.game-card[data-game="duamatch"]::before { background: linear-gradient(90deg, #EC008C, #f4c430); }
.game-card[data-game="ayat"]::before { background: linear-gradient(90deg, #40916c, #2d6a4f); }
.game-card[data-game="surahorder"]::before { background: linear-gradient(90deg, #d4a017, #f4c430); }
.game-card[data-game="islamquiz"]::before { background: linear-gradient(90deg, #4488cc, #6c5ce7); }
.game-card[data-game="hadithornot"]::before { background: linear-gradient(90deg, #e74c3c, #EC008C); }

.game-card-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.game-card[data-game="quiz"] .game-card-icon { background: linear-gradient(135deg, rgba(236,0,140,0.2), rgba(244,196,48,0.2)); }
.game-card[data-game="memory"] .game-card-icon { background: linear-gradient(135deg, rgba(45,106,79,0.3), rgba(244,196,48,0.2)); }
.game-card[data-game="catch"] .game-card-icon { background: linear-gradient(135deg, rgba(244,196,48,0.3), rgba(255,107,53,0.2)); }
.game-card[data-game="puzzle"] .game-card-icon { background: linear-gradient(135deg, rgba(108,92,231,0.3), rgba(236,0,140,0.2)); }
.game-card[data-game="breaker"] .game-card-icon { background: linear-gradient(135deg, rgba(230,57,70,0.3), rgba(244,196,48,0.2)); }
.game-card[data-game="twenty48"] .game-card-icon { background: linear-gradient(135deg, rgba(244,196,48,0.3), rgba(255,107,53,0.2)); }
.game-card[data-game="colorswitch"] .game-card-icon { background: linear-gradient(135deg, rgba(236,0,140,0.3), rgba(108,92,231,0.2)); }
.game-card[data-game="flappy"] .game-card-icon { background: linear-gradient(135deg, rgba(244,196,48,0.3), rgba(236,0,140,0.2)); }
.game-card[data-game="snake"] .game-card-icon { background: linear-gradient(135deg, rgba(64,145,108,0.3), rgba(244,196,48,0.2)); }
.game-card[data-game="blockblast"] .game-card-icon { background: linear-gradient(135deg, rgba(108,92,231,0.3), rgba(255,107,53,0.2)); }
.game-card[data-game="wordscramble"] .game-card-icon { background: linear-gradient(135deg, rgba(108,92,231,0.3), rgba(162,155,254,0.2)); }
.game-card[data-game="mosque"] .game-card-icon { background: linear-gradient(135deg, rgba(45,106,79,0.3), rgba(64,145,108,0.2)); }
.game-card[data-game="tasbih"] .game-card-icon { background: linear-gradient(135deg, rgba(244,196,48,0.3), rgba(64,145,108,0.2)); }
.game-card[data-game="duamatch"] .game-card-icon { background: linear-gradient(135deg, rgba(236,0,140,0.3), rgba(244,196,48,0.2)); }
.game-card[data-game="ayat"] .game-card-icon { background: linear-gradient(135deg, rgba(64,145,108,0.3), rgba(45,106,79,0.2)); }
.game-card[data-game="surahorder"] .game-card-icon { background: linear-gradient(135deg, rgba(212,160,23,0.3), rgba(244,196,48,0.2)); }
.game-card[data-game="islamquiz"] .game-card-icon { background: linear-gradient(135deg, rgba(68,136,204,0.3), rgba(108,92,231,0.2)); }
.game-card[data-game="hadithornot"] .game-card-icon { background: linear-gradient(135deg, rgba(231,76,60,0.3), rgba(236,0,140,0.2)); }

.game-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.game-card-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.game-card-best {
    margin-top: 8px;
    font-size: 0.7rem;
    color: var(--gold);
    font-weight: 500;
}

/* Featured game (quiz takes full width) */
.game-card-featured {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    padding: 20px;
}

.game-card-featured .game-card-icon {
    margin: 0;
    width: 64px;
    height: 64px;
    font-size: 32px;
    flex-shrink: 0;
}

/* --- Game Container --- */
.game-container {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 500;
    display: flex;
    flex-direction: column;
}

.game-header {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    flex-shrink: 0;
}

.game-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.game-title-bar {
    font-size: 0.9rem;
    font-weight: 600;
}

.game-score-live {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gold);
    background: rgba(244,196,48,0.1);
    padding: 4px 12px;
    border-radius: 20px;
}

.game-timer {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gold);
}

.game-timer.danger { color: var(--red); }
.game-timer.danger svg { stroke: var(--red); }

.game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.game-dom {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Game Over Modal --- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 30px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    animation: modalIn 0.4s ease;
    border: 1px solid var(--border-color);
}

@keyframes modalIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.game-over-stars {
    margin-bottom: 15px;
}

.go-star {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin: 0 5px;
    transition: all 0.3s ease;
}

.go-star.active {
    color: var(--gold);
    text-shadow: 0 0 20px rgba(244,196,48,0.5);
    animation: starPop 0.4s ease;
}

@keyframes starPop {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.game-over-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 15px;
    background: linear-gradient(135deg, var(--accent-grape), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-over-score {
    margin-bottom: 10px;
}

.score-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.score-value {
    font-size: 3rem;
    font-weight: 800;
    color: var(--gold);
}

.game-over-best {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.game-over-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.game-over-actions .btn { flex: 1; padding: 12px; font-size: 0.9rem; }

/* --- Leaderboard Page --- */
.leaderboard-header {
    text-align: center;
    margin-bottom: 25px;
}

.leaderboard-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.leaderboard-month {
    color: var(--gold);
    font-size: 0.9rem;
    font-weight: 500;
}

.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    padding: 0 10px;
}

.podium-item {
    text-align: center;
    flex: 1;
    max-width: 110px;
}

.podium-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.podium-item:nth-child(1) .podium-avatar { background: linear-gradient(135deg, #c0c0c0, #a0a0a0); }
.podium-item:nth-child(2) .podium-avatar {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
    border: 3px solid var(--gold);
    box-shadow: 0 0 20px rgba(244,196,48,0.3);
}
.podium-item:nth-child(3) .podium-avatar { background: linear-gradient(135deg, #cd7f32, #a0622e); }

.podium-name {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.podium-score {
    font-size: 0.75rem;
    color: var(--gold);
    font-weight: 600;
}

.podium-bar {
    margin-top: 10px;
    border-radius: 8px 8px 0 0;
    width: 100%;
}

.podium-item:nth-child(1) .podium-bar { height: 60px; background: linear-gradient(180deg, #c0c0c0, #808080); }
.podium-item:nth-child(2) .podium-bar { height: 80px; background: linear-gradient(180deg, var(--gold), var(--gold-dark)); }
.podium-item:nth-child(3) .podium-bar { height: 45px; background: linear-gradient(180deg, #cd7f32, #8b5e3c); }

.podium-rank {
    font-size: 0.7rem;
    color: var(--bg-primary);
    font-weight: 700;
    padding-top: 8px;
}

.leaderboard-list {
    list-style: none;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
}

.leaderboard-row.current-user {
    border-color: var(--accent-grape);
    background: rgba(236,0,140,0.08);
}

.lb-rank {
    width: 30px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
}

.lb-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 12px;
    color: var(--accent-grape);
}

.lb-info { flex: 1; }
.lb-name { font-size: 0.9rem; font-weight: 600; }
.lb-games { font-size: 0.7rem; color: var(--text-muted); }
.lb-score { font-size: 0.95rem; font-weight: 700; color: var(--gold); }

/* Prize badges */
.lb-prize {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    margin-left: 8px;
}

.prize-gold { background: rgba(244,196,48,0.2); color: var(--gold); }
.prize-silver { background: rgba(192,192,192,0.2); color: #c0c0c0; }
.prize-bronze { background: rgba(205,127,50,0.2); color: #cd7f32; }

/* --- Profile Page --- */
.profile-header {
    text-align: center;
    margin-bottom: 25px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-grape), var(--gold));
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.profile-name {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-phone {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px 10px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.profile-games-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.profile-game-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
}

.pg-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
}

.pg-info { flex: 1; }
.pg-name { font-size: 0.85rem; font-weight: 600; }
.pg-plays { font-size: 0.7rem; color: var(--text-muted); }
.pg-score { font-size: 0.9rem; font-weight: 700; color: var(--gold); }

.btn-logout {
    margin-top: 25px;
    background: rgba(230,57,70,0.1);
    color: var(--red);
    border: 1px solid rgba(230,57,70,0.2);
}

/* --- Quiz Game Styles --- */
.quiz-container {
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.quiz-progress {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
}

.quiz-progress-dot {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-card);
    transition: background 0.3s ease;
}

.quiz-progress-dot.correct { background: var(--green-light); }
.quiz-progress-dot.wrong { background: var(--red); }
.quiz-progress-dot.current { background: var(--accent-grape); }

.quiz-timer-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    margin-bottom: 25px;
    overflow: hidden;
}

.quiz-timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green-light), var(--gold), var(--red));
    border-radius: 3px;
    transition: width 0.1s linear;
}

.quiz-category {
    font-size: 0.75rem;
    color: var(--accent-grape);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.quiz-question {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 25px;
    min-height: 80px;
}

.quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quiz-answer {
    padding: 16px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-answer:active { transform: scale(0.98); }

.quiz-answer-letter {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.quiz-answer.correct {
    border-color: var(--green-light);
    background: rgba(64,145,108,0.15);
}

.quiz-answer.correct .quiz-answer-letter {
    background: var(--green-light);
    color: white;
}

.quiz-answer.wrong {
    border-color: var(--red);
    background: rgba(230,57,70,0.15);
    animation: shake 0.4s ease;
}

.quiz-answer.wrong .quiz-answer-letter {
    background: var(--red);
    color: white;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.quiz-score-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 800;
    pointer-events: none;
    animation: scorePopup 0.8s ease forwards;
    z-index: 600;
}

.quiz-score-popup.positive { color: var(--green-light); }
.quiz-score-popup.negative { color: var(--red); }

@keyframes scorePopup {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    50% { transform: translate(-50%, -70%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -100%) scale(1); }
}

/* --- Memory Game Styles --- */
.memory-container {
    padding: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.memory-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 0.85rem;
}

.memory-stat {
    background: var(--bg-card);
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 500;
}

.memory-stat span { color: var(--gold); font-weight: 700; }

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.memory-card {
    aspect-ratio: 3/4;
    perspective: 600px;
    cursor: pointer;
}

.memory-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

.memory-card.flipped .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-front, .memory-card-back {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-sm);
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.memory-card-back {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    border: 2px solid var(--border-color);
}

.memory-card-back::after {
    content: '';
    width: 70%;
    height: 70%;
    background: repeating-conic-gradient(var(--accent-grape) 0% 25%, transparent 0% 50%) 50% / 20px 20px;
    opacity: 0.15;
    border-radius: 6px;
}

.memory-card-front {
    background: var(--bg-card);
    border: 2px solid var(--gold);
    transform: rotateY(180deg);
    flex-direction: column;
    gap: 6px;
    padding: 8px;
}

.memory-card-front .card-emoji {
    font-size: 2rem;
}

.memory-card-front .card-label {
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}

.memory-card.matched .memory-card-front {
    border-color: var(--green-light);
    background: rgba(64,145,108,0.15);
}

.memory-card.matched { pointer-events: none; }

/* --- Catch Game (Canvas) --- */
/* Handled mostly in Canvas, minimal CSS needed */

/* --- Puzzle Styles --- */
.puzzle-container {
    padding: 15px;
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
}

.puzzle-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 0.85rem;
}

.puzzle-stat {
    background: var(--bg-card);
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 500;
}

.puzzle-stat span { color: var(--gold); font-weight: 700; }

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    aspect-ratio: 1;
    max-width: 320px;
    margin: 0 auto 20px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.puzzle-tile {
    background: var(--bg-card);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    border: 1px solid var(--border-color);
    aspect-ratio: 1;
    color: var(--text-primary);
}

.puzzle-tile:active { transform: scale(0.95); }

.puzzle-tile.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.puzzle-tile.correct {
    color: var(--green-light);
    border-color: rgba(64,145,108,0.3);
}

.puzzle-preview {
    margin-bottom: 15px;
}

.puzzle-preview img {
    max-width: 150px;
    border-radius: var(--radius-sm);
    opacity: 0.7;
}

/* --- Block Breaker (Canvas) --- */
/* Handled in Canvas */

/* --- Utilities --- */
.text-gold { color: var(--gold); }
.text-grape { color: var(--accent-grape); }
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

/* --- Confetti (for quiz correct answers) --- */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: confettiFall 1.5s ease forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* --- Responsive --- */
@media (max-width: 350px) {
    .games-grid { gap: 10px; }
    .game-card { padding: 14px 10px; }
    .game-card-icon { width: 44px; height: 44px; font-size: 22px; }
    .pin-digit { width: 48px; height: 52px; }
}

@media (min-width: 500px) {
    .page-content { max-width: 500px; margin-inline: auto; }
    .games-grid { gap: 16px; }
}

/* --- 2048 Game Styles --- */
.t48-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.t48-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 8px;
    width: min(90vw, 340px);
    aspect-ratio: 1;
}

.t48-cell {
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
}

.t48-empty {
    background: rgba(255,255,255,0.04);
}

.t48-tile-el {
    transition: left 0.12s ease, top 0.12s ease;
}

.t48-new {
    animation: t48Spawn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.t48-merge {
    animation: t48Merge 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.t48-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 20px;
    text-align: center;
}

@keyframes t48Spawn {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes t48Merge {
    0% { transform: scale(1); }
    40% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* ============================================
   Social Links & Marketing
   ============================================ */

.social-links {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.social-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 25px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.social-btn:active {
    transform: scale(0.95);
}

.social-btn span {
    font-size: 0.78rem;
}

.social-fb {
    background: rgba(24, 119, 242, 0.15);
    color: #4599ff;
}

.social-wa {
    background: rgba(37, 211, 102, 0.15);
    color: #25d366;
}

.social-web {
    background: rgba(236, 0, 140, 0.15);
    color: var(--accent-grape-light);
}

/* Home marketing section */
.home-marketing {
    text-align: center;
    margin-top: 15px;
    padding: 20px 15px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.marketing-brand {
    margin-bottom: 15px;
}

.marketing-logo {
    width: 130px;
    height: auto;
    object-fit: contain;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.85);
    padding: 10px 20px;
    border-radius: 12px;
}

.marketing-brand p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Profile marketing section */
.profile-marketing {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
}
