/* --- 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;
}

/* Game hosted on another site: the arrow marks the jump off 3rt1. */
.btn-external {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.external-icon {
    flex-shrink: 0;
}

/* Text for screen readers only, e.g. the "opens in a new tab" warning. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.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;
    }
}

/* --- Footer links and copyright --- */
.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-bottom: 0.75rem;
}
.footer-links a { color: var(--color-text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--color-primary); text-decoration: underline; }
.footer-copyright { display: block; margin-top: 0.5rem; }
.footer-copyright a { color: var(--color-text-muted); }
.footer-copyright a:hover { color: var(--color-primary); }

/* --- Legal documents --- */
.legal-content { max-width: 44rem; }
.legal-content h2 { font-size: 1.25rem; margin: 2rem 0 0.6rem; }
.legal-content h3 { font-size: 1rem; margin: 1.25rem 0 0.4rem; }
.legal-content p, .legal-content ul { color: var(--color-text-muted); }
.legal-content p + p { margin-top: 0.75rem; }
.legal-content ul { margin: 0.6rem 0 0.6rem 1.25rem; }
.legal-content li { margin-bottom: 0.3rem; }

/* --- Contact form --- */
.contact-card { max-width: 38rem; }
.contact-form { display: flex; flex-direction: column; gap: 1rem; margin: 1.25rem 0; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-weight: 600; font-size: 0.9rem; }
.contact-form input,
.contact-form select,
.contact-form textarea {
    font: inherit;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-input-bg);
    color: var(--color-text);
    width: 100%;
    min-height: 2.75rem;
}
.contact-form textarea { resize: vertical; }
.contact-form input:focus-visible,
.contact-form select:focus-visible,
.contact-form textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}
.field-error { color: var(--color-danger); font-size: 0.85rem; }
.form-error {
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius);
    padding: 0.7rem 0.85rem;
}

/* Hidden from people, filled by form-spraying bots. Positioned off-screen
   rather than display:none, which some bots skip. */
.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
