:root {
    --bg-color: #0a0a0f;
    --surface: #1a1a2e;
    --card-bg: #1a1a2e;
    --primary: #00d4ff;
    --secondary: #1a1a3d;
    --accent: #e67e22;
    --purple: #a78bfa;
    --green: #4ade80;
    --text-main: #ffffff;
    --text-muted: #a0a0c0;
    --success: #00ff88;
    --error: #ff4444;
    --warning: #ffaa00;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Orbitron', sans-serif;
    --card-shadow: 0 10px 30px rgba(0,0,0,0.4);
    --glass-border: 1px solid rgba(255,255,255,0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
    margin: 0; padding: 0;
    background: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

/* ===== HEADER ===== */
.app-header {
    position: sticky; top: 0; z-index: 1000;
    background: linear-gradient(135deg, var(--secondary), #0d0d25);
    border-bottom: 2px solid var(--primary);
    padding: env(safe-area-inset-top) 1.5rem 0;
    height: calc(72px + env(safe-area-inset-top));
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.header-brand {
    display: flex; align-items: center; gap: 1rem;
}

.brand-logo {
    height: 32px; width: auto;
    opacity: 0.8;
}

.back-to-base-logo {
    height: 18px; width: auto;
    filter: grayscale(100%) brightness(1.5);
}

.brand-text { display: flex; flex-direction: column; gap: 0.2rem; }

.app-title {
    font-family: var(--font-display);
    font-size: 1.4rem; font-weight: 700;
    color: white; margin: 0;
    line-height: 1;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.brand-subtitle {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.hud-controls {
    display: flex; align-items: center; gap: 10px;
}

.hud-btn {
    background: rgba(255,255,255,0.05);
    border: var(--glass-border);
    color: rgba(255,255,255,0.8);
    padding: 8px 14px; border-radius: 8px;
    cursor: pointer; font-size: 12px;
    display: flex; align-items: center; gap: 6px;
    text-decoration: none;
    transition: all 0.2s;
    font-family: var(--font-main);
    min-height: 36px;
    touch-action: manipulation;
}

.hud-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: white;
    transform: translateY(-1px);
}

.profile-quick-btn {
    padding: 6px 10px;
    font-size: 16px;
}

.xp-display {
    font-size: 13px; font-weight: 600;
    color: var(--success);
    background: rgba(0,255,136,0.1);
    border: 1px solid rgba(0,255,136,0.2);
    padding: 8px 16px; border-radius: 20px;
    white-space: nowrap;
    display: flex; align-items: center; gap: 6px;
    box-shadow: 0 0 10px rgba(0,255,136,0.1);
}

.hamburger-btn {
    display: none;
    background: none;
    border: 1px solid rgba(255,255,255,0.3);
    color: white; font-size: 20px;
    padding: 10px 12px; border-radius: 8px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Menu */
.mobile-menu {
    display: none;
    position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 0; right: 0;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--primary);
    z-index: 999;
    flex-direction: column;
    padding: 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-height: calc(100vh - 60px - env(safe-area-inset-top));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-menu.open { display: flex; animation: slideDown 0.3s ease; }

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.mobile-menu button, .mobile-menu a {
    background: rgba(255,255,255,0.05);
    border: var(--glass-border);
    color: var(--text-main); padding: 14px 15px;
    border-radius: 10px; margin-bottom: 8px;
    cursor: pointer; font-size: 15px;
    text-decoration: none; text-align: left;
    display: flex; align-items: center; gap: 12px;
    font-family: var(--font-main);
    min-height: 44px;
}

.mob-xp {
    color: var(--success); font-weight: 600;
    padding: 14px 15px; text-align: center;
    background: rgba(0,255,136,0.08);
    border-radius: 10px; margin-bottom: 8px;
}

@media (max-width: 768px) {
    .hud-controls { display: none; }
    .hamburger-btn { display: flex; }
    .app-header { height: 60px; padding: 0 15px; padding-top: env(safe-area-inset-top); }
    .app-title { font-size: 1.1rem; }
    .brand-logo { height: 28px; }
    .brand-subtitle { display: none; }
}

/* Small phones (iPhone SE, etc) */
@media (max-width: 480px) {
    .app-header { padding: env(safe-area-inset-top) 12px 0; height: 56px; min-height: 56px; }
    .app-title { font-size: 1rem; letter-spacing: 0.5px; }
    .brand-logo { height: 24px; }
    .view { padding: 15px; }
    .view-title { font-size: 20px; }
    .track-card { padding: 15px; }
    .track-icon { width: 44px; height: 44px; font-size: 24px; }
    .node-card { padding: 12px; gap: 12px; }
    .node-icon { width: 44px; height: 44px; font-size: 20px; }
    .card { padding: 20px 15px; border-radius: 20px; }
    .card h2 { font-size: 18px; }
    .card p { font-size: 14px; }
    .flip-card { height: 180px; }
    .flip-front, .flip-back { padding: 15px; }
    .flip-front { font-size: 18px; }
    .flip-back { font-size: 14px; }
    .quiz-btn { padding: 14px; font-size: 14px; min-height: 44px; }
    .match-item { padding: 12px 8px; font-size: 12px; min-height: 60px; }
    .btn-primary, .btn-secondary { padding: 14px 20px; font-size: 15px; min-height: 48px; }
    .auth-container { padding: 20px; margin: 10px; }
    .level-card { padding: 12px; }
    .level-icon { width: 36px; height: 36px; }
    .home-icon { font-size: 56px; }
    .home-title { font-size: 24px; }
    .profile-stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .profile-stat-card { padding: 12px; }
    .badges-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .quick-stats { padding: 12px; gap: 10px; }
    .quick-stat .stat-value { font-size: 16px; }
    .quick-stat .stat-label { font-size: 10px; }
}

/* Extra small phones (320px) */
@media (max-width: 360px) {
    .track-grid { gap: 10px; }
    .track-card { padding: 12px; }
    .track-header { gap: 10px; }
    .track-info h3 { font-size: 14px; }
    .track-info p { font-size: 11px; }
    .track-icon { width: 40px; height: 40px; font-size: 20px; }
    .match-game { gap: 8px; }
    .match-item { padding: 10px 6px; font-size: 11px; min-height: 56px; }
    .node-card { padding: 10px; }
    .node-icon { width: 40px; height: 40px; font-size: 18px; }
    .node-info h3 { font-size: 14px; }
    .node-info p { font-size: 11px; }
    .view { padding: 12px; }
    .card { padding: 15px 12px; }
    .card-icon { font-size: 40px; }
    .profile-stats-grid { gap: 8px; }
    .profile-stat-card { padding: 10px; }
    .stat-number { font-size: 16px; }
    .badges-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .badge-icon { font-size: 20px; }
    .badge-name { font-size: 8px; }
}

/* Tablets and landscape */
@media (min-width: 1024px) {
    #app { max-width: 900px; }
    .track-grid { grid-template-columns: 1fr 1fr; gap: 20px; }
    .track-card { padding: 25px; }
    .view { padding: 30px; }
    .card { padding: 40px 35px; }
    .card h2 { font-size: 26px; }
    .card p { font-size: 18px; line-height: 1.7; }
    .flip-card { height: 260px; }
    .match-game { gap: 15px; }
    .match-item { padding: 20px 15px; font-size: 15px; }
    .node-grid { grid-template-columns: 1fr; gap: 15px; }
    .profile-stats-grid { grid-template-columns: repeat(4, 1fr); }
    .badges-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .footer-content { padding: 0 30px; }
}

/* ===== APP CONTAINER ===== */
#app {
    flex: 1;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ===== VIEWS ===== */
.view {
    display: none;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.view.active {
    display: flex;
    animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.view-center {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.view-header {
    text-align: center;
    margin-bottom: 25px;
}

.view-title {
    font-family: var(--font-display);
    font-size: 24px;
    color: var(--primary);
    margin: 0 0 8px 0;
    text-shadow: 0 0 15px rgba(0,212,255,0.2);
}

.view-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}

.back-btn {
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin-bottom: 15px;
    transition: color 0.2s;
}

.back-btn:hover { color: white; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== AUTH VIEW ===== */
.auth-container {
    background: var(--surface);
    border-radius: 20px;
    border: var(--glass-border);
    padding: 30px;
    max-width: 400px;
    width: 100%;
    margin: auto;
    box-shadow: var(--card-shadow);
}

.auth-tabs {
    display: flex;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 25px;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--secondary);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.auth-icon {
    font-size: 48px;
    margin-bottom: 15px;
    text-align: center;
    display: block;
}

.auth-title {
    text-align: center;
    font-family: var(--font-display);
    font-size: 24px;
    margin: 0 0 5px 0;
    color: white;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin: 0 0 25px 0;
    font-size: 14px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 12px;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-submit {
    margin-top: 10px;
    width: 100%;
}

.guest-btn {
    width: 100%;
    margin-top: 15px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
}

/* ===== TRACKS VIEW ===== */
.track-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

@media (min-width: 600px) {
    .track-grid { grid-template-columns: 1fr 1fr; }
}

.track-card {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.track-card:hover {
    border-color: var(--track-color, var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.track-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--track-color, var(--primary));
}

.track-header {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
}

.track-icon {
    font-size: 28px;
    background: rgba(255,255,255,0.05);
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.track-info h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: white;
}

.track-info p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.track-complete-badge {
    margin-left: auto;
    background: var(--success);
    color: black;
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold;
    font-size: 12px;
}

.track-progress {
    margin-top: auto;
}

.track-progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.track-progress-fill {
    height: 100%;
    background: var(--track-color, var(--primary));
    transition: width 0.5s ease;
}

.track-progress-text {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.track-stats {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.quick-stats {
    display: flex;
    gap: 15px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 15px;
    justify-content: space-around;
}

.quick-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 18px;
    color: white;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== NODES VIEW ===== */
.track-icon-large {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

.node-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 25px;
}

.node-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.node-card:not(.locked):hover {
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.08);
}

.node-card.locked {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.8);
}

.node-icon {
    font-size: 24px;
    width: 48px; height: 48px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--text-muted);
}

.node-info { flex: 1; }

.node-info h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: white;
}

.node-info p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.node-levels {
    display: inline-block;
    font-size: 10px;
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 6px;
    color: rgba(255,255,255,0.7);
}

.node-status {
    width: 40px;
    text-align: right;
    display: flex; justify-content: flex-end;
}

.status-complete { color: var(--success); font-weight: bold; }
.status-locked { color: rgba(255,255,255,0.3); }
.status-progress { color: var(--primary); font-size: 12px; font-weight: 600; }

.node-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: rgba(255,255,255,0.2);
    z-index: 2;
}

/* ===== LEVEL SELECT / HOME ===== */
.home-content {
    text-align: center;
    margin-top: 10px;
    flex: 1;
}

.home-icon { font-size: 72px; margin-bottom: 20px; text-shadow: 0 0 30px rgba(0,212,255,0.3); }

.home-title {
    font-family: var(--font-display);
    font-size: 28px; color: white;
    margin: 0 0 5px 0;
}

.home-subtitle {
    color: var(--primary);
    font-size: 14px; margin: 0 0 30px 0; letter-spacing: 1px;
}

.mission-box {
    background: rgba(0,212,255,0.06);
    border: 1px solid rgba(0,212,255,0.2);
    padding: 20px; border-radius: 16px;
    margin: 0 0 30px 0;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.mission-box::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary);
}

.mission-box strong {
    display: block; margin-bottom: 8px;
    color: var(--primary); font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
}

.mission-box span {
    font-size: 15px; color: rgba(255,255,255,0.9);
    line-height: 1.6;
}

.node-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.node-stat {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted); font-size: 14px;
}

.level-grid {
    display: grid;
    gap: 12px;
}

.level-card {
    background: var(--surface);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.level-card:not(.locked):not(.coming-soon):hover {
    border-color: var(--primary);
    transform: translateX(4px);
    background: rgba(255,255,255,0.08);
}

.level-card.locked { opacity: 0.5; pointer-events: none; }
.level-card.coming-soon { opacity: 0.6; pointer-events: none; border-style: dashed; }
.level-card.completed { border-color: rgba(0,255,136,0.3); background: rgba(0,255,136,0.04); }

.level-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    color: var(--primary);
}

.completed .level-icon { background: var(--success); color: black; }

.level-info h3 { margin: 0 0 4px 0; font-size: 15px; color: white; }
.level-info p { margin: 0; font-size: 12px; color: var(--text-muted); }

.level-status {
    font-size: 11px; padding: 4px 10px; border-radius: 12px; font-weight: 600; white-space: nowrap;
}
.level-status.available { background: rgba(0,212,255,0.15); color: var(--primary); }
.level-status.complete { color: var(--success); }
.level-status.locked-tag { color: rgba(255,255,255,0.3); }

/* ===== GAME VIEW ===== */
.progress-dots {
    display: flex; gap: 8px; justify-content: center; margin: 0 0 20px 0; flex-shrink: 0;
}

.dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: rgba(255,255,255,0.15);
    transition: all 0.3s ease;
}

.dot.active { background: var(--primary); transform: scale(1.5); box-shadow: 0 0 8px var(--primary); }
.dot.completed { background: var(--success); }

#card-stack {
    flex: 1; position: relative; width: 100%; min-height: 400px;
}

.card {
    background: var(--surface);
    border-radius: 24px;
    padding: 30px 25px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    border: var(--glass-border);
    display: flex; flex-direction: column;
    height: 100%;
    animation: cardEnter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardEnter {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.card-content-wrapper {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center;
}

.card-icon { font-size: 56px; margin-bottom: 20px; }

.card h2 {
    font-size: 22px; margin: 0 0 15px 0; color: var(--primary);
    font-weight: 700; line-height: 1.3;
}

.card p {
    font-size: 16px; line-height: 1.6; color: rgba(255,255,255,0.85);
    margin: 0 0 25px 0;
}

/* ===== PROFILE VIEW ===== */
.profile-header {
    text-align: center;
    background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%);
    border-radius: 20px;
    padding: 30px 20px;
    margin-bottom: 25px;
    border: var(--glass-border);
}

.profile-avatar {
    position: relative;
    width: 80px; height: 80px;
    margin: 0 auto 15px;
    display: flex; align-items: center; justify-content: center;
}

#profile-avatar-icon { font-size: 48px; z-index: 2; }

.profile-level-ring {
    position: absolute;
    top: -5px; left: -5px; right: -5px; bottom: -5px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    animation: spin 8s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.profile-name { font-size: 20px; margin: 0 0 5px 0; color: white; }
.profile-rank { color: var(--primary); font-size: 14px; margin: 0 0 20px 0; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

.profile-xp-bar { width: 100%; max-width: 300px; margin: 0 auto; }
.xp-bar-bg { height: 10px; background: rgba(0,0,0,0.3); border-radius: 5px; overflow: hidden; margin-bottom: 8px; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); width: 0%; transition: width 1s ease; }
.xp-bar-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

.profile-stats-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 30px;
}

.profile-stat-card {
    background: var(--surface); border: var(--glass-border);
    padding: 15px; border-radius: 14px;
    display: flex; flex-direction: column; align-items: center; gap: 5px;
}

.profile-stat-card i { color: var(--primary); font-size: 18px; margin-bottom: 5px; }
.stat-number { font-size: 20px; font-weight: 700; color: white; font-family: var(--font-display); }
.stat-label { font-size: 12px; color: var(--text-muted); }

.section-title {
    font-size: 16px; color: white; margin: 0 0 15px 0; padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.badges-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 15px; margin-bottom: 30px;
}

.badge-item {
    aspect-ratio: 1;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 10px;
    border: 1px solid transparent;
}

.badge-item.earned { background: rgba(0,212,255,0.1); border-color: var(--primary); box-shadow: 0 0 15px rgba(0,212,255,0.1); }
.badge-item.locked { opacity: 0.5; }

.badge-icon { font-size: 24px; margin-bottom: 5px; }
.badge-name { font-size: 9px; text-align: center; line-height: 1.2; color: var(--text-muted); }
.badge-item.earned .badge-name { color: white; }

.track-progress-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 30px; }
.track-progress-item { display: flex; align-items: center; gap: 15px; font-size: 13px; }
.track-progress-info { display: flex; align-items: center; gap: 10px; width: 140px; }
.track-progress-bar-small { flex: 1; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.track-progress-fill-small { height: 100%; background: var(--primary); }

.logout-btn { margin-top: auto; }

/* ===== BUTTONS ===== */
.btn-primary, .btn-secondary {
    border: none;
    padding: 16px 30px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: all 0.2s;
    font-family: var(--font-main);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--primary);
    color: #000;
    box-shadow: 4px 20px rgba(0,212,255,0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 25px rgba(0,212,255,0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: white;
}

.btn-secondary:hover { background: rgba(255,255,255,0.15); }

.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }

/* ===== INTERACTIVE ELEMENTS (Flip, Quiz, Match) ===== */
/* Flip Card */
.flip-card {
    width: 100%; height: 220px; 
    perspective: 1000px; 
    -webkit-perspective: 1000px;
    margin-bottom: 25px; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.flip-card-inner {
    position: relative; width: 100%; height: 100%; 
    transition: transform 0.6s; 
    -webkit-transition: -webkit-transform 0.6s;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner { 
    transform: rotateY(180deg); 
    -webkit-transform: rotateY(180deg);
}
.flip-front, .flip-back {
    position: absolute; width: 100%; height: 100%; 
    backface-visibility: hidden; 
    -webkit-backface-visibility: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 16px; padding: 20px; text-align: center;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}
.flip-front {
    background: rgba(255,255,255,0.03); border: 2px solid var(--primary);
    color: var(--primary); font-size: 22px; font-weight: 700;
    z-index: 2;
}
.flip-front::after {
    content: 'Tap to reveal'; display: block; font-size: 12px; color: var(--text-muted); margin-top: 10px; font-weight: 400;
}
.flip-back {
    background: #0d0d25; color: #e6e6e6; 
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    font-size: 16px; line-height: 1.5; border: 1px solid rgba(255,255,255,0.1);
}

/* Quiz */
.quiz-options { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 10px; }
.quiz-btn {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    padding: 16px; border-radius: 12px; color: white; text-align: left;
    cursor: pointer; transition: all 0.2s; font-size: 15px; font-family: var(--font-main);
    min-height: 48px;
    touch-action: manipulation;
}
.quiz-btn:active { background: rgba(255,255,255,0.1); }
.quiz-btn.correct { background: rgba(0,255,136,0.15); border-color: var(--success); color: var(--success); }
.quiz-btn.wrong { background: rgba(255,68,68,0.15); border-color: var(--error); color: var(--error); }

/* Match */
.match-game { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin: 15px 0; }
.match-item {
    background: rgba(255,255,255,0.05); padding: 15px 10px; border-radius: 12px;
    font-size: 13px; cursor: pointer; border: 1px solid transparent;
    display: flex; align-items: center; justify-content: center; text-align: center;
    min-height: 70px; min-width: 44px;
    transition: all 0.2s; user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.match-item.selected { border-color: var(--primary); background: rgba(0,212,255,0.1); }
.match-item.matched { border-color: var(--success); background: rgba(0,255,136,0.1); color: var(--success); pointer-events: none; }
.match-item.wrong { border-color: var(--error); animation: shake 0.4s; }

/* Slider */
.slider-container { width: 100%; margin: 25px 0; }
.slider-track { display: flex; align-items: center; gap: 15px; }
.slider-track input[type="range"] {
    flex: 1; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px;
    background: rgba(255,255,255,0.2); outline: none;
}
.slider-track input[type="range"]::-moz-range-track {
    height: 6px; border-radius: 3px;
    background: rgba(255,255,255,0.2);
}
.slider-track input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); cursor: pointer; box-shadow: 0 0 10px var(--primary);
    margin-top: -11px;
}
.slider-track input[type="range"]::-moz-range-thumb {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); cursor: pointer; border: none;
    box-shadow: 0 0 10px var(--primary);
}
.slider-value { font-size: 32px; font-weight: 800; color: var(--primary); text-align: center; margin: 15px 0 0; font-family: var(--font-display); }

/* ===== COMPLETE VIEW ===== */
.complete-icon { font-size: 80px; margin-bottom: 20px; animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.complete-title { color: var(--success); font-size: 28px; }
.xp-reward-box {
    background: rgba(0,255,136,0.05); border: 1px solid rgba(0,255,136,0.2);
    padding: 20px 40px; border-radius: 16px; margin-bottom: 30px;
}
.xp-reward-value { font-size: 42px; color: var(--success); display: block; font-family: var(--font-display); }
.node-complete-badge { font-size: 64px; margin: 10px 0 20px; animation: spin 1s ease-out; }

/* ===== FOOTER ===== */
.app-footer {
    background: linear-gradient(180deg, var(--secondary), #050508);
    border-top: 1px solid rgba(255,255,255,0.05);
    padding: 40px 0 calc(20px + env(safe-area-inset-bottom));
    margin-top: auto;
}
.app-footer.hidden { display: none; }
.footer-content { max-width: 800px; margin: 0 auto; padding: 0 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 30px; }
.footer-section h4 { color: white; margin: 0 0 15px 0; font-family: var(--font-display); font-size: 14px; }
.footer-section p, .footer-link { color: rgba(255,255,255,0.6); font-size: 13px; line-height: 1.6; text-decoration: none; display: block; margin-bottom: 8px; }
.footer-link:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.05); margin-top: 30px; padding: 20px; text-align: center; color: rgba(255,255,255,0.4); font-size: 12px; }

/* Utilities */
.hidden { display: none !important; }
@keyframes popIn { 0% { transform: scale(0); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
