:root {
    --bg-color: #0b1220;
    --bg-accent: radial-gradient(circle at top, rgba(63,176,255,0.14), transparent 48%);
    --card-bg: #0f1724;
    --card-bg-soft: rgba(15, 23, 36, 0.82);
    --text-color: #e6eef6;
    --text-muted: #9fb0c8;
    --primary: #3fb0ff;
    --primary-hover: #1ea0f5;
    --easy: #22c55e;
    --medium: #eab308;
    --hard: #ef4444;
    --border-color: #334155;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

:root[data-theme="light"] {
    --bg-color: #f4f7fb;
    --bg-accent: radial-gradient(circle at top, rgba(63,176,255,0.18), transparent 42%);
    --card-bg: #ffffff;
    --card-bg-soft: rgba(255, 255, 255, 0.86);
    --text-color: #102033;
    --text-muted: #5b6d81;
    --primary: #176fd6;
    --primary-hover: #0f5bb2;
    --border-color: #d6e0ea;
}

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

body {
    background: var(--bg-accent), var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: clamp(14px, 2vw, 16px);
}

/* Ensure minimum touch target size (WCAG AA) */
button, a[role="button"], .control-btn, input[type="button"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Prevent horizontal scrolling on any viewport */
html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    width: 100%;
}

/* Utility: visually hidden (for accessible labels) */
.visually-hidden {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    left: -999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.skip-link:focus {
    left: 1rem;
    top: 1rem;
    width: auto;
    height: auto;
    background: var(--card-bg);
    color: var(--text-color);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    z-index: 9999;
}

/* Focus outlines for accessibility */
:focus {
    outline: 3px solid rgba(63,176,255,0.16);
    outline-offset: 2px;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
}

ul {
    list-style: none;
}

/* Loading & Error States */

/* Skeleton pulse animation */
@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

.skeleton {
    background: var(--card-bg);
    border-radius: 12px;
    animation: skeleton-pulse 2s ease-in-out infinite;
}

.skeleton-text {
    background: linear-gradient(90deg, var(--border-color) 25%, rgba(255, 255, 255, 0.1) 50%, var(--border-color) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 2s ease-in-out infinite;
    height: 0.875rem;
    border-radius: 4px;
}

.skeleton-text.large {
    height: 1.5rem;
}

.skeleton-text.small {
    height: 0.75rem;
}

/* Spinner animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    color: var(--text-muted);
}

/* Error message styling */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 1.5rem;
    color: var(--text-color);
    margin: 2rem auto;
    max-width: 500px;
    text-align: center;
}

.error-message p {
    margin: 0.5rem 0;
}

.error-message button {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: var(--bg-color);
    border-radius: 6px;
    font-weight: 600;
    transition: background 0.2s;
}

.error-message button:hover {
    background: var(--primary-hover);
}
