/* ================================================
   SALAM GAMES — Design System v2.0
   A gorgeous, kid-friendly, app-like experience
   ================================================ */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');
* { font-family: 'Nunito', sans-serif; box-sizing: border-box; }

/* ---- CSS Custom Properties ---- */
:root {
    /* Primary palette */
    --sky-light: #e0f7fa;
    --sky: #4fc3f7;
    --sky-dark: #0288d1;
    --purple: #7c4dff;
    --purple-dark: #651fff;
    --pink: #f06292;
    --gold: #ffd54f;
    --gold-dark: #ffb300;
    --emerald: #66bb6a;
    --coral: #ff7043;
    
    /* Neutrals */
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-500: #9e9e9e;
    --gray-700: #616161;
    --gray-900: #212121;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.16);
    --shadow-kid: 0 6px 0 rgba(0,0,0,0.15);
    --shadow-glow-sky: 0 0 20px rgba(79,195,247,0.4);
    --shadow-glow-purple: 0 0 20px rgba(124,77,255,0.4);
    --shadow-glow-gold: 0 0 20px rgba(255,213,79,0.4);
    
    /* Borders */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --radius-xl: 36px;
    --radius-full: 9999px;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Transitions */
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 200ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;
}

/* ---- Base ---- */
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
    margin: 0;
    background: linear-gradient(180deg, #dff6ff 0%, #b8ecff 40%, #d4f0ff 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Polka dot overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,0.45) 2px, transparent 2px);
    background-size: 28px 28px;
    pointer-events: none;
    z-index: 0;
}

/* ---- Floating stars canvas ---- */
#stars-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* ---- Loading Screen ---- */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a237e 0%, #311b92 50%, #4a148c 100%);
    transition: opacity 0.6s ease, visibility 0.6s ease;
}
.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}
.loading-mosque { font-size: 80px; animation: float 3s ease-in-out infinite; }
.loading-title { color: white; font-size: 2rem; font-weight: 900; margin-top: 16px; }
.loading-dots { display: flex; gap: 8px; margin-top: 20px; }
.loading-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--gold);
    animation: dot-bounce 1.4s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

/* ---- Navigation ---- */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 3px solid rgba(79,195,247,0.3);
    transition: box-shadow var(--duration-normal) var(--ease-smooth);
}
.top-nav.scrolled {
    box-shadow: var(--shadow-md);
    border-bottom-color: rgba(79,195,247,0.5);
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-logo { display: flex; align-items: center; gap: 10px; cursor: pointer; text-decoration: none; }
.nav-logo-icon { font-size: 2.5rem; }
.nav-logo-text h1 { margin: 0; font-size: 1.4rem; font-weight: 900; line-height: 1.1; }
.nav-logo-text h1:first-child { color: var(--sky-dark); }
.nav-logo-text h1:last-child { color: var(--purple); }
.nav-links { display: flex; align-items: center; gap: 12px; }
.nav-links a, .nav-links button {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-smooth);
    border: none;
    cursor: pointer;
    background: none;
}

/* Profile badge */
.profile-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    border-radius: var(--radius-full);
    border: 3px solid white;
    cursor: pointer;
    transition: transform var(--duration-fast) var(--ease-bounce);
    text-decoration: none;
}
.profile-badge:hover { transform: scale(1.05); }
.profile-avatar { font-size: 1.6rem; }
.profile-info { display: none; }
.profile-name { color: white; font-weight: 800; font-size: 0.85rem; line-height: 1.2; }
.profile-points { color: rgba(255,255,255,0.85); font-size: 0.75rem; font-weight: 600; }

@media (min-width: 640px) {
    .profile-info { display: block; }
}

/* ---- Mobile Bottom Nav ---- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 3px solid rgba(79,195,247,0.2);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--gray-500);
    font-size: 0.7rem;
    font-weight: 700;
    transition: color var(--duration-fast);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
}
.bottom-nav-item.active { color: var(--sky-dark); }
.bottom-nav-item .nav-icon { font-size: 1.5rem; }

@media (min-width: 768px) {
    .bottom-nav { display: none; }
    .content-wrapper { padding-bottom: 0 !important; }
}

/* ---- Content Wrapper ---- */
.content-wrapper {
    position: relative;
    z-index: 1;
    padding-bottom: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 70px);
    min-height: calc(100dvh - 70px);
    box-sizing: border-box;
}

/* ---- Hero Section ---- */
.hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
}
.hero-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(224,247,250,0.9));
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    border: 4px solid rgba(255,255,255,0.8);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.hero-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(124,77,255,0.08), transparent 70%);
    border-radius: 50%;
}
.hero-emoji { font-size: 4rem; animation: float 3s ease-in-out infinite; }
.hero-title {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 900;
    color: var(--gray-900);
    margin: 0;
    line-height: 1.2;
}
.hero-gradient-text {
    background: linear-gradient(135deg, var(--sky-dark), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-subtitle {
    color: var(--gray-700);
    font-weight: 600;
    margin-top: 8px;
    font-size: 1rem;
}

/* ---- Quick Stats ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: var(--space-lg);
}
.stat-card {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    border: 3px solid var(--gray-200);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-bounce);
}
.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--sky);
    box-shadow: var(--shadow-glow-sky);
}
.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.5rem; font-weight: 900; margin: 4px 0 2px; }
.stat-label { font-size: 0.75rem; font-weight: 700; color: var(--gray-500); }

/* ---- Games Grid ---- */
.games-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md) var(--space-lg);
}
.games-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
@media (min-width: 768px) {
    .games-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}
@media (min-width: 1024px) {
    .games-grid { grid-template-columns: repeat(3, 1fr); gap: 24px; }
}

/* ---- Game Card ---- */
.game-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 4px solid var(--gray-200);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: all var(--duration-normal) var(--ease-bounce);
    box-shadow: var(--shadow-sm);
}
.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-lg);
}
.game-card:active {
    transform: translateY(-2px) scale(0.98);
}

/* Card badge */
.card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 900;
    color: white;
    z-index: 2;
}
.badge-daily { background: linear-gradient(135deg, #ff6b35, #f7c948); }
.badge-hot { background: linear-gradient(135deg, #f06292, #ba68c8); }
.badge-new { background: linear-gradient(135deg, #66bb6a, #26a69a); }
.badge-star { background: linear-gradient(135deg, #ffd54f, #ff8f00); color: #5d4037; }

/* Card icon area */
.card-icon-area {
    height: clamp(100px, 20vw, 140px);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
    position: relative;
    overflow: hidden;
}
.card-emoji {
    font-size: clamp(3rem, 8vw, 4rem);
    transition: transform var(--duration-normal) var(--ease-bounce);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}
.game-card:hover .card-emoji {
    transform: scale(1.2) rotate(-5deg);
}

/* Card decorative elements */
.card-deco {
    position: absolute;
    opacity: 0.3;
    font-size: 2rem;
}
.card-deco-1 { bottom: -8px; right: -8px; }
.card-deco-2 { top: 8px; left: 8px; font-size: 1.5rem; }

/* Card text */
.card-title {
    font-size: clamp(1rem, 3vw, 1.25rem);
    font-weight: 900;
    margin: 0 0 6px;
    line-height: 1.2;
}
.card-desc {
    font-size: 0.85rem;
    color: var(--gray-700);
    font-weight: 600;
    margin: 0;
    flex: 1;
    line-height: 1.4;
}
.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-sm);
    font-size: 0.75rem;
    font-weight: 700;
}

/* ---- Featured card (Daily Challenge) ---- */
.featured-card {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #ff9800, #f44336, #e91e63);
    border: none;
    color: white;
    padding: var(--space-xl);
    position: relative;
}
.featured-card .card-title { color: white; font-size: clamp(1.4rem, 4vw, 2rem); }
.featured-card .card-desc { color: rgba(255,255,255,0.9); font-size: 1rem; }
.featured-card .card-meta { color: rgba(255,255,255,0.8); }
.featured-card:hover { transform: translateY(-4px); }

.featured-inner {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}
.featured-emoji {
    font-size: 4rem;
    animation: float 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));
}
.featured-content { flex: 1; }

.featured-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: var(--space-md);
    padding: 12px 28px;
    background: white;
    color: #e91e63;
    font-weight: 900;
    font-size: 1.1rem;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--duration-fast) var(--ease-bounce);
}
.featured-btn:hover { transform: scale(1.05); box-shadow: var(--shadow-lg); }

/* Live pulse indicator */
.live-pulse {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 800;
    color: rgba(255,255,255,0.95);
    margin-bottom: 8px;
}
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #76ff03;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Animated bg shapes for featured card */
.featured-bg-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    animation: float-shape 8s ease-in-out infinite;
}

/* ---- Section Headers ---- */
.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--space-lg);
    padding: 0 var(--space-md);
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}
.section-header h2 {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--gray-900);
    margin: 0;
}
.section-emoji { font-size: 1.8rem; }

/* ---- Footer (desktop) ---- */
.site-footer {
    background: white;
    border-top: 4px solid rgba(79,195,247,0.3);
    padding: var(--space-xl) var(--space-md);
    text-align: center;
    position: relative;
    z-index: 1;
}
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}
.footer-links a {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--duration-fast);
}
.footer-links a:hover { color: var(--sky-dark); }
.footer-copy { color: var(--gray-500); font-size: 0.85rem; margin: 0; }

@media (min-width: 768px) {
    .site-footer { display: block; }
}

/* ---- Profile Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal);
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9) translateY(20px);
    transition: transform var(--duration-slow) var(--ease-bounce);
}
.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

/* ---- Settings Modal ---- */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal);
}
.settings-overlay.active { opacity: 1; visibility: visible; }

.settings-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform var(--duration-slow) var(--ease-bounce);
}
.settings-overlay.active .settings-content {
    transform: scale(1);
}

/* ---- Scroll Reveal ---- */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s var(--ease-smooth);
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Animations ---- */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.5); }
}

@keyframes float-shape {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(20px, -20px) rotate(120deg); }
    66% { transform: translate(-10px, 10px) rotate(240deg); }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

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

@keyframes count-up {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes ripple {
    0% { transform: scale(0); opacity: 0.6; }
    100% { transform: scale(4); opacity: 0; }
}

/* Ripple effect on tap */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

/* ---- Utility Classes ---- */
.text-center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Mobile-first responsive helpers */
@media (max-width: 639px) {
    .hide-mobile { display: none !important; }
    .nav-links > a:not(.profile-badge) { display: none; }
    .hero-card { padding: var(--space-lg); }
    .featured-inner { flex-direction: column; text-align: center; }
}

@media (min-width: 640px) {
    .hide-desktop { display: none !important; }
}

/* ---- Avatar Image Styling ---- */
.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
