/**
 * Comprehensive Theme System for Heuristic Reflexes
 * Includes Dark, Light, Blue, Purple, Green, Nord, Dracula, and Custom themes
 * With UI scale support and full responsive design
 */

/* ========== BASE THEME VARIABLES ========== */
:root {
    /* Action colors (consistent across themes) */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #6366f1;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #eab308;
    --info-color: #06b6d4;
    
    /* UI Scale (controlled via settings) */
    --ui-scale: 1.0;
    --base-font-size: calc(16px * var(--ui-scale));
    --base-spacing: calc(1rem * var(--ui-scale));
}

/* ========== DARK THEME (Default) ========== */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #141414;
    --bg-hover: #1f1f1f;
    
    --text-primary: #ffffff;
    --text-secondary: #d4d4d4;
    --text-muted: #737373;
    
    --border-color: #262626;
    --border-accent: #404040;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.8);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.8);
    --shadow-xl: 0 8px 16px 0 rgba(0, 0, 0, 0.9);
}

/* ========== LIGHT THEME ========== */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-hover: #e5e7eb;
    
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    
    --border-color: #e5e7eb;
    --border-accent: #d1d5db;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 8px 16px 0 rgba(0, 0, 0, 0.15);
}

/* ========== BLUE THEME ========== */
[data-theme="blue"] {
    --bg-primary: #0a0f1e;
    --bg-secondary: #0f1628;
    --bg-tertiary: #1a2236;
    --bg-hover: #232d44;
    
    --text-primary: #e0f2fe;
    --text-secondary: #bae6fd;
    --text-muted: #7dd3fc;
    
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    
    --border-color: #1e3a5f;
    --border-accent: #2563eb;
    
    --shadow-sm: 0 1px 2px 0 rgba(37, 99, 235, 0.2);
    --shadow-md: 0 2px 4px 0 rgba(37, 99, 235, 0.3);
    --shadow-lg: 0 4px 8px 0 rgba(37, 99, 235, 0.4);
    --shadow-xl: 0 8px 16px 0 rgba(37, 99, 235, 0.5);
}

/* ========== PURPLE THEME ========== */
[data-theme="purple"] {
    --bg-primary: #1a0a1e;
    --bg-secondary: #240f2e;
    --bg-tertiary: #301540;
    --bg-hover: #3d1f52;
    
    --text-primary: #f5e6ff;
    --text-secondary: #e0b3ff;
    --text-muted: #c084fc;
    
    --primary-color: #a855f7;
    --primary-hover: #9333ea;
    --secondary-color: #c084fc;
    
    --border-color: #4c1d95;
    --border-accent: #7c3aed;
    
    --shadow-sm: 0 1px 2px 0 rgba(168, 85, 247, 0.2);
    --shadow-md: 0 2px 4px 0 rgba(168, 85, 247, 0.3);
    --shadow-lg: 0 4px 8px 0 rgba(168, 85, 247, 0.4);
    --shadow-xl: 0 8px 16px 0 rgba(168, 85, 247, 0.5);
}

/* ========== GREEN THEME ========== */
[data-theme="green"] {
    --bg-primary: #0a1e0f;
    --bg-secondary: #0f2817;
    --bg-tertiary: #1a3622;
    --bg-hover: #23442d;
    
    --text-primary: #e6fff0;
    --text-secondary: #b3ffd6;
    --text-muted: #6ee7b7;
    
    --primary-color: #10b981;
    --primary-hover: #059669;
    --success-color: #22c55e;
    
    --border-color: #1e5f3a;
    --border-accent: #059669;
    
    --shadow-sm: 0 1px 2px 0 rgba(16, 185, 129, 0.2);
    --shadow-md: 0 2px 4px 0 rgba(16, 185, 129, 0.3);
    --shadow-lg: 0 4px 8px 0 rgba(16, 185, 129, 0.4);
    --shadow-xl: 0 8px 16px 0 rgba(16, 185, 129, 0.5);
}

/* ========== NORD THEME ========== */
[data-theme="nord"] {
    --bg-primary: #2e3440;
    --bg-secondary: #3b4252;
    --bg-tertiary: #434c5e;
    --bg-hover: #4c566a;
    
    --text-primary: #eceff4;
    --text-secondary: #e5e9f0;
    --text-muted: #d8dee9;
    
    --primary-color: #5e81ac;
    --primary-hover: #81a1c1;
    --success-color: #a3be8c;
    --danger-color: #bf616a;
    --warning-color: #ebcb8b;
    
    --border-color: #4c566a;
    --border-accent: #5e81ac;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 8px 16px 0 rgba(0, 0, 0, 0.6);
}

/* ========== DRACULA THEME ========== */
[data-theme="dracula"] {
    --bg-primary: #282a36;
    --bg-secondary: #21222c;
    --bg-tertiary: #343746;
    --bg-hover: #44475a;
    
    --text-primary: #f8f8f2;
    --text-secondary: #e6e6e6;
    --text-muted: #6272a4;
    
    --primary-color: #bd93f9;
    --primary-hover: #9580d4;
    --success-color: #50fa7b;
    --danger-color: #ff5555;
    --warning-color: #f1fa8c;
    --info-color: #8be9fd;
    
    --border-color: #44475a;
    --border-accent: #6272a4;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 8px 16px 0 rgba(0, 0, 0, 0.7);
}

/* ========== CUSTOM THEME (Applied via JavaScript) ========== */
/* Custom theme colors are set dynamically via inline styles */

/* ========== BASE STYLES ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: var(--base-font-size);
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ========== FULL SCREEN CONTAINER ========== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg-primary);
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: var(--bg-secondary);
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
}

/* Auth Pages Container - Centered */
.auth-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 450px;
    background: var(--bg-secondary);
    border-radius: calc(8px * var(--ui-scale));
    box-shadow: var(--shadow-xl);
    padding: calc(40px * var(--ui-scale));
    border: 1px solid var(--border-accent);
    max-height: 90vh;
    overflow-y: auto;
}

/* Admin Container - Full Screen */
.admin-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: var(--bg-secondary);
    overflow: hidden;
    border: none;
}

/* ========== HEADER ========== */
header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: calc(20px * var(--ui-scale)) calc(32px * var(--ui-scale));
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-accent);
    flex-shrink: 0;
    min-height: calc(70px * var(--ui-scale));
}

header h1 {
    font-size: calc(1.8em * var(--ui-scale));
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: calc(15px * var(--ui-scale));
    align-items: center;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: calc(10px * var(--ui-scale));
    color: var(--text-secondary);
    font-size: calc(0.9em * var(--ui-scale));
}

.admin-badge {
    background: var(--primary-color);
    color: white;
    padding: calc(4px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border-radius: calc(4px * var(--ui-scale));
    font-size: calc(0.7em * var(--ui-scale));
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#game-info {
    display: flex;
    gap: calc(20px * var(--ui-scale));
    font-size: calc(1.1em * var(--ui-scale));
}

#game-info span {
    background: var(--bg-primary);
    padding: calc(8px * var(--ui-scale)) calc(16px * var(--ui-scale));
    border-radius: calc(4px * var(--ui-scale));
    border: 1px solid var(--border-accent);
}

/* ========== MAIN CONTENT AREA ========== */
main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: calc(40px * var(--ui-scale));
    position: relative;
    background: var(--bg-primary);
}

.screen {
    display: none;
    text-align: center;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100%;
}

#start-screen h2,
#game-over-screen h2 {
    font-size: calc(2.5em * var(--ui-scale));
    margin-bottom: calc(20px * var(--ui-scale));
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.5px;
}

#start-screen p {
    font-size: calc(1.2em * var(--ui-scale));
    margin-bottom: calc(30px * var(--ui-scale));
    color: var(--text-secondary);
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: calc(20px * var(--ui-scale));
}

.form-group label {
    display: block;
    margin-bottom: calc(8px * var(--ui-scale));
    color: var(--text-secondary);
    font-weight: 500;
    font-size: calc(0.9em * var(--ui-scale));
}

.form-control {
    width: 100%;
    padding: calc(12px * var(--ui-scale)) calc(16px * var(--ui-scale));
    background: var(--bg-primary);
    border: 1px solid var(--border-accent);
    border-radius: calc(4px * var(--ui-scale));
    color: var(--text-primary);
    font-size: calc(1em * var(--ui-scale));
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    box-shadow: inset 0 0 0 1px var(--primary-color);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23737373' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right calc(12px * var(--ui-scale)) center;
    padding-right: calc(36px * var(--ui-scale));
}

select.form-control option {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: calc(8px * var(--ui-scale));
}

.form-check {
    display: flex;
    align-items: center;
    gap: calc(10px * var(--ui-scale));
    margin-bottom: calc(15px * var(--ui-scale));
}

.form-check input[type="checkbox"] {
    width: calc(18px * var(--ui-scale));
    height: calc(18px * var(--ui-scale));
    cursor: pointer;
}

.form-check label {
    margin: 0;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Color picker input */
input[type="color"] {
    width: calc(60px * var(--ui-scale));
    height: calc(40px * var(--ui-scale));
    border: 1px solid var(--border-accent);
    border-radius: calc(4px * var(--ui-scale));
    cursor: pointer;
    background: var(--bg-primary);
}

/* ========== BUTTONS ========== */
.btn {
    padding: calc(12px * var(--ui-scale)) calc(28px * var(--ui-scale));
    font-size: calc(0.95em * var(--ui-scale));
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: calc(6px * var(--ui-scale));
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-hover);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.btn-success {
    background: var(--success-color);
    color: white;
    border-color: #16a34a;
}

.btn-success:hover {
    background: #16a34a;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    border-color: #dc2626;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning-color);
    color: black;
    border-color: #ca8a04;
}

.btn-warning:hover {
    background: #ca8a04;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.btn-sm {
    padding: calc(6px * var(--ui-scale)) calc(14px * var(--ui-scale));
    font-size: calc(0.875em * var(--ui-scale));
}

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

.btn-primary:active,
.btn-success:active,
.btn-danger:active {
    transform: translateY(0);
}

.btn-action {
    padding: calc(20px * var(--ui-scale)) calc(50px * var(--ui-scale));
    font-size: calc(1.3em * var(--ui-scale));
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    color: white;
    animation: pulse 2s infinite;
}

.btn-action:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* ========== ALERTS ========== */
.alert {
    padding: calc(14px * var(--ui-scale)) calc(20px * var(--ui-scale));
    border-radius: calc(4px * var(--ui-scale));
    margin-bottom: calc(20px * var(--ui-scale));
    border-left: 3px solid;
    font-size: calc(0.95em * var(--ui-scale));
    background: var(--bg-tertiary);
}

.alert-success {
    border-left-color: var(--success-color);
    color: var(--success-color);
}

.alert-danger {
    border-left-color: var(--danger-color);
    color: var(--danger-color);
}

.alert-warning {
    border-left-color: var(--warning-color);
    color: var(--warning-color);
}

.alert-info {
    border-left-color: var(--info-color);
    color: var(--info-color);
}

/* ========== TABLES ========== */
.table-container {
    overflow-x: auto;
    overflow-y: auto;
    margin-top: calc(20px * var(--ui-scale));
    border: 1px solid var(--border-accent);
    background: var(--bg-primary);
    border-radius: calc(4px * var(--ui-scale));
    max-height: calc(600px * var(--ui-scale));
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-accent);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: calc(14px * var(--ui-scale)) calc(18px * var(--ui-scale));
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    font-size: calc(0.85em * var(--ui-scale));
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

td {
    padding: calc(14px * var(--ui-scale)) calc(18px * var(--ui-scale));
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
    font-size: calc(0.9em * var(--ui-scale));
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: var(--bg-tertiary);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ========== CARDS ========== */
.card {
    background: var(--bg-tertiary);
    border-radius: calc(6px * var(--ui-scale));
    padding: calc(24px * var(--ui-scale));
    margin-bottom: calc(20px * var(--ui-scale));
    border: 1px solid var(--border-accent);
}

.card-header {
    font-size: calc(1.3em * var(--ui-scale));
    font-weight: 600;
    margin-bottom: calc(16px * var(--ui-scale));
    color: var(--text-primary);
}

.card-body {
    color: var(--text-secondary);
}

/* ========== AUTH PAGES ========== */
.auth-header {
    text-align: center;
    margin-bottom: calc(30px * var(--ui-scale));
}

.auth-header h1 {
    font-size: calc(2em * var(--ui-scale));
    margin-bottom: calc(8px * var(--ui-scale));
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: calc(0.95em * var(--ui-scale));
}

.auth-footer {
    text-align: center;
    margin-top: calc(24px * var(--ui-scale));
    padding-top: calc(24px * var(--ui-scale));
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: calc(0.9em * var(--ui-scale));
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ========== ADMIN PANEL ========== */
.admin-header {
    background: var(--bg-tertiary);
    padding: calc(32px * var(--ui-scale));
    border-bottom: 2px solid var(--border-accent);
    flex-shrink: 0;
}

.admin-header h1 {
    font-size: calc(2em * var(--ui-scale));
    margin-bottom: calc(8px * var(--ui-scale));
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.admin-header p {
    color: var(--text-muted);
    font-size: calc(0.95em * var(--ui-scale));
}

.admin-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: calc(30px * var(--ui-scale));
    background: var(--bg-primary);
}

.admin-section {
    margin-bottom: calc(40px * var(--ui-scale));
}

.admin-section h2 {
    font-size: calc(1.5em * var(--ui-scale));
    margin-bottom: calc(20px * var(--ui-scale));
    color: var(--text-primary);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: calc(20px * var(--ui-scale));
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(18px * var(--ui-scale));
    background: var(--bg-tertiary);
    border-radius: calc(6px * var(--ui-scale));
    border: 1px solid var(--border-accent);
}

.setting-info h3 {
    font-size: calc(1.1em * var(--ui-scale));
    margin-bottom: calc(4px * var(--ui-scale));
    color: var(--text-primary);
}

.setting-info p {
    font-size: calc(0.875em * var(--ui-scale));
    color: var(--text-muted);
}

/* ========== STATUS BADGES ========== */
.badge {
    display: inline-block;
    padding: calc(4px * var(--ui-scale)) calc(10px * var(--ui-scale));
    border-radius: calc(4px * var(--ui-scale));
    font-size: calc(0.7em * var(--ui-scale));
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success-color);
    border-color: var(--success-color);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.badge-primary {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.15);
    color: var(--warning-color);
    border-color: var(--warning-color);
}

/* ========== ACTION BUTTONS IN TABLES ========== */
.action-buttons {
    display: flex;
    gap: calc(6px * var(--ui-scale));
    flex-wrap: wrap;
    align-items: center;
}

.action-buttons form {
    display: inline;
    margin: 0;
}

.action-buttons .btn {
    white-space: nowrap;
    padding: calc(8px * var(--ui-scale)) calc(14px * var(--ui-scale));
    font-size: calc(0.8em * var(--ui-scale));
}

/* ========== FOOTER ========== */
footer {
    background: var(--bg-tertiary);
    padding: calc(16px * var(--ui-scale));
    text-align: center;
    color: var(--text-muted);
    font-size: calc(0.85em * var(--ui-scale));
    border-top: 2px solid var(--border-accent);
    flex-shrink: 0;
}

/* ========== NOTIFICATION BADGE ========== */
.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger-color);
    color: white;
    font-size: calc(0.7em * var(--ui-scale));
    font-weight: 700;
    padding: calc(2px * var(--ui-scale)) calc(6px * var(--ui-scale));
    border-radius: calc(10px * var(--ui-scale));
    min-width: calc(18px * var(--ui-scale));
    height: calc(18px * var(--ui-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.btn {
    position: relative;
}

/* ========== GAME CANVAS ========== */
#game-canvas {
    width: 100%;
    height: 100%;
    position: relative;
}

#game-area {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: calc(400px * var(--ui-scale));
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-accent);
    margin-bottom: calc(30px * var(--ui-scale));
    flex-wrap: wrap;
}

.tab-button {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    padding: calc(14px * var(--ui-scale)) calc(28px * var(--ui-scale));
    cursor: pointer;
    font-size: calc(0.95em * var(--ui-scale));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    margin-bottom: -2px;
    position: relative;
}

.tab-button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tab-button.active {
    background: var(--bg-secondary);
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 768px) {
    :root {
        --base-font-size: calc(14px * var(--ui-scale));
    }
    
    header {
        flex-direction: column;
        gap: calc(15px * var(--ui-scale));
        padding: calc(15px * var(--ui-scale));
        min-height: auto;
    }
    
    header h1 {
        font-size: calc(1.5em * var(--ui-scale));
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
        gap: calc(10px * var(--ui-scale));
    }
    
    .header-actions .btn {
        width: 100%;
    }
    
    #game-info {
        gap: calc(10px * var(--ui-scale));
        font-size: calc(1em * var(--ui-scale));
        flex-wrap: wrap;
    }
    
    main,
    .admin-content {
        padding: calc(15px * var(--ui-scale));
    }
    
    .admin-header {
        padding: calc(20px * var(--ui-scale));
    }
    
    .auth-container {
        width: 95%;
        padding: calc(24px * var(--ui-scale));
    }
    
    .table-container {
        font-size: calc(0.85em * var(--ui-scale));
        border: none;
    }
    
    th,
    td {
        padding: calc(10px * var(--ui-scale)) calc(8px * var(--ui-scale));
    }
    
    th {
        font-size: calc(0.75em * var(--ui-scale));
    }
    
    .action-buttons {
        flex-direction: column;
        gap: calc(4px * var(--ui-scale));
    }
    
    .action-buttons .btn {
        width: 100%;
        font-size: calc(0.75em * var(--ui-scale));
        padding: calc(6px * var(--ui-scale)) calc(10px * var(--ui-scale));
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-button {
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    :root {
        --base-font-size: calc(13px * var(--ui-scale));
    }
}

/* ========== UTILITY CLASSES ========== */
.text-center {
    text-align: center;
}

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

.mb-2 {
    margin-bottom: calc(0.5rem * var(--ui-scale));
}

.mb-3 {
    margin-bottom: calc(1rem * var(--ui-scale));
}

.mb-4 {
    margin-bottom: calc(1.5rem * var(--ui-scale));
}

.mt-2 {
    margin-top: calc(0.5rem * var(--ui-scale));
}

.mt-3 {
    margin-top: calc(1rem * var(--ui-scale));
}

.mt-4 {
    margin-top: calc(1.5rem * var(--ui-scale));
}

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

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

.gap-2 {
    gap: calc(0.5rem * var(--ui-scale));
}

.gap-3 {
    gap: calc(1rem * var(--ui-scale));
}

/* ========== CUSTOM SCROLLBAR ========== */
::-webkit-scrollbar {
    width: calc(10px * var(--ui-scale));
    height: calc(10px * var(--ui-scale));
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border: 2px solid var(--bg-secondary);
    border-radius: calc(5px * var(--ui-scale));
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========== SELECTION ========== */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* ========== INPUT AUTOFILL DARK MODE FIX ========== */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0 1000px var(--bg-primary) inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* ========== LOADING SPINNER ========== */
.spinner {
    display: inline-block;
    width: calc(40px * var(--ui-scale));
    height: calc(40px * var(--ui-scale));
    border: calc(4px * var(--ui-scale)) solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========== THEME PREVIEW BOXES ========== */
.theme-preview {
    width: 100%;
    height: calc(100px * var(--ui-scale));
    border-radius: calc(6px * var(--ui-scale));
    border: 2px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.theme-preview:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.theme-preview.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.theme-preview-colors {
    display: flex;
    width: 100%;
    height: 100%;
}

.theme-preview-color {
    flex: 1;
    height: 100%;
}

/* ========== COLOR PICKER GRID ========== */
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: calc(15px * var(--ui-scale));
    margin-top: calc(20px * var(--ui-scale));
}

.color-picker-item {
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--ui-scale));
}

.color-picker-item label {
    font-size: calc(0.85em * var(--ui-scale));
    color: var(--text-secondary);
    font-weight: 500;
}

.color-picker-wrapper {
    display: flex;
    gap: calc(10px * var(--ui-scale));
    align-items: center;
}

.color-picker-wrapper input[type="color"] {
    flex-shrink: 0;
}

.color-picker-wrapper input[type="text"] {
    flex: 1;
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
    background: var(--bg-primary);
    border: 1px solid var(--border-accent);
    border-radius: calc(4px * var(--ui-scale));
    color: var(--text-primary);
    font-size: calc(0.9em * var(--ui-scale));
    font-family: 'Courier New', monospace;
}

/* ========== SLIDER ========== */
.slider-container {
    margin-bottom: calc(25px * var(--ui-scale));
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: calc(10px * var(--ui-scale));
    color: var(--text-secondary);
    font-size: calc(0.9em * var(--ui-scale));
}

.slider-value {
    color: var(--primary-color);
    font-weight: 700;
}

input[type="range"] {
    width: 100%;
    height: calc(6px * var(--ui-scale));
    border-radius: calc(3px * var(--ui-scale));
    background: var(--bg-primary);
    border: 1px solid var(--border-accent);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: calc(20px * var(--ui-scale));
    height: calc(20px * var(--ui-scale));
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: var(--shadow-md);
}

input[type="range"]::-moz-range-thumb {
    width: calc(20px * var(--ui-scale));
    height: calc(20px * var(--ui-scale));
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: var(--shadow-md);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}
