:root {
    --bg-dark: #050811;
    --bg-card: #0c1020;
    --bg-card-border: #1a233d;
    --accent-cyan: #00f0ff;
    --accent-green: #10b981;
    --accent-gold: #f59e0b;
    --accent-blue: #38bdf8;
    --accent-purple: #a855f7;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'Fira Code', monospace;
    --font-title: 'Orbitron', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    line-height: 1.5;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 20px;
    max-width: 1440px;
    margin: 0 auto;
    gap: 18px;
}

/* App Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    padding: 16px 24px;
    border-radius: 12px;
}

.badge-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.12);
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 4px;
}

.app-header h1 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    letter-spacing: 1px;
    font-weight: 900;
}

.accent-cyan { color: var(--accent-cyan); }
.challenge-pill-box { display: flex; align-items: center; gap: 8px; }
.challenge-pill { font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent-gold); background: rgba(245, 158, 11, 0.15); border: 1px solid var(--accent-gold); padding: 4px 12px; border-radius: 20px; font-weight: 600; }
.header-actions { display: flex; gap: 10px; }

.btn {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--bg-card-border);
    background: #172036;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.btn:hover { background: #253356; border-color: var(--accent-cyan); }
.btn-primary { background: var(--accent-cyan); color: #000; font-weight: 700; border: none; }
.btn-primary:hover { background: #38bdf8; }
.btn-secondary { background: #12192c; color: var(--text-muted); }
.btn-mic { background: rgba(56, 189, 248, 0.15); border-color: var(--accent-blue); color: var(--accent-blue); }

/* Challenge Selector Bar */
.challenge-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 900px) {
    .challenge-selector { grid-template-columns: 1fr; }
}

.challenge-tab {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.challenge-tab:hover { background: #131b33; border-color: var(--accent-cyan); color: var(--text-main); }
.challenge-tab.active { background: #162547; border-color: var(--accent-cyan); color: #fff; box-shadow: 0 0 15px rgba(0, 240, 255, 0.15); }
.challenge-tab .sub { font-size: 0.72rem; font-family: var(--font-mono); color: var(--text-muted); }

/* Main Arena Grid */
.arena-grid {
    display: grid;
    grid-template-columns: 1fr 380px 320px;
    gap: 18px;
    flex: 1;
}

@media (max-width: 1200px) {
    .arena-grid { grid-template-columns: 1fr; }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255, 255, 255, 0.08); padding-bottom: 8px; }
.card-header h3 { font-family: var(--font-title); font-size: 0.95rem; color: var(--accent-cyan); }
.sandbox-badge { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent-green); background: rgba(16, 185, 129, 0.15); padding: 2px 6px; border-radius: 10px; }

/* Editor Card */
.editor-header { display: flex; align-items: center; justify-content: space-between; background: #080d1a; padding: 8px 12px; border-radius: 8px 8px 0 0; border: 1px solid var(--bg-card-border); }
.file-tab { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent-cyan); background: #131c33; padding: 4px 10px; border-radius: 4px; }
.form-select { background: #131c33; border: 1px solid var(--bg-card-border); color: var(--text-main); font-size: 0.78rem; font-family: var(--font-mono); padding: 4px 8px; border-radius: 4px; }

.code-area {
    width: 100%;
    min-height: 380px;
    background: #03060c;
    border: 1px solid var(--bg-card-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.6;
    padding: 14px;
    resize: vertical;
    outline: none;
}

.editor-actions { display: flex; gap: 10px; }

/* Profiler Metric Boxes */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.metric-box {
    background: #080d1a;
    border: 1px solid var(--bg-card-border);
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.m-label { font-size: 0.72rem; font-family: var(--font-mono); color: var(--text-muted); }
.m-val { font-size: 1.1rem; font-family: var(--font-mono); font-weight: 700; color: var(--text-main); }
.m-val.green { color: var(--accent-green); }
.m-val.cyan { color: var(--accent-cyan); }
.m-sub { font-size: 0.7rem; font-family: var(--font-mono); color: var(--text-muted); }

/* Security Audit Box */
.audit-box {
    background: #080d1a;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.audit-header { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent-green); font-weight: 700; }
.audit-status { background: rgba(16, 185, 129, 0.15); padding: 2px 6px; border-radius: 8px; }

.audit-list { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-family: var(--font-mono); color: var(--text-muted); }
.audit-list strong { color: var(--text-main); }

/* AI Code Explanation Card */
.ai-analysis-card {
    background: #080d1a;
    border: 1px solid var(--bg-card-border);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-header { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent-cyan); font-weight: 700; }
.ai-body { font-size: 0.82rem; color: var(--text-muted); line-height: 1.4; }

/* Leaderboard */
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.leaderboard-table th { text-align: left; font-family: var(--font-mono); color: var(--text-muted); padding: 8px; border-bottom: 1px solid var(--bg-card-border); }
.leaderboard-table td { padding: 10px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.leaderboard-table .score { font-family: var(--font-mono); color: var(--accent-gold); font-weight: 700; }

/* Author Details Footer */
.author-footer {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.footer-card {
    background: rgba(13, 21, 37, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px 28px;
    text-align: center;
    max-width: 850px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.developed-by { font-size: 0.9rem; color: #94a3b8; }
.developed-by .author-name { color: #00f0ff; font-weight: 700; }
.developed-by .heart { color: #ef4444; display: inline-block; animation: heartPulse 1.5s infinite; }
@keyframes heartPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }
.footer-links { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; font-size: 0.85rem; }
.footer-link { color: #00f0ff; text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.footer-links .dot { color: #475569; }
.tech-badges { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
.badge-pill { background: rgba(6, 182, 212, 0.08); border: 1px solid rgba(6, 182, 212, 0.3); color: #38bdf8; padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-family: var(--font-mono); display: inline-flex; align-items: center; gap: 4px; }
.copyright-text { font-size: 0.75rem; color: #64748b; }
