/* ============================================================
   BrainBrawl — Core Styles
   ============================================================ */

/* --- CSS Variables (Theme System) --- */
:root,
[data-theme="dark"] {
    --bg-primary: #0d0221;
    --bg-secondary: #150535;
    --bg-card: #1a0a3e;
    --bg-input: #200d4a;
    --bg-hover: #2a1560;
    --text-primary: #f0e6ff;
    --text-secondary: #a78bdb;
    --text-muted: #6b4fa0;
    --border-color: #3a1f7a;
    --border-light: #2a1560;
    --accent-pink: #f72585;
    --accent-purple: #7209b7;
    --accent-blue: #4361ee;
    --accent-cyan: #4cc9f0;
    --accent-green: #06d6a0;
    --accent-orange: #f77f00;
    --accent-yellow: #ffd60a;
    --gradient-brand: linear-gradient(135deg, #f72585, #7209b7, #3a0ca3, #4361ee, #4cc9f0);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

[data-theme="light"] {
    --bg-primary: #f0f2f8;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #e8ecf4;
    --bg-hover: #dde2ee;
    --text-primary: #1a1a2e;
    --text-secondary: #555e70;
    --text-muted: #8892a8;
    --border-color: #d0d5e2;
    --border-light: #e0e4ee;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-cyan);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* --- Logo --- */
.logo-text {
    font-size: 36px;
    font-weight: 800;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    line-height: 1.1;
}
.logo-sm { font-size: 24px; }
.logo-xs { font-size: 18px; }

.tagline {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
    text-decoration: none;
    line-height: 1;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
    color: #fff;
    box-shadow: 0 4px 15px rgba(247, 37, 133, 0.3);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(247, 37, 133, 0.4); }

.btn-secondary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    color: #fff;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--radius-sm); }

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}
.form-group input::placeholder {
    color: var(--text-muted);
}

.form-error {
    color: var(--accent-pink);
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 8px;
}

/* --- Auth Pages --- */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.logo-section {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-md);
}
.auth-card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* --- Lobby --- */
.lobby-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

.lobby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.username-display {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.action-card h2 {
    font-size: 18px;
    margin-bottom: 4px;
}
.action-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* --- Game Page --- */
.game-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.game-code-display {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-yellow);
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

.game-area {
    flex: 1;
}

/* --- Admin --- */
.admin-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-admin {
    background: rgba(247, 37, 133, 0.2);
    color: var(--accent-pink);
    border: 1px solid rgba(247, 37, 133, 0.3);
}

/* --- Modal --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

/* --- Scrollbar (thin, subtle) --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* --- Safe area for notched iPhones --- */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}
