@font-face { font-family: 'Naskh'; src: url('./assets/fonts/NotoNaskhArabic-Variable.ttf') format('truetype'); font-weight: 400 700; }
@font-face { font-family: 'Alex'; src: url('./assets/fonts/Alexandria-Variable.ttf') format('truetype'); font-weight: 100 900; }
/* headlines: Rakkas, heavy as a film poster; everything else stays Naskh (reading) and Alexandria (interface) */
@font-face { font-family: 'Rakkas'; src: url('./assets/fonts/Rakkas-Regular.ttf') format('truetype'); font-weight: 400; }

/* =====================================================================
   الدَّور الثالث: the interface
   A PS1-era survival-horror skin: black lacquer panels with brass corner
   brackets, sodium-lamp gold for what is read, dried blood for what is
   chosen, film grain and scanlines over every screen. No letter-spacing on
   Arabic (it breaks the joins); spacing is done with words and rules.
   ===================================================================== */
:root {
  --ink: #e8dcc4; --ink2: #cfc2aa; --dim: #8f8370; --mute: #5d5446;
  --gold: #c9a46a; --gold-hi: #f1d9a4; --gold-lo: #6d5a3c;
  --blood: #7e1810; --blood-hi: #c2321f; --rust: #a4542a;
  --panel: rgba(9, 7, 6, .94); --line: rgba(232, 220, 196, .13); --line-gold: rgba(201, 164, 106, .3);
  --bk: 18px; /* corner bracket length */
  /* four brass corner brackets, layered over any background */
  --corners:
    linear-gradient(var(--gold), var(--gold)) left top / var(--bk) 2px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left top / 2px var(--bk) no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / var(--bk) 2px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / 2px var(--bk) no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / var(--bk) 2px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / 2px var(--bk) no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / var(--bk) 2px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / 2px var(--bk) no-repeat;
  --scan: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 3px);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  /* a rule with a diamond in the middle */
  --orn: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='12' viewBox='0 0 240 12'><defs><linearGradient id='g'><stop offset='0' stop-color='%23c9a46a' stop-opacity='0'/><stop offset='.5' stop-color='%23c9a46a'/><stop offset='1' stop-color='%23c9a46a' stop-opacity='0'/></linearGradient></defs><rect y='5.5' width='240' height='1' fill='url(%23g)'/><path d='M120 1 L125 6 L120 11 L115 6 Z' fill='%23140e0a' stroke='%23c9a46a'/><path d='M120 4 L122 6 L120 8 L118 6 Z' fill='%23c2321f'/></svg>");
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--ink); overflow: hidden; font-family: 'Alex', sans-serif; user-select: none; }
#game { position: fixed; inset: 0; overflow: hidden; }
#game canvas.stage { max-width: 100%; max-height: 100%; }
canvas.stage { position: absolute; image-rendering: pixelated; image-rendering: crisp-edges; }
.hidden { display: none !important; }
::selection { background: var(--blood); }
* { scrollbar-width: thin; scrollbar-color: var(--gold-lo) transparent; }

/* film grain over everything, very faint over the 3D view */
#fx { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
#fx .grain { position: absolute; inset: -60px; background: var(--grain); opacity: .07; mix-blend-mode: overlay; animation: grain .5s steps(1) infinite; }
#fx .vig { position: absolute; inset: 0; background: radial-gradient(ellipse 85% 80% at 50% 50%, transparent 60%, rgba(0,0,0,.55) 100%); }
@keyframes grain { 0% { transform: translate(0,0); } 20% { transform: translate(-23px,14px); } 40% { transform: translate(17px,-31px); } 60% { transform: translate(-9px,27px); } 80% { transform: translate(31px,6px); } }
@keyframes throb { 50% { opacity: .4; } }
@keyframes flick { 0%, 91%, 100% { opacity: 1; } 92% { opacity: .35; } 93% { opacity: 1; } 95.5% { opacity: .6; } 96.5% { opacity: 1; } }
@keyframes cursor { 0%, 100% { transform: translateY(-50%) rotate(45deg) scale(1); } 50% { transform: translateY(-50%) rotate(45deg) scale(.7); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); filter: blur(3px); } }

/* =================== button glyphs =================== */
kbd { display: inline-block; direction: ltr; font-family: 'Alex', monospace; font-weight: 600; font-size: .74em; min-width: 1.9em; height: 1.9em; line-height: 1.6em; text-align: center;
  border: 1px solid rgba(232,220,196,.42); border-bottom-width: 3px; border-radius: 5px; padding: 0 .45em; margin: 0 .12em;
  color: #efe3c8; background: linear-gradient(#2c251d, #120f0b); box-shadow: 0 1px 4px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08); vertical-align: middle; }
.gl { display: inline-flex; align-items: center; justify-content: center; direction: ltr; font-family: 'Alex', sans-serif; font-weight: 700; vertical-align: middle;
  margin: 0 .14em; color: #e9dfca; box-shadow: 0 1px 4px rgba(0,0,0,.6); line-height: 1; }
.gl.face { width: 1.75em; height: 1.75em; border-radius: 50%; border: 2px solid currentColor; background: radial-gradient(circle at 40% 35%, #2c2620, #0e0c0a); font-size: .8em; }
.g-a { color: #9ccc8f; } .g-b { color: #df7b66; } .g-y { color: #e3c56e; }
body[data-device="pad-ps"] .g-a { color: #9db4e6; } body[data-device="pad-ps"] .g-b { color: #e2827a; } body[data-device="pad-ps"] .g-y { color: #7fcfb0; }
.gl.sh { height: 1.55em; min-width: 2.4em; padding: 0 .4em; border-radius: .55em .55em .25em .25em; border: 2px solid rgba(232,220,196,.6); background: linear-gradient(#2a241d, #12100c); font-size: .66em; }
.gl.sys { height: 1.55em; padding: 0 .55em; border-radius: .8em; border: 2px solid rgba(232,220,196,.5); background: #15120e; font-size: .6em; }
.gl.stick { width: 1.9em; height: 1.9em; border-radius: 50%; border: 2px solid rgba(232,220,196,.6); background: radial-gradient(circle, #3a332a 0 38%, #15120e 40%); font-size: .62em; }
.gl.dpad { width: 1.45em; height: 1.45em; box-shadow: none; filter: drop-shadow(0 1px 2px #000);
  background: linear-gradient(rgba(232,220,196,.85), rgba(232,220,196,.85)) center / 34% 100% no-repeat, linear-gradient(rgba(232,220,196,.85), rgba(232,220,196,.85)) center / 100% 34% no-repeat; }
.gl.dpad.v { background: linear-gradient(#efe3c8, #efe3c8) center / 34% 100% no-repeat, linear-gradient(rgba(232,220,196,.28), rgba(232,220,196,.28)) center / 100% 34% no-repeat; }
.gl.dpad.h { background: linear-gradient(rgba(232,220,196,.28), rgba(232,220,196,.28)) center / 34% 100% no-repeat, linear-gradient(#efe3c8, #efe3c8) center / 100% 34% no-repeat; }
.gl-keys { display: inline-flex; direction: ltr; align-items: center; }
/* a legend: glyph + label pairs */
[data-hint] > span { display: inline-flex; align-items: center; gap: .45em; margin: 0 .8em; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; row-gap: 8px; font-size: 14px; color: #b4a78f; }

/* =================== shared pieces =================== */
/* a framed lacquer panel */
.inv-wrap, .menu-box {
  background: var(--corners), var(--scan), radial-gradient(ellipse 120% 90% at 50% 0%, #1a1410 0%, #0b0907 55%, #060504 100%);
  border: 1px solid var(--line-gold);
  box-shadow: 0 0 0 1px #000, 0 0 0 6px rgba(9,7,6,.9), 0 0 0 7px rgba(201,164,106,.12), 0 40px 120px #000, inset 0 0 120px rgba(0,0,0,.7);
  animation: riseIn .28s ease-out;
}
/* the plain action button: a stamped plate */
#inv-actions button, .pz-btn {
  all: unset; box-sizing: border-box; cursor: pointer; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 26px; font-family: 'Alex'; font-weight: 500; font-size: 15px; color: var(--ink2);
  background: linear-gradient(#211b15, #0f0c09); border: 1px solid rgba(201,164,106,.32); border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255,235,200,.08), inset 0 -2px 0 rgba(0,0,0,.5), 0 3px 10px rgba(0,0,0,.6);
  transition: color .15s, background .15s, border-color .15s, box-shadow .15s, transform .08s;
}
#inv-actions button:hover, .pz-btn:hover, .pz-btn.sel, #cacts .pz-btn.sel {
  color: #fff3dc; border-color: var(--gold);
  background: linear-gradient(#5a1a12, #2c0c08);
  box-shadow: inset 0 1px 0 rgba(255,200,170,.18), inset 0 -2px 0 rgba(0,0,0,.5), 0 0 18px rgba(194,50,31,.35), 0 3px 10px rgba(0,0,0,.6);
  text-shadow: 0 0 10px rgba(255,140,100,.45);
}
.pz-btn:active, #inv-actions button:active { transform: translateY(1px); }
.pz-btn:disabled { opacity: .35; cursor: default; }
/* a held press fills the plate from the start side */
.pz-btn.hold { overflow: hidden; min-width: 220px; }
.pz-btn.hold::before { content: ''; position: absolute; inset: 0; inset-inline-end: auto; width: calc(var(--k, 0) * 100%); background: linear-gradient(90deg, rgba(194,50,31,.75), rgba(241,217,164,.35)); z-index: -1; }
.pz-btn.hold { isolation: isolate; }

/* =================== HUD =================== */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
/* the clock: a little plate, the night draining out of a bar */
#clock { position: absolute; top: 16px; left: 18px; direction: ltr; display: flex; flex-direction: column; align-items: flex-start; padding: 8px 16px 8px 14px;
  background: linear-gradient(90deg, rgba(8,6,5,.82), rgba(8,6,5,.5) 70%, rgba(8,6,5,0)); border-left: 2px solid var(--gold);
  text-shadow: 0 0 6px #000; transition: color 1s, border-color 1s; }
#clock::before { content: ''; position: absolute; left: -2px; top: -1px; width: 10px; height: 1px; background: var(--gold); }
#clock::after { content: ''; position: absolute; left: -2px; bottom: -1px; width: 10px; height: 1px; background: var(--gold); }
#clock-time { font-family: 'Alex'; font-weight: 300; font-size: 28px; line-height: 1.05; color: #efe3c8; }
#clock-bar { position: relative; display: block; width: 140px; height: 4px; margin: 6px 0 5px; background: rgba(232,220,196,.1); box-shadow: inset 0 0 0 1px rgba(0,0,0,.6); overflow: hidden; }
#clock-bar::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 13px, rgba(0,0,0,.7) 13px 14px); }
#clock-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #6d5a3c, var(--gold)); box-shadow: 0 0 8px rgba(201,164,106,.6); transition: width .6s linear; }
#clock-note { font-size: 11px; color: var(--dim); direction: rtl; }
#clock.late #clock-time { color: #e0a97f; }
#clock.late #clock-fill { background: linear-gradient(90deg, #8a5a3a, #d9a07a); }
#clock.dawn { border-left-color: #e06a4a; }
#clock.dawn #clock-time { color: #ee7656; animation: throb 1.2s infinite; text-shadow: 0 0 12px rgba(224,90,60,.6); }
#clock.dawn #clock-fill { background: linear-gradient(90deg, #8a3a2a, #e06a4a); box-shadow: 0 0 10px rgba(224,90,60,.8); }
#clock.hit { animation: clockhit .6s ease-out; }
@keyframes clockhit { 0% { transform: translateX(-7px); filter: brightness(2) saturate(2); } 20% { transform: translateX(6px); } 40% { transform: translateX(-3px); } 100% { transform: none; } }
#clock-pen { font-size: 14px; font-weight: 600; color: #ef7a58; opacity: 0; direction: rtl; margin-top: 2px; text-shadow: 0 0 8px rgba(224,90,60,.6); }
#clock-pen.show { animation: pen 3.2s ease-out; }
@keyframes pen { 0% { opacity: 0; transform: translateY(-4px); } 10% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* the room's name: a title card in the corner */
#room-name { position: absolute; top: 14px; right: 64px; font-family: 'Rakkas'; font-weight: 400; font-size: 26px; opacity: 0; transition: opacity 1.4s; text-shadow: 0 0 10px #000, 0 0 2px #000;
  padding-bottom: 8px; background: var(--orn) right bottom / 160px 12px no-repeat; }
#room-name.show { opacity: .9; }

/* the interaction marker: a diamond on the object, the action at the bottom */
#target { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; }
.tg-diamond { position: absolute; left: -8px; top: -8px; width: 16px; height: 16px; transform: rotate(45deg); border: 2px solid #f6ead2;
  background: radial-gradient(circle, #fff6e0 0 25%, rgba(246,234,210,.85) 30%); box-shadow: 0 0 14px rgba(255,236,200,.6), 0 0 2px #000; animation: tgpulse 1.8s ease-in-out infinite; }
.tg-diamond::after { content: ''; position: absolute; inset: -7px; border: 1px solid rgba(246,234,210,.35); }
#target.far .tg-diamond { background: rgba(0,0,0,.3); opacity: .8; animation: none; }
#target.far .tg-diamond::after { display: none; }
@keyframes tgpulse { 50% { box-shadow: 0 0 22px rgba(255,236,200,.85), 0 0 2px #000; transform: rotate(45deg) scale(1.15); } }
#pips { position: absolute; inset: 0; pointer-events: none; }
#pips i { position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; transform: rotate(45deg); background: rgba(232,220,196,.55); box-shadow: 0 0 5px #000; }
#prompt { position: absolute; bottom: 7%; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 11px 54px; white-space: nowrap;
  background:
    linear-gradient(90deg, transparent, rgba(201,164,106,.55) 30%, rgba(201,164,106,.55) 70%, transparent) top / 100% 1px no-repeat,
    linear-gradient(90deg, transparent, rgba(201,164,106,.3) 30%, rgba(201,164,106,.3) 70%, transparent) bottom / 100% 1px no-repeat,
    linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,.78) 22%, rgba(0,0,0,.78) 78%, rgba(0,0,0,0));
  font-size: 18px; color: #efe3c8; }
#prompt.pop { animation: prpop .22s ease-out; }
@keyframes prpop { from { opacity: 0; transform: translate(-50%, 6px); } }
#prompt.far { opacity: .78; }
.pr-btn { display: inline-flex; font-size: 20px; }
.pr-verb { font-size: 13px; color: #b4a78f; }
.pr-name { font-family: 'Naskh'; font-weight: 600; font-size: 21px; }
.pr-cycle { display: inline-flex; font-size: 15px; opacity: .55; margin-inline-start: 6px; }
#hover-label { position: fixed; font-size: 13px; color: var(--ink); background: rgba(6,5,4,.85); border: 1px solid var(--line-gold); padding: 3px 10px; transform: translate(-50%, -140%); white-space: nowrap; }
#thought { position: absolute; bottom: 17%; left: 50%; transform: translateX(-50%); font-family: 'Naskh'; font-size: 20px; color: #cfc2aa; text-shadow: 0 0 10px #000, 0 0 3px #000; max-width: 70%; text-align: center; font-style: italic; opacity: 0; transition: opacity .8s; }
#thought.show { opacity: 1; }
#thought.tip { font-family: 'Alex'; font-style: normal; font-size: 16px; color: #d8ccb3; line-height: 2.1; background: rgba(6,5,4,.78); border: 1px solid var(--line-gold); padding: 6px 24px; }
#ctrl-strip { position: absolute; bottom: 22px; left: 22px; display: flex; font-size: 13px; color: #b4a78f; opacity: 0; transition: opacity 1s; text-shadow: 0 0 6px #000; }
#ctrl-strip.show { opacity: .85; }
#menu-btn { all: unset; position: absolute; top: 16px; right: 16px; pointer-events: auto; cursor: pointer; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--ink); opacity: .55; background: rgba(6,5,4,.5); border: 1px solid var(--line-gold); transition: opacity .2s, background .2s; }
#menu-btn:hover { opacity: 1; background: rgba(126,24,16,.6); }
#menu-btn.fresh { opacity: .85; }
#menu-btn.fresh::after { content: ''; position: absolute; top: -4px; left: -4px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); }

/* =================== dialogue: a cinematic band =================== */
#msg { position: fixed; z-index: 36; left: 0; right: 0; bottom: 0; padding: 64px 12vw 50px;
  background:
    linear-gradient(90deg, transparent 8%, rgba(201,164,106,.4) 35%, rgba(201,164,106,.4) 65%, transparent 92%) 0 30px / 100% 1px no-repeat,
    linear-gradient(to top, rgba(0,0,0,.95) 0%, rgba(0,0,0,.84) 55%, rgba(0,0,0,0) 100%);
  font-family: 'Naskh'; font-size: clamp(19px, 1.65vw, 26px); line-height: 1.8; text-align: center; color: #ece2cd; text-shadow: 0 1px 2px #000; }
#msg::before { content: ''; position: absolute; left: 50%; top: 24px; width: 13px; height: 13px; margin-left: -6.5px; transform: rotate(45deg); background: #0c0907; border: 1px solid var(--gold); box-shadow: inset 0 0 0 3px #0c0907, inset 0 0 0 6px var(--blood-hi); }
#msg-catch { position: fixed; inset: 0; z-index: 35; cursor: pointer; }
#msg-text { max-width: 980px; margin: 0 auto; min-height: 1.8em; }
#msg-who { width: fit-content; margin: 0 auto 6px; padding: 1px 22px; font-family: 'Alex'; font-weight: 600; font-size: .6em; color: var(--gold-hi); opacity: .95;
  background: linear-gradient(90deg, transparent, rgba(126,24,16,.55) 20%, rgba(126,24,16,.55) 80%, transparent); }
#msg.inner #msg-text { font-style: italic; color: #b9ad98; font-size: .94em; }
#msg.stage #msg-text { font-family: 'Alex'; font-size: .72em; color: #93a29a; }
#msg-choices { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 14px; justify-content: center; font-family: 'Alex'; font-size: 18px; }
#msg-choices.row { flex-direction: row; gap: 18px; }
#msg-choices button { all: unset; cursor: pointer; position: relative; padding: 8px 40px; color: #a99d86; border: 1px solid transparent; transition: color .15s, background .15s; }
#msg-choices button.sel, #msg-choices button:hover { color: #fff3dc; border-color: rgba(201,164,106,.5); background: linear-gradient(90deg, rgba(126,24,16,0), rgba(126,24,16,.6) 25%, rgba(126,24,16,.6) 75%, rgba(126,24,16,0)); text-shadow: 0 0 10px rgba(255,140,100,.4); }
#msg-choices button.sel::before { content: ''; position: absolute; inset-inline-start: 14px; top: 50%; width: 7px; height: 7px; background: var(--gold-hi); transform: translateY(-50%) rotate(45deg); animation: cursor 1s ease-in-out infinite; }
#msg-next { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; font-size: 15px; color: #8b7f6b; animation: throb 1.6s infinite; }

/* =================== overlays =================== */
.overlay { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.82); }
.overlay::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--scan); opacity: .55; }
.overlay > * { position: relative; z-index: 1; }
.overlay .hint { position: absolute; bottom: 0; left: 0; right: 0; z-index: 2; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; padding: 14px 20px 16px;
  background: linear-gradient(90deg, transparent, rgba(201,164,106,.35) 20%, rgba(201,164,106,.35) 80%, transparent) top / 100% 1px no-repeat, linear-gradient(to top, rgba(0,0,0,.92), rgba(0,0,0,.6)); font-size: 14px; color: #b4a78f; }
.overlay .hint .pz-btn.pz-back, .inv-foot .pz-back { padding: 4px 16px; font-size: 13px; margin-inline-start: 14px; }

/* =================== documents =================== */
#doc .paper { width: min(640px, 90vw); max-height: calc(100vh - 140px); overflow: auto; padding: 48px 56px; position: relative;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.1), transparent 60%), linear-gradient(170deg, #cbbd9f, #b3a283 60%, #9c8a6a);
  color: #2a2116; font-family: 'Naskh'; font-size: 21px; line-height: 1.95;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 14px 70px #000, inset 0 0 90px rgba(80,50,20,.5); transform: rotate(-.6deg); animation: paperIn .35s ease-out; }
@keyframes paperIn { from { opacity: 0; transform: rotate(-2deg) translateY(18px) scale(.97); } }
#doc .paper::before { content: ''; position: absolute; top: -2px; left: 50%; width: 110px; height: 26px; margin-left: -55px; transform: rotate(2deg); background: rgba(225,215,180,.55); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
#doc .paper::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 80% 85%, rgba(110,40,20,.24), transparent 30%), radial-gradient(circle at 12% 70%, rgba(60,40,20,.2), transparent 25%), var(--grain); background-size: auto, auto, 180px; mix-blend-mode: multiply; opacity: .9; }
#doc h2 { font-size: 18px; font-weight: 700; margin: 0 0 18px; color: #4a3826; border-bottom: 1px solid rgba(60,40,20,.35); padding-bottom: 8px; font-family: 'Alex'; }
#doc-body p { margin: 0 0 .6em; white-space: pre-line; }
#doc-body p.sd { font-family: 'Alex'; font-size: .78em; opacity: .75; }
#doc-body p.sig { text-align: left; font-style: italic; }
#doc .paper.hand { font-style: italic; color: #1f2a3a; }
#doc .paper.print { font-family: 'Alex'; font-size: 16px; line-height: 1.8; }
#doc .paper.photo { background: #1d1a16; color: #d6ccb6; }
#doc .paper.photo h2 { color: #b9a988; }
#doc .paper.tape { background: #050608; color: #b9d2c2; font-family: 'Alex'; font-size: 17px; box-shadow: 0 0 60px rgba(120,200,160,.08), inset 0 0 0 1px rgba(150,220,180,.15); transform: none; }
#doc .paper.tape h2 { color: #8fb8a0; border-color: rgba(150,220,180,.2); }
#doc .paper.photo::before, #doc .paper.tape::before, #doc .paper.phone::before { display: none; }
#doc .paper.tape::after, #doc .paper.phone::after { background: var(--scan); mix-blend-mode: normal; }
#doc .paper.phone { background: #10131a; color: #d8dcea; font-family: 'Alex'; font-size: 16px; box-shadow: 0 0 60px rgba(140,160,220,.08); transform: none; }
#doc .paper.phone h2 { color: #aab4d0; border-color: rgba(170,180,210,.2); }
#doc-hint { font-size: 13px; }

/* =================== inventory =================== */
.inv-wrap { width: min(1000px, 94vw); height: min(640px, 90vh); padding: 20px 28px; display: flex; flex-direction: column; position: relative; }
.inv-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; margin-bottom: 16px;
  background: linear-gradient(90deg, transparent, var(--line-gold) 15%, var(--line-gold) 85%, transparent) bottom / 100% 1px no-repeat; }
.inv-tabs { display: flex; align-items: center; gap: 2px; margin: 0; }
.inv-tabs button { all: unset; cursor: pointer; position: relative; padding: 8px 18px 10px; font-family: 'Alex'; font-weight: 500; font-size: 15px; color: var(--dim); transition: color .15s; }
.inv-tabs button:hover { color: var(--ink2); }
.inv-tabs button.on { color: #fff1d6; text-shadow: 0 0 12px rgba(201,164,106,.4); }
.inv-tabs button.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -13px; height: 3px; background: linear-gradient(90deg, transparent, var(--blood-hi), transparent); box-shadow: 0 0 10px rgba(194,50,31,.7); }
.inv-tabs button.on::before { content: ''; position: absolute; left: 50%; bottom: -16px; width: 7px; height: 7px; margin-left: -3.5px; transform: rotate(45deg); background: var(--gold-hi); }
.inv-tabs button.fresh::after { content: ''; display: inline-block; position: static; width: 5px; height: 5px; margin-inline-start: 6px; vertical-align: super; border-radius: 50%; background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.tab-glyph { display: inline-flex; font-size: 17px; cursor: pointer; margin: 0 8px; }
#inv-clock { direction: ltr; font-family: 'Alex'; font-weight: 300; font-size: 20px; color: var(--ink2); padding: 2px 14px; border-left: 2px solid var(--gold); }
.inv-main { flex: 1; display: flex; gap: 26px; min-height: 0; }
#inv-grid { display: grid; grid-template-columns: repeat(4, 98px); grid-auto-rows: 98px; gap: 10px; align-content: start; }
.slot { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: radial-gradient(ellipse at 50% 40%, #1d1813, #0a0807 75%); border: 1px solid rgba(232,220,196,.1);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.9), inset 0 0 0 1px rgba(0,0,0,.6), 0 1px 0 rgba(255,235,200,.04); transition: border-color .12s, background .12s; }
.slot img { width: 86%; height: 86%; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 4px 4px rgba(0,0,0,.8)); }
.slot.empty { cursor: default; opacity: .45; }
.slot.empty::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; transform: rotate(45deg); border: 1px solid rgba(232,220,196,.15); }
.slot.sel { --bk: 14px; border-color: rgba(201,164,106,.45);
  background: var(--corners), radial-gradient(ellipse at 50% 45%, rgba(201,164,106,.22), #110d0a 75%);
  box-shadow: inset 0 0 22px rgba(201,164,106,.15), 0 0 16px rgba(201,164,106,.18); }
.slot.sel img { filter: drop-shadow(0 0 8px rgba(255,220,160,.35)) drop-shadow(0 4px 4px rgba(0,0,0,.8)); }
.slot-doc { position: absolute; bottom: 4px; left: 6px; font-size: 13px; color: var(--gold); opacity: .85; }
.inv-side { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#inv-view { position: relative; height: 270px; border: 1px solid var(--line);
  background: radial-gradient(ellipse 45% 12% at 50% 86%, rgba(0,0,0,.8), transparent), radial-gradient(ellipse 60% 70% at 50% 40%, #2a2219, #0b0907 70%, #050403); box-shadow: inset 0 0 40px #000; }
#inv-view::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--scan); opacity: .5; }
#inv-view canvas { width: 100%; height: 100%; image-rendering: pixelated; }
#inv-name { font-family: 'Rakkas'; font-weight: 400; font-size: 27px; line-height: 1.4; margin: 14px 0 6px; padding-bottom: 8px; color: #f3e6cc; background: var(--orn) right bottom / 200px 12px no-repeat; }
#inv-name:empty { background: none; padding: 0; }
#inv-desc { font-family: 'Naskh'; font-size: 17px; line-height: 1.75; color: var(--ink2); margin: 0; min-height: 80px; }
#inv-actions { display: flex; gap: 10px; margin-top: auto; }
.inv-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px;
  background: linear-gradient(90deg, transparent, var(--line-gold) 15%, var(--line-gold) 85%, transparent) top / 100% 1px no-repeat; }
.inv-foot .legend { justify-content: flex-start; }
#inv-files, #inv-log, #inv-notes, #inv-family { position: absolute; inset: 78px 28px 72px; }
/* the other pages sit over the bag: the bag itself goes, not just behind a tint */
#inv:not([data-tab="items"]) .inv-main { visibility: hidden; }
/* the family page wants the room: the panel grows and the page fills it */
#inv[data-tab="family"] .inv-wrap { width: min(1600px, 98vw); height: min(1000px, 96vh); padding: 14px 18px; }
#inv[data-tab="family"] #inv-family { inset: 64px 12px 60px; background: radial-gradient(ellipse at 50% 45%, #1a140f, #070605 75%); }
#inv-files { overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; align-content: start; padding: 2px; background: none; }
#inv-files button { all: unset; cursor: pointer; position: relative; padding: 14px 18px 14px 18px; padding-inline-start: 40px; font-family: 'Naskh'; font-size: 17px; color: var(--ink2);
  background: linear-gradient(#15110d, #0b0907); border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,235,200,.04); transition: all .12s; }
#inv-files button::before { content: ''; position: absolute; inset-inline-start: 16px; top: 50%; width: 12px; height: 15px; margin-top: -8px; background: linear-gradient(#cbbd9f, #9c8a6a); box-shadow: 1px 1px 0 rgba(0,0,0,.5); clip-path: polygon(0 0, 70% 0, 100% 25%, 100% 100%, 0 100%); }
#inv-files button:hover, #inv-files button.sel { color: #fff1d6; border-color: rgba(201,164,106,.55); background: linear-gradient(90deg, rgba(126,24,16,.45), rgba(126,24,16,.15)); }
#inv-log { overflow: auto; padding: 4px 8px 30px; font-family: 'Naskh'; background: none; }
#inv-log h4, #inv-notes h4 { font-family: 'Alex'; font-weight: 500; font-size: 13px; color: var(--gold); margin: 20px 0 8px; padding-bottom: 6px;
  background: linear-gradient(90deg, transparent, var(--line-gold)) bottom / 100% 1px no-repeat; }
#inv-log .lg { margin: 0 0 6px; font-size: 17px; line-height: 1.7; color: #d9ccb3; }
#inv-log .lg b { font-family: 'Alex'; font-weight: 600; font-size: 12px; color: var(--gold); margin-left: 10px; }
#inv-log .lg.inner, #inv-log .lg.thought { font-style: italic; color: #a99d86; }
#inv-log .lg.stage { font-family: 'Alex'; font-size: 14px; color: #8b9890; }
#inv-log .lg.choice { color: #f3e6cc; }
#inv-log .lg.choice::before { content: '◆ '; color: var(--blood-hi); font-size: .7em; }
#inv-log .lg.card { text-align: center; color: #b9a988; }
#inv-log .log-empty, .inv-empty { color: var(--dim); font-family: 'Naskh'; }
#inv-notes { overflow: auto; padding: 6px 10px 30px; font-family: 'Naskh'; background: none; }
.nt-goal { padding: 4px 18px 12px; border-inline-start: 3px solid var(--blood-hi); background: linear-gradient(90deg, transparent, rgba(126,24,16,.18)); }
.nt-goal h4 { margin-top: 10px !important; }
.nt-goal p { margin: 0 0 6px; font-size: 21px; line-height: 1.7; color: #f0e4cc; }
.nt-goal p.nt-hint { font-size: 16px; color: #c9b48a; font-style: italic; }
.nt-goal p.nt-hint::before { content: '— '; color: #8a7a5c; }
.nt-row { all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; padding: 11px 16px; margin: 0 0 8px; font-size: 17px; line-height: 1.7; color: #d9ccb3;
  background: linear-gradient(#14100c, #0a0807); border: 1px solid var(--line); transition: all .12s; }
.nt-row.sel, .nt-row:hover { border-color: rgba(201,164,106,.55); background: linear-gradient(90deg, rgba(126,24,16,.4), rgba(126,24,16,.1)); }
.nt-recap { color: #d9b48a; }
.nt-q .nt-qq { display: block; color: #efe3ca; }
.nt-q .nt-open { display: block; font-size: 14px; color: var(--dim); }
.nt-q.fresh .nt-qq::after { content: ' •'; color: var(--gold); }
.nt-q.solved { cursor: default; }
.nt-q .nt-ink { display: block; margin-top: 4px; font-size: 17px; color: #9fb6d8; }
#inv.picking .inv-tabs button[data-tab="log"], #inv.picking .inv-tabs button[data-tab="family"], #inv.picking .inv-tabs button[data-tab="notes"] { display: none; }
#inv.picking #inv-clock { direction: rtl; font-family: 'Naskh'; font-size: 18px; color: #d9b48a; border-left: 0; border-right: 2px solid var(--blood-hi); }

/* =================== title =================== */
#title { flex-direction: column; background:
  radial-gradient(ellipse 70% 50% at 50% 38%, rgba(126,24,16,.16), transparent 70%),
  radial-gradient(ellipse at 50% 45%, rgba(0,0,0,.3), rgba(0,0,0,.9) 75%); }
/* after an ending: the same title at first light */
#title.dawn { background:
  radial-gradient(ellipse 80% 45% at 50% 30%, rgba(240,200,160,.08), transparent 70%),
  radial-gradient(ellipse at 50% 45%, rgba(20,16,18,.08), rgba(16,14,20,.72) 80%); }
#title.dawn h1 { color: #d8d6d0; }
#title.dawn h1::before, #title.dawn h1::after { animation: none; opacity: 0; }
.title-wrap { text-align: center; position: relative; display: flex; flex-direction: column; align-items: center; }
.title-sub { display: flex; align-items: center; gap: 16px; color: var(--dim); font-size: 14px; word-spacing: .4em; }
.title-sub::before, .title-sub::after { content: ''; width: 70px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.title-sub::after { transform: scaleX(-1); }
#title h1 { position: relative; font-family: 'Rakkas'; font-weight: 400; font-size: clamp(64px, 10.5vw, 148px); line-height: 1.3; margin: 4px 0 0; color: #e2d2b2;
  text-shadow: 0 0 40px rgba(194,50,31,.45), 0 0 2px rgba(0,0,0,.9), 0 6px 24px #000; animation: flick 7s infinite; }
#title h1::before, #title h1::after { content: attr(data-text); position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: .65; }
#title h1::before { color: #c2321f; animation: glitchA 6s infinite steps(1); }
#title h1::after { color: #3fa5a0; animation: glitchB 6s infinite steps(1); }
@keyframes glitchA { 0%, 88%, 100% { transform: none; clip-path: inset(0 0 100% 0); } 89% { transform: translate(-6px, 0); clip-path: inset(20% 0 55% 0); } 90% { transform: translate(5px, 0); clip-path: inset(62% 0 12% 0); } 91% { transform: translate(-3px, 0); clip-path: inset(40% 0 40% 0); } 92% { clip-path: inset(0 0 100% 0); } }
@keyframes glitchB { 0%, 88%, 100% { transform: none; clip-path: inset(0 0 100% 0); } 89% { transform: translate(6px, 0); clip-path: inset(55% 0 20% 0); } 90% { transform: translate(-4px, 0); clip-path: inset(10% 0 70% 0); } 91.5% { transform: translate(3px, 0); clip-path: inset(30% 0 50% 0); } 92% { clip-path: inset(0 0 100% 0); } }
.title-ch { color: #b9a988; font-family: 'Naskh'; font-size: 22px; margin: 2px 0 40px; padding: 0 0 14px; background: var(--orn) center bottom / 240px 12px no-repeat; min-width: 320px; }
.title-foot { margin-top: 48px; font-size: 12px; color: var(--mute); display: flex; align-items: center; gap: 10px; }
.title-foot::before { content: ''; width: 6px; height: 6px; transform: rotate(45deg); background: var(--blood-hi); box-shadow: 0 0 8px var(--blood-hi); animation: throb 2s infinite; }

/* =================== menus =================== */
.menu { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.menu button { all: unset; box-sizing: border-box; cursor: pointer; position: relative; min-width: 300px; padding: 10px 46px; text-align: center;
  font-family: 'Alex'; font-weight: 500; font-size: 18px; color: #9a8e77; transition: color .15s, background .2s, text-shadow .2s; }
.menu button::before { content: ''; position: absolute; inset-inline-start: 16px; top: 50%; width: 8px; height: 8px; transform: translateY(-50%) rotate(45deg); background: var(--gold-hi); box-shadow: 0 0 8px rgba(241,217,164,.7); opacity: 0; transition: opacity .15s; }
.menu button::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(201,164,106,.6), transparent); opacity: 0; transition: opacity .15s; }
.menu button:hover, .menu button.sel { color: #fff1d6; background: linear-gradient(90deg, rgba(126,24,16,0), rgba(126,24,16,.62) 22%, rgba(126,24,16,.62) 78%, rgba(126,24,16,0)); text-shadow: 0 0 12px rgba(255,140,100,.45); }
.menu button.sel::before { opacity: 1; animation: cursor 1s ease-in-out infinite; }
.menu button:hover::after, .menu button.sel::after { opacity: 1; }
.menu button.danger.sel, .menu button.danger:hover { color: #ff9b7c; background: linear-gradient(90deg, rgba(160,20,10,0), rgba(160,20,10,.8) 22%, rgba(160,20,10,.8) 78%, rgba(160,20,10,0)); }
/* an option row: label, then ◂ value ▸ */
.menu button.opt { display: flex; justify-content: space-between; align-items: center; gap: 48px; min-width: min(460px, 86vw); padding: 10px 46px; }
.menu button.opt::after { display: block; }
.opt-v { display: inline-flex; align-items: center; gap: 10px; color: #e9dfca; direction: ltr; }
.opt-v b { font-weight: 500; min-width: 5.5em; text-align: center; padding: 2px 6px; background: rgba(0,0,0,.4); border: 1px solid var(--line); }
.opt-v .arr { font-style: normal; opacity: .3; padding: 0 6px; font-size: 20px; line-height: 1; }
.menu button.sel .opt-v .arr { opacity: 1; color: var(--gold-hi); }
.menu-foot { margin-top: 26px; display: flex; justify-content: center; flex-wrap: wrap; font-size: 14px; color: #9a8e77; padding-top: 14px;
  background: linear-gradient(90deg, transparent, var(--line) 25%, var(--line) 75%, transparent) top / 100% 1px no-repeat; }
.menu-box { position: relative; padding: 34px 50px 26px; text-align: center; min-width: 380px; max-width: min(780px, 94vw); max-height: 92vh; overflow: auto; }
.menu-box h2 { font-family: 'Rakkas'; font-weight: 400; font-size: 34px; line-height: 1.4; margin: 0 0 20px; padding-bottom: 14px; color: #f0e2c4; text-shadow: 0 0 18px rgba(194,50,31,.35); background: var(--orn) center bottom / 220px 12px no-repeat; }
.menu-box p { color: var(--ink2); font-family: 'Naskh'; font-size: 16px; line-height: 1.8; text-align: right; }
.menu-text { max-width: min(640px, 92vw); }
.menu-q { font-family: 'Naskh'; font-size: 20px; text-align: center !important; color: #e9dfca; margin: 0 0 14px; }
.menu-q small { display: block; font-size: 15px; color: var(--dim); margin-top: 6px; }
.menu-text .menu-goal, .menu-goal { font-family: 'Naskh'; font-size: 18px; line-height: 1.7; color: #e9dfca; text-align: center !important; max-width: min(560px, 90vw); margin: 0 auto 18px; padding: 10px 18px;
  border-inline-start: 3px solid var(--blood-hi); background: linear-gradient(90deg, transparent, rgba(126,24,16,.2)); }
.menu-text .menu-goal small, .menu-goal small { display: block; font-size: 15px; color: #c9b48a; font-style: italic; margin-top: 4px; }
.ctrl-table { border-collapse: collapse; margin: 0 auto 6px; font-size: 16px; color: #d9ccb3; }
.ctrl-table th { font-weight: 500; font-size: 12px; color: var(--gold); padding: 0 16px 8px; }
.ctrl-table td { padding: 7px 16px; border-top: 1px solid var(--line); text-align: right; }
.ctrl-table td + td { text-align: center; font-size: 19px; }
.ctrl-table tr:nth-child(odd) td { background: rgba(255,235,200,.02); }
.ctrl-note { font-size: 15px !important; line-height: 1.9 !important; margin: 14px 0 0; color: var(--ink2); font-family: 'Naskh'; text-align: right; }

/* chapter cards / loading */
#card { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; pointer-events: none; }
#card-text { font-family: 'Naskh'; font-size: clamp(22px, 2.6vw, 34px); text-align: center; line-height: 1.9; color: #dcd0b8; max-width: 70vw; text-shadow: 0 0 12px #000; white-space: pre-line; }
#card-next { position: absolute; bottom: 12%; left: 50%; transform: translateX(-50%); display: flex; font-size: 16px; color: #8b7f6b; animation: throb 1.4s infinite; }
#loading { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 22px; }
#loading > div { padding: 0 0 14px; min-width: 200px; text-align: center; background: var(--orn) center bottom / 200px 12px no-repeat; animation: throb 1.4s infinite; }

/* =====================================================================
   close-ups (puzzles): the object under a lamp, framed like a lens
   ===================================================================== */
#puzzle { padding: 76px 24px 92px; background:
  radial-gradient(ellipse 52% 58% at 50% 47%, rgba(64,48,32,.5), rgba(18,13,9,.6) 55%, rgba(0,0,0,.95) 85%), rgba(0,0,0,.9); }
/* viewfinder brackets at the screen's corners */
#puzzle::before { content: ''; position: absolute; inset: 22px 22px 72px; pointer-events: none; z-index: 0; --bk: 34px; opacity: .55;
  background:
    linear-gradient(var(--gold), var(--gold)) left top / var(--bk) 1px no-repeat, linear-gradient(var(--gold), var(--gold)) left top / 1px var(--bk) no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / var(--bk) 1px no-repeat, linear-gradient(var(--gold), var(--gold)) right top / 1px var(--bk) no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / var(--bk) 1px no-repeat, linear-gradient(var(--gold), var(--gold)) left bottom / 1px var(--bk) no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / var(--bk) 1px no-repeat, linear-gradient(var(--gold), var(--gold)) right bottom / 1px var(--bk) no-repeat; }
#puzzle-body { max-height: 100%; display: flex; align-items: center; justify-content: center; animation: riseIn .3s ease-out; }
/* the clock keeps running in a close-up: lift it above the overlay, hide the rest of the HUD */
body:has(#puzzle:not(.hidden)) #hud { z-index: 31; }
body:has(#puzzle:not(.hidden)) #hud > :not(#clock) { visibility: hidden; }
body:has(#puzzle.see:not(.hidden)) #hud { z-index: 5; }
/* a wrong answer bleeds red into the frame */
body:has(#clock.hit) #puzzle { animation: hurt .7s ease-out; }
@keyframes hurt { 0% { box-shadow: inset 0 0 0 4px rgba(194,50,31,.9), inset 0 0 220px rgba(194,50,31,.65); } 100% { box-shadow: inset 0 0 0 0 transparent, inset 0 0 220px transparent; } }

.pz { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; }
/* the header plate: a kicker, the name, a rule */
.pz-title { display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: 'Rakkas'; font-weight: 400; font-size: 30px; line-height: 1.45; color: #f0e2c4;
  text-shadow: 0 0 20px rgba(201,164,106,.25), 0 2px 6px #000; padding-bottom: 14px; background: var(--orn) center bottom / 240px 12px no-repeat; text-align: center; }
.pz-title::before { content: 'عن قرب'; font-family: 'Alex'; font-weight: 600; font-size: 11px; color: var(--blood-hi); padding: 1px 12px; border: 1px solid rgba(194,50,31,.5); background: rgba(126,24,16,.18); text-shadow: none; }
#mir-cap { font-family: 'Naskh'; font-size: 20px; font-weight: 400; font-style: italic; }
#mir-cap::before { display: none; }
.pz-row { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
/* what Salem notices: a thought on a red rule */
.pz-note { font-family: 'Naskh'; font-size: 18px; color: #cbbfa7; min-height: 1.7em; font-style: italic; max-width: min(620px, 86vw); text-align: center; padding: 0 16px; text-shadow: 0 2px 6px #000; }
.pz-note:not(:empty) { border-inline-start: 2px solid var(--blood-hi); border-inline-end: 2px solid var(--blood-hi); background: linear-gradient(90deg, transparent, rgba(0,0,0,.55) 15%, rgba(0,0,0,.55) 85%, transparent); }
.pz-flash { position: absolute; inset: 0; pointer-events: none; background: #c8d8ff; mix-blend-mode: screen; opacity: 0; z-index: 2; }

/* ---------- the breaker panel: painted steel, tape labels ---------- */
.panel-box { width: min(760px, 92vw); position: relative; padding: 34px 34px 26px; border-radius: 5px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px),
    linear-gradient(175deg, #8b8a83, #6d6c66 45%, #55544f);
  box-shadow: 0 0 0 9px #2d2c29, 0 0 0 10px #0d0d0c, 0 0 0 11px rgba(201,164,106,.18), inset 0 2px 0 rgba(255,255,255,.18), inset 0 -3px 0 rgba(0,0,0,.35), inset 0 0 80px rgba(0,0,0,.5), 0 40px 90px #000; }
.panel-box::before { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: 5px;
  background: radial-gradient(circle at 72% 26%, rgba(120,60,20,.4), transparent 34%), radial-gradient(circle at 18% 84%, rgba(70,35,12,.45), transparent 30%), radial-gradient(circle at 92% 92%, rgba(60,30,10,.35), transparent 20%), var(--grain);
  background-size: auto, auto, auto, 180px; mix-blend-mode: multiply; }
.panel-box .screw { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #d8d6cf, #77756e 55%, #3d3c38); box-shadow: 0 1px 2px rgba(0,0,0,.7), inset 0 0 0 1px rgba(0,0,0,.4); }
.panel-box .screw::after { content: ''; position: absolute; left: 2px; right: 2px; top: 6px; height: 2px; background: #3a3935; transform: rotate(var(--r, 30deg)); }
.panel-box .screw:nth-of-type(1) { top: 10px; left: 10px; } .panel-box .screw:nth-of-type(2) { top: 10px; right: 10px; --r: -20deg; }
.panel-box .screw:nth-of-type(3) { bottom: 10px; left: 10px; --r: 70deg; } .panel-box .screw:nth-of-type(4) { bottom: 10px; right: 10px; --r: 10deg; }
.sticker { position: relative; margin: 0 auto 20px; width: fit-content; background: linear-gradient(#f3ebd2, #e1d6b4); color: #2b2419; padding: 4px 20px; font-family: 'Naskh'; font-weight: 600; font-size: 15px; transform: rotate(-1.2deg); box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.sticker::before { content: ''; position: absolute; top: -6px; left: 50%; width: 40px; height: 12px; margin-left: -20px; background: rgba(230,220,180,.6); transform: rotate(4deg); }
.breakers { display: flex; gap: 10px; justify-content: center; direction: rtl; padding: 16px 12px 12px; background: linear-gradient(#3b3a36, #2a2926); border-radius: 3px; box-shadow: inset 0 3px 8px rgba(0,0,0,.7), 0 1px 0 rgba(255,255,255,.12); }
.brk { width: 88px; display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer; }
.brk .body { width: 50px; height: 124px; position: relative; border-radius: 3px;
  background: linear-gradient(90deg, #cfc9b9, #f1ece0 30%, #e6e0d2 70%, #bdb7a7); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.6), 0 4px 6px rgba(0,0,0,.55); }
.brk .body::before { content: ''; position: absolute; left: 10px; right: 10px; top: 10px; height: 82px; border-radius: 2px; background: linear-gradient(#141414, #2b2b2b); box-shadow: inset 0 2px 5px #000; }
/* the trip indicator: green off, red on */
.brk .body::after { content: ''; position: absolute; left: 50%; bottom: 11px; width: 16px; height: 7px; margin-left: -8px; border-radius: 1px; background: #2f6a3a; box-shadow: inset 0 1px 2px rgba(0,0,0,.6); }
.brk.on .body::after { background: #d0321f; box-shadow: inset 0 1px 1px rgba(255,255,255,.3), 0 0 8px rgba(208,50,31,.8); }
.brk .lever { position: absolute; z-index: 1; left: 13px; right: 13px; height: 36px; top: 53px; border-radius: 2px; transition: top .12s cubic-bezier(.3,1.6,.6,1);
  background: linear-gradient(90deg, #1d1d1d, #4a4a4a 40%, #262626); box-shadow: 0 3px 3px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.2); }
.brk .lever::after { content: ''; position: absolute; left: 3px; right: 3px; top: 6px; height: 2px; background: rgba(255,255,255,.15); box-shadow: 0 6px 0 rgba(255,255,255,.1), 0 12px 0 rgba(255,255,255,.08); }
.brk.on .lever { top: 13px; background: linear-gradient(90deg, #7d150d, #c22d1c 40%, #8e180f); }
.brk:hover .body, .brk.focus .body { box-shadow: inset 0 0 0 1px rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.6), 0 4px 6px rgba(0,0,0,.55), 0 0 0 3px #12100c, 0 0 0 5px var(--gold-hi), 0 0 24px rgba(241,217,164,.55); }
/* masking tape with the circuit's name in marker */
.brk .lbl { font-family: 'Naskh'; font-weight: 600; font-size: 14px; color: #1a1712; text-align: center; line-height: 1.3; min-height: 44px; width: 88px; padding: 4px 3px 3px;
  background: linear-gradient(#ece2c4, #dccfa9); box-shadow: 0 1px 3px rgba(0,0,0,.45); transform: rotate(-1deg); }
.brk:nth-child(even) .lbl { transform: rotate(1.2deg); }
.brk .lbl small { display: block; font-family: 'Alex'; font-weight: 600; font-size: 12px; color: #6b1a12; }
.brk .lbl small.smudge { color: transparent; text-shadow: 0 0 6px rgba(40,30,20,.85); }
.main-brk { margin-top: 18px; display: flex; justify-content: center; align-items: center; gap: 18px; }
.main-brk .brk { width: auto; }
.main-brk .body { width: 100px; height: 132px; }
.main-brk .body::before { left: 14px; right: 14px; }
.main-brk .lever { left: 18px; right: 18px; top: 58px; height: 38px; }
.main-brk .brk.on .lever { top: 14px; }
.main-brk .tag { font-family: 'Alex'; font-weight: 700; color: #f2ead4; font-size: 16px; padding: 4px 14px; background: #7e1810; box-shadow: 0 2px 4px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.15); }

/* ---------- combination locks: drums behind a brass plate ---------- */
.lock { position: relative; display: flex; gap: 12px; direction: ltr; padding: 30px 36px; border-radius: 14px;
  background: radial-gradient(ellipse at 28% 18%, rgba(255,232,170,.3), transparent 50%), linear-gradient(160deg, #a4834a, #6f5329 50%, #4a3618);
  box-shadow: inset 0 1px 0 rgba(255,240,200,.45), inset 0 -2px 0 rgba(0,0,0,.4), inset 0 0 40px rgba(0,0,0,.45), 0 0 0 3px #2a1d0e, 0 0 0 4px rgba(201,164,106,.3), 0 34px 80px #000; }
.lock::after { content: ''; position: absolute; inset: 0; border-radius: 14px; pointer-events: none; background: var(--grain); background-size: 180px; mix-blend-mode: overlay; opacity: .5; }
/* Nasser's door: a steel padlock with its shackle */
.lock.padlock { margin-top: 70px; border-radius: 10px 10px 22px 22px;
  background: radial-gradient(ellipse at 28% 18%, rgba(255,255,255,.28), transparent 50%), linear-gradient(160deg, #8d9296, #5c6165 50%, #3a3e42);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), inset 0 -2px 0 rgba(0,0,0,.4), inset 0 0 40px rgba(0,0,0,.45), 0 0 0 3px #16181a, 0 0 0 4px rgba(201,164,106,.25), 0 34px 80px #000; }
.lock.padlock::before { content: ''; position: absolute; z-index: -1; left: 50%; top: -78px; width: 170px; height: 120px; margin-left: -85px; border: 18px solid #9aa0a4; border-bottom: 0; border-radius: 85px 85px 0 0;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.35), 0 -2px 0 rgba(0,0,0,.4); border-top-color: #b4babd; }
.lock.padlock::after { border-radius: 10px 10px 22px 22px; }
.wheel { position: relative; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wheel button { all: unset; cursor: pointer; width: 0; height: 0; border-left: 11px solid transparent; border-right: 11px solid transparent; padding: 0; margin: 4px 0; font-size: 0; opacity: .55; transition: opacity .1s, filter .1s; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
.wheel button:first-child { border-bottom: 11px solid #2a1d0e; }
.wheel button:last-child { border-top: 11px solid #2a1d0e; }
.lock.padlock .wheel button:first-child { border-bottom-color: #16181a; }
.lock.padlock .wheel button:last-child { border-top-color: #16181a; }
.wheel button:hover, .wheel.focus button { opacity: 1; }
.wheel.focus button:first-child { border-bottom-color: var(--gold-hi); filter: drop-shadow(0 0 4px rgba(241,217,164,.8)); }
.wheel.focus button:last-child { border-top-color: var(--gold-hi); filter: drop-shadow(0 0 4px rgba(241,217,164,.8)); }
.wheel .num { position: relative; width: 62px; height: 100px; overflow: hidden; cursor: pointer; border-radius: 4px; font-family: 'Alex';
  background: linear-gradient(#0a0806, #2c241a 20%, #574a36 50%, #2c241a 80%, #0a0806);
  box-shadow: inset 0 0 0 2px #1a120a, inset 0 10px 12px rgba(0,0,0,.85), inset 0 -10px 12px rgba(0,0,0,.85), 0 1px 0 rgba(255,240,200,.25); }
.wheel .num::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 46px; margin-top: -23px; pointer-events: none; border-top: 1px solid rgba(0,0,0,.6); border-bottom: 1px solid rgba(0,0,0,.6); background: linear-gradient(rgba(255,240,210,.08), transparent 40%); }
.wheel .drum { position: absolute; left: 0; right: 0; top: 50%; display: flex; flex-direction: column; align-items: center; transform: translateY(-50%); }
.wheel .drum i { font-style: normal; font-size: 22px; line-height: 30px; color: #cdb98f; opacity: .3; transform: scaleY(.65); }
.wheel .drum b { font-size: 42px; line-height: 46px; font-weight: 500; color: #f6e8c6; text-shadow: 0 2px 2px #000; }
.wheel.focus .num { box-shadow: inset 0 0 0 2px #1a120a, inset 0 10px 12px rgba(0,0,0,.85), inset 0 -10px 12px rgba(0,0,0,.85), 0 0 0 2px var(--gold-hi), 0 0 18px rgba(241,217,164,.5); }
.wheel.focus .drum b { color: #fff; text-shadow: 0 0 10px rgba(255,220,160,.6), 0 2px 2px #000; }

/* ---------- the medallion ---------- */
.medal svg { width: min(450px, calc(100vh - 370px)); height: min(450px, calc(100vh - 370px)); filter: drop-shadow(0 30px 50px #000); }
.medal text { font-family: 'Naskh'; font-weight: 700; }
.medal .pz-note { font-size: 15px; }
.medal .ring { transition: filter .15s; }
.medal .ring:hover > circle:first-child { filter: brightness(1.25); }

/* ---------- mirror / tape frames ---------- */
.frame-img { width: min(900px, 90vw); aspect-ratio: 16/9; position: relative; background: #000; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(201,164,106,.35), 0 0 0 8px #0d0b09, 0 0 0 9px rgba(201,164,106,.15), 0 40px 90px #000; }
.frame-img::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--scan), radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,.55)); }
.frame-img canvas { width: 100%; height: 100%; display: block; }
.frame-img.tape43 { aspect-ratio: 4 / 3; width: min(900px, 90vw, calc((100vh - 180px) * 4 / 3)); }

/* ---------- the iron close-ups (valve, hatch, weld, cylinder, hold) ---------- */
.valve-box { position: relative; width: min(400px, calc(100vh - 330px), 80vw); aspect-ratio: 1; border-radius: 6px; overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #2a231c, #0c0a08 70%, #050403);
  box-shadow: 0 0 0 1px rgba(201,164,106,.35), 0 0 0 8px #15110e, 0 0 0 9px rgba(0,0,0,.9), 0 0 0 10px rgba(201,164,106,.15), inset 0 0 70px #000, 0 40px 90px #000; }
.valve-box::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(0,0,0,.6)), var(--grain); background-size: auto, 180px; mix-blend-mode: multiply; opacity: .8; }
.valve-box svg { width: 100%; height: 100%; display: block; }
.valve-box .hfocus { stroke: #8a6a3a; filter: drop-shadow(0 0 6px rgba(241,217,164,.7)); }
.valve-box .lug:hover rect { stroke: var(--gold-hi); }
.weld-box { aspect-ratio: auto; width: auto; }
.weld-box svg { width: min(340px, 60vw, calc((100vh - 300px) * .77)); height: auto; display: block; }

/* ---------- the camcorder ---------- */
.pz.cam { flex-direction: row; gap: 28px; align-items: center; }
.cam-body { position: relative; width: min(820px, 64vw, calc((100vh - 220px) * 4 / 3)); aspect-ratio: 4 / 3; background: #000; border-radius: 8px;
  border: 16px solid #18181b; box-shadow: 0 0 0 1px #2c2c30, 0 0 0 3px #0a0a0b, inset 0 0 30px rgba(0,0,0,.9), 0 40px 90px #000; }
.cam-body::before { content: 'REC ●  SP'; position: absolute; top: -14px; right: 10px; font-family: 'Alex'; font-weight: 700; font-size: 9px; color: #6a6a70; direction: ltr; }
.cam-body::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--scan); opacity: .7; }
.cam-body canvas { width: 100%; height: 100%; display: block; }
.vf-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Alex', monospace; font-size: 15px; color: #e8f0ff; text-shadow: 0 0 4px #000; direction: ltr; pointer-events: none; z-index: 1; }
.vf-msg.hidden { display: none; }
.vf-ui { position: absolute; z-index: 1; top: 8px; left: 10px; right: 10px; display: flex; justify-content: space-between; font-family: 'Alex', monospace; font-size: 13px; color: #cfe8d8; text-shadow: 0 0 4px #000; direction: ltr; pointer-events: none; }
.vf-scrub { position: absolute; z-index: 1; bottom: 8px; left: 10px; right: 10px; display: flex; gap: 3px; direction: ltr; }
.vf-scrub i { flex: 1; height: 4px; background: rgba(200,230,210,.18); }
.vf-scrub i.p { background: rgba(200,230,210,.55); }
.vf-scrub i.c { background: #e8f0e0; box-shadow: 0 0 6px #e8f0e0; }
.cam-list { display: flex; flex-direction: column; gap: 10px; min-width: 180px; }
/* the cassettes: a label strip on a black shell */
.cam-list button { all: unset; cursor: pointer; position: relative; padding: 10px 14px 10px 14px; font-family: 'Naskh'; font-weight: 600; font-size: 16px; color: #2a2018;
  background: linear-gradient(#e6dcc0, #cdbf9b) padding-box; border: 6px solid #141416; border-bottom-width: 14px; border-radius: 4px; box-shadow: 0 4px 10px rgba(0,0,0,.6); transition: transform .12s; }
.cam-list button::after { content: ''; position: absolute; left: 50%; bottom: -11px; width: 46px; height: 7px; margin-left: -23px; border-radius: 3px; background: #2a2a2e; box-shadow: inset 0 1px 2px #000; }
.cam-list button.seen { opacity: .62; }
.cam-list button.sel, .cam-list button:hover { transform: translateX(-8px); box-shadow: 0 0 0 2px var(--gold-hi), 0 0 18px rgba(241,217,164,.4), 0 4px 10px rgba(0,0,0,.6); opacity: 1; }

/* ---------- Chapter Three: Little Nour's phone ---------- */
.phone { position: relative; width: min(300px, 70vw); height: min(560px, calc(100vh - 180px)); background: linear-gradient(135deg, #1a1a1e, #0b0b0d 60%); border-radius: 30px; padding: 46px 12px 40px;
  box-shadow: 0 30px 80px #000, inset 0 0 0 2px #2a2a2e, inset 0 0 0 4px #0a0a0b, 0 0 0 1px rgba(201,164,106,.2); }
.phone::before { content: ''; position: absolute; top: 18px; left: 50%; width: 54px; height: 6px; margin-left: -27px; border-radius: 3px; background: #1c1c20; box-shadow: inset 0 1px 2px #000; }
.phone::after { content: ''; position: absolute; bottom: 10px; left: 50%; width: 34px; height: 22px; margin-left: -17px; border-radius: 8px; border: 2px solid #232327; }
.phone-screen { position: relative; height: 100%; overflow: hidden; border-radius: 4px; background: linear-gradient(#1a1f2c, #0e1018); color: #e6e8f0; font-family: 'Alex'; font-size: 13px; image-rendering: pixelated; display: flex; flex-direction: column; box-shadow: 0 0 30px rgba(120,150,230,.12); }
.phone-crack { position: absolute; inset: 46px 12px 40px; width: calc(100% - 24px); height: calc(100% - 86px); pointer-events: none; }
.ph-bar { display: flex; justify-content: space-between; padding: 4px 8px; font-size: 11px; opacity: .8; direction: ltr; }
.ph-lock { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 14px; }
.ph-time { font-size: 40px; font-weight: 300; }
.ph-wall { width: 70%; height: 36px; border-radius: 6px; background: linear-gradient(90deg, #d88aa6, #8a9ad8); opacity: .25; }
.ph-notif { background: rgba(255,255,255,.1); padding: 6px 12px; border-radius: 8px; font-size: 12px; }
.ph-dots { display: flex; gap: 12px; direction: ltr; margin-top: 6px; }
.ph-dots i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #cfd4e0; }
.ph-dots i.on { background: #cfd4e0; }
.ph-note { min-height: 1.4em; font-size: 12px; text-align: center; color: #b8c0d8; padding: 2px 10px; }
.ph-pad { display: grid; grid-template-columns: repeat(3, 56px); gap: 9px; direction: ltr; margin-top: 4px; }
.ph-pad button, .ph-home button, .ph-list button { all: unset; cursor: pointer; box-sizing: border-box; }
.ph-pad button { height: 44px; border-radius: 50%; background: rgba(255,255,255,.08); text-align: center; line-height: 44px; font-size: 19px; }
.ph-pad button[disabled] { opacity: .3; cursor: default; }
.ph-pad button.sel, .ph-pad button:hover:not([disabled]) { background: rgba(255,255,255,.22); outline: 1px solid #f3e2b0; }
.ph-home { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 26px 18px; }
.ph-home button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border-radius: 10px; position: relative; font-size: 12px; }
.ph-home button.sel, .ph-home button:hover { background: rgba(255,255,255,.12); outline: 1px solid #f3e2b0; }
.ph-home em { position: absolute; top: 2px; left: 18px; background: #d23a3a; border-radius: 9px; padding: 0 6px; font-style: normal; font-size: 11px; }
.ph-ic { width: 44px; height: 44px; border-radius: 11px; display: block; }
.ph-ic.msg { background: #3aa060; } .ph-ic.files { background: #d8a030; } .ph-ic.photos { background: #3a7ad8; opacity: .6; } .ph-ic.music { background: #c84a8a; opacity: .6; }
.ph-title { padding: 6px 12px; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.1); }
.ph-list { display: flex; flex-direction: column; }
.ph-list button { display: grid; grid-template-columns: 1fr auto; padding: 9px 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
.ph-list button b { font-weight: 600; } .ph-list button small { grid-column: 1; opacity: .6; font-size: 11px; } .ph-list button span { grid-row: 1; grid-column: 2; font-size: 10px; opacity: .5; direction: ltr; }
.ph-list button.sel, .ph-list button:hover { background: rgba(255,255,255,.1); outline: 1px solid #f3e2b0; }
.ph-empty { padding: 30px 14px; text-align: center; opacity: .6; }
.ph-thread { flex: 1; overflow-y: auto; padding: 8px 10px 18px; display: flex; flex-direction: column; gap: 5px; scrollbar-width: thin; }
.ph-date { align-self: center; font-size: 10px; opacity: .5; margin-top: 8px; }
.ph-b { max-width: 78%; padding: 6px 10px; border-radius: 12px; font-size: 13px; line-height: 1.5; font-family: 'Naskh'; }
.ph-b.in { align-self: flex-start; background: #2c3242; border-bottom-right-radius: 3px; }    /* RTL: what comes in sits on the right, */
.ph-b.out { align-self: flex-end; background: #2f7a52; border-bottom-left-radius: 3px; }      /* what she sent on the left */
.ph-video { margin: 14px 10px 8px; aspect-ratio: 16 / 9; background: #000; position: relative; overflow: hidden; }
.ph-video.glitch .ph-blocks { opacity: 1; }
.ph-blocks { position: absolute; inset: 0; opacity: 0; transition: opacity .6s; background:
  linear-gradient(90deg, transparent 0 20%, #1f6a2a 20% 34%, transparent 34% 60%, #2a8a3a 60% 70%, transparent 70%) 0 20% / 100% 18% no-repeat,
  linear-gradient(90deg, #185a24 0 12%, transparent 12% 46%, #2a7a34 46% 58%, transparent 58%) 0 62% / 100% 14% no-repeat,
  linear-gradient(90deg, transparent 0 70%, #1f6a2a 70% 92%, transparent 92%) 0 84% / 100% 10% no-repeat; }
.ph-scrub { display: flex; gap: 2px; margin: 0 10px; direction: ltr; }
.ph-scrub i { flex: 1; height: 3px; background: rgba(200,230,210,.18); } .ph-scrub i.p { background: rgba(200,230,210,.55); } .ph-scrub i.c { background: #e8f0e0; }

/* ---------- Chapter Four ---------- */
.cone-box { position: relative; width: min(640px, 86vw, calc((100vh - 290px) * 4 / 3)); aspect-ratio: 4 / 3; overflow: hidden; border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(201,164,106,.35), 0 0 0 8px #15110e, 0 0 0 9px rgba(201,164,106,.15), 0 40px 90px #000, inset 0 0 40px rgba(0,0,0,.3); }
.cone-box svg { width: 100%; height: 100%; display: block; cursor: pointer; }
/* under the bed: the room stays on screen, only a bar at the bottom */
#puzzle.see { background: transparent; align-items: flex-end; }
#puzzle.see::before, #puzzle.see::after { display: none; }
.pz.under { gap: 12px; margin-bottom: 4vh; padding: 16px 30px; --bk: 12px; background: var(--corners), linear-gradient(rgba(6,5,4,.82), rgba(6,5,4,.9)); border: 1px solid var(--line-gold); }
.pz.under .pz-btn.sel, #hslow.sel, #hfast.sel { color: #fff3dc; border-color: var(--gold); background: linear-gradient(#5a1a12, #2c0c08); }
.under-bar { width: 280px; height: 4px; background: rgba(232,220,196,.12); box-shadow: inset 0 0 0 1px rgba(0,0,0,.6); }
.under-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); box-shadow: 0 0 8px rgba(241,217,164,.6); }

/* =================== the family page «العائلة» =================== */
.fam-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.fam-page { box-shadow: 0 8px 40px #000, inset 0 0 40px rgba(80,50,20,.4); transform: rotate(-.3deg); }
.fam-card { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; background: rgba(4,3,2,.9); }
.fam-card .fam-back { position: absolute; bottom: 6px; left: 8px; }
.fam-paper { width: min(560px, 92%); max-height: 94%; overflow: auto; padding: 26px 34px 30px; box-sizing: border-box;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.08), transparent 60%), linear-gradient(170deg, #cbbd9f, #b3a283 60%, #9c8a6a);
  color: #33343c; font-family: 'Naskh'; font-style: italic; font-size: 18px; line-height: 1.75; box-shadow: 0 10px 50px #000, inset 0 0 70px rgba(80,50,20,.45); transform: rotate(.4deg); }
.fam-paper .new { color: #0e0e16; text-shadow: 0 0 .5px #0e0e16; }
.fam-head { display: flex; gap: 16px; align-items: center; margin-bottom: 6px; }
.fam-portrait { width: 66px; height: 78px; image-rendering: pixelated; border: 1px solid rgba(40,40,46,.55); box-shadow: 2px 3px 0 rgba(0,0,0,.2); }
.fam-olderpics { display: flex; gap: 6px; margin-top: 4px; }
.fam-olderpics canvas { width: 22px; height: 26px; image-rendering: pixelated; opacity: .6; border: 1px solid rgba(40,40,46,.4); }
.fam-head h3 { margin: 0; font-size: 24px; font-weight: 700; }
.fam-old { font-size: 16px; color: #55565e; }
.fam-paper h4 { font-family: 'Alex'; font-style: normal; font-weight: 500; font-size: 12px; color: #5a4a36; margin: 14px 0 2px; border-bottom: 1px solid rgba(60,40,20,.25); padding-bottom: 2px; }
.fam-paper p { margin: 0 0 .25em; }
.fam-line.dead { border-top: 1px solid rgba(40,40,46,.45); padding-top: 2px; display: inline-block; }
.fam-line.r-known { font-weight: 600; }
.fam-line s, .fam-old s { text-decoration-thickness: 1.5px; text-decoration-color: #2a2a30; }
.fam-line.solved { color: #1f3b6e; font-weight: 600; }
.fam-line.solved.new { color: #102a5a; }
.fam-q { font-style: normal; color: #6a1a14; }
.fam-recs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.fam-rec { all: unset; cursor: pointer; font-family: 'Naskh'; font-size: 15px; padding: 1px 10px; border: 1px solid rgba(40,40,46,.4); border-radius: 2px; color: #26262c; }
.fam-rec:hover, .fam-rec.sel { background: rgba(40,40,46,.12); border-color: #26262c; }
.fam-keep { display: flex; align-items: center; gap: 10px; }
.fam-keep img { width: 40px; height: 40px; image-rendering: pixelated; filter: sepia(.4) contrast(1.1); }

/* =================== small screens =================== */
@media (max-width: 760px) {
  #inv-grid { grid-template-columns: repeat(3, 72px); grid-auto-rows: 72px; }
  .inv-main { flex-direction: column; }
  #inv-view { height: 160px; }
  #msg { font-size: 18px; padding: 56px 6vw 46px; }
  #ctrl-strip { display: none; }
  #prompt { font-size: 15px; padding: 8px 28px; }
  .pr-name { font-size: 18px; }
  .menu button { min-width: 240px; }
  .menu button.opt { gap: 18px; }
  .menu-box { min-width: 0; padding: 26px 22px; }
  .pz.cam { flex-direction: column; align-items: center; }
  .cam-list { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  #puzzle { padding: 64px 12px 110px; }
  #puzzle::before { inset: 12px 12px 96px; }
  .brk { width: 64px; } .brk .lbl { width: 64px; font-size: 12px; }
  .breakers { gap: 4px; overflow-x: auto; }
}

/* ---- Chapter Five: the rubbing close-up, the nuts, the strikes ---- */
.rub-box { position: relative; width: min(720px, calc((100vh - 330px) * 1.6), 86vw); aspect-ratio: 480 / 300; box-shadow: 0 14px 50px #000, inset 0 0 0 1px rgba(255,240,210,.15); transform: rotate(-.6deg); }
.rub-box canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; cursor: crosshair; touch-action: none; }
.rub-box::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--grain); background-size: 180px; mix-blend-mode: multiply; opacity: .35; }
.c5-box { position: relative; width: min(560px, calc((100vh - 330px) * 1.5), 86vw); aspect-ratio: 3 / 2; border-radius: 6px; overflow: hidden; box-shadow: 0 14px 50px #000; }
.c5-box svg, .c5-box canvas { width: 100%; height: 100%; display: block; }
.c5-box::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 50%, rgba(0,0,0,.55)), var(--grain); background-size: auto, 180px; mix-blend-mode: multiply; opacity: .8; }
.c5-box .nut { cursor: pointer; }
.c5-box .nut.focus polygon { stroke: var(--gold-hi); stroke-width: 3; filter: drop-shadow(0 0 6px rgba(241,217,164,.7)); }
.pz-btn.size { min-width: 64px; font-family: 'Alex'; }
.strike-bar { width: min(420px, 70vw); height: 8px; background: rgba(255,255,255,.08); border: 1px solid var(--line-gold); }
.strike-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6a5a48, #d8ccb0); transition: width .25s; }

/* Touch: keep the middle of the frame open, with the same muted brass as
   the HUD. The surface itself never intercepts taps on the room. */
#touch-controls { position: fixed; inset: 0; z-index: 34; pointer-events: none; direction: ltr;
  --tc-left: max(22px, env(safe-area-inset-left)); --tc-right: max(22px, env(safe-area-inset-right));
  --tc-bottom: max(24px, env(safe-area-inset-bottom)); }
#touch-controls button { box-sizing: border-box; font-family: 'Alex', sans-serif; color: var(--ink2); cursor: pointer;
  touch-action: none; -webkit-tap-highlight-color: transparent; pointer-events: auto; user-select: none; -webkit-user-select: none; }
.tc-button { border: 1px solid rgba(201,164,106,.38); background: rgba(12,10,8,.56); box-shadow: inset 0 0 16px rgba(201,164,106,.035), 0 2px 12px rgba(0,0,0,.2);
  border-radius: 50%; min-width: 44px; height: 44px; padding: 0 8px; font-size: 12px; }
#touch-controls button.pressed { border-color: var(--gold-hi); color: #fff1d6; background-color: rgba(75,46,25,.72); }
#touch-controls button:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 4px; }
.tc-bag { position: absolute; right: calc(var(--tc-right) + 54px); top: max(12px, env(safe-area-inset-top)); }
.tc-bag svg { width: 22px; height: 22px; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.4; }
.tc-move { position: absolute; left: var(--tc-left); bottom: var(--tc-bottom); width: 106px; }
.tc-stick { display: block; position: relative; width: 106px; height: 106px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(201,164,106,.25); background: radial-gradient(circle, rgba(8,6,5,.12) 0 45%, rgba(8,6,5,.32) 46%); }
.tc-stick i { position: absolute; top: calc(50% - 19px); left: calc(50% - 19px); width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(232,220,196,.5); background: rgba(201,164,106,.15); pointer-events: none; }
.tc-cross { opacity: .25; font-size: 70px; line-height: 1; pointer-events: none; }
.tc-caption { display: block; padding-top: 7px; text-align: center; color: rgba(232,220,196,.5); font-size: 10px; text-shadow: 0 1px 3px #000; }
.tc-primary { display: flex; align-items: center; gap: 14px; }
.tc-run { width: 56px; height: 56px; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.tc-run small { font-size: 8px; color: var(--dim); }
.tc-run.active { border-color: var(--gold-hi); background: rgba(85,55,25,.8); color: #fff1d6; box-shadow: 0 0 12px rgba(201,164,106,.18); }
.tc-run.active small { color: var(--gold-hi); }
.tc-actions { position: absolute; right: var(--tc-right); bottom: calc(var(--tc-bottom) + 18px); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.tc-use { width: 68px; height: 68px; font-size: 13px; border-color: rgba(201,164,106,.58); }
.tc-cycle { display: flex; gap: 6px; direction: ltr; }
.tc-cycle button { font-size: 26px; line-height: 1; }
#touch-controls[data-mode="puzzle"] .tc-stick { width: 88px; height: 88px; }
#touch-controls[data-mode="puzzle"] .tc-move { width: 88px; bottom: max(10px, env(safe-area-inset-bottom)); }
#touch-controls[data-mode="puzzle"] .tc-caption { display: none; }
#touch-controls[data-mode="puzzle"] .tc-actions { bottom: max(12px, env(safe-area-inset-bottom)); }
#touch-controls[data-mode="puzzle"] .tc-use { width: 58px; height: 58px; font-size: 12px; }
#touch-controls[data-mode="tape"] .tc-actions { bottom: max(12px, env(safe-area-inset-bottom)); }
.touch-glyph { box-shadow: none; font-weight: 400; font-size: .8em; color: var(--gold); }
body.mobile-ui #ctrl-strip, body.mobile-ui #hover-label, body.mobile-ui .pr-btn, body.mobile-ui .pr-cycle { display: none; }
body.mobile-ui canvas.stage { touch-action: none; }
body.mobile-ui #menu-btn { top: max(12px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); width: 44px; height: 44px; }
body.mobile-ui #room-name { top: max(64px, calc(env(safe-area-inset-top) + 52px)); right: max(22px, env(safe-area-inset-right)); font-size: 22px; }
body.mobile-ui #clock { top: max(12px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
body.mobile-ui #prompt { bottom: max(28px, env(safe-area-inset-bottom)); max-width: calc(100vw - 440px); padding: 8px 20px; white-space: normal; text-align: center; }
body.mobile-ui .pr-name { font-size: 17px; }
body.mobile-ui .pr-verb { display: none; }
body.mobile-ui #puzzle { padding-bottom: max(122px, calc(env(safe-area-inset-bottom) + 110px)); }
body.mobile-ui #puzzle-body { display: block; overflow: auto; max-width: 100%; width: 100%; overscroll-behavior: contain; }
body.mobile-ui #puzzle-hint > [data-hint] { display: none; }
body.mobile-ui #puzzle-hint { padding: 12px 0 max(12px, env(safe-area-inset-bottom)); background: none; pointer-events: none; }
body.mobile-ui #puzzle-hint .pz-back { pointer-events: auto; min-height: 44px; margin: 0; }
body.mobile-ui #doc-hint { min-height: 54px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
body.mobile-ui:has(#doc:not(.hidden)) #msg-catch { pointer-events: none; }
body.mobile-ui #doc .paper { touch-action: pan-y; overscroll-behavior: contain; }
body.mobile-ui .menu-box { max-height: 92dvh; max-width: 94vw; overflow: auto; }
body.mobile-ui .title-wrap { max-height: 96dvh; max-width: 96vw; overflow: auto; padding: 12px; }
body.mobile-ui .inv-tabs { overflow-x: auto; min-width: 0; }
body.mobile-ui .inv-tabs button { flex-shrink: 0; min-height: 44px; padding-inline: 12px; }
body.mobile-ui .tab-glyph { display: none; }
body.mobile-ui #inv-back { min-height: 44px; }
body.mobile-ui .inv-main { overflow-y: auto; }
body.mobile-ui .inv-foot { flex-shrink: 0; }

@media (max-width: 600px) {
  body.mobile-ui #prompt { bottom: calc(184px + env(safe-area-inset-bottom)); max-width: 88vw; width: max-content; }
  body.mobile-ui #clock-time { font-size: 23px; }
  body.mobile-ui #clock-bar { width: 100px; }
  body.mobile-ui .inv-wrap { padding: 12px; height: 94dvh; }
  body.mobile-ui .inv-head { gap: 6px; margin-bottom: 12px; }
  body.mobile-ui #inv-clock { font-size: 14px; padding: 2px 6px; flex-shrink: 0; }
  body.mobile-ui .inv-main { overflow-y: auto; flex-shrink: 1; }
  body.mobile-ui #inv-grid { flex-shrink: 0; }
  body.mobile-ui #inv-view { height: 120px; flex-shrink: 0; }
  body.mobile-ui #doc .paper { padding: 26px; font-size: 19px; }
  body.mobile-ui #msg { max-height: 75dvh; overflow-y: auto; }
  body.mobile-ui #msg-choices.row { flex-wrap: wrap; gap: 4px; }
}
@media (max-height: 500px) {
  body.mobile-ui .title-ch { margin-bottom: 12px; }
  body.mobile-ui .title-foot { margin-top: 16px; }
  body.mobile-ui #title h1 { font-size: 60px; }
  body.mobile-ui #puzzle { padding-top: 64px; padding-bottom: max(110px, calc(env(safe-area-inset-bottom) + 98px)); }
  body.mobile-ui .pz { gap: 6px; }
  body.mobile-ui .pz-title { font-size: 22px; }
  body.mobile-ui .pz-title::before { display: none; }
  body.mobile-ui .pz-note { font-size: 13px; }
  body.mobile-ui .lock { padding: 10px 20px; gap: 10px; }
  body.mobile-ui .wheel { width: 50px; }
  body.mobile-ui .wheel .num { width: 46px; height: 60px; }
  body.mobile-ui .wheel .num::after { height: 34px; margin-top: -17px; }
  body.mobile-ui .wheel .drum i { font-size: 14px; line-height: 20px; }
  body.mobile-ui .wheel .drum b { font-size: 30px; line-height: 34px; }
  body.mobile-ui .lock.padlock { margin-top: 40px; }
  body.mobile-ui .lock.padlock::before { top: -46px; width: 110px; height: 72px; margin-left: -55px; border-width: 10px; }
  body.mobile-ui .pz-row .pz-btn { min-height: 36px; padding: 6px 20px; }
  body.mobile-ui .inv-wrap { padding: 14px 22px; }
  body.mobile-ui .inv-head { padding-bottom: 8px; margin-bottom: 10px; }
  body.mobile-ui #inv-grid { grid-template-columns: repeat(4, 64px); grid-auto-rows: 64px; flex-shrink: 0; }
  body.mobile-ui #msg { padding: 36px 8vw 40px; max-height: 85dvh; overflow-y: auto; font-size: 18px; }
  body.mobile-ui #msg::before { top: 14px; }
}

/* A quiet intermission when a phone or tablet is held upright. */
#rotate-screen { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 40%, #211810, #090706 70%); text-align: center; }
.rotate-card { max-width: 300px; }
.rotate-card svg { width: 100px; height: 80px; fill: none; stroke: var(--gold); stroke-width: 1.5; opacity: .75; }
.rotate-card h2 { font-family: 'Rakkas'; font-size: 36px; font-weight: 400; color: var(--gold-hi); margin: 18px 0 6px; }
.rotate-card p { font-family: 'Naskh'; font-size: 21px; color: var(--ink2); margin: 0 0 24px; }
.rotate-card small { display: block; font-size: 11px; line-height: 1.8; color: var(--dim); margin-top: 24px; }
.rotate-card button { min-height: 48px; }
body.landscape-required #touch-controls { display: none; }
#display-notice { position: fixed; z-index: 110; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: 90vw; padding: 12px 20px; border: 1px solid var(--line-gold); background: var(--panel); color: var(--ink); text-align: center; font-size: 13px; }

/* Mobile layout follows the device, even with a controller attached. Keep
   all of these rules separate from the desktop notebook and panels. */
.fam-mobile-toolbar, .fam-mobile-people { display: none; }
body.mobile-ui { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body.mobile-ui button, body.mobile-ui summary, body.mobile-ui a { touch-action: manipulation; }
body.mobile-ui #touch-controls button { touch-action: none; }
body.mobile-ui .overlay { padding-inline: max(12px, env(safe-area-inset-left)); }
body.mobile-ui .menu { width: min(460px, 100%); }
body.mobile-ui .menu button { min-width: 0; width: 100%; min-height: 44px; padding: 10px 26px; font-size: 15px; }
body.mobile-ui .menu button.opt { gap: 16px; }
body.mobile-ui .opt-l { text-align: right; }
body.mobile-ui .opt-v { flex-shrink: 0; gap: 4px; }
body.mobile-ui .opt-v .arr { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0; }
body.mobile-ui .menu-box { min-width: 0; width: min(600px, 94vw); padding: 16px 22px; max-height: calc(100dvh - 20px); overscroll-behavior: contain; }
body.mobile-ui .menu-box h2 { font-size: 28px; margin-bottom: 8px; padding-bottom: 8px; }
body.mobile-ui .menu-foot { margin-top: 12px; padding-top: 10px; font-size: 12px; }
body.mobile-ui .menu-foot { display: none; }
body.mobile-ui .menu .menu-back { position: sticky; bottom: 0; z-index: 2; background: var(--panel); border-top: 1px solid var(--line-gold); }
body.mobile-ui .ctrl-table { width: 100%; font-size: 12px; }
body.mobile-ui .ctrl-table td, body.mobile-ui .ctrl-table th { padding: 5px; }
body.mobile-ui .ctrl-note { font-size: 14px; line-height: 1.8; }
body.mobile-ui .inv-wrap, body.mobile-ui #inv[data-tab="family"] .inv-wrap { width: calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right)));
  height: calc(100dvh - max(20px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); padding: 12px 16px; }
body.mobile-ui .inv-head { flex-shrink: 0; gap: 8px; margin-bottom: 10px; padding-bottom: 8px; }
body.mobile-ui .inv-tabs { flex: 1; scrollbar-width: none; }
body.mobile-ui .inv-tabs button { padding: 6px 12px; font-size: 13px; }
body.mobile-ui .inv-tabs button.on::after { bottom: 0; }
body.mobile-ui .inv-tabs button.on::before { bottom: -2px; }
body.mobile-ui #inv-clock { font-size: 16px; padding: 2px 8px; flex-shrink: 0; }
body.mobile-ui .inv-foot { margin-top: 8px; padding-top: 8px; min-height: 44px; }
body.mobile-ui #inv-legend { display: none; }
body.mobile-ui #inv-back { padding: 8px 24px; }
body.mobile-ui .inv-main { flex-direction: row; gap: 16px; overflow: hidden; }
body.mobile-ui #inv-grid { overflow-y: auto; overscroll-behavior: contain; grid-template-columns: repeat(4, 64px); grid-auto-rows: 64px; gap: 8px; padding: 2px; }
body.mobile-ui .inv-side { display: block; overflow-y: auto; overscroll-behavior: contain; padding-inline-end: 6px; }
body.mobile-ui .inv-side > * { flex-shrink: 0; }
body.mobile-ui #inv-view { float: left; width: clamp(96px, 30%, 160px); height: 110px; min-height: 110px; margin: 0 12px 8px 0; }
body.mobile-ui #inv-name { font-size: 24px; margin: 0 0 4px; padding-bottom: 6px; }
body.mobile-ui #inv-desc { min-height: 0; font-size: 17px; line-height: 1.7; }
body.mobile-ui #inv-actions { clear: both; position: sticky; bottom: 0; z-index: 1; margin-top: 12px; padding: 8px 0 4px;
  background: linear-gradient(transparent, #0b0907 8px); }
body.mobile-ui #inv-actions button { min-height: 44px; padding: 8px 20px; }
body.mobile-ui #inv-files, body.mobile-ui #inv-log, body.mobile-ui #inv-notes, body.mobile-ui #inv[data-tab="family"] #inv-family { inset: 72px 16px 64px; }
body.mobile-ui #inv-files { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
body.mobile-ui #inv-files button { min-height: 52px; padding-block: 10px; font-size: 18px; }
body.mobile-ui #inv-log, body.mobile-ui #inv-notes { overscroll-behavior: contain; padding: 4px 10px 24px; }
body.mobile-ui #inv-log .lg { font-size: 18px; }
body.mobile-ui .nt-row { min-height: 52px; padding: 12px 16px; }
body.mobile-ui #doc .paper { padding: 24px 32px; max-height: calc(100dvh - 86px); font-size: 19px; transform: none; }
body.mobile-ui #doc .paper.print, body.mobile-ui #doc .paper.phone, body.mobile-ui #doc .paper.tape { font-size: 16px; }
body.mobile-ui #doc-hint { padding: 10px 20px max(10px, env(safe-area-inset-bottom)); }
body.mobile-ui #msg { padding: 34px max(28px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)); max-height: 85dvh; overflow-y: auto; overscroll-behavior: contain; }
body.mobile-ui #msg-choices { gap: 8px; font-size: 16px; }
body.mobile-ui #msg-choices button { min-height: 44px; padding: 10px 30px; box-sizing: border-box; max-width: 100%; }
body.mobile-ui #msg-choices.row { flex-wrap: wrap; gap: 8px; }
body.mobile-ui .pz.cam { flex-direction: row; gap: 16px; }
body.mobile-ui .cam-list { flex-direction: column; min-width: 140px; max-height: 100%; overflow-y: auto; }
body.mobile-ui .cam-list button { min-height: 44px; font-size: 14px; }
body.mobile-ui .cam-body { width: min(52vw, calc((100dvh - 200px) * 4 / 3)); }
body.mobile-ui .phone { width: 280px; height: auto; min-height: 330px; padding: 36px 12px 30px; }
body.mobile-ui .phone-screen { min-height: 270px; }
body.mobile-ui .phone-crack { inset: 36px 12px 30px; height: calc(100% - 66px); }
body.mobile-ui .ph-lock { padding-top: 4px; gap: 6px; }
body.mobile-ui .ph-time { font-size: 26px; }
body.mobile-ui .ph-pad { gap: 6px; margin: 4px 0 10px; }
body.mobile-ui .ph-pad button { min-height: 44px; }
body.mobile-ui .valve-box { width: min(280px, 42dvh, 60vw); }
body.mobile-ui .weld-box svg { width: min(260px, 42dvh, 60vw); }
body.mobile-ui .medal svg { width: min(300px, 50dvh, 65vw); height: auto; }
body.mobile-ui .cone-box { width: min(440px, 64dvh, 80vw); }
body.mobile-ui .rub-box { width: min(560px, 54vw); }
body.mobile-ui .c5-box { width: min(420px, 60dvh, 70vw); }
body.mobile-ui .frame-img.tape43 { width: min(70vw, calc((100dvh - 200px) * 4 / 3)); }
body.mobile-ui .panel-box { display: grid; grid-template-columns: minmax(0, 1fr) 80px; gap: 10px; width: min(760px, 90vw); padding: 16px; }
body.mobile-ui .sticker { grid-column: 1 / -1; margin: 0 auto 4px; padding: 2px 16px; }
body.mobile-ui .breakers { justify-content: flex-start; gap: 6px; padding: 8px; overflow-x: auto; }
body.mobile-ui .brk { width: 56px; flex-shrink: 0; gap: 8px; }
body.mobile-ui .brk .body { height: 92px; }
body.mobile-ui .brk .body::before { height: 60px; }
body.mobile-ui .brk .lever { top: 43px; height: 28px; }
body.mobile-ui .brk.on .lever { top: 12px; }
body.mobile-ui .brk .lbl { width: 56px; font-size: 12px; }
body.mobile-ui .main-brk { flex-direction: column; gap: 8px; margin-top: 0; }
body.mobile-ui .main-brk .body { width: 56px; }
body.mobile-ui .main-brk .lever { left: 13px; right: 13px; }
body.mobile-ui .main-brk .tag { font-size: 11px; padding: 4px 8px; text-align: center; }

/* The mobile family index and the full tree share the same learned facts. */
body.mobile-ui .fam-mobile-toolbar { display: flex; position: absolute; inset: 0 0 auto; height: 48px; align-items: center; justify-content: space-between; gap: 8px; z-index: 1; }
body.mobile-ui .fam-view-switch, body.mobile-ui .fam-zoom { display: flex; gap: 8px; }
body.mobile-ui .fam-nav-hint { font-size: 10px; color: var(--dim); text-align: center; }
body.mobile-ui .fam-mobile-toolbar .pz-btn { min-height: 44px; padding: 6px 20px; font-size: 13px; }
body.mobile-ui .fam-mobile-toolbar [aria-pressed="true"] { color: var(--gold-hi); border-color: var(--gold); }
body.mobile-ui .fam-zoom .pz-btn { min-width: 44px; padding: 6px; font-size: 22px; }
body.mobile-ui #inv-family[data-family-view="people"] .fam-zoom { visibility: hidden; }
body.mobile-ui .fam-mobile-people { display: block; position: absolute; inset: 54px 0 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 4px 16px; }
body.mobile-ui .fam-mobile-people h3 { font-family: 'Rakkas'; color: var(--gold); font-weight: 400; font-size: 22px; margin: 8px 0; }
body.mobile-ui .fam-person-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
body.mobile-ui .fam-person { all: unset; box-sizing: border-box; position: relative; display: flex; flex-direction: column; min-height: 76px; padding: 12px 16px 12px 38px;
  background: linear-gradient(155deg, #c6b798, #b09e7d); color: #2c2c34; font-family: 'Naskh'; line-height: 1.6; font-size: 17px; border: 1px solid #7e7058; border-radius: 2px; cursor: pointer; touch-action: manipulation; }
body.mobile-ui .fam-person-name { font-weight: 700; font-size: 21px; }
body.mobile-ui .fam-person small, body.mobile-ui .fam-person s { font-size: 15px; }
body.mobile-ui .fam-person i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 26px; font-style: normal; color: #67573f; }
body.mobile-ui .fam-person:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
body.mobile-ui .fam-person.sel { border-color: var(--gold-hi); box-shadow: inset 0 0 0 1px #736044; }
body.mobile-ui .fam-mobile-notes { margin-top: 16px; padding: 12px; border-top: 1px solid var(--line-gold); font-family: 'Naskh'; font-size: 18px; color: var(--ink2); }
body.mobile-ui .fam-mobile-notes summary { min-height: 44px; cursor: pointer; }
body.mobile-ui .fam-mobile-notes p { margin: 0 0 10px; }
body.mobile-ui .fam-wrap { inset: 54px 0 0; display: block; overflow: auto; overscroll-behavior: contain; direction: ltr; touch-action: pan-x pan-y pinch-zoom; }
body.mobile-ui .fam-page { display: block; transform: none; max-width: none; margin: 0; }
body.mobile-ui #inv-family[data-family-view="people"] .fam-wrap, body.mobile-ui #inv-family[data-family-view="chart"] .fam-mobile-people { display: none; }
body.mobile-ui #inv-family[data-card-open] .fam-mobile-toolbar { visibility: hidden; }
body.mobile-ui .fam-card { padding: 4px; }
body.mobile-ui .fam-paper { width: min(800px, 100%); height: 100%; max-height: 100%; padding: 18px 24px 24px; transform: none; overscroll-behavior: contain; font-size: 18px; line-height: 1.8; }
body.mobile-ui .fam-card .fam-back { display: none; }
body.mobile-ui .fam-portrait { width: 44px; height: 52px; }
body.mobile-ui .fam-head h3 { font-size: 26px; }
body.mobile-ui .fam-rec { min-height: 44px; box-sizing: border-box; display: inline-flex; align-items: center; padding: 6px 12px; font-size: 17px; }
@media (max-width: 740px) {
  body.mobile-ui #inv-grid { grid-template-columns: repeat(3, 64px); }
  body.mobile-ui .inv-main { gap: 12px; }
  body.mobile-ui .inv-tabs button { font-size: 12px; padding-inline: 8px; }
  body.mobile-ui .fam-person-grid { gap: 8px; }
}
