/* byo venue — the console's dusk, in a webpage.
 *
 * Organized tokens → base → components → pages. Before this it was dated
 * strata: every feature appended its block to the bottom and nothing was ever
 * consolidated, which is how `.swatch` came to be defined twice (the second one
 * silently breaking the palette editor's chips), `.edit-page` came to be defined
 * twice with opposite layout models, and four different greys came to mean
 * "body text". Add to the section you belong in, not to the end of the file. */

/* ==== tokens ============================================================== */
:root {
  color-scheme: dark;

  /* surfaces, from furthest back to nearest */
  --ink: #16121f;      /* the page */
  --well: #100d18;     /* recessed: inputs, pre, logs */
  --raise: #1a1626;    /* raised: cards */
  --line: #2b2537;     /* hairline, and the quiet button's fill */
  --line-2: #3a3347;   /* a border that needs to be seen */

  /* text, from loudest to quietest — two body greys, not four */
  --bright: #f8ecd4;   /* headings */
  --text: #c6d2ee;     /* body */
  --dim: #94897f;      /* labels, secondary */
  --faint: #6e6470;    /* muted, tertiary */

  /* accent + state */
  --amber: #e8b878;
  --amber-lit: #f0d090;
  --good: #8fd08a;
  --bad: #ef5d57;
  --info: #8fa3dd;

  --mono: ui-monospace, monospace;

  /* type scale — seven steps, was thirteen sizes including two fractional */
  --t-xs: 11px; --t-sm: 12px; --t-md: 13px; --t-base: 15px;
  --t-lg: 17px; --t-xl: 19px; --t-2xl: 22px;

  /* space scale — six steps, was ~20 ad-hoc padding values */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 22px; --s6: 32px;

  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-pill: 999px;
}

/* ==== base ================================================================ */
body { margin: 0; background: var(--ink); color: var(--text);
  font: var(--t-base)/1.5 var(--mono); }
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { color: var(--bright); font-size: var(--t-2xl); }
h2 { color: var(--bright); font-size: var(--t-lg); }
.muted { color: var(--faint); }

header { display: flex; justify-content: space-between; align-items: baseline;
  padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line); }
.brand { font-weight: bold; font-size: var(--t-lg); color: var(--bright); }
nav { display: flex; gap: var(--s3); align-items: baseline; }
main { max-width: 880px; margin: 0 auto; padding: var(--s5) var(--s5) 64px; }
main.full-bleed { max-width: none; padding: var(--s3) var(--s4) 40px; }

.flash { max-width: 880px; margin: var(--s3) auto 0; padding: var(--s2) var(--s5); }
.notice { color: var(--good); }
.alert { color: var(--bad); }

.card { border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s4) var(--s4); margin: var(--s3) 0; background: var(--raise); }
.card h2 { margin: 0 0 var(--s1); }
.crumbs { margin-bottom: var(--s3); }
.headline { margin: var(--s2) 0 var(--s4); }
.actions { display: flex; gap: var(--s3); margin-top: var(--s2);
  align-items: center; flex-wrap: wrap; }

/* ==== components ========================================================== */

/* one button, four intents, one size modifier. Replaced five unrelated
   treatments that differed only in padding and font-size. */
.btn, input[type=submit], button[type=submit] {
  display: inline-flex; align-items: center; gap: var(--s1);
  background: var(--line); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: var(--s2) var(--s3); font: inherit; font-size: var(--t-md);
  cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--amber); color: var(--amber); text-decoration: none; }
/* A bare submit is its form's primary action, styled so a missed class can
   never leave a button unreadable. :not(.btn) matters — an attribute selector
   outweighs a class, so without it every button_to marked .btn (archive,
   revoke, discard) came out looking like the page's primary action. */
.btn.primary, input[type=submit]:not(.btn), button[type=submit]:not(.btn) {
  background: var(--amber); color: var(--ink); border-color: var(--amber);
  font-weight: bold; }
.btn.primary:hover, input[type=submit]:not(.btn):hover, button[type=submit]:not(.btn):hover {
  background: var(--amber-lit); border-color: var(--amber-lit); color: var(--ink); }
.btn.quiet { background: none; border-color: transparent; color: var(--amber);
  padding-left: 0; padding-right: 0; }
.btn.quiet:hover { color: var(--amber-lit); text-decoration: underline; }
.btn.danger { background: none; border-color: var(--bad); color: var(--bad);
  font-weight: normal; }
.btn.danger:hover { background: var(--bad); color: var(--ink); border-color: var(--bad); }
.btn.sm { padding: var(--s1) var(--s2); font-size: var(--t-sm); font-weight: normal; }
button:disabled, input[type=submit]:disabled { opacity: .45; cursor: not-allowed; }
/* button_to wraps its button in a form — keep it on the line it was written on */
form.button_to { display: inline-block; }

/* one pill, named for the state it means rather than the page it's on.
   Replaced .status, .chip and .gc-seats. */
.pill { display: inline-block; padding: 1px var(--s2); border-radius: var(--r-pill);
  font-size: var(--t-sm); vertical-align: middle; background: var(--line);
  color: var(--dim); font-weight: normal; }
.pill.ok { background: #2b3a26; color: var(--good); }
.pill.bad { background: #3a2626; color: var(--bad); }
.pill.info { background: #34304a; color: var(--info); }
.pill.warn { background: #3d3520; color: var(--amber); }
.pill.neutral { background: var(--line-2); color: #c8b0e0; }

/* the uppercase tracked section heading — was four separate rules at four sizes */
.section-title { font-size: var(--t-md); letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 var(--s2); }

/* one label+control pair */
.field { margin: 0 0 var(--s3); }
.field > label, label { color: var(--dim); font-size: var(--t-md); display: block; }
input[type=text], input[type=email], input[type=password], input[type=number],
textarea, input[type=file] {
  width: 100%; box-sizing: border-box; background: var(--well); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: var(--s2) var(--s2); font: inherit; margin: var(--s1) 0 var(--s3); }
input:focus, textarea:focus { outline: none; border-color: var(--amber); }
input.narrow { width: 6em; }
input.narrow-wide { max-width: 22em; }

/* a radio and its consequence, in prose */
.choice { display: flex; gap: var(--s2); align-items: flex-start;
  padding: var(--s2) 0; color: var(--text); font-size: var(--t-md); cursor: pointer; }
.choice input { margin-top: 3px; accent-color: var(--amber); }
.choice b { color: var(--bright); font-weight: normal; }

/* the only irreversible corner of the app, marked as such */
.card.danger { border-color: #4a2b2b; }
.danger-row { display: flex; gap: var(--s4); align-items: flex-start;
  justify-content: space-between; padding: var(--s3) 0;
  border-top: 1px solid var(--line); flex-wrap: wrap; }
.danger-row:first-of-type { border-top: 0; }
.danger-row p { margin: var(--s1) 0; font-size: var(--t-md); max-width: 52ch; }
.manifest { margin: var(--s1) 0 var(--s3); padding-left: var(--s4);
  font-size: var(--t-md); max-width: 52ch; }
.manifest li { margin: 2px 0; }
.card.notice-card { border-color: var(--amber); }

pre.log { background: var(--well); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: var(--s3); overflow-x: auto;
  font-size: var(--t-sm); color: var(--dim); }

/* ==== the arcade ========================================================== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--s5); }
.gamecard .preview { display: block; aspect-ratio: 16 / 9; border-radius: var(--r-lg);
  border: 1px solid var(--line); background-size: 100% auto; background-position: 0 0;
  background-repeat: no-repeat; position: relative; overflow: hidden;
  image-rendering: pixelated; }
.gamecard .preview:hover { border-color: var(--amber); text-decoration: none; }
/* portrait games get a phone-shaped card (432x768 title cards) */
.gamecard .preview.portrait { aspect-ratio: 9 / 16; max-width: 220px; margin: 0 auto; }
.gc-seats { position: absolute; top: var(--s2); left: 10px; color: var(--bright);
  font-size: var(--t-sm); font-weight: bold; background: rgba(10, 8, 16, 0.7);
  padding: 2px 7px; border-radius: var(--r-pill); }
.gc-title { position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--s5) var(--s3) var(--s2); color: var(--bright); font-weight: bold;
  font-size: 16px; text-shadow: 0 1px 3px #000;
  background: linear-gradient(transparent, rgba(10, 8, 16, 0.85)); }
.gc-play { position: absolute; top: var(--s2); right: 10px; color: var(--bright);
  text-shadow: 0 1px 3px #000; opacity: 0; transition: opacity .15s; }
.preview:hover .gc-play { opacity: 1; }
.gc-meta { margin: var(--s2) 2px; font-size: var(--t-md); }
.gc-blank { display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16 / 9; border: 1px dashed var(--line-2); border-radius: var(--r-lg);
  color: var(--faint); font-size: var(--t-md); text-align: center; padding: var(--s3); }

/* ==== the game page ======================================================= */
.gamedesc { color: var(--text); max-width: 60ch; }
/* the owner's way in, one line, below the thing everyone else came for */
.owner-strip { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap;
  margin: var(--s5) 0 0; padding-top: var(--s3); border-top: 1px solid var(--line);
  font-size: var(--t-md); }
.versions-list > summary { cursor: pointer; margin-top: var(--s3); }

/* ==== your games ========================================================== */
.railrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  padding: 3px 0; font-size: var(--t-md); }
.railrow .muted { font-size: var(--t-sm); }
.gamerow h2 .pill { margin-left: var(--s2); }
.archived-drawer { margin-top: var(--s6); }
.archived-drawer > summary { cursor: pointer; color: var(--faint);
  font-size: var(--t-md); }
.archived-drawer .railrow { padding: var(--s2) 0; }

/* ==== the workbench ======================================================= */
.edit-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding-bottom: 10px; }
.edit-head .back { color: var(--bright); font-weight: bold; }
.edit-head .head-state { font-size: var(--t-md); }
.edit-head .head-actions { margin-left: auto; display: flex; gap: 10px;
  align-items: center; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 var(--s2); }
.tabs button { background: none; border: 0; color: var(--faint);
  padding: var(--s2) var(--s3); cursor: pointer; font: inherit; font-size: var(--t-sm);
  letter-spacing: .06em; text-transform: uppercase; border-bottom: 2px solid transparent; }
.tabs button:hover { color: #a3a8bd; }
.tabs button.on { color: var(--amber); border-bottom-color: var(--amber); }
.tabs .dot { color: var(--amber); }
.edit-page { display: flex; flex-direction: column; }
.edit-page > .pane { padding: var(--s4) var(--s4); overflow-y: auto; flex: 1;
  max-width: 900px; width: 100%; }

.tasking-form textarea { width: 100%; margin: var(--s2) 0 var(--s3); }
.tasking-form label { font-size: var(--t-sm); color: var(--faint); }
.tasking-form .rounds { display: flex; align-items: center; gap: var(--s2); }
.tasking-form .rounds input { width: 4.5em; margin: 0; }
.attach h3 { font-size: var(--t-sm); letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); border-top: 1px solid var(--line); padding-top: 10px;
  margin: 0 0 var(--s2); }
.attach-row { display: flex; align-items: center; gap: var(--s2);
  font-size: var(--t-md); margin: var(--s2) 0; }
.attach-note { font-size: var(--t-sm); margin: 2px 0 2px 26px; display: flex;
  gap: var(--s2); align-items: center; }
.attach-note input[type=text] { flex: 1; margin: 0; }

.draft-frame { width: 100%; aspect-ratio: 16 / 10; border: 1px solid var(--line);
  border-radius: var(--r-lg); background: var(--ink); }
.draft-frame.portrait { aspect-ratio: 9 / 16; max-width: min(320px, 100%);
  display: block; margin: 0 auto; }
/* the game and what it tracks, side by side; wraps to stacked on narrow */
.play-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: flex-start; }
.play-row .draft-frame { flex: 1 1 460px; }
.state-panel { flex: 1 1 300px; max-height: 60vh; overflow: auto; margin: 0;
  padding: var(--s2); border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--ink); color: var(--dim); font: var(--t-xs)/1.35 var(--mono);
  white-space: pre; }
.playnote { font-size: var(--t-sm); margin: var(--s2) 0; }
.draft-notice { background: var(--line); border: 1px solid var(--amber);
  color: var(--bright); border-radius: var(--r-md); padding: var(--s2) var(--s3);
  margin-bottom: var(--s2); font-size: var(--t-md); }
.files .delta { color: var(--amber); margin-left: var(--s2); }
.files pre { max-height: 300px; overflow: auto; font-size: var(--t-xs); }

/* ==== the transcript ====================================================== */
.chat-status { font-size: var(--t-sm); color: var(--dim); padding: 5px var(--s1); }
.chat-status.running { color: var(--amber); }
.chat-status.failed { color: var(--bad); }
.chat-log { overflow-y: auto; max-height: 68dvh; display: flex;
  flex-direction: column; padding: var(--s3) var(--s3) var(--s2);
  background: var(--well); border: 1px solid var(--line); border-radius: var(--r-lg); }
/* one group per run: a run is a whole conversation, not a turn in a stream */
#chat-runs { display: flex; flex-direction: column; gap: var(--s2); }
.run > summary { cursor: pointer; font-size: var(--t-sm); color: var(--dim);
  padding: var(--s2) var(--s2); border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--ink); }
.run[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.run > summary b { color: var(--text); font-weight: normal; }
.run.live > summary { color: var(--amber); border-color: #4a3a24; }
.run.legacy > summary { color: #5c5568; }
.run[open] .chat-log { border-top-left-radius: 0; border-top-right-radius: 0; }
.transcript { margin: 10px 0; }
.transcript > summary { font-size: var(--t-sm); padding: var(--s1) 0; }
/* console register: >-prompted user lines open a turn; everything is a log line */
.msg { font-size: var(--t-md); margin: 2px 0; }
.msg.user { margin-top: var(--s3); padding-top: 10px; border-top: 1px solid #221c2e;
  color: var(--amber); }
.msg.user:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.msg.user .ps1 { margin-right: var(--s2); color: #8a6a3e; }
.msg.user .msg-body { white-space: pre-wrap; }
.msg.assistant .msg-body { color: #d3d6e0; }
.msg.assistant .msg-body p { margin: var(--s2) 0; }
.msg.notice .msg-body { color: #b08a4e; font-size: var(--t-sm); }
.msg .tool-line { font-size: var(--t-sm); color: var(--faint); margin: 1px 0 1px 2px; }
.msg .tool-line b { color: var(--dim); font-weight: normal; }
.msg img.frame { max-width: 100%; border: 1px solid var(--line);
  border-radius: var(--r-sm); image-rendering: pixelated; margin: 3px 0; }
.msg img.pause-shot { max-width: 180px; display: block; }
.tool-card { margin: 2px 0 2px 2px; font-size: var(--t-sm); }
.tool-card summary { cursor: pointer; list-style: none; display: flex; gap: var(--s2);
  align-items: baseline; color: var(--dim); }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card .t-ico { width: 18px; text-align: center; }
.tool-card b { color: var(--text); font-weight: normal; }
.tool-card .t-sum { color: var(--faint); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 46ch; }
.tool-card .t-state { margin-left: auto; }
.tool-card .t-run { color: #5c5568; font-size: var(--t-xs); margin: 2px 0 0 24px; }
.tool-card.ok .t-state { color: var(--good); }
.tool-card.err .t-state, .tool-card.err b { color: var(--bad); }
.tool-card[open] summary { color: var(--text); }
.tool-card pre { max-height: 240px; overflow: auto; font-size: var(--t-xs);
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: var(--s2) var(--s2); margin: var(--s1) 0; }

/* mobile: the log is the page — it can't be a scroll box inside a scroll page */
@media (max-width: 900px) {
  .chat-log { max-height: none; overflow: visible; }
}

/* ==== the devlog: the public account of how a game got here =============== */
.devlog { margin: var(--s5) 0; }
.devlog > h2 { font-size: var(--t-base); letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); }
.compose input[type=text], .compose textarea { width: 100%; margin: var(--s1) 0; }
.entry { border-left: 2px solid var(--line); padding: 2px 0 2px var(--s4);
  margin: var(--s4) 0 26px; }
.entry-head h2 { margin: 0; font-size: var(--t-xl); }
.entry-head .muted { margin: 2px 0 10px; font-size: var(--t-sm); }
.entry-body p { margin: var(--s2) 0; }
.entry-body img { max-width: 100%; border: 1px solid var(--line);
  border-radius: var(--r-sm); image-rendering: pixelated; }
.entry-body pre { background: #1c1826; padding: var(--s2) var(--s2);
  border-radius: var(--r-sm); overflow-x: auto; font-size: var(--t-sm); }
.entry-body code { font-size: var(--t-sm); }
.entry-body blockquote { border-left: 2px solid #4a4b63; margin: var(--s2) 0;
  padding-left: var(--s3); color: #a3a8bd; }
.log-head { display: flex; align-items: baseline; gap: var(--s3); }
.log-head .muted { font-size: var(--t-sm); }
.playables { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: var(--s3) 0; }
.playables.options { border: 1px dashed #4a4b63; border-radius: var(--r-md);
  padding: 10px var(--s3); }
.playable { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); }
.playable .diff { font-size: var(--t-xs); }
.changes { margin-top: var(--s2); font-size: var(--t-sm); }
.changes ul { margin: var(--s2) 0 0; padding-left: 18px; }
.changes li { margin: 2px 0; }
.changes code { color: #a3a8bd; }
/* a color's dot in a ledger line. Named apart from the palette editor's .swatch,
   which it used to silently overwrite — same class, two unrelated elements. */
.swatch-dot { display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; border: 1px solid var(--line); vertical-align: middle; }
.entry-feed .entry { margin: var(--s3) 0 var(--s4); }
.entry-feed .entry-head h2 { font-size: var(--t-base); }

/* ==== the palette builder ================================================= */
.swatches { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0; }
.swatch { display: inline-flex; align-items: center; gap: 5px; padding: 3px var(--s2);
  border-radius: var(--r-sm); border: 1px solid var(--line); font-size: var(--t-xs);
  background: var(--well); }
.swatch i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); }
.swatch button { background: none; color: var(--faint); border: none; padding: 0 2px;
  cursor: pointer; font-size: var(--t-xs); }
.swatch button:hover { color: var(--bad); }
.palette-add { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap;
  margin-bottom: 10px; }
.palette-add input[type=text] { flex: 1; min-width: 120px; margin: 0; }
.upload-pal { display: inline-flex; }
/* the in-page color picker (native color inputs are swatch-grid dialogs on linux) */
.picker { margin: var(--s2) 0 10px; max-width: 360px; }
.picker .sv { position: relative; height: 132px; border-radius: var(--r-md);
  border: 1px solid var(--line); touch-action: none; cursor: crosshair;
  background-image: linear-gradient(to top, #000, transparent),
                    linear-gradient(to right, #fff, transparent); }
.picker .hue { position: relative; height: 20px; margin-top: 10px;
  border-radius: var(--r-pill); touch-action: none; cursor: ew-resize;
  border: 1px solid var(--line);
  background: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00); }
.picker .thumb { position: absolute; width: 16px; height: 16px; border-radius: var(--r-pill);
  border: 2px solid var(--bright); box-shadow: 0 0 0 1px var(--ink);
  transform: translate(-50%, -50%); pointer-events: none; top: 50%; }
.picker .sv .thumb { background: transparent; }
.pick-row { display: flex; gap: var(--s2); align-items: center; margin-top: 10px; }
.pick-row .preview { width: 36px; height: 36px; border-radius: var(--r-md);
  border: 1px solid var(--line); }
.pick-row input.hex { width: 110px; flex: none; margin: 0; text-transform: lowercase; }

/* the new-game form's read-only roll: three colors, one link, no picker */
.roll-strip { display: flex; align-items: center; gap: var(--s3); margin: var(--s1) 0 var(--s3); }
.roll-strip .chips { display: flex; gap: var(--s2); }
.roll-strip i { width: 26px; height: 26px; border-radius: var(--r-sm);
  border: 1px solid var(--line); display: block; }

/* ==== playtesting ========================================================= */
/* the capture surface is a bare shell page (app/views/playtests/new.html.erb);
   these style the REVIEW screen */
.playtest-review .pt-row { display: flex; align-items: center; gap: 10px;
  margin: var(--s2) 0; }
.playtest-review .pt-frame { color: var(--faint); font-size: var(--t-sm); min-width: 44px; }
.playtest-review .pt-thumb { width: 72px; border: 1px solid var(--line);
  image-rendering: pixelated; }
.playtest-review .pt-body { flex: 1; margin: 0; }
.playtest-review textarea { width: 100%; }

/* ==== docs ================================================================ */
.docs { display: flex; gap: 28px; align-items: flex-start; }
.docs-nav { position: sticky; top: 20px; display: flex; flex-direction: column;
  gap: var(--s2); min-width: 130px; border-right: 1px solid var(--line);
  padding-right: var(--s4); }
.docs-nav a.current { color: var(--bright); font-weight: bold; }
.docs-body { max-width: 660px; min-width: 0; }
.docs-body h1 { font-size: 24px; }
.docs-body h2 { margin-top: 28px; }
.docs-body pre, .docs-body code { background: var(--well); border-radius: var(--r-sm); }
.docs-body code { padding: 1px 5px; color: var(--amber); font-size: var(--t-md); }
.docs-body pre { border: 1px solid var(--line); padding: var(--s3) var(--s3);
  overflow-x: auto; }
.docs-body pre code { background: none; border: none; padding: 0; color: var(--text); }
.docs-body table { border-collapse: collapse; margin: var(--s3) 0; }
.docs-body th, .docs-body td { border: 1px solid var(--line);
  padding: var(--s2) var(--s3); text-align: left; }
.docs-body th { color: var(--bright); }
.docs-body a { text-decoration: underline; }
