/* ========================================
   SrbijaVoz 3D PWA - Design System
   3D-aware glassmorphism over Three.js canvas
   Colors: Navy, Red, Gold | Fonts: Outfit, Inter
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; height: auto; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #050811;
    color: #ffffff;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input { font-family: inherit; outline: none; }
img { max-width: 100%; display: block; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #0A1128; }
::-webkit-scrollbar-thumb { background: #E3000F; border-radius: 4px; }

/* --- CSS Variables --- */
:root {
    --navy: #0A1128;
    --navy-light: #182346;
    --navy-dark: #050811;
    --red: #E3000F;
    --red-dark: #B8000C;
    --gold: #D4AF37;
    --gold-light: #FFD700;
    --white: #ffffff;
    --gray: #94a3b8;
    --gray-light: #cbd5e1;
    --gray-dark: #334155;
    --success: #22c55e;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-full: 9999px;
    --shadow: 0 8px 32px rgba(0,0,0,0.3);
    --shadow-red: 0 4px 20px rgba(227,0,15,0.3);
    --shadow-gold: 0 4px 20px rgba(212,175,55,0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-height: 70px;
}

/* --- 3D Canvas Layer --- */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}
#canvas-container.dimmed {
    opacity: 0.4;
}
#canvas-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* --- UI Layer (on top of 3D) --- */
#ui-layer {
    position: relative;
    z-index: 10;
    width: 100%;
    pointer-events: none;
}
#ui-layer > * {
    pointer-events: auto;
}

/* --- Typography --- */
h1, h2, h3, h4, h5 { font-family: var(--font-heading); font-weight: 700; line-height: 1.1; }
h1 { font-size: clamp(1.8rem, 5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 4vw, 2.2rem); }
h3 { font-size: clamp(1.1rem, 3vw, 1.5rem); }
p { line-height: 1.6; color: var(--gray-light); }
.text-gradient { background: linear-gradient(135deg, #fff 0%, #9BA4C1 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-gold { background: linear-gradient(135deg, var(--gold-light) 0%, var(--red) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-red { background: linear-gradient(135deg, var(--red) 0%, #ff4444 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-red { color: var(--red); }
.text-gold { color: var(--gold); }
.text-gray { color: var(--gray); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.font-heading { font-family: var(--font-heading); }

/* --- Layout --- */
.container { width: 100%; max-width: 480px; margin: 0 auto; padding: 0 20px; }
.page { display: none; min-height: 100vh; min-height: 100dvh; padding-top: calc(var(--safe-top) + 16px); padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px); }
.page.active { display: block; animation: fadeIn 0.3s ease; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.w-full { width: 100%; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-2 { padding: 16px; }
.p-3 { padding: 20px; }
.p-4 { padding: 24px; }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes bounceIn { 0% { transform: scale(0.3); opacity: 0; } 50% { transform: scale(1.05); } 70% { transform: scale(0.9); } 100% { transform: scale(1); opacity: 1; } }
@keyframes confetti { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(-200px) rotate(720deg); opacity: 0; } }
@keyframes heroFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* --- Glass Effect (3D-aware: more transparent to show canvas) --- */
.glass {
    background: rgba(10, 17, 40, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius);
}
.glass-light {
    background: rgba(24, 35, 70, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
}
.glass-solid {
    background: rgba(10, 17, 40, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
}

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 28px; border-radius: var(--radius-sm); font-weight: 600;
    font-size: 0.95rem; transition: var(--transition); min-height: 48px;
    -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn-red { background: var(--red); color: white; box-shadow: var(--shadow-red); }
.btn-red:hover { background: var(--red-dark); transform: translateY(-1px); }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: #0A1128; box-shadow: var(--shadow-gold); }
.btn-gold:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn-outline { background: transparent; color: white; border: 1.5px solid rgba(255,255,255,0.2); }
.btn-outline:hover { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.05); }
.btn-ghost { background: rgba(255,255,255,0.05); color: var(--gray-light); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-white { background: white; color: #0A1128; font-weight: 800; box-shadow: 0 0 40px rgba(255,255,255,0.3); }
.btn-white:hover { transform: scale(1.05); }
.btn-sm { padding: 10px 20px; font-size: 0.85rem; min-height: 40px; }
.btn-lg { padding: 16px 32px; font-size: 1.05rem; }
.btn-full { width: 100%; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-round { border-radius: var(--radius-full); }

/* --- Input --- */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 0.85rem; color: var(--gray); font-weight: 500; }
.input {
    width: 100%; padding: 14px 16px; background: rgba(24, 35, 70, 0.6);
    border: 1.5px solid rgba(255,255,255,0.1); border-radius: var(--radius-sm);
    color: white; font-size: 1rem; transition: var(--transition);
}
.input:focus { border-color: var(--red); background: rgba(24, 35, 70, 0.8); }
.input::placeholder { color: var(--gray-dark); }
textarea.input { resize: vertical; min-height: 80px; }

/* --- Cards --- */
.card {
    background: rgba(10, 17, 40, 0.6);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}
.card:hover { border-color: rgba(255,255,255,0.12); transform: translateY(-2px); }
.card-red { border-color: rgba(227, 0, 15, 0.3); }
.card-red:hover { border-color: rgba(227, 0, 15, 0.5); box-shadow: var(--shadow-red); }
.card-gold { border-color: rgba(212, 175, 55, 0.3); }
.card-gold:hover { border-color: rgba(212, 175, 55, 0.5); box-shadow: var(--shadow-gold); }

/* ==========================================
   3D HERO LANDING PAGE (Overlay-style sections)
   ========================================== */
#page-landing-3d {
    padding: 0;
    min-height: auto;
}
#scroll-container {
    height: 400vh;
    width: 100%;
    position: relative;
}

/* Hero Nav (mix-blend-difference like original) */
.hero-nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    mix-blend-mode: difference;
    pointer-events: auto;
}
.hero-nav-logo {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.3rem;
    color: white;
    letter-spacing: 3px;
}
.hero-nav-links {
    display: none;
    align-items: center;
    gap: 32px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #9ca3af;
}
.hero-nav-links a { transition: color 0.3s; }
.hero-nav-links a:hover { color: white; }
.hero-nav-links a.gold { color: var(--gold); }
.hero-nav-divider { width: 1px; height: 16px; background: #4b5563; }

/* Mobile hamburger */
.hero-hamburger {
    display: flex;
    background: none;
    color: white;
    padding: 8px;
    z-index: 51;
}
.hero-hamburger svg { width: 24px; height: 24px; }

/* Mobile menu overlay */
.hero-mobile-menu {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(20px);
    z-index: 45;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.hero-mobile-menu.open {
    opacity: 1;
    pointer-events: auto;
}
.hero-mobile-menu a {
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #9ca3af;
    transition: color 0.3s;
}
.hero-mobile-menu a:hover { color: white; }

/* Hero Section 1 - Title */
.hero-section {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 16px;
}
.hero-title {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: clamp(3rem, 10vw, 10rem);
    text-align: center;
    line-height: 0.95;
    color: white;
    mix-blend-mode: overlay;
}
.hero-subtitle {
    margin-top: 24px;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: #9ca3af;
    max-width: 500px;
    text-align: center;
    line-height: 1.6;
}
.hero-scroll-cta {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--red);
    animation: pulse 2s infinite;
    white-space: nowrap;
}

/* Hero Section 2 - Train Info (glass card, left-aligned) */
.hero-glass-card {
    padding: 24px;
    border-radius: 24px;
    max-width: 480px;
    width: 100%;
    transition: transform 0.5s;
    pointer-events: auto;
}
.hero-glass-card:hover { transform: scale(1.03); }
.hero-card-sub {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gold);
    letter-spacing: 3px;
    margin-bottom: 12px;
}
.hero-card-title {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 700;
    color: white;
    margin-bottom: 16px;
    line-height: 1.1;
}
.hero-card-desc {
    color: #9ca3af;
    font-size: clamp(0.85rem, 2vw, 1rem);
    line-height: 1.7;
}

/* Hero Section 3 - AI & Games (right-aligned) */
.hero-right { align-items: flex-end; text-align: right; }
.hero-right .hero-card-sub { color: var(--red); }

.hero-action-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
    pointer-events: auto;
    width: 100%;
}
.hero-action-card {
    padding: 16px 20px;
    border-radius: 16px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 16px;
}
.hero-action-card:hover { background: rgba(255,255,255,0.1); }
.hero-action-card.gold-border { border: 1px solid rgba(212,175,55,0.3); }
.hero-action-icon { font-size: 1.5rem; }
.hero-action-label { font-weight: 700; font-size: 0.95rem; }
.hero-action-label.gold { color: var(--gold); }

/* Hero Section 4 - PWA Install */
.hero-install-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 6vw, 4.5rem);
    font-weight: 700;
    color: white;
    margin-bottom: 24px;
    line-height: 1.1;
}
.hero-install-title .gradient-span {
    background: linear-gradient(to right, var(--red), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@media (min-width: 640px) {
    .hero-nav-links { display: flex; }
    .hero-hamburger { display: none; }
    .hero-section { padding: 24px 48px; }
    .hero-glass-card { padding: 48px; }
    .hero-action-cards { flex-direction: row; gap: 16px; }
    .hero-action-card { width: 200px; flex-direction: column; text-align: center; }
}

/* ==========================================
   APP PAGES (Post-login, 3D background)
   ========================================== */

/* --- Top Header --- */
.top-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    padding: calc(var(--safe-top) + 12px) 20px 12px;
    background: linear-gradient(to bottom, rgba(5,8,17,0.95), rgba(5,8,17,0));
    pointer-events: none;
}
.top-header-inner { max-width: 480px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; pointer-events: auto; }
.logo { font-family: var(--font-heading); font-weight: 800; font-size: 1.3rem; letter-spacing: 1px; cursor: pointer; }
.logo span { color: var(--red); }

/* --- Bottom Navigation --- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    padding: 8px 12px calc(var(--safe-bottom) + 8px);
    background: rgba(10, 17, 40, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.06);
}
.bottom-nav-inner {
    max-width: 480px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-around;
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 12px; border-radius: var(--radius-sm);
    color: var(--gray); font-size: 0.65rem; font-weight: 500;
    transition: var(--transition); -webkit-tap-highlight-color: transparent;
    background: none; min-width: 56px;
}
.nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }
.nav-item.active { color: var(--red); }
.nav-item.active svg { filter: drop-shadow(0 0 6px rgba(227,0,15,0.5)); }

/* --- Landing Page (non-3D fallback / auth entry) --- */
.landing-hero {
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 40px 24px;
    background: radial-gradient(ellipse at 50% 30%, rgba(227,0,15,0.08) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 80%, rgba(212,175,55,0.05) 0%, transparent 50%);
}
.landing-logo { font-family: var(--font-heading); font-weight: 900; font-size: clamp(2.5rem, 8vw, 4rem); letter-spacing: 3px; margin-bottom: 8px; }
.landing-logo .red { color: var(--red); }
.landing-subtitle { font-size: clamp(1rem, 3vw, 1.3rem); color: var(--gray); margin-bottom: 48px; font-weight: 300; }
.landing-divider { width: 60px; height: 3px; background: var(--red); margin: 0 auto 32px; border-radius: 2px; }
.landing-buttons { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
.landing-footer { position: absolute; bottom: 40px; color: var(--gray-dark); font-size: 0.75rem; }

/* --- Auth Pages --- */
.auth-page {
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 24px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card.glass-solid { padding: 32px 24px; }
.auth-back { align-self: flex-start; margin-bottom: 32px; color: var(--gray); font-size: 0.9rem; display: flex; align-items: center; gap: 6px; background: none; }
.auth-title { margin-bottom: 8px; }
.auth-subtitle { margin-bottom: 32px; color: var(--gray); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-error { background: rgba(227,0,15,0.1); border: 1px solid rgba(227,0,15,0.3); border-radius: var(--radius-sm); padding: 12px; color: #ff6b6b; font-size: 0.85rem; display: none; }
.auth-error.show { display: block; animation: fadeIn 0.3s ease; }
.auth-switch { text-align: center; margin-top: 24px; color: var(--gray); font-size: 0.9rem; }
.auth-switch a { color: var(--red); font-weight: 600; }

/* --- Dashboard --- */
.dash-greeting { margin-bottom: 4px; }
.dash-name { color: var(--gold); }
.dash-section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: var(--gray); margin-bottom: 12px; margin-top: 28px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dash-card {
    padding: 20px 16px; border-radius: var(--radius); cursor: pointer;
    display: flex; flex-direction: column; gap: 8px;
    transition: var(--transition); -webkit-tap-highlight-color: transparent;
}
.dash-card-icon { font-size: 1.8rem; }
.dash-card-title { font-family: var(--font-heading); font-weight: 600; font-size: 0.95rem; }
.dash-card-desc { font-size: 0.75rem; color: var(--gray); line-height: 1.4; }
.dash-card-full { grid-column: 1 / -1; }
.dash-featured {
    position: relative; overflow: hidden; padding: 24px 20px;
    background: linear-gradient(135deg, rgba(227,0,15,0.15), rgba(212,175,55,0.1));
    border: 1px solid rgba(227,0,15,0.2);
}
.dash-featured::before {
    content: ''; position: absolute; top: -50%; right: -30%; width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(227,0,15,0.1), transparent);
    border-radius: 50%;
}

/* --- Games Hub --- */
.game-card {
    padding: 24px 20px; border-radius: var(--radius); cursor: pointer;
    display: flex; gap: 16px; align-items: center; margin-bottom: 12px;
    transition: var(--transition); -webkit-tap-highlight-color: transparent;
}
.game-card-icon { font-size: 2.5rem; min-width: 50px; text-align: center; }
.game-card-info { flex: 1; }
.game-card-title { font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem; margin-bottom: 4px; }
.game-card-desc { font-size: 0.8rem; color: var(--gray); }
.game-card-badge { font-size: 0.7rem; display: inline-block; padding: 3px 10px; border-radius: var(--radius-full); margin-top: 6px; font-weight: 600; }
.badge-red { background: rgba(227,0,15,0.2); color: #ff6b6b; }
.badge-gold { background: rgba(212,175,55,0.2); color: var(--gold); }
.badge-green { background: rgba(34,197,94,0.2); color: #4ade80; }

/* --- Game Header --- */
.game-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 0; margin-bottom: 16px;
}
.game-back { background: none; color: var(--gray); display: flex; align-items: center; gap: 4px; font-size: 0.9rem; }
.game-score { font-family: var(--font-heading); font-weight: 700; font-size: 1.2rem; color: var(--gold); }
.game-timer { font-family: var(--font-heading); font-weight: 600; color: var(--red); font-size: 1.1rem; }

/* --- Quiz --- */
.quiz-progress { height: 4px; background: var(--navy-light); border-radius: 2px; margin-bottom: 24px; overflow: hidden; }
.quiz-progress-bar { height: 100%; background: var(--red); border-radius: 2px; transition: width 0.5s ease; }
.quiz-question-num { font-size: 0.8rem; color: var(--gray); margin-bottom: 8px; }
.quiz-question { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 600; margin-bottom: 24px; line-height: 1.4; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
    width: 100%; padding: 16px 18px; border-radius: var(--radius-sm); text-align: left;
    background: rgba(24, 35, 70, 0.5); border: 1.5px solid rgba(255,255,255,0.08);
    color: white; font-size: 0.95rem; transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.quiz-option:hover { border-color: rgba(255,255,255,0.2); background: rgba(24, 35, 70, 0.7); }
.quiz-option.correct { background: rgba(34,197,94,0.2); border-color: var(--success); color: var(--success); }
.quiz-option.wrong { background: rgba(227,0,15,0.2); border-color: var(--red); color: #ff6b6b; }
.quiz-option.disabled { pointer-events: none; opacity: 0.6; }
.quiz-streak { font-size: 0.8rem; color: var(--gold); text-align: center; margin-top: 12px; }
.quiz-timer-bar { height: 3px; background: var(--navy-light); border-radius: 2px; margin-bottom: 16px; overflow: hidden; }
.quiz-timer-fill { height: 100%; background: var(--red); transition: width 1s linear; }

/* --- Memory --- */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.memory-card {
    aspect-ratio: 3/4; border-radius: var(--radius-sm); cursor: pointer;
    position: relative; perspective: 600px;
    -webkit-tap-highlight-color: transparent;
}
.memory-card-inner {
    position: relative; width: 100%; height: 100%;
    transition: transform 0.5s ease; transform-style: preserve-3d;
}
.memory-card.flipped .memory-card-inner { transform: rotateY(180deg); }
.memory-card.matched .memory-card-inner { transform: rotateY(180deg); }
.memory-card.matched { opacity: 0.7; pointer-events: none; }
.memory-card-face {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border-radius: var(--radius-sm); display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 6px;
    font-size: 0.7rem; text-align: center; line-height: 1.3;
}
.memory-card-back {
    background: linear-gradient(135deg, var(--navy-light), var(--navy));
    border: 1.5px solid rgba(227,0,15,0.3);
}
.memory-card-back::after {
    content: '?'; font-family: var(--font-heading); font-size: 1.5rem;
    color: var(--red); font-weight: 700;
}
.memory-card-front {
    background: rgba(24,35,70,0.8); border: 1.5px solid rgba(212,175,55,0.4);
    transform: rotateY(180deg); color: white;
}
.memory-card-emoji { font-size: 1.5rem; margin-bottom: 4px; }
.memory-card-text { font-weight: 600; font-size: 0.65rem; }
.memory-stats { display: flex; justify-content: center; gap: 24px; margin-top: 16px; }
.memory-stat { text-align: center; }
.memory-stat-val { font-family: var(--font-heading); font-weight: 700; font-size: 1.3rem; color: var(--gold); }
.memory-stat-label { font-size: 0.7rem; color: var(--gray); }

/* --- Location --- */
.location-map {
    width: 100%; aspect-ratio: 16/9; border-radius: var(--radius);
    background: var(--navy-light); position: relative; overflow: hidden;
    margin-bottom: 16px; border: 1px solid rgba(255,255,255,0.06);
}
.location-route { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.location-dot {
    width: 12px; height: 12px; border-radius: 50%; background: var(--red);
    position: absolute; box-shadow: 0 0 10px rgba(227,0,15,0.6);
    transition: all 0.5s ease;
}
.location-dot.active { width: 16px; height: 16px; background: var(--gold); box-shadow: 0 0 15px rgba(212,175,55,0.7); }
.location-hints { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.location-hint {
    padding: 12px 16px; border-radius: var(--radius-sm);
    background: rgba(24,35,70,0.5); border: 1px solid rgba(255,255,255,0.06);
    font-size: 0.9rem; color: var(--gray-light);
    animation: fadeIn 0.5s ease;
}
.location-hint .hint-num { color: var(--gold); font-weight: 700; margin-right: 8px; }
.location-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.location-option {
    padding: 14px 12px; border-radius: var(--radius-sm); text-align: center;
    background: rgba(24,35,70,0.5); border: 1.5px solid rgba(255,255,255,0.08);
    color: white; font-size: 0.9rem; font-weight: 500; transition: var(--transition);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.location-option:hover { border-color: rgba(255,255,255,0.2); }
.location-option.correct { background: rgba(34,197,94,0.2); border-color: var(--success); }
.location-option.wrong { background: rgba(227,0,15,0.2); border-color: var(--red); }
.location-edu {
    padding: 16px; border-radius: var(--radius); margin-top: 16px;
    background: rgba(212,175,55,0.08); border: 1px solid rgba(212,175,55,0.2);
    animation: slideUp 0.5s ease;
}
.location-edu h4 { color: var(--gold); margin-bottom: 8px; font-size: 1rem; }
.location-edu p { font-size: 0.85rem; color: var(--gray-light); }
.location-stamp {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
    border-radius: var(--radius-full); background: rgba(212,175,55,0.15);
    border: 1px solid rgba(212,175,55,0.3); font-size: 0.8rem; color: var(--gold);
    margin-top: 8px; animation: bounceIn 0.6s ease;
}

/* --- AI Creator --- */
.ai-steps { display: flex; gap: 4px; margin-bottom: 24px; }
.ai-step-dot { flex: 1; height: 3px; border-radius: 2px; background: var(--navy-light); transition: background 0.5s ease; }
.ai-step-dot.active { background: var(--gold); }
.ai-step-dot.done { background: var(--success); }
.ai-content { min-height: 300px; }
.ai-edu-text { font-size: 0.95rem; color: var(--gray-light); line-height: 1.8; margin-bottom: 24px; }
.ai-edu-text strong { color: white; }
.ai-examples { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.ai-example {
    padding: 12px 16px; border-radius: var(--radius-sm);
    background: rgba(24,35,70,0.4); border: 1px solid rgba(255,255,255,0.06);
    cursor: pointer; transition: var(--transition); font-size: 0.9rem;
}
.ai-example:hover { border-color: var(--gold); background: rgba(212,175,55,0.05); }
.ai-example-icon { margin-right: 8px; }
.ai-colors { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.ai-color {
    width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
    border: 2px solid transparent; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.ai-color.selected { border-color: white; transform: scale(1.1); }
.ai-color::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: white; opacity: 0; transition: opacity 0.2s; }
.ai-color.selected::after { opacity: 1; }
.ai-loading { text-align: center; padding: 40px 20px; }
.ai-spinner { width: 50px; height: 50px; border: 3px solid var(--navy-light); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 20px; }
.ai-facts { margin-top: 20px; }
.ai-fact { padding: 12px; border-radius: var(--radius-sm); background: rgba(212,175,55,0.05); border-left: 3px solid var(--gold); margin-bottom: 10px; font-size: 0.85rem; color: var(--gray-light); animation: fadeIn 0.5s ease; }
.ai-preview { width: 100%; aspect-ratio: 9/16; max-height: 400px; border-radius: var(--radius); border: 1px solid rgba(255,255,255,0.1); background: white; }

/* --- Media --- */
.media-tabs { display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.media-tab {
    padding: 10px 20px; border-radius: var(--radius-full); white-space: nowrap;
    font-size: 0.85rem; font-weight: 500; background: rgba(24,35,70,0.5);
    border: 1px solid rgba(255,255,255,0.06); color: var(--gray);
    transition: var(--transition); cursor: pointer;
}
.media-tab.active { background: var(--red); color: white; border-color: var(--red); }
.video-card { margin-bottom: 16px; border-radius: var(--radius); overflow: hidden; }
.video-thumb {
    width: 100%; aspect-ratio: 16/9; background: var(--navy-light);
    position: relative; cursor: pointer; overflow: hidden;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-play {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(227,0,15,0.9); display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.video-thumb:hover .video-play { transform: translate(-50%, -50%) scale(1.1); background: var(--red); }
.video-play::after { content: ''; width: 0; height: 0; border-left: 18px solid white; border-top: 11px solid transparent; border-bottom: 11px solid transparent; margin-left: 3px; }
.video-info { padding: 14px 4px; }
.video-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.video-meta { font-size: 0.8rem; color: var(--gray); }
.video-player { width: 100%; aspect-ratio: 16/9; border-radius: var(--radius); margin-bottom: 16px; }
.video-player iframe { width: 100%; height: 100%; border: none; border-radius: var(--radius); }

/* --- Profile --- */
.profile-header { text-align: center; padding: 32px 0 24px; }
.profile-avatar {
    width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--red), var(--gold));
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-heading); font-size: 2rem; font-weight: 800;
}
.profile-username { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.profile-stats { display: flex; justify-content: center; gap: 32px; margin-top: 16px; }
.profile-stat { text-align: center; }
.profile-stat-val { font-family: var(--font-heading); font-weight: 700; font-size: 1.5rem; color: var(--gold); }
.profile-stat-label { font-size: 0.75rem; color: var(--gray); }
.profile-section { margin-top: 28px; }
.profile-section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: var(--gray); margin-bottom: 12px; }
.profile-app {
    display: flex; align-items: center; gap: 14px; padding: 16px;
    border-radius: var(--radius-sm); margin-bottom: 8px;
    background: rgba(24,35,70,0.4); border: 1px solid rgba(255,255,255,0.06);
    transition: var(--transition); cursor: pointer;
}
.profile-app:hover { border-color: rgba(212,175,55,0.3); }
.profile-app-icon {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--navy-light), var(--navy));
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
    flex-shrink: 0;
}
.profile-app-info { flex: 1; min-width: 0; }
.profile-app-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-app-date { font-size: 0.75rem; color: var(--gray); }

/* --- Install Guide --- */
.install-device { margin-bottom: 20px; }
.install-device-title { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.install-steps { padding-left: 20px; }
.install-steps li { margin-bottom: 8px; font-size: 0.9rem; color: var(--gray-light); line-height: 1.5; }
.install-steps li strong { color: white; }

/* --- PWA Banner --- */
.pwa-banner {
    display: none; position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
    left: 12px; right: 12px; z-index: 90;
    padding: 16px 20px; border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(227,0,15,0.9), rgba(180,0,10,0.95));
    backdrop-filter: blur(10px); box-shadow: var(--shadow);
    animation: slideUp 0.5s ease;
}
.pwa-banner.show { display: flex; align-items: center; gap: 14px; }
.pwa-banner-text { flex: 1; }
.pwa-banner-title { font-weight: 700; font-size: 0.95rem; }
.pwa-banner-desc { font-size: 0.8rem; opacity: 0.9; }
.pwa-banner-btn { padding: 10px 20px; background: white; color: var(--red); border-radius: var(--radius-sm); font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.pwa-banner-close { background: none; color: white; opacity: 0.7; font-size: 1.2rem; padding: 4px; }

/* --- Loading / Skeleton --- */
.skeleton { background: linear-gradient(90deg, var(--navy-light) 25%, rgba(255,255,255,0.05) 50%, var(--navy-light) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.2); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }

/* --- Toast --- */
.toast {
    position: fixed; top: calc(var(--safe-top) + 16px); left: 50%; transform: translateX(-50%) translateY(-100px);
    padding: 14px 24px; border-radius: var(--radius-sm); z-index: 200;
    font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: calc(100% - 40px);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast-success { background: rgba(34,197,94,0.95); color: white; }
.toast-error { background: rgba(227,0,15,0.95); color: white; }
.toast-info { background: rgba(10,17,40,0.95); color: white; border: 1px solid rgba(255,255,255,0.1); }

/* --- Game Over / Result Screen --- */
.result-screen { text-align: center; padding: 40px 20px; animation: fadeIn 0.5s ease; }
.result-icon { font-size: 4rem; margin-bottom: 16px; animation: bounceIn 0.6s ease; }
.result-score { font-family: var(--font-heading); font-size: 2.5rem; font-weight: 800; margin-bottom: 4px; }
.result-label { color: var(--gray); font-size: 0.9rem; margin-bottom: 24px; }
.result-details { display: flex; justify-content: center; gap: 24px; margin-bottom: 32px; }
.result-detail { text-align: center; }
.result-detail-val { font-family: var(--font-heading); font-weight: 700; font-size: 1.2rem; }
.result-detail-label { font-size: 0.75rem; color: var(--gray); }
.result-buttons { display: flex; flex-direction: column; gap: 10px; max-width: 280px; margin: 0 auto; }

/* --- Language Toggle --- */
.lang-toggle {
    display: flex; border-radius: var(--radius-full); overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1); background: rgba(24,35,70,0.5);
}
.lang-btn {
    padding: 6px 14px; font-size: 0.75rem; font-weight: 600; background: transparent;
    color: var(--gray); transition: var(--transition);
}
.lang-btn.active { background: var(--red); color: white; }

/* --- Offline Banner --- */
.offline-indicator {
    display: none; position: fixed; top: calc(var(--safe-top) + 4px); left: 50%; transform: translateX(-50%);
    padding: 6px 16px; border-radius: var(--radius-full); z-index: 200;
    background: rgba(212,175,55,0.9); color: #0A1128; font-size: 0.75rem; font-weight: 600;
}
.offline-indicator.show { display: block; animation: fadeIn 0.3s ease; }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-text { color: var(--gray); font-size: 0.9rem; }

/* --- 3D Loading Screen --- */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #050811;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease;
}
#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}
.loading-logo {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 2rem;
    letter-spacing: 4px;
    margin-bottom: 24px;
}
.loading-logo .red { color: var(--red); }
.loading-bar {
    width: 200px;
    height: 3px;
    background: var(--navy-light);
    border-radius: 2px;
    overflow: hidden;
}
.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--red), var(--gold));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* --- Responsive --- */
@media (min-width: 640px) {
    .container { max-width: 520px; }
    .memory-grid { gap: 10px; }
    .dash-grid { gap: 16px; }
    .landing-logo { letter-spacing: 5px; }
}
@media (min-width: 768px) {
    .container { max-width: 580px; }
    h1 { font-size: 3rem; }
}
