:root {
  --bg: #121419;
  --pane: #1a1d24;
  --pane-2: #222631;
  --line: #2d3240;
  --ink: #e6e2d8;
  --ink-2: #9aa0ad;
  --ink-3: #646b7a;
  --amber: #e8a33d;
  --green: #4fbf73;
  --red: #e0584b;
  --blue: #5b93e6;
  --violet: #a07de0;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--ink); background: var(--pane-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input:focus, textarea:focus { outline: 1px solid var(--amber); border-color: var(--amber); }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 14px; height: 44px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--pane); }
.brand { font: 600 15px var(--mono); color: var(--amber); text-decoration: none; letter-spacing: 0.04em; }
.tagline { color: var(--ink-3); }
.spacer { flex: 1; }
.status { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; }
.top-btn { background: var(--pane-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
.top-btn:hover { border-color: var(--ink-3); }
.top-btn:disabled, .top-btn:disabled:hover { opacity: 0.45; cursor: not-allowed; border-color: var(--line); }
a.top-btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
.top-btn.primary { background: var(--amber); color: #1a1408; border-color: var(--amber); font-weight: 600; }
.top-actions { position: relative; }
.more-btn { display: none; }
.game-card-fine { font-size: 13px; color: var(--ink-3) !important; margin-top: 2px !important; }
.history { display: none; position: absolute; right: 0; top: 36px; z-index: 10; width: 440px; max-height: 60vh; overflow-y: auto; background: var(--pane); border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.history.on { display: block; }
.history-head { color: var(--ink-3); font: 12px var(--mono); padding: 2px 4px 8px; }
.history-row { display: flex; gap: 8px; align-items: center; padding: 5px 4px; border-top: 1px solid #20242d; }
.history-n { font: 12px var(--mono); color: var(--amber); flex: 0 0 32px; }
.history-label { flex: 1; font-size: 13px; }
.history-label em { color: var(--ink-3); font-style: normal; font-size: 12px; }

.light { display: inline-flex; align-items: center; gap: 6px; font: 600 12px var(--mono); letter-spacing: 0.05em; }
.light i { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.light em { font-style: normal; font-weight: 400; color: var(--ink-2); }
.people i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.life.asleep i { background: var(--blue); }
.life.thinking i { background: var(--violet); box-shadow: 0 0 10px var(--violet); animation: pulse 1s ease-in-out infinite; }
.life.resting i { background: var(--amber); }
.life.error i { background: var(--red); box-shadow: 0 0 8px var(--red); }
@keyframes pulse { 50% { opacity: 0.35; } }
.status-detail { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- the frame ---------- */
body.frame-page { display: flex; flex-direction: column; height: 100vh; }
body.frame-page > .top { flex: none; }
.frame {
  display: grid; gap: 8px; padding: 8px; flex: 1; min-height: 0;
  grid-template-columns: minmax(0, 1fr) 320px 400px;
  grid-template-rows: minmax(0, 1.9fr) minmax(0, 1fr);
  grid-template-areas: "stage chat insp" "wb chat insp";
}
/* The view lays the grid out for what shows (frame.js laidOut); a hidden pane takes no room. */
.frame .pane.off { display: none; }
.pane { background: var(--pane); border: 1px solid var(--line); border-radius: 10px; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.stage-pane { grid-area: stage; background: #08090c; }
.wb-pane { grid-area: wb; }
.wb-pane.wb-big { position: fixed; inset: 56px 16px 16px; z-index: 40; box-shadow: 0 10px 40px #000a; }
.chat-pane { grid-area: chat; }
.insp-pane { grid-area: insp; }
.art-pane { grid-area: art; }
.photos-pane { grid-area: photos; }
.store-pane { grid-area: store; }
.panel-label { display: flex; justify-content: space-between; align-items: center; }
.panel-close { background: none; border: 0; color: var(--ink-3); font: inherit; cursor: pointer; padding: 0 2px; }
.panel-close:hover { color: var(--ink); }
.panel-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }

/* stage */
.stage-wrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; outline: none; }
.stage-wrap:focus-visible { box-shadow: inset 0 0 0 1px var(--amber); }
.stage-layers { position: relative; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.stage-layers canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: auto; }
/* (crisp only at a whole number of screen pixels to each of the game's: stage.js fit) */
.stage-layers.crisp canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.stage-gl { display: none; }
.stage-gl.on { display: block; }
.stage-halt { display: none; position: absolute; inset: auto 12px 12px 12px; padding: 10px 12px; background: rgba(60, 16, 14, 0.92); border: 1px solid var(--red); border-radius: 8px; font: 12px var(--mono); gap: 10px; align-items: center; }
.stage-halt.on { display: flex; }
.stage-halt div { flex: 1; white-space: pre-wrap; }
.stage-halt button { background: var(--red); border: 0; border-radius: 6px; padding: 4px 10px; color: #fff; }

/* touch pad */
.pad { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 10px; gap: 12px; touch-action: none; user-select: none; -webkit-user-select: none; }
.pad-arrows { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 46px); gap: 6px; }
.pad-btn { background: var(--pane-2); border: 1px solid var(--line); border-radius: 10px; color: var(--ink-2); font-size: 16px; touch-action: none; -webkit-tap-highlight-color: transparent; }
.pad-btn.on { background: var(--amber); color: #1a1408; border-color: var(--amber); }
.pad-space { width: 96px; height: 96px; border-radius: 50%; font: 600 13px var(--mono); }

/* whiteboard */
.pane-label { padding: 5px 10px; font: 11px var(--mono); color: var(--ink-3); border-bottom: 1px solid var(--line); }
.wb-holder { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #2a2d36; padding: 6px; }
.wb-canvas { touch-action: none; cursor: crosshair; border-radius: 4px; }
.wb-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.wb-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.wb-swatch.on, .wb-custom.on { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.wb-group { display: flex; align-items: center; gap: 4px; padding-right: 6px; border-right: 1px solid var(--line); }
.wb-colors { flex-wrap: wrap; gap: 3px; max-width: 100%; }
.wb-tool, .wb-size { min-width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; background: var(--pane-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; color: var(--ink-2); font-size: 15px; }
.wb-tool.on, .wb-size.on { border-color: var(--amber); color: var(--amber); }
.wb-size i { display: block; border-radius: 50%; border: 1px solid #0006; }
.wb-custom { width: 26px; height: 24px; padding: 0; border: 2px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.wb-btn { background: var(--pane-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; }
.wb-btn.primary { background: var(--amber); color: #1a1408; border-color: var(--amber); font-weight: 600; }
.wb-baton { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.wb-note { width: 180px; padding: 3px 8px; }
.wb-seen { color: var(--ink-3); font: 12px var(--mono); }
.wb-turn { color: var(--violet); font: 12px var(--mono); }

/* chat */
.chat-log { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 92%; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-who { font: 11px var(--mono); color: var(--ink-3); }
.chat-text { white-space: pre-wrap; padding: 6px 10px; border-radius: 10px; background: var(--pane-2); text-align: left; }
.chat-msg.mine .chat-text { background: #3a2e19; }
.chat-input { margin: 0; resize: none; flex: 1; min-width: 0; }
.chat-making { display: none; margin: 6px 8px 0; font: 12px var(--mono); color: var(--ink-3); }
.chat-making.on { display: block; }
.chat-making-words { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.chat-making-words span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-making-words span:last-child { flex: none; white-space: nowrap; }
.chat-making-bar { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.chat-making-bar i { display: block; height: 100%; background: var(--amber); transition: width 1s linear; }
.chat-send-row { display: flex; gap: 6px; align-items: stretch; margin: 8px; }
.chat-send { background: var(--amber); color: #1a1408; border: 0; border-radius: 6px; padding: 0 14px; font-weight: 600; }
.chat-mic { background: var(--pane-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; font-size: 18px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chat-mic.on { background: var(--red); border-color: var(--red); box-shadow: 0 0 0 3px rgba(224, 88, 75, 0.35); }
.chat-mic.busy { opacity: 0.6; }
.chat-starter { margin: auto 0 0; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; }
.chat-starter p { margin: 0; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-chip { background: var(--pane-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; color: var(--ink); }
.chat-chip:hover { border-color: var(--amber); }
.chat-starter-fine { font-size: 12px; color: var(--ink-3); }
.chat-notice { align-self: center; max-width: 90%; padding: 6px 12px; border-radius: 999px; background: var(--pane-2); color: var(--ink-2); font-size: 12px; text-align: center; }
.link-btn.inline { flex: none; display: inline; color: var(--amber); }

/* inspector */
.insp-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); }
.insp-tab { background: none; border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; color: var(--ink-2); font: 12px var(--mono); }
.insp-tab.on { border-color: var(--line); background: var(--pane-2); color: var(--ink); }
.insp-tab.fresh::after { content: " •"; color: var(--amber); }
.insp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.insp-edit { flex: 1; margin: 6px; resize: none; font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.insp-bar { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 8px; color: var(--ink-3); font: 12px var(--mono); }
.insp-store { flex: 1; margin: 6px; padding: 8px; overflow: auto; font: 12px/1.5 var(--mono); color: var(--ink-2); background: var(--pane-2); border-radius: 6px; }
.insp-fault { margin: 6px 6px 0; padding: 6px 8px; border: 1px solid var(--red); border-radius: 6px; color: #f3b3ab; font: 12px var(--mono); }
.doings { flex: 1; overflow-y: auto; padding: 6px; }
.doing { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px solid #20242d; }
.doing-kind { flex: 0 0 56px; font: 11px var(--mono); color: var(--ink-3); padding-top: 1px; }
.doing pre { margin: 0; flex: 1; white-space: pre-wrap; word-break: break-word; font: 12px/1.45 var(--mono); color: var(--ink-2); }
.doing.thought pre { color: var(--ink); font-family: var(--sans); font-size: 13px; }
.doing.wake .doing-kind { color: var(--violet); }
.doing.fault pre, .doing.fault .doing-kind { color: var(--red); }
.doing.changed .doing-kind { color: var(--amber); }
.doing.shard .doing-kind { color: var(--green); }
.cover { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(8, 9, 12, 0.82); padding: 16px; }
.cover-box { max-width: 440px; background: var(--pane); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-wrap: wrap; gap: 10px; }
.cover-box p { flex: 1 0 100%; margin: 0 0 6px; }
/* a link as a QR code (a private game's copy for another device) */
canvas.qr { display: block; width: 200px; height: 200px; margin: 12px auto 0; border-radius: 6px; image-rendering: pixelated; }
.cover-box { position: relative; }
.working { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; padding: 20px; text-align: center; border-radius: 12px; background: rgba(26, 29, 36, 0.92); color: var(--ink); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--amber); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cover-box a { text-decoration: none; display: inline-flex; align-items: center; }
.game-card { flex: 1 0 100%; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.game-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }
.game-card strong { font-size: 20px; }
.game-card-by { color: var(--ink-3); font-size: 13px; }
.game-card p.game-card-about { color: var(--ink); }
.game-card p { flex: none !important; margin: 6px 0 0 !important; color: var(--ink-2); }
.frame.playing { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "stage"; }
.top-btn.on { border-color: var(--green); color: var(--green); }
.stage-pane { position: relative; }
.toasts { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; pointer-events: none; z-index: 5; }
.toast { pointer-events: auto; max-width: min(520px, 100%); background: rgba(26, 29, 36, 0.92); border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; transition: opacity 0.8s; }
.toast.gone { opacity: 0; }
.toast-who { font: 11px var(--mono); color: var(--ink-3); }
.boot-fault { color: var(--red); padding: 20px; }

/* ---------- lobby ---------- */
.lobby-main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; display: flex; flex-direction: column; gap: 36px; }
.lobby h2 { margin: 0 0 6px; font: 600 15px var(--mono); color: var(--amber); letter-spacing: 0.03em; }
.hint { color: var(--ink-3); margin: 0 0 14px; max-width: 70ch; }
.intro { padding: 12px 0 4px; }
.intro h1 { margin: 8px 0 12px; font: 700 clamp(30px, 5.4vw, 52px)/1.1 var(--sans); letter-spacing: -0.01em; }
.intro-lead { margin: 0; color: var(--ink); font-size: clamp(17px, 2vw, 20px); max-width: 52ch; }
.steps { list-style: none; margin: 24px 0 18px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.step { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--pane); border: 1px solid var(--line); border-radius: 12px; }
.step strong { font-size: 16px; }
.step span:last-child { color: var(--ink-2); }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--amber); color: #1a1408; font: 700 14px/26px var(--sans); text-align: center; margin-bottom: 4px; }
.intro-fine { margin: 0; color: var(--ink-3); font-size: 13px; max-width: 75ch; }
@media (max-width: 700px) { .steps { grid-template-columns: 1fr; gap: 4px; margin: 14px 0 12px; } .step { display: grid; grid-template-columns: 26px 1fr; column-gap: 12px; align-items: center; padding: 2px 0; background: none; border: 0; } .step-n { margin: 0; } .step span:last-child { display: none; } }
/* the hero's demo: a real change, before and after */
.intro-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; align-items: center; }
@media (max-width: 860px) { .intro-top { grid-template-columns: 1fr; gap: 18px; } }
.demo { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.demo-screen { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #08090c; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); }
.demo-screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.demo-after { animation: demo-after 10s ease-in-out infinite; }
.demo-ask { position: absolute; left: 10px; bottom: 10px; max-width: 72%; padding: 8px 12px; border-radius: 12px 12px 12px 4px; background: rgba(36, 31, 20, 0.94); border: 1px solid var(--amber); font-size: 14px; display: flex; flex-direction: column; gap: 2px; animation: demo-ask 10s ease-in-out infinite; }
.demo-ask span { font: 11px var(--mono); color: var(--amber); }
.demo-tag { position: absolute; left: 50%; transform: translateX(-50%); top: 10px; padding: 2px 8px; border-radius: 999px; background: rgba(8, 9, 12, 0.7); font: 11px var(--mono); color: var(--ink-2); }
.demo-tag.before { animation: demo-before-tag 10s ease-in-out infinite; }
.demo-tag.after { animation: demo-after 10s ease-in-out infinite; color: var(--amber); }
.demo figcaption { color: var(--ink-3); font-size: 13px; }
@keyframes demo-after { 0%, 42% { opacity: 0; } 50%, 92% { opacity: 1; } 100% { opacity: 0; } }
@keyframes demo-before-tag { 0%, 42% { opacity: 1; } 50%, 92% { opacity: 0; } 100% { opacity: 1; } }
@keyframes demo-ask { 0%, 12% { opacity: 0; transform: translateY(8px); } 18%, 70% { opacity: 1; transform: none; } 78%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .demo-after, .demo-tag.after, .demo-ask { animation: none; opacity: 1; } .demo-tag.before { display: none; } }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cards-all { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }   /* every game: smaller cards, more to a row */
.more-games { display: block; margin: 14px auto 0; }
.more-games[hidden] { display: none; }
.cards-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 260px); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.card { display: flex; flex-direction: column; background: var(--pane); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; color: var(--ink); text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.card:hover { border-color: var(--amber); transform: translateY(-2px); }
.thumb { aspect-ratio: 16 / 9; background: radial-gradient(circle at 30% 25%, hsl(var(--hue, 250) 45% 30%), transparent 60%), linear-gradient(135deg, hsl(var(--hue, 250) 35% 16%), hsl(calc(var(--hue, 250) + 50) 35% 12%)); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; display: block; }
.thumb-name { font: 800 clamp(40px, 7vw, 64px) var(--sans); color: hsl(var(--hue, 250) 55% 70% / 0.55); text-shadow: 0 2px 16px rgba(0, 0, 0, 0.4); }
/* a game's name in place of a picture it never has (a private game) */
.thumb .thumb-words, .yours-row .thumb .thumb-words { font: 700 15px/1.2 var(--sans); color: hsl(var(--hue, 250) 55% 82% / 0.9); text-align: center; padding: 0 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card-text { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 12px; }
.card-text strong { font-size: 15px; }
.card.big .card-text strong { font-size: 17px; }
.card-given { font: 11px var(--mono); color: var(--ink-3); }
.card-from { font-size: 12px; color: var(--ink-3); }
.card-note { color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-facts { color: var(--ink-3); font-size: 12px; }
.seed-btn { background: var(--pane-2); border: 1px solid var(--amber); color: var(--amber); border-radius: 8px; padding: 8px 16px; font-weight: 600; }
.seed-btn:hover { background: var(--amber); color: #1a1408; }
.make-banner { display: flex; align-items: center; gap: 14px; margin: 12px 0 4px; padding: 14px 18px; background: var(--pane); border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 10px; }
.make-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--amber); animation: make-pulse 2.4s ease-in-out infinite; }
@keyframes make-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 163, 61, 0.55); transform: scale(0.85); } 50% { box-shadow: 0 0 0 9px rgba(232, 163, 61, 0); transform: scale(1); } }
.make-text { flex: 1; min-width: 0; color: var(--ink-2, var(--ink)); }
.make-text strong { color: var(--ink); }
.make-go { flex: none; padding: 10px 18px; }
@media (prefers-reduced-motion: reduce) { .make-dot { animation: none; } }
@media (max-width: 640px) { .make-banner { padding: 10px 12px; gap: 10px; } .make-text span { display: none; } .make-go { padding: 8px 12px; } }
.me { color: var(--ink-3); font-size: 12px; display: flex; gap: 4px; align-items: center; }
.me-name { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline dotted; }
.name-input { flex: 1 1 200px; }
.hint-bar { display: flex; gap: 10px; align-items: center; padding: 8px 14px; background: #241f14; border-bottom: 1px solid #4a3a1a; color: var(--ink); font-size: 13px; }
.hint-bar span { flex: 1; }
.history-head { display: flex; gap: 10px; align-items: flex-start; }
.history-head span { flex: 1; }

@media (max-width: 900px) {
  body.frame-page { height: auto; min-height: 100vh; }
  .frame.playing { grid-template-rows: auto; height: auto; }
  .frame.playing .stage-wrap { min-height: 55vh; }
  .frame:not(.playing) { height: auto; }
  .stage-wrap { min-height: 32vh; }
  .top { height: auto; min-height: 44px; flex-wrap: wrap; padding: 6px 10px; gap: 8px; }
  .status { flex: 1 1 100%; order: 3; }
  .top-actions { margin-left: auto; flex-wrap: wrap; }
  .top-actions:not(.more-open) .top-btn.more { display: none; }
  .top-actions .more-btn { display: inline-flex; }
  .history { width: calc(100vw - 20px); right: -4px; }
  .wb-note { width: 120px; }
  .tagline { display: none; }
  .status-detail, .chat-head-detail { display: none; }
  .status .people { display: none; }
}

/* the sandbox holds the ludant and shows nothing */
iframe.sandbox { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }

/* the cost meter, and the frame's banners (asking to connect, checking in) */
.spend { margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; color: var(--ink-2); font: 12px var(--mono); }
.spend.warm { color: var(--amber); border-color: var(--amber); }
.spend.hot { color: var(--red); border-color: var(--red); }
.spend.connect { background: var(--amber); border-color: var(--amber); color: #1a1408; font: 600 13px var(--sans); padding: 3px 10px; }
.meter-pop { position: fixed; top: 48px; right: 12px; z-index: 40; width: min(380px, calc(100vw - 24px)); background: var(--pane); border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); font-size: 13px; }
.meter-pop p { margin: 0 0 8px; color: var(--ink-2); }
.meter-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--ink-2); }
.meter-every { width: 80px; padding: 2px 6px; }
.banner { position: fixed; left: 50%; top: 56px; transform: translateX(-50%); z-index: 45; width: min(520px, calc(100vw - 24px)); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--pane); border: 1px solid var(--amber); border-radius: 10px; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.banner p { flex: 1 0 100%; margin: 0 0 4px; }
.banner a { text-decoration: none; }
.stage-starved { display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 8px 12px; background: rgba(26, 29, 36, 0.92); border: 1px solid var(--line); border-radius: 8px; font: 12px var(--mono); color: var(--ink-2); }
.stage-starved.on { display: block; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); min-height: 34px; }
.chat-head-detail { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .light { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.chat-head .chat-head-detail { flex: 1 10 0; min-width: 0; }
.chat-thinking .chat-text { color: var(--ink-3); font-style: italic; }
.chat-thinking .wait-card { display: flex; flex-direction: column; gap: 3px; font-style: normal; min-width: 220px; }
.wait-now, .wait-step { display: flex; gap: 10px; justify-content: space-between; }
.wait-now { color: var(--ink-2); font-style: italic; }
.wait-total { font: 11px var(--mono); color: var(--ink-3); text-align: right; opacity: 0.8; }
.wait-clock { font-family: var(--mono, monospace); font-style: normal; font-size: 12px; color: var(--ink-3); }
.wait-step { font-size: 12.5px; color: var(--ink-3); }
.wait-step .wait-clock { font-size: 11px; }
.wait-step.more { font-style: italic; }
.wait-step.failed { color: var(--red, #e06c6c); }
.dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- device check: readable from the couch ---------- */
body.check { font-size: 20px; }
.check-main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.check-card { background: var(--pane); border: 1px solid var(--line); border-radius: 14px; padding: 24px 28px; margin-bottom: 24px; }
.check-card h2 { margin: 0 0 10px; font: 600 32px var(--sans); color: var(--amber); }
.check-text { font-size: 24px; margin: 0 0 16px; max-width: 46ch; }
.check-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.check-btn { font-size: 22px; padding: 12px 22px; border-radius: 10px; background: var(--pane-2); border: 2px solid var(--line); }
.check-btn.primary { background: var(--amber); color: #1a1408; border-color: var(--amber); font-weight: 600; }
.check-btn:focus { outline: 3px solid var(--blue); }
.check-id { color: var(--ink-3); font: 13px var(--mono); }
.check-main h3 { font: 600 15px var(--mono); color: var(--ink-3); }
.check-pad { margin-bottom: 14px; font-size: 15px; color: var(--ink-2); }
.check-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.check-b { font: 13px var(--mono); padding: 4px 8px; border-radius: 6px; background: var(--pane-2); border: 1px solid var(--line); }
.check-b.on { background: var(--green); color: #0d1a10; border-color: var(--green); }
.check-axes { font: 13px var(--mono); color: var(--ink-3); }
.check-none, .check-keys { color: var(--ink-3); font-size: 15px; margin-top: 6px; }
.check-meter { height: 22px; background: var(--pane-2); border-radius: 11px; overflow: hidden; max-width: 600px; }
.check-meter i { display: block; height: 100%; width: 0; background: var(--green); transition: width 0.05s; }
.check-summary { font: 13px var(--mono); color: var(--ink-2); white-space: pre-wrap; max-height: 50vh; overflow: auto; }
/* the ludant playing itself: its color on the stage's edge, and jumps ahead announced */
.stage-layers { transition: box-shadow 0.25s; }
.stage-layers.ludant-playing { box-shadow: 0 0 0 3px var(--violet), 0 0 22px 2px rgba(160, 125, 224, 0.55); }
.stage-flash { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 6px 12px; border-radius: 8px; background: rgba(26, 29, 36, 0.9); border: 1px solid var(--violet); color: var(--ink); font: 13px var(--mono); opacity: 0; pointer-events: none; }
.stage-flash.on { animation: flash 2.4s ease-out forwards; }
@keyframes flash { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
/* controllers: where the controller is, and what it has focused on the page */
.pad-focus { outline: 3px solid var(--amber) !important; outline-offset: 2px; }
.pad-chip { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; padding: 8px 14px; border-radius: 10px; background: rgba(26, 29, 36, 0.94); border: 1px solid var(--amber); font: 14px var(--mono); color: var(--ink); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.pad-chip.on { opacity: 1; }
.lobby-tip { color: var(--ink-3); font-size: 13px; }
.keep-box { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; background: #241f14; border: 1px solid #4a3a1a; border-radius: 12px; }
.keep-box p { flex: 1 1 100%; margin: 0; }
.tip-bar { max-width: 1100px; margin: 10px auto 0; padding: 0 16px; }
.card-published { font-size: 12px; color: var(--green); }
.stage-layers.rebuilt { animation: rebuilt 1.6s ease-out; }
@keyframes rebuilt { 0% { box-shadow: 0 0 0 4px var(--amber), 0 0 30px 4px rgba(232, 163, 61, 0.7); } 100% { box-shadow: 0 0 0 0 transparent; } }
/* your games: the ones you shape, and how each shared one is doing */
.yours-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 14px; }
.yours { display: flex; flex-direction: column; gap: 8px; background: var(--pane); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.yours-row { display: flex; gap: 12px; align-items: center; padding: 4px; border-radius: 8px; border: 1px solid transparent; color: var(--ink); text-decoration: none; }
.yours-row:hover { border-color: var(--amber); }
.yours-row .thumb { flex: 0 0 112px; width: 112px; border-radius: 6px; overflow: hidden; }
.yours-row .thumb-name, .tree-head .thumb-name { font-size: 26px; }
.yours-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.yours-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.yours-where { font: 11px var(--mono); color: var(--ink-3); }
.yours-where.shared { color: var(--green); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { display: flex; align-items: baseline; gap: 8px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2); text-decoration: none; transition: border-color 0.15s; }
.stat:hover { border-color: var(--amber); }
.stat strong { font: 700 22px var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; }
/* a game's tree (line.html) */
.tree-head { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 20px; align-items: start; }
.tree-head .thumb { border-radius: 10px; overflow: hidden; }
.tree-text { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tree-text h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); text-wrap: balance; }
.tree-text .card-from a { color: var(--amber); }
.tree-text .stats { max-width: 360px; }
.tree-text .seed-btn { align-self: flex-start; text-decoration: none; }
.versions-wrap { overflow-x: auto; }
.versions { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.versions th { text-align: left; font: 11px var(--mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); }
.versions td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .tree-head { grid-template-columns: 1fr; } }

/* choices: options over the stage */
.choices-panel { position: absolute; inset: 12px; z-index: 8; display: flex; flex-direction: column; gap: 12px; padding: 16px; background: rgba(14, 16, 21, 0.94); border: 1px solid var(--amber); border-radius: 12px; overflow: auto; }
.choices-head { display: flex; flex-direction: column; gap: 2px; }
.choices-head strong { font-size: 20px; }
.choices-who { font: 11px var(--mono); color: var(--ink-3); }
.choices-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); flex: 1; align-content: start; }
.choice { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--pane-2); border: 2px solid var(--line); border-radius: 10px; text-align: left; }
.choice:hover, .choice.pad-focus { border-color: var(--amber); }
.choice img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #0a0c10; border-radius: 6px; }
.choice-label { font-size: 16px; font-weight: 600; }
.choice-note { color: var(--ink-3); font-size: 13px; }
.choices-foot { display: flex; justify-content: flex-end; }
.choices-said { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8; padding: 10px 16px; border-radius: 10px; background: rgba(26, 29, 36, 0.94); border: 1px solid var(--green); font-size: 16px; }
/* the inspector's art gallery */
.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 8px; overflow: auto; }
.art-item { margin: 0; background: var(--pane-2); border-radius: 8px; padding: 6px; }
.art-item img { width: 100%; aspect-ratio: 1; object-fit: contain; background: repeating-conic-gradient(#2a2e38 0 25%, #20232b 0 50%) 0 0 / 16px 16px; border-radius: 4px; }
.art-item figcaption { font: 11px var(--mono); color: var(--ink-3); display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.art-item figcaption strong { color: var(--ink); }
.photo-item { position: relative; }
.photo-item img { object-fit: cover; background: none; }
.photo-remove { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgb(0 0 0 / 0.6); color: #fff; cursor: pointer; font-size: 13px; }
.photo-remove:hover { background: #b3261e; }
.photo-why { font-style: italic; }
.art-item figcaption span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.art-model { cursor: pointer; }
.art-model:hover { outline: 1px solid var(--amber); }
.mv-cover { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.mv-panel { background: var(--pane); border: 1px solid var(--line); border-radius: 10px; width: min(860px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.mv-head { display: flex; align-items: baseline; gap: 6px; font: 12px var(--mono); color: var(--ink-3); }
.mv-head strong { color: var(--ink); font-size: 14px; }
.mv-close { margin-left: auto; background: none; border: 0; color: var(--ink-2); font-size: 16px; cursor: pointer; }
.mv-canvas { width: 100%; height: min(60vh, 520px); border-radius: 6px; touch-action: none; cursor: grab; display: block; }
.mv-canvas:active { cursor: grabbing; }
.mv-buttons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mv-buttons .wb-btn.on { border-color: var(--amber); color: var(--amber); }
.mv-label { font: 11px var(--mono); color: var(--ink-3); }
.mv-gap { flex: 1; }
.mv-note { margin: 0; font: 11px var(--mono); color: var(--ink-3); }
.insp-empty { color: var(--ink-3); padding: 12px; }
.wb-btn.danger, .top-btn.danger { border-color: var(--red); color: #f3b3ab; }
.top-btn.danger:hover, .wb-btn.danger:hover { background: var(--red); color: #fff; }
.history-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 4px 2px; border-top: 1px solid #20242d; margin-top: 4px; }

/* play mode on a phone: the stage fills the screen */
.full-bar { display: none; }
body.fullplay { overflow: hidden; height: 100vh; height: 100dvh; min-height: 0; }
body.fullplay > .top, body.fullplay .hint-bar { display: none; }
body.fullplay .frame, body.fullplay .frame.playing { position: fixed; inset: 0; z-index: 40; padding: 0; height: auto; grid-template-rows: minmax(0, 1fr); }
body.fullplay .stage-pane { border: 0; border-radius: 0; }
body.fullplay .stage-wrap { min-height: 0; }
body.fullplay .full-bar { display: flex; gap: 6px; position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); z-index: 6; }
.full-btn { width: 36px; height: 36px; border-radius: 50%; background: rgba(26, 29, 36, 0.7); border: 1px solid var(--line); color: var(--ink-2); font-size: 16px; }
.full-btn[hidden] { display: none; }
/* what it's costing, where the top bar isn't: the stage's top left */
.cost-chip { display: none; position: absolute; z-index: 6; top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); height: 36px; padding: 0 12px; border-radius: 18px; background: rgba(26, 29, 36, 0.7); border: 1px solid var(--line); font: 13px var(--mono); color: var(--ink-2); }
body.fullplay .cost-chip { display: block; }
body.fullplay .cost-chip[hidden] { display: none; }
.cost-chip.warm { color: var(--amber); border-color: var(--amber); }
.cost-chip.hot { color: var(--red); border-color: var(--red); }
/* playing: the way to the chat stays on the stage */
.talk-float { display: none; position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 6; padding: 8px 16px; border-radius: 999px; background: rgba(26, 29, 36, 0.85); border: 1px solid var(--amber); color: var(--ink); font-size: 14px; font-weight: 600; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); }
.talk-float:hover { background: var(--amber); color: #1a1408; }
.frame.no-chat .talk-float { display: block; }
body.fullplay .talk-float { bottom: auto; left: auto; transform: none; top: max(8px, env(safe-area-inset-top)); right: calc(max(8px, env(safe-area-inset-right)) + 84px); padding: 7px 14px; }
/* on a phone, the first sitting's hint floats over the game */
.hint-float { position: absolute; left: 8px; right: 8px; top: 54px; z-index: 7; flex-wrap: wrap; border: 1px solid #4a3a1a; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
.hint-float span { flex: 1 0 100%; }
body.fullplay .hint-bar.hint-float { display: flex; }
/* upright, the game sits just above the controls, like a handheld: eyes and thumbs together */
@media (orientation: portrait) {
  body.fullplay .stage-wrap { align-items: flex-end; padding-bottom: 14px; }
  body.fullplay .marquee { display: flex; }
  body.fullplay .toasts { top: 150px; bottom: auto; }
}
.marquee { display: none; position: absolute; top: 76px; left: 18px; right: 18px; z-index: 4; flex-direction: column; gap: 2px; pointer-events: none; }
.marquee strong { font: 700 26px/1.15 var(--sans); }
.marquee span { color: var(--ink-2); font-size: 14px; }
/* sideways, the pad floats over the game's lower corners */
@media (orientation: landscape) {
  body.fullplay .pad { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); pointer-events: none; z-index: 4; }
  body.fullplay .pad > * { pointer-events: auto; }
  body.fullplay .pad-btn { background: rgba(26, 29, 36, 0.45); border-color: rgba(255, 255, 255, 0.18); }
  body.fullplay .pad-btn.on { background: var(--amber); }
}

/* reporting */
.report-box { flex-direction: column; flex-wrap: nowrap; max-width: 480px; }
.report-reason { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.report-note { width: 100%; background: var(--pane-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; }
.issue-box { max-width: 520px; max-height: 86vh; overflow-y: auto; }
.issue-box p { margin: 0; flex-basis: 100%; }
.issue-title { font-size: 1.1em; font-weight: 600; }
.issue-label { color: var(--ink-2); font-size: 0.85em; margin-top: 4px !important; }
.issue-text { white-space: pre-wrap; }
.issue-with { color: var(--ink-2); font-size: 0.85em; }
.rules { max-width: 680px; margin: 0 auto; padding: 32px 16px 64px; }
.rules li { margin: 6px 0; }
.rules a { color: var(--amber); }
.in-short { padding: 4px 18px 10px; margin: 18px 0; background: var(--pane); border: 1px solid var(--line); border-radius: 12px; }
.in-short h2 { margin-top: 14px !important; }
.lobby-foot { color: var(--ink-3); font-size: 12px; }
.lobby-foot a { color: var(--ink-2); }
.rules h2 { font: 600 15px var(--mono); color: var(--amber); margin: 26px 0 6px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline dotted; flex: 1 0 100%; text-align: left; }
.ask-fail { color: #f3b3ab; font-size: 13px; margin: 0; }
.ask-fail:empty { display: none; }
.share-done { color: var(--green); font-size: 13px; margin: 0; }
.share-done:empty { display: none; }
.recovery-code { flex: 1 0 100%; margin: 0; padding: 10px 12px; background: var(--pane-2); border: 1px solid var(--amber); border-radius: 8px; font: 15px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; user-select: all; }
.me-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.devices { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; background: var(--pane); border: 1px solid var(--line); border-radius: 8px; }
.pair-box { margin-top: 10px; }
.pair-code { font-size: 26px; letter-spacing: 0.12em; text-align: center; }

/* Sharing: the panel (link, private or public, send update) and the ready badge. */
.share-btn.ready { border-color: var(--amber); color: var(--amber); }
.share-row { display: flex; gap: 8px; width: 100%; }
.share-row .share-link { flex: 1; min-width: 0; font: 13px var(--mono); }
.share-about { flex: 1 1 100%; width: 100%; min-height: 6.5em; resize: vertical; font: inherit; line-height: 1.4; }
.share-vis-row { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.share-vis { display: flex; gap: 8px; align-items: baseline; color: var(--ink-2); cursor: pointer; }
.share-vis input { flex: none; }
.share-vis strong { color: var(--ink); flex: none; min-width: 5.5em; white-space: nowrap; }   /* the choice's name on one line, its words beside it */
.share-vis span { flex: 1; min-width: 0; }
.share-follow { color: var(--ink-2); font-size: 14px; }

/* screen.html: just the game, its light, and the mic (screen.js) */
body.screen-page { margin: 0; height: 100vh; overflow: hidden; background: #08090c; }
body.screen-page .stage-pane { position: fixed; inset: 0; display: flex; flex-direction: column; }
.screen-life { position: absolute; top: 12px; left: 12px; z-index: 5; font: 13px var(--mono); background: rgba(26, 29, 36, 0.8); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; }
.screen-life .light em { margin-left: 6px; color: var(--ink-3); font-style: normal; }
.chat-mic.screen-mic { position: absolute; right: 24px; bottom: 24px; z-index: 6; width: 96px; height: 96px; border-radius: 50%; font-size: 40px; padding: 0; }
body.screen-page .toasts { right: 140px; }
