/**
 * Base CSS - Reset, Typography, Layout, Utilities
 * All colors reference tokens.css custom properties.
 */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

[data-theme="dark"] {
    color-scheme: dark;
}

body {
    font-family: var(--font-body);
    background: var(--bg-page);
    min-height: 100vh;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.55;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    transition: background var(--t), color var(--t);
}

/* Warm atmospheric glow */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 500px;
    background: var(--page-glow);
    pointer-events: none;
    z-index: 0;
    transition: background var(--t);
}

a {
    color: var(--gold);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

img {
    display: block;
    max-width: 100%;
}

/* Sprite rendering */
.sprite {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Utility classes */
.text-muted { color: var(--text-secondary); }
.text-dim { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--error); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

.money { color: var(--color-money); font-variant-numeric: tabular-nums; font-weight: 600; }
.level { color: var(--gold); font-weight: 600; }

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 32px;
}

.container-narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-6);
}

.container-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* Page header */
.page-header {
    margin-bottom: var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-header h2 {
    font-size: 24px;
    margin-bottom: var(--space-2);
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Grid layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-6);
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty/loading state text */
.loading-text, .empty {
    text-align: center;
    padding: var(--space-10);
    color: var(--text-secondary);
}

/* Clickable elements */
.clickable {
    cursor: pointer;
    color: var(--gold);
}

.clickable:hover {
    text-decoration: underline;
}

/* Focus visible */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: var(--ring-offset);
    border-radius: 3px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
}
