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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    overflow: hidden;
    /* Fix for mobile browser chrome eating into viewport */
    height: 100dvh;
    height: 100vh; /* fallback */
}

/* App Container (Mobile Simulator for Desktop views) */
.app-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* accounts for mobile browser bars */
    max-width: var(--mobile-width);
    margin: 0 auto;
    background-color: var(--bg-base);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

@media (min-width: 481px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #050505;
    }
    .app-container {
        height: 90vh;
        height: 90dvh;
        max-height: 900px;
        border-radius: var(--radius-lg);
        border: 1px solid var(--bg-elevated);
    }
}

/* Typography Enhancements */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
    color: var(--text-secondary);
    font-weight: 300;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: var(--radius-rounded);
}

/* Views Management */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    background-color: var(--bg-surface);
    z-index: 10;
    /* Use flex so header + scroll-content + nav stack correctly */
    overflow: hidden;
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 20;
}

/* Content Area within Views (below header, above nav) */
.view-content {
    flex: 1;
    min-height: 0; /* Critical: allows flex child to shrink and scroll */
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
}

.view-content-no-nav {
    flex: 1;
    min-height: 0; /* Critical: allows flex child to shrink and scroll */
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
}

/* Splash Screen Special Override */
#splash-screen {
    background: var(--bg-base);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.splash-content {
    text-align: center;
    animation: fadeIn var(--transition-slow);
}

.logo-icon {
    font-size: 5rem;
    margin-bottom: var(--spacing-md);
    filter: drop-shadow(var(--shadow-neon));
}

.logo-text {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: var(--spacing-sm);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-2xl);
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s infinite linear;
    margin: 0 auto;
}

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

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

/* Layout Utilities */
.flex-row { display: flex; flex-direction: row; }
.flex-col { display: flex; flex-direction: column; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.w-100 { width: 100%; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.text-center { text-align: center; }
