/* Theme colors. These are Midnight's (the default); js/theme-boot.js sets the chosen theme's base colors
   on <html> before the page draws. Everything below the line is mixed from the base colors, so a theme
   only has to set the base. Player colors (--A, --B) are the same in every theme on purpose. */
:root {
  --bg: #17171b; --bg2: #1f1f25; --bg3: #2a2a32; --line: #34343e; --line2: #474753;
  --tx: #ececf1; --tx2: #a7a7b3; --tx3: #7d7d89;
  --acc: #f2b84b; --acc-tx: #1b1405;
  --ok: #5bc48a; --warn: #f2c94c; --bad: #ef6b6b;
  --stage: #26262c; --stage-dot: #2e2e35;
  --r: 10px;
  --A: #F2734B; --B: #4C9BE8;
  color-scheme: dark;
  /* ---- mixed from the above (tools/theme-audit.mjs mixes them the same way) */
  --line3: color-mix(in srgb, var(--tx) 30%, var(--line2));
  --acc-soft: color-mix(in srgb, var(--acc) 16%, var(--bg2));
  --acc-line: color-mix(in srgb, var(--acc) 40%, var(--bg2));
  --hover: color-mix(in srgb, var(--tx) 6%, var(--bg2));
  --row-on: color-mix(in srgb, var(--acc) 12%, var(--bg2));
  --pop: color-mix(in srgb, var(--bg2) 96%, transparent);
  --scrim: color-mix(in srgb, var(--bg) 62%, transparent);
  --label: color-mix(in srgb, var(--bg2) 92%, transparent);
  --label-hover: color-mix(in srgb, var(--tx) 9%, var(--bg2));
  --soft-line: color-mix(in srgb, var(--tx) 25%, transparent);
  --new-bg: color-mix(in srgb, #4C9BE8 22%, var(--bg2)); --new-tx: color-mix(in srgb, #4C9BE8 42%, var(--tx));
  --edit-bg: color-mix(in srgb, #e0a020 22%, var(--bg2)); --edit-tx: color-mix(in srgb, #e0a020 42%, var(--tx));
  --move-bg: color-mix(in srgb, #9b6bff 22%, var(--bg2)); --move-tx: color-mix(in srgb, #9b6bff 42%, var(--tx));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); font: 14px/1.45 var(--font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif); }
/* fancy themes' fonts: the logo and big titles (brand), and headings (head); body text keeps the body font */
.brand, .hero h1 { font-family: var(--font-brand, inherit); }
h1, h2, h3, .ph > span:first-child, .tp-name b, .topbar .theme b, .sv-title b, .banner h2, .handoff b, .partnerhead { font-family: var(--font-head, inherit); }
body { overflow: hidden; }
button { font: inherit; color: inherit; touch-action: manipulation; }
/* It's an app, not a document: no text selection, no long-press menus, no gray flash on taps
   (iPad Safari), no double-tap zoom. Typing boxes stay selectable. */
html { -webkit-tap-highlight-color: transparent; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select, [contenteditable=true] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img, canvas, svg, a { -webkit-user-drag: none; }
*:focus:not(:focus-visible) { outline: none; }
input, select { font: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#app { height: 100%; }

/* ---------- shared bits */
.btn { color: var(--tx); background: var(--bg3); border: 1px solid var(--line2); border-radius: var(--r); padding: 9px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
a.btn { color: var(--tx); text-decoration: none; }
a.btn.primary { color: var(--btn-tx, var(--acc-tx)); }
.btn:hover { border-color: var(--line3); }
.btn.primary { background: var(--btn-bg, var(--acc)); color: var(--btn-tx, var(--acc-tx)); border-color: transparent; background-origin: border-box; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { padding: 13px 22px; font-size: 16px; }
.link { background: none; border: 0; color: var(--tx2); cursor: pointer; padding: 0; font-size: 12px; }
.link:hover { color: var(--tx); text-decoration: underline; }
.ib { background: none; border: 0; color: var(--tx2); cursor: pointer; width: 28px; height: 28px; border-radius: 7px; display: inline-grid; place-items: center; font-size: 17px; }
.ib:hover:not(:disabled) { background: var(--bg3); color: var(--tx); }
.ib.on { background: var(--acc-soft); color: var(--acc); }
.ib:disabled { opacity: .35; cursor: default; }
.chip { background: var(--bg3); border: 1px solid var(--line); color: var(--tx2); border-radius: 999px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.chip.on { background: var(--acc-soft); border-color: var(--acc); color: var(--acc); }
.seg { display: flex; gap: 6px; margin: 6px 0; }
.hint { color: var(--tx2); font-size: 12.5px; margin: 6px 0; }
.tog { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--tx2); cursor: pointer; }
.tog.small { font-size: 11px; font-weight: 400; }
input[type=range] { accent-color: var(--acc); }
input[type=checkbox] { accent-color: var(--acc); }
select { background: var(--bg3); border: 1px solid var(--line2); border-radius: 7px; color: var(--tx); padding: 3px 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.ck { background-color: #fff; background-image: linear-gradient(45deg, #e3e3e3 25%, transparent 25%, transparent 75%, #e3e3e3 75%), linear-gradient(45deg, #e3e3e3 25%, transparent 25%, transparent 75%, #e3e3e3 75%); background-size: 8px 8px; background-position: 0 0, 4px 4px; }

/* ---------- studio layout */
.studio { --tbw: 52px; display: grid; grid-template-columns: var(--tbw) 1fr 292px; grid-template-rows: 52px 1fr; grid-template-areas: "top top top" "tools stage panel"; height: 100%; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--bar-bg, var(--bg2)); color: var(--bar-tx, var(--tx)); border-bottom: 1px solid var(--line); min-width: 0; }
/* text that sits straight on a top bar uses the bar's own text colors (some themes' bars are light or a gradient) */
.topbar .theme small, .topbar .partner, .topbar > .ib, header.bar > .ib, .sv-top .sv-title span, .sv-res small { color: var(--bar-tx2, var(--tx2)); }
.toolbar { grid-area: tools; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 4px; overflow-y: auto; scrollbar-width: none; }
.tgroup { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.tgroup:last-child { border-bottom: 0; }
.tool { width: 40px; height: 36px; background: none; border: 0; border-radius: 8px; color: var(--tx2); cursor: pointer; display: grid; place-items: center; font-size: 20px; }
.tool:hover:not(:disabled) { background: var(--bg3); color: var(--tx); }
.tool.on { background: var(--acc-soft); color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc-line); }
.tool:disabled { opacity: .3; cursor: default; }
.swatch { width: 24px; height: 24px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 0 0 1px #000; display: block; }
.mobile-only { display: none !important; }
.stage { grid-area: stage; position: relative; overflow: hidden; background: var(--stage); background-image: var(--stage-img, radial-gradient(var(--stage-dot) 1px, transparent 1px)); background-size: var(--stage-size, 22px 22px); min-width: 0; }
.stage canvas.view { position: absolute; inset: 0; display: block; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* the side panel, hidden for more room */
.studio.panel-hidden { grid-template-columns: var(--tbw) 1fr 0; }
.panel-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; background: var(--bg2); border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--tx3); }
/* short screens (an iPad on its side): the tool bar in two columns so every button fits */
@media (max-height: 940px) and (min-width: 761px) {
  .studio { --tbw: 92px; }
  .toolbar { padding: 4px 0; gap: 2px; }
  .tgroup { display: grid; grid-template-columns: repeat(2, 40px); gap: 2px; padding: 3px 0; }
  .tool { height: 34px; }
}
.studio.panel-hidden .panel { display: none; }
.panel-tab { position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 3; display: none; align-items: center; justify-content: center; width: 22px; height: 64px; border: 1px solid var(--line2); border-right: 0; border-radius: 10px 0 0 10px; background: var(--bg2); color: var(--tx2); cursor: pointer; font-size: 16px; padding: 0; }
.panel-tab:hover { color: var(--tx); background: var(--bg3); }
.studio.panel-hidden .panel-tab { display: flex; }
.overlays { position: absolute; inset: 0; pointer-events: none; }
.overlays > * { pointer-events: auto; }
.panel { grid-area: panel; background: var(--bg2); border-left: 1px solid var(--line); overflow-y: auto; scrollbar-width: thin; }
.panel section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ph { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.ph > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.ph .acts, .ph .chips { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.ph .link { margin-left: auto; }

/* color */
.colorpick canvas { display: block; width: 100%; border-radius: 7px; cursor: crosshair; touch-action: none; }
.colorpick .sv { height: 130px; }
.colorpick .hue { height: 14px; margin-top: 8px; }
.colorpick .row { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.colorpick .cur { width: 26px; height: 26px; border-radius: 7px; border: 2px solid #fff; box-shadow: 0 0 0 1px #000; }
.colorpick .hex { width: 78px; background: var(--bg3); border: 1px solid var(--line2); border-radius: 7px; color: var(--tx); padding: 3px 6px; font-family: ui-monospace, monospace; font-size: 12px; }
.colorpick .quick { display: flex; gap: 3px; flex-wrap: wrap; }
.qs { width: 15px; height: 15px; border-radius: 4px; border: 1px solid var(--soft-line); cursor: pointer; padding: 0; }

/* tool options */
.opt { display: grid; grid-template-columns: 74px 1fr 46px; align-items: center; gap: 8px; font-size: 12.5px; color: var(--tx2); margin: 4px 0; }
.opt b { font-weight: 500; color: var(--tx); text-align: right; font-size: 12px; }
.opt.toggles { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
details summary { cursor: pointer; color: var(--tx2); font-size: 12.5px; margin: 6px 0; }

/* layers */
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--tx2); margin: -2px 0 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.lcount { color: var(--tx3); font-weight: 400; font-size: 11.5px; }
.rows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lrow { display: flex; align-items: center; gap: 7px; padding: 4px 6px 4px 0; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; position: relative; background: var(--bg2); touch-action: none; }
.lrow:last-child { border-bottom: 0; }
.lrow:hover { background: var(--hover); }
.lrow.on { background: var(--row-on); }
.lrow.hid .thumb, .lrow.hid .name { opacity: .45; }
.lrow.dragging { opacity: .6; }
.lrow.dropabove::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 3px; background: var(--acc); }
.lrow .stripe { width: 5px; align-self: stretch; display: flex; flex-direction: column; flex: none; }
.lrow .thumb { width: 44px; height: 33px; border-radius: 4px; border: 1px solid var(--line2); flex: none; }
.lrow .role { color: var(--tx3); font-size: 15px; }
.lrow .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; outline: none; }
.lrow .name[contenteditable=true] { background: var(--bg); border-radius: 4px; padding: 0 4px; text-overflow: clip; }
.lrow .pin { color: var(--tx2); font-size: 13px; }
.badge { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 6px; }
.badge:empty { display: none; }
.b-new { background: var(--new-bg); color: var(--new-tx); }
.b-edited { background: var(--edit-bg); color: var(--edit-tx); }
.b-moved { background: var(--move-bg); color: var(--move-tx); }
.lrow.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.lprops { margin-top: 8px; }
.lp-row { display: flex; align-items: center; gap: 6px; margin: 5px 0; font-size: 12.5px; color: var(--tx2); }
.lp-row input[type=range] { flex: 1; }
.lp-row b { font-weight: 500; color: var(--tx); width: 36px; text-align: right; font-size: 12px; }
.lp-row select { flex: 1; }
.lp-row .tog { flex: 1; }

/* palette */
.sub { font-size: 11.5px; color: var(--tx2); margin: 8px 0 5px; display: flex; justify-content: space-between; align-items: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px 5px; }
.sw { position: relative; width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--soft-line); cursor: pointer; padding: 0; }
.sw:hover { outline: 2px solid var(--tx); }
.sw .d { position: absolute; bottom: -3px; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--bg2); }
.sw .pinic { position: absolute; top: -7px; right: -6px; font-size: 12px; color: var(--tx); }
.brushes { display: flex; flex-direction: column; gap: 5px; }
.bcard { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-align: left; font-size: 12px; overflow: hidden; }
.bcard:hover { border-color: var(--line2); }
.bcard.using { border-color: var(--B); }
.bcard.current { box-shadow: inset 0 0 0 1px var(--acc); }
.bcard .bstripe { width: 4px; align-self: stretch; }
.bcard .bs { background: #fff; border-radius: 4px; line-height: 0; }
.bcard .bl { flex: 1; color: var(--tx2); }
.bcard .bl b { color: var(--tx); font-weight: 500; }
.bcard .tag { font-size: 10.5px; background: var(--new-bg); color: var(--new-tx); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.palette .empty { color: var(--tx3); font-size: 12px; margin-top: 6px; }

/* overlays */
.toasts { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 5; }
.toast { background: var(--pop); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 8px 8px 14px; display: flex; gap: 8px; align-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.4); font-size: 13px; max-width: min(560px, 92vw); }
.toast button { background: var(--bg3); border: 1px solid var(--line2); border-radius: 7px; padding: 3px 9px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.toast button.x { background: none; border: 0; color: var(--tx3); padding: 2px; }
.loupe { position: absolute; display: flex; gap: 10px; align-items: center; background: var(--pop); border: 1px solid var(--line2); border-radius: 12px; padding: 8px 10px; pointer-events: none !important; z-index: 6; }
.loupe .ring { width: 38px; height: 38px; border-radius: 50%; border: 7px solid; box-shadow: 0 0 0 1px #000, inset 0 0 0 1px #000; flex: none; }
.loupe .lt { display: flex; flex-direction: column; font-size: 12px; gap: 2px; }
.loupe .lt b { font-family: ui-monospace, monospace; font-weight: 500; }
.loupe .bw canvas { background: #fff; border-radius: 4px; }
.loupe .small { color: var(--tx2); font-size: 11px; }
.whatshere { position: absolute; width: 270px; background: var(--pop); border: 1px solid var(--line2); border-radius: 12px; padding: 6px; z-index: 6; box-shadow: 0 8px 28px rgba(0,0,0,.45); }
.wh-h { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--tx2); padding: 2px 4px 6px; }
.wh-h .x { margin-left: auto; width: 22px; height: 22px; font-size: 14px; }
.wh-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; cursor: pointer; }
.wh-row:hover { background: var(--bg3); }
.wh-row .sq { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.wh-row .nm { flex: 1; font-size: 13px; display: flex; flex-direction: column; }
.wh-row small { color: var(--tx2); font-size: 11px; }
.wh-row .use { background: var(--bg3); border: 1px solid var(--line2); border-radius: 7px; font-size: 11px; padding: 2px 7px; cursor: pointer; }
.wh-empty { color: var(--tx2); font-size: 12px; padding: 6px; }
.selbar { position: absolute; display: flex; gap: 4px; background: var(--pop); border: 1px solid var(--line2); border-radius: 10px; padding: 4px; z-index: 4; }
.selbar button { background: none; border: 0; border-radius: 7px; padding: 5px 8px; cursor: pointer; color: var(--tx2); display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.selbar button:hover { background: var(--bg3); color: var(--tx); }
.selbar button.primary { background: var(--acc); color: var(--acc-tx); font-weight: 600; }
.handoff { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: var(--pop); border: 1px solid var(--line2); border-radius: 14px; padding: 12px 16px; display: flex; gap: 12px; align-items: center; z-index: 7; box-shadow: 0 10px 34px rgba(0,0,0,.5); max-width: min(560px, 92vw); transition: opacity .45s, transform .45s; }
.handoff.out { opacity: 0; transform: translate(-50%, -10px); }
.handoff i.big { font-size: 26px; color: var(--acc); }
.handoff b { display: block; }
.handoff span { color: var(--tx2); font-size: 13px; }
.banner { position: absolute; inset: 0; display: grid; place-items: center; background: var(--scrim); z-index: 8; text-align: center; }
.banner .bx { background: var(--pop); border: 1px solid var(--line2); border-radius: 16px; padding: 22px 28px; max-width: 460px; }
.banner .count { font-size: 64px; font-weight: 800; color: var(--acc); line-height: 1; margin: 8px 0; }
.stackview { position: absolute; inset: 0; background: var(--bg); z-index: 9; display: flex; flex-direction: column; animation: svIn .16s ease-out; }
.stackview.out { opacity: 0; transition: opacity .16s; }
@keyframes svIn { from { opacity: 0; } }
.sv-top { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bar-bg, var(--bg2)); color: var(--bar-tx, var(--tx)); border-bottom: 1px solid var(--line); }
.sv-top .sv-ic { font-size: 22px; color: var(--acc); }
.sv-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sv-title b { font-size: 15px; }
.sv-title span { color: var(--bar-tx2, var(--tx2)); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-res { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.sv-res canvas { width: 64px; height: 48px; border-radius: 5px; border: 1px solid var(--line2); }
.sv-res small { color: var(--bar-tx2, var(--tx3)); font-size: 10.5px; }
.sv-done { padding: 9px 16px; font-size: 15px; }
.sv-done kbd { font: 600 10.5px ui-monospace, monospace; background: rgba(0,0,0,.18); border-radius: 4px; padding: 1px 5px; margin-left: 2px; }
.sv-body { position: relative; flex: 1; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 40% 45%, var(--bg2) 0%, var(--bg) 70%); touch-action: none; }
.sv-canvas { position: absolute; inset: 0; display: block; }
.sv-labels { position: absolute; top: 0; }
.sv-label { position: absolute; left: 0; top: 0; height: 46px; width: 240px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px; border-radius: 10px; background: var(--label); border: 1px solid var(--line); cursor: grab; user-select: none; transition: background .12s, border-color .12s; }
.sv-label .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sv-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.sv-name b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-name small { color: var(--tx2); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-name em { font-style: normal; color: var(--edit-tx); }
.sv-btns { display: flex; }
.sv-btns .ib { width: 26px; height: 26px; font-size: 15px; }
.sv-label.hover { background: var(--label-hover); border-color: var(--line2); }
.sv-label.on { border-color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); }
.sv-label.hid .sv-name b { color: var(--tx2); }
@media (max-width: 640px) {
  .sv-label { width: 150px; }
  .sv-label .sv-btns .ib:not([data-a=eye]) { display: none; }
  .sv-title span, .sv-res { display: none; }
}

/* top bar (game) */
.topbar .theme { display: flex; flex-direction: column; min-width: 0; }
.topbar .theme small { color: var(--bar-tx2, var(--tx2)); font-size: 11.5px; }
.topbar .theme b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.topbar .sp { flex: 1; }
.timer { position: relative; width: 40px; height: 40px; flex: none; }
.timer svg { transform: rotate(-90deg); }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.timer.low span { color: var(--bad); }
.turnpill { background: var(--bg3); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; color: var(--tx2); white-space: nowrap; }
.partner { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--bar-tx2, var(--tx2)); white-space: nowrap; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--B); box-shadow: 0 0 0 0 currentColor; animation: pulse 1.4s infinite; color: var(--B); }
.pulse.idle { animation: none; opacity: .5; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
.brand { font-weight: 800; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand .logo { width: 26px; height: 26px; }

/* ---------- pages (home, lobby, themes, reveal, history) */
.page { height: 100%; overflow-y: auto; }
.page .wrap { max-width: 980px; margin: 0 auto; padding: 22px 18px 60px; }
.page header.bar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--bar-bg, var(--bg2)); color: var(--bar-tx, var(--tx)); position: sticky; top: 0; z-index: 2; }
.page header.bar .sp { flex: 1; }
.hero { text-align: center; padding: 26px 0 10px; }
.hero h1 { font-size: clamp(32px, 6vw, 54px); margin: 0 0 6px; letter-spacing: -1px; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--A), var(--B)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--tx2); font-size: 16px; max-width: 560px; margin: 0 auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 22px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.card h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; font-size: 13px; color: var(--tx2); }
.field input { background: var(--bg); border: 1px solid var(--line2); border-radius: 9px; padding: 10px 12px; color: var(--tx); font-size: 15px; }
.field input:focus { outline: 2px solid var(--acc); outline-offset: -1px; }
.codeinput { text-transform: uppercase; letter-spacing: 6px; font-weight: 700; font-family: ui-monospace, monospace; text-align: center; font-size: 22px !important; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 28px; }
.how div { color: var(--tx2); font-size: 13.5px; }
.how b { color: var(--tx); display: block; margin-bottom: 2px; }
.how i.ti { font-size: 22px; color: var(--acc); }
.bigcode { font-family: ui-monospace, monospace; font-size: clamp(40px, 9vw, 72px); font-weight: 800; letter-spacing: 10px; text-align: center; margin: 6px 0; }
.players { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.pcard { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-width: 200px; }
.pcard .av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; }
.pcard.empty { border-style: dashed; color: var(--tx3); }
.settings { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; margin: 10px 0 18px; }
.settings .seg button { min-width: 44px; }
.center { text-align: center; }
.muted { color: var(--tx2); }
.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 18px 0; }
.themecard { background: var(--bg2); border: 2px solid var(--line); border-radius: 14px; padding: 18px; font-size: 18px; font-weight: 600; cursor: pointer; text-align: left; min-height: 92px; }
.themecard:hover { border-color: var(--line2); }
.themecard.on { border-color: var(--acc); background: var(--acc-soft); }
.reveal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.reveal-grid .pic { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.reveal-grid canvas { width: 100%; aspect-ratio: 4/3; border-radius: 8px; display: block; background: #fff; }
.reveal-grid .cap { display: flex; align-items: baseline; gap: 6px; margin: 2px 2px 8px; font-size: 13px; color: var(--tx2); flex-wrap: wrap; }
.reveal-grid .cap b { color: var(--tx); font-size: 16px; }
.player { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.player .scrub { flex: 1; min-width: 200px; position: relative; }
.player .scrub input { width: 100%; }
.player .marks { display: flex; font-size: 11px; color: var(--tx3); }
.player .marks span { flex: 1; }
.turncard { text-align: center; color: var(--tx2); min-height: 22px; font-size: 14px; }
.turncard b { color: var(--tx); }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.ggame { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; }
.ggame:hover { border-color: var(--line2); }
.ggame .two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ggame img, .ggame canvas { width: 100%; aspect-ratio: 4/3; border-radius: 6px; background: #fff; display: block; object-fit: cover; }
.ggame .meta { font-size: 12.5px; color: var(--tx2); margin-top: 6px; }
.partnerhead { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; font-size: 16px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal .box { background: var(--bg2); border: 1px solid var(--line2); border-radius: 16px; padding: 20px; width: min(420px, 100%); }
.modal h3 { margin: 0 0 8px; }
/* the theme gallery */
.modal .box.wide { width: min(780px, 100%); max-height: 88vh; overflow-y: auto; }
.tp-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.tp-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
.tp-head .muted { font-size: 13px; }
.tp-group { font-size: 12px; color: var(--tx2); margin: 14px 0 6px; text-transform: none; }
.tp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.tp-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--bg3); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; text-align: left; }
.tp-card:hover { border-color: var(--line3); }
.tp-card.on { border-color: var(--acc); box-shadow: 0 0 0 2px var(--acc-soft); }
.tp-name { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.tp-name b { font-weight: 600; }
.tp-name em { font-style: normal; font-size: 10.5px; background: var(--acc-soft); color: var(--acc); border-radius: 6px; padding: 0 6px; }
.tp-card small { color: var(--tx2); font-size: 11.5px; line-height: 1.35; }
.tp-mini { height: 86px; display: grid; grid-template-columns: 15px 1fr 36px; grid-template-rows: 13px 1fr; overflow: hidden; border: 1px solid rgba(0,0,0,.25); }
.tp-top { grid-column: 1 / 4; display: flex; align-items: center; gap: 3px; padding: 0 5px; font-size: 9px; font-weight: 700; }
.tp-top b { width: 6px; height: 6px; border-radius: 50%; }
.tp-top span { margin-left: 3px; }
.tp-top i { margin-left: auto; width: 14px; height: 6px; border-radius: 3px; }
.tp-tools { display: flex; flex-direction: column; gap: 3px; padding: 3px; }
.tp-tools i { display: block; height: 6px; border-radius: 2px; opacity: .9; }
.tp-stage { display: flex; align-items: center; justify-content: center; background-size: 8px 8px; }
.tp-paper { width: 64%; height: 68%; background: #fff; border-radius: 2px; box-shadow: 0 2px 6px rgba(0,0,0,.3); position: relative; }
.tp-paper::after { content: ""; position: absolute; left: 18%; top: 34%; width: 52%; height: 5px; border-radius: 3px; background: #2b2b2b; transform: rotate(-7deg); }
.tp-panel { display: flex; flex-direction: column; gap: 3px; padding: 4px; }
.tp-panel i { display: block; height: 5px; border-radius: 2px; }
.tp-panel .tp-btn { height: 8px; margin-top: auto; }
.theme-btn .lbl { display: inline; }
.tp-extras { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; margin: 8px 0 2px; background: var(--bg3); border: 1px solid var(--line); border-radius: 12px; }
.tp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tp-label { font-size: 12.5px; color: var(--tx2); min-width: 104px; }
.tp-accents { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tp-acc { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bg2); box-shadow: 0 0 0 1px var(--line2); cursor: pointer; padding: 0; display: inline-grid; place-items: center; position: relative; }
.tp-acc.on { box-shadow: 0 0 0 2px var(--tx); }
.tp-acc.own { width: auto; border-radius: 999px; padding: 0 10px; font-size: 12px; background: var(--bg2); color: var(--tx2); }
.tp-acc.own.on { color: var(--tx); }
.tp-acc.custom { background: conic-gradient(#ef4444, #f59e0b, #84cc16, #06b6d4, #6366f1, #d946ef, #ef4444); color: #fff; font-size: 14px; overflow: hidden; }
.tp-acc.custom i { text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.tp-acc.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.qs-theme { width: 17px; height: 15px; border-radius: 4px; border: 1px solid var(--line2); background: var(--bg3); color: var(--tx3); cursor: pointer; padding: 0; display: inline-grid; place-items: center; font-size: 11px; }
.qs-theme.on { background: var(--acc-soft); color: var(--acc); border-color: var(--acc); }
@media (max-width: 760px) { .theme-btn .lbl { display: none; } }
@media (max-width: 520px) { .tp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .tp-card small { display: none; } .tp-mini { height: 64px; } }

/* ---------- small screens: tool bar along the bottom, panel as a drawer */
@media (max-width: 760px) {
  .studio { grid-template-columns: 1fr; grid-template-rows: 48px 1fr 54px; grid-template-areas: "top" "stage" "tools"; }
  .toolbar { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0 4px; border-right: 0; border-top: 1px solid var(--line); }
  .tgroup { flex-direction: row; border-bottom: 0; border-right: 1px solid var(--line); padding: 0 4px; }
  .tool { width: 38px; height: 40px; flex: none; }
  .mobile-only { display: grid !important; }
  .studio.panel-hidden { grid-template-columns: 1fr; }
  .panel-head { display: none; }
  .studio.panel-hidden .panel { display: block; }
  .studio .panel-tab { display: none !important; }
  .panel { position: fixed; right: 0; top: 48px; bottom: 54px; width: min(320px, 88vw); transform: translateX(105%); transition: transform .2s; z-index: 20; box-shadow: -10px 0 30px rgba(0,0,0,.5); }
  .studio.show-panel .panel { transform: none; }
  .topbar { gap: 8px; padding: 0 8px; }
  .topbar .brand span, .partner .pname { display: none; }
  .reveal-grid { grid-template-columns: 1fr; }
}
