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

:root {
    --bg: #0d1117;
    --card: #161b22;
    --card-hover: #1c2128;
    --border: #30363d;
    --border-light: #484f58;
    --text: #e6edf3;
    --muted: #8b949e;
    --dim: #6e7681;
    --claude: #f97316;
    --chatgpt: #3b82f6;
    --human: #58a6ff;
    --accent: #f0883e;
    --success: #3fb950;
    --danger: #f85149;
    --radius: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Header ────────────────────────────────────────────────────────────── */
header { background: var(--card); border-bottom: 1px solid var(--border); padding: 0.9rem 0; }
.header-inner { display: flex; align-items: center; gap: 1rem; }
.logo { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.subtitle { color: var(--muted); font-size: 0.85rem; flex: 1; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.4rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card); color: var(--text); font-family: var(--font);
    font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--border-light); background: var(--card-hover); }
.btn-primary { background: var(--claude); border-color: var(--claude); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin: 1.25rem 0; overflow: hidden; }
.card > h2, .card-head h2 { font-size: 0.95rem; font-weight: 700; }
.card > h2 { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.card-body { padding: 1.25rem; }
.toggle-arrow { color: var(--dim); font-size: 0.7rem; transition: transform 0.2s; }

/* ── Labels & Badges ───────────────────────────────────────────────────── */
.label { display: inline-block; padding: 0.12rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.claude-label { color: var(--claude); }
.chatgpt-label { color: var(--chatgpt); }
.badge { display: inline-block; padding: 0.12rem 0.5rem; border-radius: 12px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-pending { background: rgba(139,148,158,0.15); color: var(--muted); }
.badge-open { background: rgba(88,166,255,0.15); color: var(--human); }
.badge-responding { background: rgba(240,136,62,0.15); color: var(--accent); animation: pulse 2s infinite; }
.badge-rating { background: rgba(249,115,22,0.15); color: var(--claude); }
.badge-complete { background: rgba(63,185,80,0.15); color: var(--success); }
.badge-playground { background: rgba(249,115,22,0.1); color: var(--claude); }
.badge-challenge { background: rgba(88,166,255,0.1); color: var(--human); }
.badge-claude { background: rgba(249,115,22,0.15); color: var(--claude); }
.badge-chatgpt { background: rgba(59,130,246,0.15); color: var(--chatgpt); }
.badge-tie { background: rgba(240,136,62,0.15); color: var(--accent); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Prompt Station ────────────────────────────────────────────────────── */
.prompt-display { padding: 1rem 1.25rem; font-family: var(--mono); font-size: 0.82rem; color: var(--muted); white-space: pre-wrap; word-break: break-word; line-height: 1.6; max-height: 200px; overflow-y: auto; background: var(--bg); margin: 0; }
.help-text { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.prompt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.prompt-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.claude-border { border-top: 3px solid var(--claude); }
.chatgpt-border { border-top: 3px solid var(--chatgpt); }
.prompt-head { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); background: var(--card-hover); }
.prompt-text { padding: 0.75rem; font-family: var(--mono); font-size: 0.72rem; color: var(--muted); white-space: pre-wrap; word-break: break-all; line-height: 1.5; max-height: 140px; overflow-y: auto; }

/* ── Active Battle ─────────────────────────────────────────────────────── */
.active-info { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.active-meta { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.active-meta .mono { font-family: var(--mono); color: var(--dim); font-size: 0.8rem; }
.active-task { font-size: 1.05rem; font-weight: 600; line-height: 1.5; white-space: pre-wrap; }
.empty-msg { padding: 2.5rem 1.25rem; text-align: center; color: var(--dim); font-size: 0.9rem; }

/* ── Playground Grid ───────────────────────────────────────────────────── */
.pg-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0; padding: 1rem; }
.pg-panel { display: flex; flex-direction: column; min-width: 0; }
.pg-head { font-weight: 700; font-size: 0.95rem; padding: 0.5rem 0; text-align: center; }
.pg-status { font-size: 0.75rem; font-weight: 400; opacity: 0.6; }
.pg-vs { display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 900; color: var(--dim); padding: 0 1.2rem; opacity: 0.4; user-select: none; }
iframe { width: 100%; height: 500px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.pg-actions { display: flex; gap: 0.4rem; padding: 0.5rem 0; justify-content: center; }

/* ── Text Solutions ────────────────────────────────────────────────────── */
.text-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1rem 1.25rem; }
.text-panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.text-head { font-weight: 700; font-size: 0.9rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); background: var(--card-hover); }
.text-body { padding: 1rem; font-size: 0.88rem; white-space: pre-wrap; word-break: break-word; max-height: 450px; overflow-y: auto; line-height: 1.7; }

/* ── Human Controls ────────────────────────────────────────────────────── */
.controls-inner { padding: 1rem 1.25rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; border-top: 1px solid var(--border); }
.rate-section h3, .vote-section h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.75rem; }
.rate-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.rate-label { min-width: 75px; font-weight: 600; font-size: 0.85rem; }
.score-btns { display: flex; gap: 3px; }
.score-btn {
    width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 4px;
    background: var(--bg); color: var(--dim); font-size: 0.75rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.1s;
}
.score-btn:hover { border-color: var(--border-light); color: var(--text); }
.score-btn.selected { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
#btn-submit-ratings { margin-top: 0.75rem; }

.vote-btns { display: flex; gap: 0.6rem; }
.vote-btn {
    flex: 1; padding: 0.7rem 0.5rem; border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--bg); color: var(--text); font-weight: 600; font-size: 0.9rem;
    cursor: pointer; text-align: center; transition: all 0.15s;
}
.claude-vote:hover { border-color: var(--claude); background: rgba(249,115,22,0.08); }
.chatgpt-vote:hover { border-color: var(--chatgpt); background: rgba(59,130,246,0.08); }
.tie-vote:hover { border-color: var(--accent); background: rgba(240,136,62,0.08); }
.vote-btn.chosen { opacity: 1; }
.vote-btn:disabled { opacity: 0.4; cursor: default; }
#vote-result { margin-top: 0.5rem; font-weight: 600; font-size: 0.9rem; text-align: center; }

/* ── AI Ratings ────────────────────────────────────────────────────────── */
.ai-ratings-head { padding: 0.75rem 1.25rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-top: 1px solid var(--border); }
.ai-ratings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; padding: 0 1.25rem 1rem; }
.ai-rating-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.ai-rating-head-inner { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.4rem; font-size: 0.8rem; color: var(--muted); }
.ai-rating-score { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.ai-rating-text { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; white-space: pre-wrap; word-break: break-word; max-height: 80px; overflow-y: auto; line-height: 1.5; }

/* ── Queue ──────────────────────────────────────────────────────────────── */
.queue-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 1.25rem; border-bottom: 1px solid var(--border); }
.queue-item:last-child { border-bottom: none; }
.queue-pos { font-family: var(--mono); font-size: 0.8rem; color: var(--dim); min-width: 22px; text-align: center; }
.queue-info { flex: 1; min-width: 0; }
.queue-task { font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-badges { display: flex; gap: 0.4rem; margin-top: 0.2rem; }
.queue-actions { display: flex; gap: 3px; }
.queue-actions button {
    width: 26px; height: 26px; background: none; border: 1px solid var(--border);
    border-radius: 4px; color: var(--muted); cursor: pointer; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center;
}
.queue-actions button:hover { border-color: var(--border-light); color: var(--text); }
.queue-actions button.del:hover { border-color: var(--danger); color: var(--danger); }

/* ── Scoreboard ────────────────────────────────────────────────────────── */
.sb-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; padding: 1.5rem 1.25rem; align-items: start; }
.sb-agent { text-align: center; }
.sb-name { font-size: 1.05rem; font-weight: 800; margin-bottom: 0.5rem; }
.sb-wins { font-size: 3rem; font-weight: 900; line-height: 1; }
.sb-wins-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.75rem; }
.sb-stat { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
.sb-stat span { color: var(--text); font-weight: 600; }
.sb-vs { display: flex; align-items: center; font-size: 2rem; font-weight: 900; color: var(--dim); opacity: 0.3; padding-top: 2.5rem; }
.sb-footer { text-align: center; padding: 0.75rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--dim); }

/* ── History ────────────────────────────────────────────────────────────── */
.history-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 1.25rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; cursor: pointer; }
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: rgba(255,255,255,0.02); }
.history-id { font-family: var(--mono); color: var(--dim); font-size: 0.78rem; min-width: 65px; }
.history-task { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; width: 90%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.modal-sm { max-width: 360px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem; }
.modal-body label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--muted); margin-bottom: 0.4rem; }
.modal-body textarea, .modal-body input[type="text"] {
    width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-family: var(--font); font-size: 0.9rem; padding: 0.65rem;
    margin-bottom: 0.75rem; resize: vertical; line-height: 1.6;
}
.modal-body textarea:focus, .modal-body input:focus { outline: none; border-color: var(--claude); }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.type-sel { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.type-btn { flex: 1; padding: 0.55rem; border: 2px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--muted); cursor: pointer; text-align: center; font-size: 0.88rem; font-weight: 500; }
.type-btn.active { border-color: var(--claude); color: var(--text); background: rgba(249,115,22,0.06); }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .prompt-row, .text-grid, .controls-inner, .ai-ratings-grid, .sb-grid { grid-template-columns: 1fr; }
    .pg-grid { grid-template-columns: 1fr; }
    .pg-vs, .sb-vs { display: none; }
    iframe { height: 350px; }
    .vote-btns { flex-direction: column; }
}
