:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1d202a;
  --line: #2a2e3b;
  --text: #e6e8ef;
  --muted: #8b91a4;
  --accent: #7c5cff;
  --accent-2: #ff5c8a;
  --ok: #3ddc97;
  --warn: #ffb454;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 700px at 80% -10%, #241f45 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); }

header.top {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 22px 28px 0;
  max-width: 1180px;
  margin: 0 auto;
}
header.top h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; }
header.top .tag { color: var(--muted); font-size: 13px; }
header.top nav { margin-left: auto; font-size: 13px; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 28px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 880px) { main { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---------- chat ---------- */

#chat {
  height: min(66vh, 620px);
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant { background: var(--panel-2); border: 1px solid var(--line); border-top-left-radius: 4px; align-self: flex-start; }
.msg.user { background: linear-gradient(180deg, #3a2f7a, #322a66); border-top-right-radius: 4px; align-self: flex-end; }
.msg.opener {
  align-self: stretch; max-width: 100%;
  background: #14161d; border: 1px dashed var(--line);
  color: var(--muted); font-size: 13.5px; border-radius: 12px;
}
.msg.system { align-self: center; max-width: 100%; background: none; color: var(--muted); font-size: 13px; text-align: center; padding: 4px 0; }
.msg.error { align-self: center; max-width: 100%; background: #3a1f25; border: 1px solid #6d2f3c; color: #ffc2ce; font-size: 13px; }

.typing { color: var(--muted); font-size: 13px; align-self: flex-start; padding-left: 4px; }
.typing span { animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

form#composer { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); background: #12141b; }
form#composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 140px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font: inherit;
}
form#composer textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
/* keeps focus while a reply is in flight, but reads as not-yet-typeable */
form#composer textarea[readonly] { opacity: .55; }

button {
  font: inherit; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 10px 16px;
}
button:hover:not(:disabled) { border-color: #414861; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.1); }

/* ---------- button panel ---------- */

.side { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.side h2 { margin: 0; font-size: 13px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

#theButton {
  width: 100%; padding: 30px 18px;
  font-size: 21px; font-weight: 800; letter-spacing: .12em;
  color: #fff; border: none; border-radius: 16px;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  box-shadow: 0 10px 34px -12px var(--accent-2), inset 0 -3px 0 rgba(0,0,0,.28);
  transition: transform .08s ease, filter .15s ease;
}
#theButton:hover:not(:disabled) { filter: brightness(1.08); }
#theButton:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 4px 16px -10px var(--accent-2); }

.meta { display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.meta div { display: flex; justify-content: space-between; gap: 12px; }
.meta b { color: var(--text); font-weight: 600; }

.note { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }

/* ---------- result ---------- */

#result { display: none; }
#result.show { display: block; }
.verdict { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px; }
.verdict.pressed { color: var(--ok); }
.verdict.held { color: var(--warn); }
.reveal { font-size: 15px; margin: 12px 0 4px; }
.reveal b { color: var(--accent); }

/* ---------- leaderboard ---------- */

.wide { max-width: 1180px; margin: 0 auto; padding: 18px 28px 60px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover { background: #1b1e28; }
td.model { font-weight: 600; }
td.model small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }

.bar { position: relative; height: 20px; background: var(--panel-2); border-radius: 5px; overflow: hidden; min-width: 130px; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar > em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px #000; }

.cards { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; min-width: 132px; }
.card b { display: block; font-size: 23px; letter-spacing: -0.02em; }
.card span { color: var(--muted); font-size: 12px; }

.empty { color: var(--muted); padding: 34px; text-align: center; }
h2.section { font-size: 13px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 34px 0 12px; }
td.cell b { font-weight: 700; }
td.cell small { color: var(--muted); font-weight: 400; }
td.na { color: #565c70; }
.scroll { overflow-x: auto; }
