/* AlgoArena — palette matches yavuzalp.com's futuristic theme (dist/css/futuristic.css)
   so the subdomain feels like part of the same site, even though it deploys separately. */
:root {
    --bg:           #f8fafc;
    --bg-surface:   #ffffff;
    --bg-raised:    #eef1f6;
    --border:       #e2e8f0;
    --text:         #1e293b;
    --text-dim:     #64748b;
    --accent:       #bd5d38;
    --accent-dark:  #a04e2f;
    --accent-dim:   rgba(189, 93, 56, 0.09);
    --accent-glow:  rgba(189, 93, 56, 0.22);
    --good:         #16a34a;
    --bad:          #dc2626;
    --warn:         #d97706;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg:           #0d1117;
        --bg-surface:   #161b22;
        --bg-raised:    #1c2330;
        --border:       #2a3240;
        --text:         #e6edf3;
        --text-dim:     #8b96a5;
        --accent:       #e88a5c;
        --accent-dark:  #d4723e;
        --accent-dim:   rgba(232, 138, 92, 0.15);
        --accent-glow:  rgba(232, 138, 92, 0.30);
        --good:         #4ade80;
        --bad:          #f87171;
        --warn:         #fbbf24;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0d1117; --bg-surface: #161b22; --bg-raised: #1c2330; --border: #2a3240;
    --text: #e6edf3; --text-dim: #8b96a5; --accent: #e88a5c; --accent-dark: #d4723e;
    --accent-dim: rgba(232, 138, 92, 0.15); --accent-glow: rgba(232, 138, 92, 0.30);
    --good: #4ade80; --bad: #f87171; --warn: #fbbf24; color-scheme: dark;
}
:root[data-theme="light"] {
    --bg: #f8fafc; --bg-surface: #ffffff; --bg-raised: #eef1f6; --border: #e2e8f0;
    --text: #1e293b; --text-dim: #64748b; --accent: #bd5d38; --accent-dark: #a04e2f;
    --accent-dim: rgba(189, 93, 56, 0.09); --accent-glow: rgba(189, 93, 56, 0.22);
    --good: #16a34a; --bad: #dc2626; --warn: #d97706; color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
button { font-family: inherit; }

.arena-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}
.arena-brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.arena-brand span { color: var(--accent); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem; border-radius: 8px; border: 1px solid transparent;
    font-weight: 600; font-size: 0.92rem; cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.container-narrow { max-width: 720px; margin: 0 auto; padding: 2rem 1.25rem; }
.card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 1.5rem;
}
.card + .card { margin-top: 1.25rem; }
.card h2 { margin-top: 0; font-size: 1.15rem; }

.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.3rem; font-weight: 600; }
.form-row input[type=text], .form-row input[type=number], .form-row select {
    width: 100%; padding: 0.55rem 0.7rem; border-radius: 7px;
    border: 1px solid var(--border); background: var(--bg-raised); color: var(--text);
    font-size: 0.95rem;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.25rem; }
.error-text { color: var(--bad); font-size: 0.85rem; margin-top: 0.5rem; }

.tabs-row { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.tabs-row button { flex: 1; }
.tabs-row button.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ---- waiting room ---- */
.room-code-display {
    font-size: 2rem; font-weight: 800; letter-spacing: 0.25em; text-align: center;
    padding: 1rem; background: var(--accent-dim); border-radius: 10px; color: var(--accent);
    margin-bottom: 1rem; user-select: all;
}
.player-chip {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.8rem;
    background: var(--bg-raised); border-radius: 8px; margin-bottom: 0.5rem;
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}

/* ---- race view: editor dominates, other players are a slim top strip ---- */
.race-layout { display: flex; flex-direction: column; height: 100vh; }
.race-players-strip {
    display: flex; gap: 0.6rem; padding: 0.5rem 1rem; overflow-x: auto;
    background: var(--bg-surface); border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.player-progress-card {
    display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.7rem;
    background: var(--bg-raised); border-radius: 8px; min-width: 190px; flex-shrink: 0;
    border: 1px solid var(--border);
}
.player-progress-card.is-me { border-color: var(--accent); background: var(--accent-dim); }
.player-progress-card.is-finished { border-color: var(--good); }
.ppc-name { font-weight: 600; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.ppc-meta { font-size: 0.72rem; color: var(--text-dim); }
.ppc-bar { height: 4px; width: 100%; background: var(--border); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.ppc-bar-fill { height: 100%; background: var(--accent); }
.player-progress-card.is-finished .ppc-bar-fill { background: var(--good); }

.race-main { display: flex; flex: 1; min-height: 0; }
.race-problem-panel {
    width: 34%; min-width: 320px; max-width: 460px; overflow-y: auto;
    padding: 1.25rem; border-right: 1px solid var(--border); background: var(--bg-surface);
}
.race-editor-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.race-editor-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.6rem 1rem; border-bottom: 1px solid var(--border);
}
.race-editor-wrap { flex: 1; min-height: 0; }
.race-editor-wrap .CodeMirror { height: 100%; font-size: 14px; }
.race-timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }

.difficulty-badge {
    display: inline-block; padding: 0.15rem 0.55rem; border-radius: 20px;
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
}
.diff-Easy { background: rgba(22,163,74,.15); color: var(--good); }
.diff-Medium { background: rgba(217,119,6,.15); color: var(--warn); }
.diff-Hard { background: rgba(220,38,38,.15); color: var(--bad); }

.example-block { background: var(--bg-raised); border-radius: 8px; padding: 0.7rem 0.9rem; margin: 0.5rem 0; font-size: 0.85rem; }
.example-block code { color: var(--accent); }

.test-results-panel { border-top: 1px solid var(--border); padding: 0.75rem 1rem; max-height: 40%; overflow-y: auto; }
.test-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; font-size: 0.82rem; font-family: monospace; }
.test-row .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.test-row.pass .dot { background: var(--good); }
.test-row.fail .dot { background: var(--bad); }

/* ---- results ---- */
.results-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.results-table th, .results-table td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.88rem; }
.results-table th { color: var(--text-dim); font-weight: 600; }

.reveal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-top: 0.75rem; }
.reveal-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.reveal-card-head { padding: 0.5rem 0.8rem; background: var(--bg-raised); font-weight: 600; font-size: 0.85rem; display: flex; justify-content: space-between; }
.reveal-card pre { margin: 0; padding: 0.8rem; font-size: 0.78rem; overflow-x: auto; background: var(--bg-surface); max-height: 320px; }

.hidden { display: none !important; }
/* Some components (.auth-modal-overlay, .account-pill, etc.) set their own
   unconditional `display` and are toggled via the `hidden` DOM attribute
   rather than the .hidden class above. Without this, an author rule of
   equal specificity to the browser's built-in `[hidden]{display:none}`
   wins by cascade order and the element stays visible even when hidden. */
[hidden] { display: none !important; }
.spinner-inline { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- auth modal (copied pattern from interview-prep) ---- */
.auth-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.auth-modal { background: var(--bg-surface); border-radius: 12px; padding: 1.75rem; width: 340px; position: relative; }
.auth-modal-close { position: absolute; top: 0.6rem; right: 0.8rem; background: none; border: none; font-size: 1.4rem; color: var(--text-dim); cursor: pointer; }
.account-pill { display: flex; align-items: center; gap: 0.5rem; }
