@font-face { font-family: Jost; src: url(fonts/jost.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url(fonts/space-mono-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url(fonts/space-mono-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root { --bg: #1428a0; --ink: #0d0b14; --paper: #fff6e4; --hot: #ff3b1d; --code: #0d1a78; --codeInk: #fff6e4; --dim: #7f92e8; --c1: #ffd400; --c2: #ff8fbf; --c3: #6fe3ee; --c4: #ffb066; --a: #1a33b8; --b: #10218a; --fig: #2b4be0; --on: #fff6e4; --onHot: #0d0b14; --onC1: #0d0b14; --hotP: #d42a10; --codeInkCode: #fff6e4; --dimCode: #9aaaf0; --c1Code: #ffd400; --c2Code: #ff8fbf; --c3Code: #6fe3ee; --c4Code: #ffb066; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 500 15px/1.3 Jost, system-ui, sans-serif; background: var(--paper); color: var(--ink); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
code, pre, kbd { font-family: 'Space Mono', monospace; }
[hidden] { display: none !important; }

/* ---- top ---- */
#top { height: 52px; display: flex; align-items: stretch; background: var(--ink); color: var(--paper); }
#top h1 { margin: 0; padding: 0 18px 0 12px; font: 800 21px/52px Jost; letter-spacing: 0.04em; display: flex; align-items: center; gap: 10px; }
.unit { width: 30px; height: 30px; background: var(--hot); display: grid; place-items: center; border-radius: 0; }
.unit i { width: 20px; height: 20px; border-radius: 50%; background: var(--paper); position: relative; }
.unit i::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--ink); }
#chips { display: flex; flex: 1; min-width: 0; overflow: hidden; }
.chip { display: grid; grid-template-columns: 34px auto; grid-template-rows: 1fr 1fr; align-items: center; column-gap: 8px; padding: 6px 12px 6px 9px; text-align: left; font: 700 13.5px/1 Jost; letter-spacing: 0.03em; white-space: nowrap; color: var(--paper); }
.chip .sw { grid-row: 1 / 3; width: 34px; height: 34px; background-size: cover; background-color: #333; }
.chip small { font: 400 10.5px/1 'Space Mono'; opacity: 0.6; letter-spacing: 0; }
.chip span:nth-child(2) { align-self: end; padding-bottom: 2px; }
.chip small { align-self: start; padding-top: 2px; }
.chip:hover { background: #ffffff22; }
.chip.on { background: var(--paper); color: var(--ink); }
.tools { display: flex; }
.tools button { padding: 0 16px; font: 700 14px Jost; letter-spacing: 0.04em; }
.tools button:hover { background: var(--hot); color: var(--onHot); }
#btnExport { background: var(--paper); color: var(--ink); }
#btnExport:hover { background: var(--c1); color: var(--onC1); }

@media (max-width: 1420px) {
  #top h1 { font-size: 18px; padding-right: 10px; gap: 7px; }
  .chip { font-size: 12px; padding: 6px 7px 6px 6px; grid-template-columns: 26px auto; column-gap: 6px; } .chip .sw { width: 26px; height: 26px; } .chip small { font-size: 9.5px; }
  .tools button { padding: 0 11px; font-size: 13px; }
}
#pickwrap { display: flex; align-items: center; gap: 8px; padding: 0 10px; font: 500 12px Jost; flex: 1; min-width: 0; }
#pick { font: 700 15px Jost; background: var(--paper); color: var(--ink); border: 0; padding: 7px 10px; max-width: 340px; width: 100%; border-radius: 0; }
.tools button.on { background: #ffffff22; }
body.playonly #left, body.playonly #side { display: none; }
body.playonly #studio { grid-template-columns: 1fr; display: grid; }
body.playonly #stage { height: 100%; }
/* ---- three fields ---- */
#studio { height: calc(100% - 52px); display: grid; grid-template-columns: minmax(420px, 40fr) minmax(400px, 42fr) minmax(300px, 25fr); }
#left { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--code); color: var(--codeInk); }
#stage { position: relative; min-width: 0; min-height: 0; background: var(--bg); }
#side { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--paper); color: var(--ink); }

/* ---- editor ---- */
#code { flex: 1; min-height: 0; position: relative; }
.ed { display: flex; overflow: hidden; font: 400 13.5px/19px 'Space Mono', monospace; }
.ed-gut { flex: 0 0 34px; text-align: right; padding: 10px 8px 200px 0; color: var(--dimCode); user-select: none; font-size: 11px; }
.ed-gut .e { color: var(--onHot); background: var(--hot); }
.ed-body { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.ed-hl, .ed textarea { position: absolute; left: 0; top: 0; margin: 0; padding: 10px 12px 10px 6px; font: inherit; white-space: pre; tab-size: 2; letter-spacing: 0; }
.ed-hl { pointer-events: none; min-width: 100%; }
.ed textarea { width: 100%; height: 100%; border: 0; outline: 0; resize: none; background: transparent; color: transparent; caret-color: var(--codeInk); overflow: auto; }
.ed textarea::selection { background: #ffffff33; color: transparent; }
.ln { min-height: 19px; }
.ln.band { background: #ffffff1c; box-shadow: -40px 0 0 #ffffff1c; }
.ln.e { background: #ff000020; }
.t-kw { color: var(--c1Code); font-weight: 700; } .t-title { color: var(--codeInk); font-weight: 700; }
.t-unit { color: var(--c4Code); } .t-tile { color: var(--c3Code); } .t-var { color: var(--c3Code); }
.t-verb { color: var(--c2Code); } .t-shape { color: var(--c1Code); } .t-flag { color: var(--dimCode); }
.t-num { font-weight: 700; } .t-op { color: var(--dimCode); } .t-str { color: var(--c3Code); } .t-com { color: var(--dimCode); font-style: italic; }
.t-err { text-decoration: underline wavy var(--hot) 2px; text-underline-offset: 3px; }
.ed-note { margin-left: 18px; font: 500 12.5px Jost; padding: 0 6px; }
.ed-note.err { background: var(--hot); color: var(--onHot); }
.ed-note.warn { color: var(--dimCode); }
.ed.scrub { cursor: ew-resize; } .ed.scrub textarea { cursor: ew-resize; }
.ed-pop { position: absolute; z-index: 5; background: var(--paper); color: var(--ink); font-size: 12.5px; min-width: 110px; }
.ed-pop div { padding: 1px 8px; display: flex; justify-content: space-between; gap: 12px; } .ed-pop kbd { font-size: 10px; opacity: 0.7; } .ed-pop .on { background: var(--ink); color: var(--paper); }
.under { display: flex; align-items: center; gap: 12px; padding: 5px 10px; font: 500 12.5px Jost; min-height: 29px; background: var(--ink); color: var(--paper); }
.status { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.bad { color: var(--onC1); background: var(--c1); padding: 1px 6px; font-weight: 700; }
.hint { opacity: 0.55; white-space: nowrap; font-size: 11.5px; }
#revert { text-decoration: underline; font-size: 12px; }
@media (max-width: 1500px) { .hint { display: none; } }

#errs { flex: 0 0 auto; max-height: 40%; overflow: auto; background: var(--hot); color: var(--onHot); font: 500 14px/1.25 Jost; }
#errs button { display: block; width: 100%; padding: 4px 10px; text-align: left; color: var(--onHot); border-top: 1px solid #ffffff44; }
#errs button:hover { background: #00000022; } #errs b { font-weight: 800; margin-right: 4px; } #errs i { display: block; padding: 2px 10px 4px; font-style: normal; opacity: 0.8; }
#left { position: relative; }
#artpanel { position: absolute; right: 10px; top: 10px; z-index: 4; width: min(248px, 62%); background: var(--paper); box-shadow: 0 0 0 3px var(--paper); }
#artpanel canvas { display: block; width: 100%; aspect-ratio: 1; touch-action: none; cursor: crosshair; }
.pp-row { display: flex; flex-wrap: wrap; gap: 3px; padding: 4px 4px 0; } .pp-row:last-child { padding-bottom: 4px; }
.pp-add button { background: none !important; color: var(--ink) !important; box-shadow: inset 0 0 0 1px var(--ink); font-size: 11.5px !important; min-height: 24px !important; padding: 2px 3px !important; }
.pp-row button:not(.pp-sw) { flex: 1; padding: 6px 2px; background: var(--ink); color: var(--paper); font: 700 12.5px Jost; min-height: 30px; }
.pp-sw { width: 18px; height: 18px; box-shadow: inset 0 0 0 1px #0004; } .pp-sw.on { box-shadow: 0 0 0 2px var(--ink); }
@media (pointer: coarse) { .pp-sw { width: 26px; height: 26px; } .pp-row button:not(.pp-sw) { min-height: 42px; } }
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.sheet .sw { display: grid; justify-items: center; gap: 2px; font: 500 11.5px Jost; overflow: hidden; }
.sheet img { width: 56px; height: 56px; }
#art { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 16px; font: 500 13.5px/1.25 Jost; } #art p { margin: 0 0 8px; } #art code { font-size: 12px; }
/* ---- coach ---- */
#coach { flex: 0 0 auto; max-height: 56%; overflow: auto; background: var(--paper); color: var(--ink); padding: 12px 14px 12px; transition: background 0.2s; }
#coach.flash { background: var(--c1); }
.ct { display: flex; align-items: baseline; gap: 10px; }
.cn { font: 800 30px/1 Jost; } .cn small { font-size: 13px; font-weight: 500; opacity: 0.6; }
#coach h4 { margin: 0; flex: 1; font: 800 20px/1.1 Jost; }
#coach .x { font-size: 12.5px; text-decoration: underline; }
#coach p { margin: 6px 0; font: 500 15px/1.32 Jost; }
#coach code { font-size: 13px; background: #00000012; padding: 0 3px; }
#coach pre { margin: 6px 0; padding: 7px 9px; background: var(--ink); color: var(--paper); font-size: 12.5px; line-height: 17px; white-space: pre-wrap; }
#coach pre.rep span { text-decoration: line-through; opacity: 0.55; }
.cb { display: flex; gap: 10px; margin-top: 8px; }
.cb button { padding: 5px 12px; font-weight: 700; background: var(--ink); color: var(--paper); }
.cb .back { background: none; color: var(--ink); text-decoration: underline; font-weight: 500; }

/* ---- game chrome (studio + export) ---- */
.gm { position: relative; height: 100%; display: flex; flex-direction: column; color: var(--on); background: var(--bg); }
.gm-hud { flex: none; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 30px 36px; gap: 2px; padding: 8px 14px 4px; height: 82px; }
.gm-name { font: 800 26px/30px Jost; letter-spacing: 0.02em; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--on); }
.gm-meters { display: flex; align-items: flex-end; gap: 14px; min-width: 0; overflow-x: auto; scrollbar-width: none; } .gm-meters > * { flex: none; }
.gm-stat { font: 700 22px/1 'Space Mono', monospace; display: grid; justify-items: start; grid-template-columns: auto auto; color: var(--on); }
.gm-stat em { grid-column: 1 / 3; font: 500 11px/1.2 Jost; letter-spacing: 0.03em; opacity: 0.8; }
.gm-stat small { font-size: 12px; font-weight: 400; align-self: end; opacity: 0.7; }
.gm-clock { color: var(--on); }
.gm-hearts { display: flex; align-items: center; gap: 4px; padding-bottom: 2px; font: 700 20px 'Space Mono', monospace; color: var(--on); } .gm-hearts small { font-size: 12px; font-weight: 400; }
.gm-hearts i { width: 17px; height: 17px; border-radius: 50%; box-shadow: inset 0 0 0 3px var(--on); }
.gm-hearts i.on { background: var(--hot); box-shadow: inset 0 0 0 3px var(--on); }
.gm-stage { position: relative; flex: 1; min-height: 0; }
.gm-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.gm-pv { flex: none; height: 68px; padding: 5px 14px; font: 600 16px/1.2 Jost; color: var(--on); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.gm-pv .hot, .gm-pv.hurt b.hot { color: var(--bg); background: var(--on); padding: 0 5px; }
.gm-pv .dim { opacity: 0.85; font-weight: 500; }
.gm-acts { flex: none; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; padding: 0 14px 7px; height: 84px; overflow-y: auto; scrollbar-width: none; } .gm-act { flex: none; height: 36px; }
.gm-act small { font-size: 12.5px !important; }
.gm-act { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; background: var(--paper); color: var(--ink); font: 700 14.5px/1 Jost; }
.gm-act kbd { font-size: 10.5px; font-weight: 700; background: var(--ink); color: var(--paper); padding: 2px 4px; }
.gm-act small { font: 500 11.5px Jost; opacity: 0.7; }
.gm-act:hover:not(:disabled) { background: var(--c1); color: var(--onC1); }
.gm-act.armed { background: var(--hot); color: var(--onHot); }
.gm-act:disabled { opacity: 0.38; cursor: default; }
.gm-wait { background: none; color: var(--on); box-shadow: inset 0 0 0 2px var(--on); }
.gm-wait kbd { background: var(--on); color: var(--bg); }
.gm-foot { display: flex; align-items: center; gap: 13px; padding: 5px 14px 8px; font: 500 13px Jost; }
.gm-foot-b { white-space: nowrap; min-height: 28px; color: var(--on); text-decoration: underline; text-underline-offset: 2px; }
.gm-foot-b:disabled { opacity: 0.4; text-decoration: none; cursor: default; }
.gm-seed { margin-left: auto; font: 400 11px 'Space Mono'; opacity: 0.85; color: var(--on); }
.gm-over { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; overflow: auto; }
.gm-card { width: min(460px, 100%); background: var(--paper); color: var(--ink); padding: 16px 18px 18px; }
.gm-card h1 { margin: 0 0 4px; font: 800 clamp(40px, 9vw, 74px)/0.95 Jost; letter-spacing: 0.01em; }
.gm-card h2 { margin: 0; font: 800 44px/1 Jost; }
.gm-card h3 { margin: 0 0 8px; font: 800 26px/1.05 Jost; }
.gm-card p { margin: 6px 0 12px; font: 500 16.5px/1.3 Jost; }
.gm-big { display: block; width: 100%; margin-top: 6px; padding: 9px 12px; text-align: left; background: var(--ink); color: var(--paper); font: 700 17px/1.15 Jost; }
.gm-big small { display: block; font: 500 12.5px/1.25 Jost; opacity: 0.75; }
.gm-big kbd { font-size: 12px; background: var(--paper); color: var(--ink); padding: 1px 5px; margin-right: 4px; }
.gm-big:hover { background: var(--hot); color: var(--onHot); }
.gm-rules { background: var(--bg); place-items: start center; }

/* ---- side: ladder ---- */
#lad { padding: 10px 14px 8px; background: var(--paper); position: relative; }
#lad.busy #big { opacity: 0.55; }
.lad-top { display: flex; align-items: flex-end; gap: 8px; justify-content: space-between; }
.bigwrap { min-width: 118px; }
#big { font: 800 58px/0.92 Jost; letter-spacing: -0.01em; transition: opacity 0.12s; }
#bigLabel { font: 500 12.5px/1.15 Jost; max-width: 140px; }
#trail { overflow: hidden; display: flex; justify-content: flex-end; max-width: 56%; }
#trail .t { fill: var(--ink); } #trail .g { fill: var(--hotP); } #trail .r { fill: #00000055; } #trail .l { stroke: #00000030; stroke-width: 2; }
#ladBars { margin-top: 8px; display: grid; gap: 3px; }
.b { display: grid; grid-template-columns: 50px 1fr 62px 64px; align-items: center; gap: 6px; font: 600 13px/1.2 Jost; }
.b .tr { height: 15px; background: #00000012; }
.b .f { display: block; height: 100%; background: var(--ink); transition: width 0.15s; }
.b.g .f { background: var(--hotP); } .b.r .f { background: #00000055; }
.b .v { font: 700 13px 'Space Mono', monospace; text-align: right; white-space: nowrap; }
.b .v i { font-style: normal; font-size: 10.5px; font-weight: 400; margin-left: 3px; }
.b .m { font: 400 11.5px 'Space Mono', monospace; white-space: nowrap; }
#verdicts { list-style: none; margin: 8px 0 0; padding: 0; font: 600 13.5px/1.22 Jost; }
#verdicts li { padding: 2px 6px; margin-top: 2px; }
#verdicts .good { background: #00000010; }
#verdicts .warn { background: var(--c1); color: var(--onC1); }
#verdicts .bad { background: var(--hot); color: var(--onHot); }
#ladMeta { font: 400 10.5px 'Space Mono', monospace; opacity: 0.6; margin-top: 4px; }
.tabs { display: flex; gap: 0; background: var(--ink); }
.tabs button { flex: 1; padding: 5px 0; color: var(--paper); font: 700 13px Jost; }
.tabs button.on { background: var(--paper); color: var(--ink); }
#rules, #words { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 16px; }
.rc-goal { font: 700 15px/1.2 Jost; margin-bottom: 8px; }
.rc-row { display: flex; gap: 7px; align-items: flex-start; font: 500 13.5px/1.26 Jost; padding: 4px 0; border-top: 2px solid #00000014; cursor: default; }
#rules .rc-row { cursor: pointer; } #rules .rc-row:hover { background: #00000008; }
.rc-row img { width: 30px; height: 30px; flex: none; }
.rc-row b { font-weight: 800; }
.rc-row .k { flex: none; width: 30px; height: 30px; display: grid; place-items: center; background: var(--ink); color: var(--paper); font: 700 13px 'Space Mono'; }
.shp { width: 30px; height: 30px; flex: none; background: #00000010; }
.shp .o { fill: var(--ink); } .shp .h { fill: var(--hotP); }
#words h5 { margin: 12px 0 3px; font: 800 16px Jost; } #words h5:first-child { margin-top: 0; }
.w { padding: 3px 0; border-top: 2px solid #00000012; font: 500 13px/1.25 Jost; }
.w > code { display: block; font-size: 11.5px; font-weight: 700; line-height: 15px; white-space: pre-wrap; }
.w span code { font-size: 11.5px; }

#voidmsg { display: none; position: absolute; inset: 0; place-content: center; text-align: center; font: 800 34px/1.2 Jost; color: var(--paper); background: var(--bg); z-index: 3; }
#voidmsg code { font-size: 18px; font-weight: 400; }
#stage.void #voidmsg { display: grid; }

/* ---- standalone ---- */
body.export { background: var(--bg); overflow: hidden; }
body.export #game { height: 100dvh; max-width: 900px; margin: 0 auto; }

.gm-item { background: var(--c1); color: var(--onC1); }
.gm-item.worn { box-shadow: inset 0 0 0 3px var(--ink); }
@media (pointer: coarse), (max-width: 700px) {
  .gm-act kbd { display: none; }
  .gm-act { min-height: 46px; padding: 8px 12px; font-size: 16px; }
  .gm-foot-b { padding: 8px 2px; font-size: 15px; }
  .gm-big { min-height: 52px; }
  .gm-pv { font-size: 17px; height: 74px; } .gm-acts { height: 108px; } .gm-act { height: 46px; }
}
/* ---- narrow: stack, the game first ---- */
@media (max-width: 1040px) {
  body { overflow: auto; }
  body { overflow: hidden; }
  #top { height: 92px; flex-wrap: wrap; align-content: flex-start; } #top h1 { font-size: 0; padding: 0 6px; gap: 0; height: 46px; } #pickwrap span { display: none; } #pickwrap { order: 3; flex: 1 0 100%; padding: 0 6px 6px; height: 46px; } #pick { max-width: none; font-size: 16px; }
  .tools { flex: 1; justify-content: flex-end; height: 46px; } .tools button { padding: 0 9px; }
  #studio { height: calc(100% - 92px); }
  body:not(.playonly) { overflow: auto; }
  body:not(.playonly) #studio { display: block; height: auto; }
  body:not(.playonly) #stage { height: 88dvh; } body:not(.playonly) #left { height: 60dvh; } body:not(.playonly) #side { height: auto; } #rules { max-height: none; }
}
@media (max-width: 480px) { .gm-seed { display: none; } .gm-foot { gap: 11px; flex-wrap: wrap; } .gm-name { font-size: 20px; } .gm-hud { flex-wrap: wrap; gap: 8px; } }

.legend { display: flex; gap: 6px; margin: 0 0 8px; } .legend span { display: grid; justify-items: center; gap: 2px; font: 500 11.5px Jost; flex: 1; min-width: 0; color: var(--ink); } .legend em { font-style: normal; } .legend img { width: 100%; max-width: 56px; }
@media (max-width: 700px) { .gm-stage { flex: 0 1 auto; aspect-ratio: var(--ar, 1); width: 100%; max-height: calc(100dvh - 92px - 82px - 74px - 108px - 50px); margin: 0 auto; } .gm-foot { margin-top: auto; } }
