/* Deep-space theme: the page floats over the #cosmos canvas. */
:root {
  color-scheme: dark;
  --bg: #020308;
  --panel: rgba(12, 14, 24, 0.84);
  --panel-solid: #0c0e18;
  --field: rgba(20, 23, 38, 0.9);
  --ink: #e8ebf5;
  --muted: #98a0b6;
  --line: rgba(160, 175, 230, 0.16);
  --mod: #b49cff;
  --ANTHROPIC: #f0936d;
  --OPENAI: #3ddbb0;
  --OPEN: #8d9dff;
  --danger: #ff7a70;
  --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

#cosmos { position: fixed; inset: 0; z-index: -1; pointer-events: none; display: block; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); padding: 0 16px 48px; min-height: 100vh; }
.top, .setup, .arena, .moderator, .verdict { max-width: 1400px; margin: 0 auto; }

.top { padding: 24px 0 8px; }
.top h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 30px; letter-spacing: -0.02em; text-shadow: 0 0 24px rgba(140, 160, 255, 0.35); }
.top h1 .brawlers { color: var(--ANTHROPIC); }
.top h1 .logo { flex: none; filter: drop-shadow(0 0 10px rgba(255, 179, 122, 0.35)); }

/* The credit at the foot of the page. */
.powered { max-width: 1400px; margin: 36px auto 0; text-align: center; font-size: 13px; }
.powered a { display: inline-flex; align-items: center; gap: 12px; color: var(--muted); text-decoration: none; padding: 10px 22px; border-radius: 99px; font-size: clamp(20px, 3vw, 28px); }
.powered a:hover, .powered a:focus-visible { color: var(--ink); background: rgba(160, 175, 230, 0.08); }
.powered b { color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
.powered .support { margin: 8px 0 0; color: var(--muted); }
.powered .support a { font-size: inherit; }
.powered .support a, dialog .note a { display: inline; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.powered .support a:hover { background: none; }
.tagline { margin: 4px 0 0; color: var(--muted); }

.setup { margin-top: 16px; }
textarea, input, select, button { font: inherit; color: inherit; }
textarea, input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--field); resize: vertical;
}
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; margin-top: 10px; }
.controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); }
textarea:focus, input:focus, select:focus, button:focus-visible { outline: 2px solid rgba(141, 157, 255, 0.7); outline-offset: 1px; }
button {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--field); cursor: pointer;
}
button:not(:disabled):hover { border-color: rgba(180, 195, 255, 0.45); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary {
  background: linear-gradient(135deg, var(--ANTHROPIC), #c77dff 50%, var(--OPEN)); color: #0b0c14;
  border-color: transparent; font-weight: 700; box-shadow: 0 0 22px rgba(160, 130, 255, 0.35);
}
.status { margin: 12px 0; font-size: 14px; color: var(--muted); min-height: 1.4em; }

.arena { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .arena { grid-template-columns: 1fr; } }

.box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; height: 62vh; min-height: 380px;
  border-top: 4px solid var(--c); transition: box-shadow 0.2s;
}
.box.active { box-shadow: 0 0 0 2px var(--c), 0 0 36px color-mix(in srgb, var(--c) 30%, transparent); }
.box-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.box-title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.state { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); }
.box.active .state { color: var(--c); }

.msgs { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { border-left: 3px solid var(--c); padding: 2px 0 2px 10px; }
.msg.mod { --c: var(--mod); }
.msg-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.msg-body { font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.err .msg-body, .verdict.err .msg-body { color: var(--danger); }
.msg.typing .msg-body::after, .verdict.typing .msg-body::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--c); }
@keyframes blink { 50% { opacity: 0; } }
.round-sep { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.chip {
  margin: 0 14px 12px; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--c) 10%, transparent); min-height: 2.2em;
}
.chip b { color: var(--c); }
.chip .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.moderator { margin-top: 14px; }
.moderator form { display: flex; gap: 8px; }

.verdict {
  margin-top: 18px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; border-top: 4px solid var(--c, var(--ink));
}
.verdict-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.verdict h2 { margin: 0 0 8px; font-size: 18px; }
#verdict-meta { color: var(--muted); font-size: 14px; }
.verdict .msg-body { font-size: 15px; }
.tie button { margin: 0 8px 8px 0; border-color: var(--c); color: var(--c); }

/* ---- account ---- */
button.link { border: none; background: none; padding: 0; text-decoration: underline; color: var(--muted); }
.fineprint { margin: 10px 0 0; font-size: 12px; color: var(--muted); max-width: 80ch; }

/* ---- per-column model picker ---- */
.picker {
  margin-top: 8px; width: 100%; text-align: left; font-size: 12px; padding: 6px 10px; color: var(--muted);
  background: color-mix(in srgb, var(--c) 8%, transparent); border-color: color-mix(in srgb, var(--c) 35%, var(--line));
}
.picker code { color: var(--ink); }
.picker .caret { float: right; }
.box-main { position: relative; flex: 1; min-height: 0; display: flex; }
.box-main .msgs { flex: 1; }
.seat-panel {
  position: absolute; inset: 0; overflow-y: auto; background: var(--panel-solid);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; z-index: 2;
}
.seat-panel[hidden] { display: none; }
.seat-panel h3 { margin: 0; font-size: 15px; }
.opt { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.opt input { margin-top: 3px; }
.opt.locked { opacity: 0.55; cursor: not-allowed; }
.note { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel-actions { margin-top: auto; display: flex; justify-content: flex-end; }
input[type="radio"] { width: auto; padding: 0; flex: none; }

/* ---- influence ("life") bars ---- */
.influence {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px 0;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
/* Metal: a steel rim (the border) around a dark groove, and the fill a polished
   rod of the seat colour, lit from above, with a fine brushed grain and a
   specular streak along its top. */
.influence-track {
  flex: 1; height: 20px; border: 3px solid transparent; border-radius: 99px; overflow: hidden;
  background:
    linear-gradient(180deg, #030409, color-mix(in srgb, var(--c) 12%, #0d0f18)) padding-box,
    linear-gradient(180deg, #9aa3b8 0%, #3b4152 38%, #12151f 55%, #5d6578 100%) border-box;
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.85), 0 2px 6px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.influence-fill {
  position: relative; height: 100%; width: 100%; border-radius: 99px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 2px),
    linear-gradient(180deg,
      color-mix(in srgb, var(--c) 45%, #fff) 0%,
      color-mix(in srgb, var(--c) 80%, #fff) 22%,
      var(--c) 45%,
      color-mix(in srgb, var(--c) 55%, #000) 80%,
      color-mix(in srgb, var(--c) 75%, #fff) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), inset 0 -2px 2px rgba(0, 0, 0, 0.35), 2px 0 4px rgba(0, 0, 0, 0.6);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.influence-fill::after {
  content: ""; position: absolute; left: 6px; right: 6px; top: 2px; height: 32%; border-radius: 99px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0));
}
.influence-label { min-width: 7.5em; text-align: right; }
.influence.leading .influence-track {
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.85), 0 2px 6px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 14px color-mix(in srgb, var(--c) 55%, transparent);
}
.influence.leading .influence-label { color: var(--c); font-weight: 600; }
/* After a vote: the bar flashes, and ▲/▼ shows how many points it moved. */
.influence-delta { opacity: 0; font-weight: 600; white-space: nowrap; }
.influence.up .influence-delta { color: var(--c); animation: delta 2.4s ease-out; }
.influence.down .influence-delta { color: var(--danger); animation: delta 2.4s ease-out; }
.influence.up .influence-fill { animation: bar-up 0.9s ease-out; }
.influence.down .influence-fill { animation: bar-down 0.9s ease-out; }
@keyframes delta { 0% { opacity: 0; transform: translateY(4px); } 12%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@keyframes bar-up { 0% { filter: brightness(1.9) saturate(1.2); } }
@keyframes bar-down { 0% { filter: brightness(0.45); } }
/* A vote in flight: a streak with a bright head, flown by flyVote() in app.js. */
.vote-star {
  position: fixed; z-index: 5; width: 96px; height: 4px; margin: -2px 0 0 -90px; transform-origin: 90px 2px;
  border-radius: 99px; pointer-events: none; background: linear-gradient(90deg, transparent, var(--c) 70%, #fff);
  filter: drop-shadow(0 0 6px var(--c));
}
.vote-star::after {
  content: ""; position: absolute; right: 0; top: 50%; width: 14px; height: 14px; margin: -7px -5px 0 0;
  border-radius: 50%; background: #fff; box-shadow: 0 0 10px 4px var(--c), 0 0 26px 8px color-mix(in srgb, var(--c) 45%, transparent);
}
@media (prefers-reduced-motion: reduce) {
  .influence-fill { transition: none; animation: none !important; }
  .msg.typing .msg-body::after, .verdict.typing .msg-body::after { animation: none; }
}

/* ---- answer labels ---- */
.msg-label { display: flex; align-items: center; gap: 8px; }

/* ---- model picker ---- */
.seat-panel fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.seat-panel legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.seat-panel legend .note { display: inline; font-weight: 400; margin-left: 4px; }
.price { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 4px; }
.picker .seat-label { color: var(--c); }

/* ---- Brawlers account ---- */
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; font-size: 14px; }
.account[hidden] { display: none; }
#acct-status b { font-variant-numeric: tabular-nums; }
.account .low { color: var(--danger); }
dialog {
  background: var(--panel-solid); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(2, 3, 8, 0.7); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; align-items: center; }
.amounts { display: flex; gap: 10px; flex-wrap: wrap; }
.amounts label { border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.amounts label:has(input:checked) { border-color: var(--OPEN); }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 8px 0 0; }
.turn-cost { color: var(--muted); font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; }
.msg.judge { --c: #ffd27a; }

/* ---- copy & export ---- */
button.copy { padding: 2px 10px; font-size: 12px; color: var(--muted); }
.verdict-head .copy { margin-left: auto; }

/* ---- sign-in gate ---- */
.gate {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  padding: 14px 16px; margin-bottom: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--OPEN) 45%, var(--line));
}
.gate[hidden] { display: none; }
.google {
  display: inline-flex; align-items: center; gap: 10px; padding: 9px 16px; border-radius: 99px;
  background: #fff; color: #1f1f1f; font-weight: 600; font-size: 14px; text-decoration: none;
  border: 1px solid #dadce0;
}
.google:hover { box-shadow: 0 0 18px rgba(255, 255, 255, 0.25); }
.google:focus-visible { outline: 2px solid rgba(141, 157, 255, 0.9); outline-offset: 2px; }
.google.off { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* ---- vote board ---- */
.board {
  max-width: 1400px; margin: 18px auto 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px;
}
.board[hidden] { display: none; }
.board h2 { margin: 0 0 8px; font-size: 16px; }
.board-scroll { overflow-x: auto; }
.board table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.board th, .board td { text-align: left; padding: 6px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.board thead th { border-top: none; color: var(--muted); font-weight: 600; }
.board thead th[data-seat] { color: var(--c); }
.board tbody th { color: var(--muted); width: 4em; }
.board .vote { color: var(--c); font-weight: 600; }
.board .conf { color: var(--muted); font-size: 12px; }
.board .conf::before { content: "· "; }
.board .switched { color: #ffd27a; }
.board .meta { color: var(--muted); }
.board .result { min-width: 14em; }
.board .result[data-kind="agreed"] { color: var(--OPENAI); font-weight: 600; }
.board .result[data-kind="differ"] { color: #ffd27a; }
.board .result[data-kind="judging"] { color: var(--muted); font-style: italic; }

/* ---- intro: the title over the three bodies' orbit, then curtains ---- */
.intro { position: fixed; inset: 0; z-index: 10; background: #020308; overflow: hidden; perspective: 900px; cursor: pointer; }
.intro[hidden] { display: none; }
.intro-sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.intro-titles { position: absolute; left: 0; right: 0; top: 66%; transform: translateY(-50%); text-align: center; pointer-events: none; }
.intro-title {
  margin: 0; font-size: clamp(44px, 10vw, 128px); font-weight: 800; letter-spacing: -0.03em;
  color: #fff3e2; text-shadow: 0 0 30px rgba(255, 190, 140, 0.55), 0 0 90px rgba(141, 157, 255, 0.45);
  animation: arrive 1.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.intro-title span { color: var(--ANTHROPIC); }
.intro-subtitle {
  margin: 0.4em 0 0; font-size: clamp(13px, 2.2vw, 24px); font-weight: 500; letter-spacing: 0.32em; text-transform: uppercase;
  color: rgba(255, 243, 226, 0.78); text-shadow: 0 0 18px rgba(141, 157, 255, 0.5);
  animation: subtitle 1.2s ease-out 0.9s both;
}
@keyframes subtitle { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes arrive {
  from { opacity: 0; letter-spacing: 0.4em; filter: blur(12px); }
  to { opacity: 1; letter-spacing: -0.03em; filter: blur(0); }
}
/* Star Wars: the title tips back and flies off into the distance. */
.intro-titles.recede { animation: recede 1.4s cubic-bezier(0.55, 0, 0.75, 0.2) forwards; transform-origin: 50% 100%; }
@keyframes recede {
  from { transform: translateY(-50%) rotateX(0) translateZ(0); opacity: 1; }
  to { transform: translateY(-26vh) rotateX(38deg) translateZ(-2600px); opacity: 0; }
}
.intro-skip {
  position: absolute; right: 18px; bottom: 18px; font-size: 13px; color: var(--muted);
  background: rgba(12, 14, 24, 0.6); border-color: var(--line);
}
.intro .curtain {
  position: absolute; top: 0; bottom: 0; width: 50%; background-color: #020308;
  background-size: 200% 100%; transition: transform 1.3s cubic-bezier(0.7, 0, 0.3, 1), filter 1.3s;
}
.intro .curtain.left { left: 0; background-position: left top; transform-origin: left center; box-shadow: inset -40px 0 60px -30px rgba(240, 147, 109, 0.5); }
.intro .curtain.right { right: 0; background-position: right top; transform-origin: right center; box-shadow: inset 40px 0 60px -30px rgba(141, 157, 255, 0.5); }
.intro.open { background: transparent; pointer-events: none; }
.intro.open .curtain.left { transform: translateX(-102%) rotateY(18deg); filter: brightness(0.5); }
.intro.open .curtain.right { transform: translateX(102%) rotateY(-18deg); filter: brightness(0.5); }
.intro.open .intro-skip { opacity: 0; }
.intro.fade { opacity: 0; transition: opacity 0.4s; }
@media (prefers-reduced-motion: reduce) { .intro-title, .intro-subtitle { animation: none; } }
