:root {
    /* Emerald Green / Dark Palette */
    --bg-main: #0A1A14;
    --bg-panel: rgba(14, 33, 27, 0.7);
    --bg-card: rgba(22, 46, 38, 0.8);
    --border-color: rgba(0, 184, 148, 0.15);
    --border-hover: rgba(0, 184, 148, 0.4);
    
    --text-main: #F4FBF9;
    --text-muted: #8AA69A;
    
    --primary: #00B894;
    --primary-hover: #009678;
    --secondary: #55EFC4;
    --accent: #FDCB6E;
    --danger: #FF7675;
    --danger-bg: rgba(255, 118, 117, 0.1);
    --success-bg: rgba(0, 184, 148, 0.1);
    
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    background-image: radial-gradient(circle at 50% 0%, rgba(0, 184, 148, 0.08) 0%, transparent 60%);
}

.hidden { display: none !important; }
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.pt-2 { padding-top: 0.5rem; }
.border-t { border-top: 1px solid var(--border-color); }
.w-full { width: 100%; }

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.app-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    padding: 16px;
    gap: 16px;
}

/* Sidebar */
.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 32px;
}
.brand svg { color: var(--primary); }

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}
.nav-item {
    background: transparent;
    border: none;
    text-align: left;
    padding: 10px 16px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-family: inherit;
}
.nav-item:hover { color: var(--text-main); background: rgba(255,255,255,0.05); }
.nav-item.active { background: var(--bg-card); color: var(--primary); border: 1px solid var(--border-color); }

.level-selector {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.level-selector::-webkit-scrollbar { width: 4px; }
.level-selector::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }

.level-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 12px;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.level-btn:hover { background: rgba(255,255,255,0.02); color: var(--text-main); }
.level-btn.active { background: var(--primary); color: #000; font-weight: 600; box-shadow: 0 4px 12px rgba(0,184,148,0.3); }
.level-btn.completed .status-icon { color: var(--secondary); }
.level-btn.active.completed .status-icon { color: #000; }
.level-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.player-stats {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.stat-box {
    background: var(--bg-card);
    padding: 12px;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid rgba(0,0,0,0.2);
}
.stat-label { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.stat-value { font-size: 1.25rem; font-weight: 700; font-family: var(--font-mono); }

/* Main Arena */
.arena-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.arena-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.level-info h1 { font-size: 1.5rem; margin-bottom: 4px; }
.level-info p { color: var(--text-muted); font-size: 0.95rem; max-width: 600px; }

.flag-toggles { display: flex; gap: 12px; }
.flag-label {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}
.flag-label:hover { border-color: var(--primary); }

.editor-section { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.regex-input-wrapper {
    display: flex;
    align-items: center;
    background: #000;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 16px;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
.regex-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.2), inset 0 2px 4px rgba(0,0,0,0.5);
}
.regex-slash {
    color: var(--secondary);
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
}
.regex-flags-display {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 1.25rem;
    margin-left: 4px;
}
.regex-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 1.5rem;
    padding: 20px 8px;
    outline: none;
    width: 100%;
}
.regex-input::placeholder { color: rgba(255,255,255,0.2); }
.regex-input:disabled { opacity: 0.5; }

.editor-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hint-box {
    background: rgba(253, 203, 110, 0.1);
    border: 1px solid rgba(253, 203, 110, 0.3);
    color: var(--accent);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

/* Test Cases */
.test-cases-section {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
}
.test-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.col-header {
    padding: 16px 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
}
.test-list {
    list-style: none;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.test-item {
    font-family: var(--font-mono);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    word-break: break-all;
}
.test-item.pass {
    background: var(--success-bg);
    border-color: var(--primary);
}
.test-item.fail {
    background: var(--danger-bg);
    border-color: var(--danger);
    opacity: 0.8;
}

.match-highlights span.highlight {
    background: rgba(0, 184, 148, 0.4);
    color: #fff;
    border-radius: 2px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #000; }
.btn-primary:not(:disabled):hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:not(:disabled):hover { background: rgba(255,255,255,0.05); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-main); }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    width: 100%;
    max-width: 450px;
    padding: 32px;
}
.score-item {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden { opacity: 0; transform: translate(-50%, 20px); pointer-events: none; }
