:root {
  --bone: #ece8dd;
  --bone-dim: #a9a597;
  --ink: #05060b;
  --gold: #e8c46a;
  --gold-dim: #8a7444;
  --noise: #e8823a;
  --blue: #7fb0e0;
  --muted: #8a90b0;
  --faint: #4d5374;
  --panel: rgba(6, 8, 16, 0.86);
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --title: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --hud-h: 172px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; color: var(--bone); font-family: var(--serif); }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; user-select: none; -webkit-user-select: none; }
#ui button, #hud, .overlay, #bubble { pointer-events: auto; }

/* ---------------- top bar ---------------- */
#vitals { position: absolute; left: 28px; top: 22px; }
#masks { display: flex; gap: 6px; }
#masks svg { width: 34px; height: 42px; filter: drop-shadow(0 0 6px rgba(220,230,255,0.25)); transition: transform .3s, opacity .3s; }
#masks svg.lost { opacity: .35; filter: none; }
#masks svg.pop { transform: scale(1.25); }
#ink { margin-top: 8px; font-family: var(--mono); font-size: 14px; color: var(--bone-dim); letter-spacing: .05em; }
#ink .ink-glyph { color: var(--gold); text-shadow: 0 0 8px rgba(232,196,106,.6); }
#place { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); text-align: center; opacity: .85; }
#place-zone { font-family: var(--title); font-size: 12px; letter-spacing: .35em; color: var(--muted); text-transform: uppercase; }
#place-room { font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--bone); margin-top: 2px; text-shadow: 0 1px 8px #000; }
#tally { position: absolute; right: 28px; top: 24px; text-align: right; font-family: var(--mono); font-size: 12.5px; color: var(--muted); line-height: 1.7; }
#tally b { color: var(--bone); font-weight: 600; }
#tally .steel { color: var(--blue); }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--hud-h);
  display: grid; grid-template-columns: auto minmax(230px, 1fr) minmax(300px, 1.25fr) auto; gap: 26px; align-items: center;
  padding: 26px 34px 20px;
  background: linear-gradient(180deg, rgba(4,5,10,0) 0%, rgba(4,5,10,.78) 22%, rgba(4,5,10,.95) 100%);
}
#hud .filigree { position: absolute; left: 6%; right: 6%; top: 12px; height: 14px; pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, var(--gold) 0 2.5px, transparent 3px),
    linear-gradient(90deg, transparent, rgba(232,196,106,.0) 2%, rgba(232,196,106,.45) 30%, rgba(232,196,106,.45) 47%, transparent 47.6%, transparent 52.4%, rgba(232,196,106,.45) 53%, rgba(232,196,106,.45) 70%, transparent 98%) center / 100% 1px no-repeat;
}
#hud .filigree::before, #hud .filigree::after { content: ''; position: absolute; top: 50%; width: 9px; height: 9px; border: 1px solid rgba(232,196,106,.55); transform: translate(-50%,-50%) rotate(45deg); }
#hud .filigree::before { left: 46%; } #hud .filigree::after { left: 54%; }

#families { display: grid; grid-template-columns: repeat(5, 74px); gap: 8px; }
.fam { position: relative; height: 92px; border: 1px solid #2a2f4a; background: linear-gradient(180deg, rgba(22,26,46,.9), rgba(10,12,22,.9));
  border-radius: 3px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 8px; cursor: pointer; transition: border-color .2s, box-shadow .2s, transform .15s; }
.fam svg { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 50px; height: 40px; }
.fam .nm { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.fam .kb { position: absolute; top: 4px; left: 6px; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.fam:hover:not(.locked) { border-color: #4a5378; transform: translateY(-1px); }
.fam.sel { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(232,196,106,.25), 0 0 22px rgba(232,196,106,.18) inset; }
.fam.sel .nm { color: var(--gold); }
.fam.locked { cursor: default; opacity: .55; }
.fam.locked .nm { color: var(--faint); }
.fam.locked svg { opacity: .25; }

#dials { display: flex; flex-direction: column; gap: 9px; }
.dial { display: grid; grid-template-columns: 24px 74px 1fr 62px; align-items: center; gap: 10px; cursor: pointer; padding: 4px 8px; border-radius: 3px; border: 1px solid transparent; }
.dial .k { font-family: var(--serif); font-style: italic; font-size: 24px; color: var(--bone); line-height: 1; }
.dial .n { font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: .04em; }
.dial .track { position: relative; height: 18px; }
.dial .track::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: linear-gradient(90deg, #2a2f4a, #4a5378 50%, #2a2f4a); }
.dial .zero { position: absolute; top: 3px; width: 1px; height: 12px; background: #4a5378; }
.dial .anchor { position: absolute; top: 5px; width: 5px; height: 8px; margin-left: -2px; border: 1px solid #5a6080; border-top: none; }
.dial .knob { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; transform: rotate(45deg); background: var(--bone); box-shadow: 0 0 8px rgba(236,232,221,.5); }
.dial .v { font-family: var(--mono); font-size: 15px; text-align: right; color: var(--bone); }
.dial.sel { border-color: rgba(232,196,106,.35); background: rgba(232,196,106,.05); }
.dial.sel .k, .dial.sel .v { color: var(--gold); }
.dial.sel .knob { background: var(--gold); box-shadow: 0 0 10px rgba(232,196,106,.7); }
.dial.edited .n::after { content: ' ◆'; color: var(--bone-dim); }

#readout { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#eq { font-family: var(--serif); font-size: 34px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 0 16px rgba(236,232,221,.15); }
#eq .var { font-style: italic; }
#eq .num { font-family: var(--mono); font-size: 26px; letter-spacing: -.02em; }
#eq .op { color: var(--bone-dim); }
#eq .sup { font-size: 20px; vertical-align: 14px; font-style: italic; }
#eq .pow { font-family: var(--serif); font-size: 30px; margin-left: 1px; }
#eq .hl { color: var(--gold); }
#eq-sub { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
#eq-sub .warn { color: var(--noise); }
#eq-sub .good { color: var(--gold); }
#soul-row { display: flex; align-items: center; gap: 12px; }
#soul-row .lbl { font-family: var(--title); font-size: 11px; letter-spacing: .3em; color: var(--muted); }
#soul { display: flex; gap: 8px; }
.orb { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--bone); transition: all .25s; }
.orb.full { background: radial-gradient(circle at 35% 35%, #fff, #dcd8ee 45%, #8f93b8 100%); box-shadow: 0 0 10px rgba(220,225,255,.55); }
.orb.spent { border-color: #6a6f90; background: transparent; box-shadow: none; }
.orb.deny { animation: deny .35s; }
@keyframes deny { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); border-color: var(--noise); } 75% { transform: translateX(4px); border-color: var(--noise); } }
#soul-note { font-family: var(--mono); font-size: 11px; color: var(--faint); }

#stance-note { position: absolute; left: 0; right: 0; top: -10px; text-align: center; font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--muted); pointer-events: none; text-shadow: 0 0 6px #000, 0 0 12px #000; }
#stance-note b { color: var(--gold); font-weight: 600; }
#actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 250px; }
#actions button { font: inherit; color: var(--muted); background: rgba(14,17,30,.9); border: 1px solid #2a2f4a; border-radius: 3px; padding: 7px 10px; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all .15s; }
#actions button:hover { border-color: #4a5378; color: var(--bone); }
#actions button .ic { font-size: 16px; width: 16px; text-align: center; }
#actions button .tx { font-family: var(--mono); font-size: 11.5px; }
#actions button.on { color: var(--gold); border-color: rgba(232,196,106,.5); }
#btn-face { grid-column: 1 / 3; }
#btn-leap { grid-column: 1 / 3; justify-content: center; padding: 11px 10px !important; border-color: rgba(236,232,221,.5) !important; color: var(--bone) !important;
  background: linear-gradient(180deg, rgba(40,44,70,.9), rgba(14,16,28,.95)) !important; }
#btn-leap .tx { font-family: var(--title) !important; font-size: 15px !important; letter-spacing: .4em; }
#btn-leap .key { font-family: var(--mono); font-size: 10px; color: var(--faint); }
#btn-leap:hover { box-shadow: 0 0 18px rgba(236,232,221,.2); }
#btn-leap:disabled { opacity: .4; cursor: default; }
#btn-sight, #btn-lens { grid-row: 1; }
#btn-face { grid-row: 2; }

/* ---------------- toasts, bubble, banners ---------------- */
#toast { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); max-width: min(760px, 80vw); text-align: center;
  font-family: var(--serif); font-style: italic; font-size: 21px; color: var(--bone); text-shadow: 0 2px 12px #000, 0 0 2px #000; opacity: 0; transition: opacity .5s; }
#toast.show { opacity: 1; }
#toast.warn { color: #f1b07a; }
#toast .hint-lbl { display: block; font-family: var(--title); font-style: normal; font-size: 11px; letter-spacing: .35em; color: var(--gold-dim); margin-bottom: 4px; }

#bubble { position: absolute; width: 360px; padding: 14px 18px 12px; background: rgba(5,6,12,.88); border: 1px solid rgba(236,232,221,.25); border-radius: 2px;
  box-shadow: 0 8px 30px rgba(0,0,0,.6); opacity: 0; transform: translateY(6px); transition: opacity .35s, transform .35s; cursor: pointer; pointer-events: none; }
#bubble.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
#bubble::after { content: ''; position: absolute; left: var(--tail, 50%); bottom: -7px; width: 12px; height: 12px; background: rgba(5,6,12,.95); border-right: 1px solid rgba(236,232,221,.25); border-bottom: 1px solid rgba(236,232,221,.25); transform: translateX(-50%) rotate(45deg); }
#bubble .who { font-family: var(--title); font-size: 12px; letter-spacing: .3em; color: var(--gold); text-transform: uppercase; margin-bottom: 6px; }
#bubble .say { font-size: 19px; line-height: 1.35; min-height: 52px; }
#bubble .more { font-family: var(--mono); font-size: 10px; color: var(--faint); text-align: right; margin-top: 6px; }

#banner { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; opacity: 0; transition: opacity .6s; pointer-events: none; }
#banner.show { opacity: 1; }
#banner .b-t { font-family: var(--title); font-size: 30px; letter-spacing: .4em; color: var(--bone); text-shadow: 0 0 30px rgba(220,230,255,.35); }
#banner .b-o { width: 340px; height: 10px; margin: 12px auto; background: linear-gradient(90deg, transparent, rgba(236,232,221,.6), transparent) center / 100% 1px no-repeat; position: relative; }
#banner .b-o::after { content: ''; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; background: var(--bone); transform: translate(-50%,-50%) rotate(45deg); }
#banner .b-s { font-family: var(--mono); font-size: 13.5px; color: var(--muted); line-height: 1.9; }
#banner .b-s b { color: var(--bone); }
#banner .b-r { font-family: var(--serif); font-style: italic; font-size: 24px; color: var(--gold); margin-top: 6px; }
#banner .b-steel { color: var(--blue); font-family: var(--title); font-size: 12px; letter-spacing: .3em; margin-top: 6px; }

/* ---------------- overlays ---------------- */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .8s; }
.overlay.show { opacity: 1; pointer-events: auto; }
#title { background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,.15), rgba(0,0,0,.75) 75%); }
#title .t-inner { text-align: center; }
#title h1 { font-family: var(--title); font-weight: 400; font-size: clamp(56px, 9vw, 128px); letter-spacing: .32em; margin: 10px 0 0 .32em; color: #f2efe6;
  text-shadow: 0 0 40px rgba(210,225,255,.35), 0 0 2px rgba(255,255,255,.5); background: linear-gradient(180deg, #fff 30%, #b9b4a6); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.t-sub { font-style: italic; font-size: 24px; color: var(--bone-dim); margin-top: 4px; }
.t-orn { width: min(560px, 70vw); height: 18px; margin: 18px auto; position: relative;
  background: linear-gradient(90deg, transparent, rgba(236,232,221,.65) 40%, transparent 48%, transparent 52%, rgba(236,232,221,.65) 60%, transparent) center / 100% 1px no-repeat; }
.t-orn::after { content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; border: 1px solid var(--bone); transform: translate(-50%,-50%) rotate(45deg); }
.t-orn.top::after { background: var(--bone); }
.t-press { font-family: var(--title); letter-spacing: .3em; font-size: 15px; color: var(--bone); animation: breathe 2.6s ease-in-out infinite; margin-top: 16px; }
.t-press b { color: var(--gold); font-weight: 400; }
.t-cont { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 10px; min-height: 16px; }
.t-keys { margin-top: 34px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); line-height: 2; }
.t-keys b { color: var(--bone); font-weight: 600; }
.t-foot { margin-top: 30px; font-family: var(--title); font-size: 10px; letter-spacing: .4em; color: var(--faint); text-transform: uppercase; }
@keyframes breathe { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

#zonecard { flex-direction: column; background: transparent; pointer-events: none !important; transition: opacity 1.2s; }
#zonecard .z-num { font-family: var(--title); font-size: 14px; letter-spacing: .6em; color: var(--muted); }
#zonecard .z-name { text-align: center; max-width: 92vw; font-family: var(--title); font-size: clamp(30px, 4.4vw, 64px); letter-spacing: .18em; color: #f2efe6; margin-top: 10px; text-shadow: 0 0 40px rgba(210,225,255,.4), 0 2px 10px #000; }
#zonecard .z-orn { width: min(520px, 60vw); height: 14px; margin: 14px 0; background: linear-gradient(90deg, transparent, rgba(236,232,221,.7), transparent) center / 100% 1px no-repeat; position: relative; }
#zonecard .z-orn::after { content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; background: var(--bone); transform: translate(-50%,-50%) rotate(45deg); }
#zonecard .z-sub { text-align: center; max-width: 86vw; font-style: italic; font-size: 24px; color: var(--bone-dim); text-shadow: 0 2px 10px #000; }

.panel-overlay { background: rgba(0,0,0,.72); }
.p-inner { max-width: 720px; padding: 38px 46px; background: var(--panel); border: 1px solid rgba(236,232,221,.2); box-shadow: 0 20px 60px rgba(0,0,0,.6); position: relative; }
.p-inner::before { content: ''; position: absolute; inset: 6px; border: 1px solid rgba(232,196,106,.15); pointer-events: none; }
.p-inner h2 { font-family: var(--title); font-weight: 400; letter-spacing: .25em; font-size: 22px; margin: 0 0 16px; color: var(--bone); }
.p-inner p, .p-inner li { font-size: 19px; line-height: 1.45; color: #d6d3ca; }
.p-inner li { margin: 6px 0; }
.p-inner b { color: var(--bone); }
.p-close { font-family: var(--mono); font-size: 12px !important; color: var(--faint) !important; text-align: center; margin-top: 18px; }
#ending table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; margin: 12px 0 18px; }
#ending td, #ending th { padding: 6px 8px; border-bottom: 1px solid #1d2136; text-align: left; color: var(--muted); }
#ending th { color: var(--faint); font-weight: 400; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
#ending td.r { color: var(--gold); font-family: var(--serif); font-style: italic; font-size: 17px; }
#ending td.s { color: var(--blue); }


/* ---------------- waking world HUD ---------------- */
.hidden { display: none !important; }
#walkhud {
  position: absolute; left: 0; right: 0; bottom: 0; height: 108px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 28px; align-items: center; padding: 22px 34px 14px;
  background: linear-gradient(180deg, rgba(4,5,10,0) 0%, rgba(4,5,10,.7) 30%, rgba(4,5,10,.92) 100%);
}
#walkhud .filigree { position: absolute; left: 6%; right: 6%; top: 8px; height: 10px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(232,196,106,.35) 30%, rgba(232,196,106,.35) 70%, transparent) center / 100% 1px no-repeat; }
#instruments { display: grid; grid-template-columns: repeat(4, 74px); gap: 8px; }
.inst { position: relative; height: 70px; border: 1px solid #2a2f4a; background: linear-gradient(180deg, rgba(22,26,46,.9), rgba(10,12,22,.9));
  border-radius: 3px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 6px; cursor: pointer; transition: border-color .2s, box-shadow .2s; pointer-events: auto; }
.inst svg { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 46px; height: 37px; }
.inst .nm { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.inst .kb { position: absolute; top: 3px; left: 5px; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.inst.sel { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(232,196,106,.25), 0 0 22px rgba(232,196,106,.18) inset; }
.inst.sel .nm { color: var(--gold); }
.inst.locked { opacity: .45; cursor: default; }
#inst-form { font-family: var(--serif); font-style: italic; font-size: 32px; color: var(--bone); text-shadow: 0 0 16px rgba(236,232,221,.15); }
#inst-note { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 2px; }
#walk-keys { font-family: var(--mono); font-size: 11.5px; color: var(--faint); line-height: 1.75; text-align: right; }
#walk-keys b { color: var(--bone-dim); font-weight: 600; }

#bossbar { position: absolute; left: 50%; bottom: 124px; width: min(640px, 70vw); transform: translateX(-50%); text-align: center; opacity: 0; transition: opacity .8s; pointer-events: none; }
#bossbar.show { opacity: 1; }
#bossbar .bb-name { font-family: var(--title); font-size: 13px; letter-spacing: .4em; color: #f1b07a; text-transform: uppercase; margin-bottom: 6px; text-shadow: 0 0 12px rgba(232,130,58,.4), 0 2px 6px #000; }
#bossbar .bb-track { height: 8px; border: 1px solid rgba(232,130,58,.55); background: rgba(10,6,4,.8); padding: 1px; }
#bossbar .bb-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #7a2e10, #e8823a 60%, #ffc08a); box-shadow: 0 0 10px rgba(232,130,58,.6); transition: width .25s; }

/* ---------------- cutscenes ---------------- */
#letterbox .lb { position: absolute; left: 0; right: 0; height: 11vh; background: #000; transition: transform .7s ease; z-index: 5; }
#letterbox .top { top: 0; transform: translateY(-100%); }
#letterbox .bot { bottom: 0; transform: translateY(100%); }
#letterbox.show .lb { transform: translateY(0); }
#cinesub { position: absolute; left: 50%; bottom: 3.2vh; transform: translateX(-50%); width: min(880px, 86vw); text-align: center; z-index: 6; opacity: 0; transition: opacity .35s; pointer-events: none; }
#cinesub.show { opacity: 1; }
#cinesub .cs-who { font-family: var(--title); font-size: 12px; letter-spacing: .38em; color: var(--gold); text-transform: uppercase; min-height: 14px; }
#cinesub .cs-text { font-size: 23px; line-height: 1.35; color: var(--bone); margin-top: 4px; min-height: 31px; text-shadow: 0 2px 8px #000; }
#cinesub.narration .cs-text { font-style: italic; color: var(--bone-dim); }
#cinesub .cs-more { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 4px; }
#cinecard { z-index: 7; background: radial-gradient(ellipse at 50% 42%, rgba(10,12,22,.96), rgba(0,0,0,.99) 70%); transition: opacity 1s; }
#cinecard .cc-inner { max-width: 760px; text-align: center; padding: 0 30px; }
#cinecard.show .cc-inner > * { animation: ccIn 1.4s both; }
#cinecard.show .cc-title { animation-delay: .25s; } #cinecard.show .cc-text { animation-delay: .55s; } #cinecard.show .cc-more { animation-delay: 1.6s; }
@keyframes ccIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#cinecard .cc-emblem svg { width: 190px; height: 190px; filter: drop-shadow(0 0 18px rgba(232,196,106,.18)); }
#cinecard .cc-emblem:empty { display: none; }
#cinecard .cc-kicker { font-family: var(--title); font-size: 12px; letter-spacing: .5em; color: var(--muted); text-transform: uppercase; margin-top: 12px; min-height: 14px; }
#cinecard .cc-title { font-family: var(--title); font-size: clamp(28px, 4vw, 46px); letter-spacing: .16em; color: #f2efe6; margin: 8px 0 18px; text-shadow: 0 0 30px rgba(210,225,255,.3); }
#cinecard .cc-text { font-size: 23px; line-height: 1.55; color: #d6d3ca; }
#cinecard .cc-more, #cinesub .cs-more { animation: breathe 2.6s ease-in-out infinite; }
#cinecard .cc-more { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 26px; }
#cine-skip { position: absolute; right: 22px; top: calc(11vh + 12px); font-family: var(--mono); font-size: 11px; color: var(--faint); opacity: 0; transition: opacity .5s; z-index: 8; pointer-events: none; }
#cine-skip.show { opacity: .8; }
.p-inner { max-height: 88vh; overflow-y: auto; }
body.cine #hud, body.cine #walkhud, body.cine #bossbar, body.cine #tally, body.cine #bubble { opacity: 0 !important; transition: opacity .5s; }

#fade { position: absolute; z-index: 20; inset: 0; background: #000; opacity: 1; transition: opacity .7s; pointer-events: none; }
#fade.clear { opacity: 0; }

@media (max-width: 1180px) {
  :root { --hud-h: 200px; }
  #hud { grid-template-columns: auto 1fr auto; gap: 16px; padding: 22px 18px 14px; }
  #families { grid-template-columns: repeat(5, 54px); }
  .fam { height: 70px; } .fam svg { width: 38px; height: 30px; top: 8px; }
  #readout { grid-column: 1 / 4; grid-row: 2; flex-direction: row; align-items: center; gap: 20px; }
  #eq { font-size: 26px; } #eq .num { font-size: 20px; }
  #actions { width: 200px; }
}

/* ---------------- the Count (arithmetic interstitial in boss fights) ---------------- */
#count { background: radial-gradient(ellipse at 50% 50%, rgba(8,10,24,.78), rgba(0,0,0,.9) 75%); transition: opacity .35s; }
#count .c-inner { text-align: center; padding: 30px 46px 26px; min-width: min(640px, 92vw); position: relative;
  background: linear-gradient(180deg, rgba(18,20,36,.92), rgba(8,9,18,.95)); border: 1px solid rgba(232,196,106,.3); box-shadow: 0 0 80px rgba(232,196,106,.08), 0 20px 60px rgba(0,0,0,.7); }
#count .c-inner::before { content: ''; position: absolute; inset: 6px; border: 1px solid rgba(232,196,106,.12); pointer-events: none; }
.c-kicker { font-family: var(--title); font-size: 12px; letter-spacing: .4em; color: var(--muted); }
.c-title { font-family: var(--serif); font-style: italic; font-size: 26px; color: var(--bone-dim); margin-top: 6px; }
.c-title b { font-family: var(--title); font-style: normal; color: var(--gold); font-size: 34px; letter-spacing: .1em; }
#c-row { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 22px 0 8px; font-family: var(--title); }
#c-row .slot { min-width: 54px; height: 72px; display: flex; align-items: center; justify-content: center; border-radius: 4px; cursor: pointer; transition: background .15s, box-shadow .15s; }
#c-row .dig { font-size: 50px; color: #f2efe6; padding: 0 6px; }
#c-row .dig .br { color: var(--gold); font-size: 44px; }
#c-row .dig.res { color: var(--gold); padding-left: 14px; }
#c-row .op { min-width: 46px; font-size: 40px; color: var(--gold); border: 1px dashed rgba(232,196,106,.35); }
#c-row .op.empty { color: rgba(232,196,106,.25); }
#c-row .slot.cur { background: rgba(232,196,106,.12); box-shadow: 0 0 0 1px rgba(232,196,106,.7), 0 0 24px rgba(232,196,106,.25); }
#c-val { font-family: var(--mono); font-size: 18px; color: var(--muted); min-height: 26px; }
#c-val.hit { color: var(--gold); }
#c-val.miss { color: #ff8a6a; }
#c-val.nudge { animation: cnudge .3s; }
@keyframes cnudge { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
#c-timer { height: 4px; margin: 14px auto 10px; width: 80%; background: rgba(255,255,255,.08); overflow: hidden; }
#c-timer .c-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #e8823a, #e8c46a); transform-origin: left; }
#c-allowed { font-family: var(--mono); font-size: 13px; color: var(--muted); }
#c-allowed b { color: var(--gold); font-size: 16px; margin: 0 3px; }
#c-keys { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-top: 10px; line-height: 1.8; }
#c-keys b { color: var(--bone-dim); }
#c-result { font-family: var(--title); letter-spacing: .3em; font-size: 22px; min-height: 30px; margin-top: 12px; }
#c-result.win { color: var(--gold); text-shadow: 0 0 20px rgba(232,196,106,.5); }
#c-result.lose { color: #ff8a6a; }
#c-result .sol { display: block; font-family: var(--mono); letter-spacing: 0; font-size: 15px; color: var(--bone-dim); margin-top: 6px; }
