/* --- Custom Properties (Light Mode) --- */
:root {
    --color-bg: #ffffff;
    --color-surface: #f9fafb;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-border: #d1d5db;
    --color-primary: #4dabf7;
    --color-primary-hover: #339af0;
    --color-danger: #dc2626;
    --color-success: #4ade80;
    --color-warning: #ffd43b;
    --color-card-bg: #ffffff;
    --color-input-bg: #f9fafb;
    --color-canvas-bg: #1a1a2e;
    --radius: 8px;
    --radius-lg: 12px;
}

/* --- Dark Mode Overrides --- */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0a0a1a;
        --color-surface: #1a1a2e;
        --color-text: #f9fafb;
        --color-text-muted: #9ca3af;
        --color-border: #374151;
        --color-primary: #4dabf7;
        --color-primary-hover: #74c0fc;
        --color-danger: #ef4444;
        --color-success: #4ade80;
        --color-warning: #ffd43b;
        --color-card-bg: #1f2937;
        --color-input-bg: #1f2937;
        --color-canvas-bg: #1a1a2e;
    }
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

body.fullscreen {
    margin: 0;
    overflow: hidden;
    background: #0a0a1a;
    color: #f9fafb;
}

body.controller {
    margin: 0;
    overflow: hidden;
    height: 100vh;
    background: #0a0a1a;
    color: #f9fafb;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
}

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

a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    margin-bottom: 0.5em;
}

p {
    margin-bottom: 1rem;
}

hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 1.5rem 0;
}

ul, ol {
    padding-left: 1.5em;
}

strong {
    font-weight: 600;
}

small {
    font-size: 0.875rem;
}

/* --- Layout --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* --- Navigation --- */
.site-header {
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
    margin-bottom: 2rem;
}

.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.nav-brand:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    align-items: center;
    padding: 0;
}

.nav-user {
    color: var(--color-primary);
    font-weight: 600;
}

/* --- Footer --- */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    margin-top: 3rem;
    text-align: center;
    color: var(--color-text-muted);
}

/* --- Cards --- */
.card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    margin-bottom: 0.75rem;
}

.card-footer {
    margin-top: 1rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #000;
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    color: #000;
}

.btn-outline {
    background: transparent;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-outline:hover {
    background: var(--color-primary);
    color: #000;
}

.btn-full {
    display: block;
    width: 100%;
}

.btn-lg {
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--color-input-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.2);
}

.form-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* --- Error Message --- */
.error-message {
    background: var(--color-danger);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.closed-beta-notice {
    text-align: center;
    padding: 0.5rem 0 1rem;
}

.closed-beta-notice h2 {
    margin-bottom: 0.75rem;
    color: var(--color-primary);
}

.closed-beta-notice p {
    margin-bottom: 0.75rem;
}

/* --- Auth --- */
.auth-container {
    max-width: 400px;
    margin: 0 auto;
    padding-top: 5vh;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--color-text-muted);
}

/* --- Badges --- */
.badge-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--color-primary);
    color: #000;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-couch {
    background: var(--color-success);
}

/* --- Game Modes --- */
.game-modes {
    display: flex;
    gap: 0.75rem;
}

.game-modes .btn {
    flex: 1;
}

/* --- Hero --- */
.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero p {
    font-size: 1.25rem;
    color: var(--color-text-muted);
}

/* --- How to Play --- */
.how-to-play {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
}

.how-to-play ol {
    padding-left: 1.5em;
}

.how-to-play li {
    margin-bottom: 0.5rem;
}

/* --- Utility --- */
.text-muted {
    color: var(--color-text-muted);
}

.text-sm {
    font-size: 0.875rem;
}

.text-center {
    text-align: center;
}

.app-version { font-size: 0.75rem; color: var(--color-text-muted); }

/* --- Learn-to-build cross-promo banner (funnel to 84arcade Academy) --- */
.learn-banner {
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    margin-top: 3rem;
}

.learn-banner__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
    flex-wrap: wrap;
}

.learn-banner__text {
    margin: 0;
    font-weight: 600;
    color: var(--color-text);
}

.learn-banner__cta {
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .learn-banner__inner {
        flex-direction: column;
        align-items: flex-start;
    }
}
