:root { --bg:#10151c; --panel:#1a222d; --ink:#ece4d3; --dim:#9aa7b5; --gold:#e8b24a; --line:#2d3947; --accent:#e8b24a; }
* { box-sizing: border-box; }
html,body { margin:0; background:var(--bg); color:var(--ink); font-family: Georgia, 'Times New Roman', serif; font-size:17px; line-height:1.45; }
.hidden { display:none !important; }
.screen { min-height:100vh; min-height:100dvh; }
#login { display:flex; align-items:center; justify-content:center; padding:20px; background:radial-gradient(ellipse at 50% 0, #26354a, var(--bg) 70%); }
.card { max-width:420px; width:100%; background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:24px; }
h1 { margin:0 0 4px; font-size:28px; color:var(--gold); }
.tag { color:var(--dim); margin-top:0; font-style:italic; }
label { display:block; margin:14px 0 0; color:var(--dim); font-size:14px; }
input[type=text], input[type=password], #say { width:100%; margin-top:4px; padding:12px; font:inherit; color:var(--ink); background:#0d1218; border:1px solid var(--line); border-radius:8px; }
button { font:inherit; cursor:pointer; border-radius:8px; border:1px solid var(--line); background:#243040; color:var(--ink); padding:10px 14px; }
button:hover:not(:disabled) { border-color:var(--gold); }
button:disabled { opacity:.45; cursor:default; }
.primary { background:var(--gold); color:#1b1306; border-color:var(--gold); font-weight:bold; }
.ghost { background:transparent; color:var(--dim); border-color:transparent; font-size:13px; padding:4px 8px; }
.err { color:#ff8e7a; min-height:1.2em; }
.fine { color:var(--dim); font-size:13px; }

#game { display:flex; flex-direction:column; max-width:760px; margin:0 auto; height:100vh; height:100dvh; }
header { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 14px; background:var(--panel); border-bottom:1px solid var(--line); font-size:14px; flex-wrap:wrap; }
header .title b { color:var(--gold); }
header .title span { color:var(--dim); margin-left:8px; font-style:italic; }
header .stats { display:flex; gap:14px; align-items:center; }
.bar { display:inline-block; width:70px; height:9px; background:#0d1218; border:1px solid var(--line); border-radius:6px; overflow:hidden; vertical-align:middle; }
.bar > i { display:block; height:100%; background:linear-gradient(90deg,#c9553d,#e8b24a,#6fbf73); width:50%; transition:width .4s; }
.mock { background:#5a3b12; color:#ffd48a; text-align:center; font-size:12px; padding:3px; }
main { flex:1; overflow-y:auto; padding:12px 14px; }
#stage { display:flex; flex-direction:column; align-items:center; gap:10px; }
#bigwrap { position:relative; width:min(62vw,260px); aspect-ratio:1; border-radius:14px; overflow:hidden; border:2px solid var(--line); background:#0d1218; transition:border-color .2s; }
#bigwrap.speaking { border-color:var(--c, var(--gold)); box-shadow:0 0 18px color-mix(in srgb, var(--c, #e8b24a) 40%, transparent); }
#big { width:100%; height:100%; object-fit:cover; display:block; }
#bigname { position:absolute; left:0; right:0; bottom:0; padding:6px 10px; background:linear-gradient(transparent, rgba(0,0,0,.75)); font-size:15px; }
.bubble { width:100%; background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:12px 14px; min-height:84px; position:relative; }
#speech { font-size:18px; }
#speech.narr { font-style:italic; color:var(--dim); }
#skip { position:absolute; right:4px; bottom:2px; }
#reportline { position:absolute; left:4px; bottom:2px; font-size:11px; opacity:.55; padding:2px 6px; }
#reportline:hover { opacity:1; }
.turn { width:100%; border:1px solid var(--gold); color:var(--gold); background:rgba(232,178,74,.08); border-radius:10px; padding:10px 14px; font-style:italic; text-align:center; }
#cast { display:flex; gap:8px; justify-content:center; margin:12px 0; }
#cast .m { width:56px; text-align:center; font-size:11px; color:var(--dim); opacity:.7; }
#cast .m.on { opacity:1; color:var(--ink); }
#cast img { width:56px; height:56px; border-radius:50%; object-fit:cover; border:2px solid var(--line); display:block; }
#cast .m.on img { border-color:var(--c); }
#cast .m.gone img { filter:grayscale(1) brightness(.5); }
#log { border-top:1px solid var(--line); padding-top:10px; color:var(--dim); font-size:15px; }
#log p { margin:0 0 8px; }
#log b { color:var(--ink); }
#log .you { text-align:right; color:#c7d8ee; }
#log .note { color:var(--gold); font-style:italic; text-align:center; }
#log .narr { font-style:italic; }
footer { padding:10px 14px calc(10px + env(safe-area-inset-bottom)); background:var(--panel); border-top:1px solid var(--line); }
#actions { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:8px; }
#sayform { display:flex; gap:8px; }
#sayform input { margin-top:0; }
.tools { display:flex; justify-content:space-between; align-items:center; font-size:12px; color:var(--dim); margin-top:6px; gap:8px; flex-wrap:wrap; }
.tools label { margin:0; font-size:12px; }
.dots::after { content:''; animation:d 1.2s steps(4) infinite; }
@keyframes d { 0%{content:''} 25%{content:'.'} 50%{content:'..'} 75%{content:'...'} }

.mapbtn { padding:4px 10px; font-size:13px; }
.mapbtn.new { border-color:var(--gold); color:var(--gold); animation:glow 1.4s infinite; }
@keyframes glow { 50% { box-shadow:0 0 10px var(--gold); } }
#mapview { position:fixed; inset:0; z-index:50; background:#0a0e13; }
#mapstage { background:#1b232e; position:absolute; inset:0; overflow:hidden; touch-action:none; cursor:grab; }
#mapinner { position:absolute; left:0; top:0; width:1672px; height:941px; transform-origin:0 0; will-change:transform; }
#mapimg, #fog, #mapsvg { position:absolute; left:0; top:0; width:1672px; height:941px; display:block; user-select:none; -webkit-user-drag:none; }
#fog { pointer-events:none; transition:opacity .4s; }
#mapsvg { overflow:visible; }
#mapframe { position:absolute; left:0; top:0; pointer-events:none; box-sizing:border-box; --inv:1;
  border:calc(3px * var(--inv)) solid #b89a54; outline:calc(1px * var(--inv)) solid rgba(0,0,0,.7); outline-offset:calc(-3px * var(--inv));
  box-shadow:inset 0 0 calc(40px * var(--inv)) rgba(0,0,0,.55), 0 0 calc(14px * var(--inv)) rgba(0,0,0,.7); }
body.dead #mapframe { border-color:#6b727a; box-shadow:inset 0 0 calc(40px * var(--inv)) rgba(0,0,0,.55); }
.mapctl { position:absolute; right:10px; top:calc(10px + env(safe-area-inset-top)); display:flex; flex-direction:column; gap:8px; }
.mapctl button { width:42px; height:42px; padding:0; font-size:20px; background:rgba(16,21,28,.85); }
#mapinfo { position:absolute; left:12px; right:70px; bottom:calc(14px + env(safe-area-inset-bottom)); background:rgba(16,21,28,.92); border:1px solid var(--gold); border-radius:10px; padding:10px 14px; font-size:15px; }
.mk { cursor:pointer; }
.mklabel { fill:#fff4d6; font-family:Georgia,serif; font-size:15px; paint-order:stroke; stroke:#10151c; stroke-width:4px; stroke-linejoin:round; }
.mklabel.band { fill:#ffd27a; }
.pulse { animation:pulse 1.8s ease-in-out infinite; transform-box:fill-box; transform-origin:center; }
@keyframes pulse { 0%,100% { transform:scale(.8); opacity:.9; } 50% { transform:scale(1.3); opacity:.3; } }

/* scene backdrops */
#stage { position:relative; border-radius:16px; padding:14px 10px 10px; background-size:cover; background-position:center top; background-repeat:no-repeat; transition:background-image .4s; overflow:hidden; }
#stage.hasbg::before { content:""; position:absolute; inset:0; background:linear-gradient(to bottom, rgba(8,11,16,.10) 0%, rgba(8,11,16,.25) 40%, rgba(8,11,16,.88) 100%); pointer-events:none; }
#stage > * { position:relative; }
#stage.hasbg .bubble { background:rgba(10,14,20,.72); border-radius:12px; padding:10px 12px; backdrop-filter:blur(3px); }
#stage.hasbg #bigwrap { width:min(50vw,215px); } #stage.hasbg { padding-top:18px; min-height:420px; justify-content:space-between; }

#cast .bond { display:block; font-style:normal; font-size:11px; }
#cast .bond.up { color:#6fbf73; } #cast .bond.down { color:#c9553d; }
#result { border:1px solid var(--gold); border-radius:12px; padding:12px 14px; margin-bottom:12px; color:var(--ink); background:rgba(232,178,74,.06); }
#result h3 { margin:0 0 6px; color:var(--gold); }
#result ul { display:flex; flex-wrap:wrap; gap:4px 14px; list-style:none; padding:0; margin:6px 0; }

/* ---------- speech bubble: the thing to read ---------- */
.bubble { min-height:9.5em; padding-top:10px; }
#who { font-size:13px; letter-spacing:.06em; text-transform:uppercase; font-weight:bold; min-height:1.2em; margin-bottom:2px; }
#speech { font-size:20px; line-height:1.5; cursor:pointer; }
#speech.narr { font-size:19px; }
.tools select { font:inherit; font-size:12px; color:var(--ink); background:#0d1218; border:1px solid var(--line); border-radius:6px; padding:2px 4px; }

/* ---------- tappable things ---------- */
.mapbtn { padding:8px 14px; font-size:14px; border-color:var(--gold); color:var(--gold); }
#cast .m { cursor:pointer; -webkit-tap-highlight-color:transparent; }
#cast .m:hover img, #cast .m:focus-visible img { border-color:var(--gold); }
#cast .m:focus-visible, #bigwrap:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }
#bigwrap { cursor:pointer; }
#stage { cursor:zoom-in; }
#stage > #viewbtn { position:absolute; top:10px; right:10px; z-index:2; padding:6px 12px; font-size:13px; background:rgba(10,14,20,.72); backdrop-filter:blur(3px); border-color:rgba(232,178,74,.5); color:var(--ink); }
#stage > .bubble, #stage > #cast { cursor:default; }

/* ---------- character sheet ---------- */
#sheet { position:fixed; inset:0; z-index:60; background:rgba(6,9,13,.82); display:flex; align-items:center; justify-content:center; padding:0; }
.sheetpanel { --c:var(--gold); position:relative; width:100%; max-width:860px; height:100%; max-height:100dvh; background:var(--panel); border:1px solid var(--line); border-top:3px solid var(--c); display:flex; flex-direction:column; overflow:hidden; }
.sheetbar { position:absolute; top:calc(8px + env(safe-area-inset-top)); left:8px; right:8px; z-index:3; display:flex; gap:8px; pointer-events:none; }
.sheetbar button { pointer-events:auto; width:42px; height:42px; padding:0; font-size:22px; line-height:1; background:rgba(16,21,28,.85); }
#sheetprev { margin-right:auto; } #sheetclose { margin-left:8px; }
.sheetfig { position:relative; flex:0 0 54%; min-height:0; background:#ece3d3; display:flex; align-items:center; justify-content:center; padding:6px; }
.sheetfig img { max-width:100%; max-height:100%; object-fit:contain; display:block; }
.sheetfig img.gone { filter:grayscale(1) brightness(.6); }
.sheettext { flex:1; overflow-y:auto; padding:14px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheettext h2 { margin:0; font-size:26px; color:var(--c); }
.sheettext h3 { margin:16px 0 4px; font-size:13px; letter-spacing:.08em; text-transform:uppercase; color:var(--dim); font-weight:normal; }
.sheettext p { margin:2px 0; }
.sheettext .role { color:var(--dim); font-style:italic; }
.sheettext .missing { color:#ff8e7a; font-style:italic; }
.sheettext .dim { color:var(--dim); font-style:italic; }
.bondline { display:inline-block; margin:6px 0 0; padding:2px 10px; border:1px solid var(--line); border-radius:99px; font-size:14px; color:var(--dim); }
.bondline.up { color:#6fbf73; border-color:#3e6b43; } .bondline.down { color:#e08a76; border-color:#7a3a2e; }
.traits { display:flex; flex-wrap:wrap; gap:6px; list-style:none; padding:0; margin:12px 0 0; }
.traits li { padding:3px 12px; border-radius:99px; background:color-mix(in srgb, var(--c) 22%, transparent); border:1px solid color-mix(in srgb, var(--c) 60%, transparent); font-size:14px; }
.reacts, .said { margin:4px 0; padding-left:20px; }
.reacts li { margin:3px 0; }
.said { list-style:none; padding:0; }
.said li { margin:6px 0; padding:8px 12px; border-left:3px solid var(--c); background:rgba(255,255,255,.04); border-radius:0 8px 8px 0; font-style:italic; }
@media (min-width:760px) {
  #sheet { padding:24px; }
  .sheetpanel { flex-direction:row; height:auto; max-height:min(92vh,900px); min-height:min(92vh,760px); border-radius:16px; }
  .sheetfig { flex:0 0 46%; padding:14px; }
  .sheettext { padding:56px 24px 24px; }
}

/* ---------- full-screen scene ---------- */
#sceneview { position:fixed; inset:0; z-index:55; background:#05080c; transition:opacity .22s; }
#sceneview.leaving { opacity:0; }
#svstage { position:absolute; inset:0; overflow:hidden; touch-action:none; cursor:grab; }
#svimg { position:absolute; left:0; top:0; max-width:none; transform-origin:0 0; will-change:transform,opacity; user-select:none; -webkit-user-drag:none; display:block; }
.svctl { position:absolute; top:calc(10px + env(safe-area-inset-top)); right:10px; display:flex; gap:8px; }
.svctl button { height:42px; background:rgba(16,21,28,.85); }
#svclose { width:42px; padding:0; font-size:20px; }
#svmap { border-color:var(--gold); color:var(--gold); }
#svcap { position:absolute; left:0; right:0; bottom:0; padding:30px 16px calc(14px + env(safe-area-inset-bottom)); background:linear-gradient(transparent, rgba(0,0,0,.8)); pointer-events:none; display:flex; flex-direction:column; gap:2px; }
#svcap b { font-size:20px; color:var(--gold); }
#svcap span { font-size:13px; color:var(--dim); }
#svhint { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); background:rgba(16,21,28,.9); border:1px solid var(--gold); color:var(--gold); border-radius:99px; padding:8px 18px; font-style:italic; pointer-events:none; }

/* the Orb */
#orbpanel { position: fixed; inset: 0; z-index: 60; background: rgba(6,10,16,.78); display: flex; align-items: flex-end; justify-content: center; }
#orbpanel.hidden { display: none; }
.orbbox { width: min(560px, 100%); max-height: 88vh; overflow: auto; background: #111a26; border: 1px solid #2c4a6a; border-radius: 16px 16px 0 0; padding: 14px 16px 20px; box-shadow: 0 -10px 40px rgba(60,140,220,.25); }
.orbhead { display: flex; align-items: center; gap: 10px; }
.orbhead h2 { flex: 1; font-size: 1.05rem; margin: 0; color: #cfe8ff; font-weight: 600; }
.orbhead button { background: none; border: 0; color: #cfe8ff; font-size: 1.6rem; line-height: 1; padding: 2px 8px; cursor: pointer; }
.orbglyph { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #8fd0ff 35%, #2a5d96 75%); box-shadow: 0 0 14px #5aaeff; flex: none; }
#orbnow { font-size: .82rem; color: #9db4cc; margin: 8px 0 10px; }
.orbroute { background: #0d141e; border: 1px solid #25374c; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.orbroute h3 { margin: 0 0 6px; font-size: .98rem; color: #ffd27a; }
.orbnums { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: #cfe8ff; margin-bottom: 6px; }
.orbnums b { color: #fff; }
.orbroute ul { margin: 4px 0 6px 18px; padding: 0; font-size: .86rem; color: #d7e2ee; }
.orbback { margin: 4px 0 0; font-size: .84rem; color: #a9c4dd; }
.orbwarn { margin: 6px 0 0; font-size: .84rem; color: #ff9b8a; font-weight: 600; }
#orbfoot { font-size: .78rem; color: #7f93a8; margin: 6px 0 0; }
#speech.narr.orb { color: #bfe0ff; }

/* character card: face, state of mind, skills */
.sheetfig #sheetimg { position:relative; }
#sheetface { position:absolute; left:12px; bottom:12px; width:92px; height:92px; border-radius:50%; object-fit:cover; border:3px solid var(--c); background:#222; box-shadow:0 3px 14px rgba(0,0,0,.45); }
#sheetface.gone { filter:grayscale(.7) brightness(.8); }
.mind { margin:10px 0 4px; padding:10px 12px; border:1px solid var(--line); border-left:3px solid var(--c); border-radius:8px; background:rgba(255,255,255,.03); }
.mind.away { border-left-color:#c8624f; }
.moodrow { display:flex; align-items:center; gap:10px; }
.mood { font-weight:bold; color:var(--c); }
.spirits { flex:1; max-width:140px; height:8px; border-radius:99px; background:rgba(255,255,255,.1); overflow:hidden; }
.spirits span { display:block; height:100%; background:linear-gradient(90deg,#c8624f,#e8b24a,#6fbf73); }
.mind p { margin:6px 0 0; }
.stats { display:grid; gap:5px; margin-top:6px; }
.stat { display:grid; grid-template-columns:86px 1fr 22px; align-items:center; gap:8px; font-size:14px; }
.stat .sn { color:var(--dim); }
.stat b { text-align:right; font-weight:600; }
.pips { display:grid; grid-template-columns:repeat(10,1fr); gap:3px; }
.pips i { height:9px; border-radius:2px; background:rgba(255,255,255,.1); }
.pips i.on { background:var(--c); }
.bio { line-height:1.5; }

/* ---- world chooser and Dead Alley theme ---- */
.worlds { display:grid; gap:8px; margin:12px 0 4px; }
.wopt { display:flex; gap:10px; align-items:center; margin:0; padding:10px 12px; border:1px solid var(--line); border-radius:10px; color:var(--ink); cursor:pointer; font-size:15px; }
.wopt em { display:block; color:var(--dim); font-size:12px; font-style:normal; }
.wopt:has(input:checked) { border-color:var(--gold); background:rgba(232,178,74,.07); }
.wopt.dead:has(input:checked) { border-color:#c9302a; background:rgba(201,48,42,.12); }
.warn { margin:10px 0 0; padding:12px; border:1px solid #c9302a; border-radius:10px; background:rgba(120,12,12,.22); color:#f0d6d2; font-size:13.5px; line-height:1.45; }
.warn .chk { display:flex; gap:8px; align-items:flex-start; margin:10px 0 0; color:#fff; font-size:14px; }
.warn .chk input { margin-top:3px; }
body.dead { --bg:#0c0809; --panel:#171112; --ink:#e6dcd6; --dim:#a08f8c; --gold:#d2554a; --line:#3a2626; --accent:#d2554a; }
body.dead .primary { background:#b3322b; border-color:#b3322b; color:#fff; }
body.dead header .title b { color:#e04a3f; letter-spacing:.06em; text-transform:uppercase; }
body.dead #fever { color:#ff6a5a; font-variant-numeric:tabular-nums; }
body.dead #clockwrap { animation:doom 2.4s ease-in-out infinite; }
@keyframes doom { 50% { opacity:.55; } }
body.dead #viewbtn { display:none !important; }
body.dead #stage.hasbg { background-size:cover; background-position:center; }
@media (prefers-reduced-motion: reduce) { body.dead #clockwrap { animation:none; } }

#login.logindead { background:linear-gradient(rgba(8,4,5,.55), rgba(8,4,5,.82)), url('/backdrops/dead/title.jpg') left center / cover no-repeat; }
#login.logindead .card { background:rgba(18,10,11,.86); border-color:#4a2222; backdrop-filter:blur(3px); }
#login.logindead h1 { color:#e04a3f; letter-spacing:.08em; text-transform:uppercase; }
body.dead .sheetfig { background:#0b0809; }
body.dead .sheetpanel { border-color:#4a2222; }
#login.logindead .card::before { content:''; display:block; height:200px; margin:-24px -24px 18px; border-radius:14px 14px 0 0; background:linear-gradient(transparent 55%, rgba(18,10,11,.95)), url('/backdrops/dead/title.jpg') 4% 30% / 210% auto no-repeat; }
#login.logindead { background:linear-gradient(rgba(8,4,5,.7), rgba(8,4,5,.9)), #080405; }

/* optional video clips under the stills */
.bgvid { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; object-position:center top; opacity:0; transition:opacity .8s; pointer-events:none; }
.bgvid.on { opacity:1; }
#stage { isolation:isolate; }
#stage > video.bgvid { position:absolute; inset:0; z-index:-1; }
#login { position:relative; overflow:hidden; }
#login > video.bgvid { z-index:0; }
#login > video.bgvid.on ~ .card, #login > .card { position:relative; z-index:1; }
#login > video.bgvid.on ~ .card { background:rgba(14,18,26,.82); backdrop-filter:blur(3px); }

/* ---------- round 1: compact layout, sticky speaker, menu ---------- */
header { flex-wrap:nowrap; gap:8px; padding:6px 10px; font-size:13px; }
header .title { flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
header .title span { margin-left:6px; }
header .stats { display:flex; gap:10px; align-items:center; margin:0; flex:none; }
.hbar { display:flex; gap:6px; flex:none; }
.hbtn { padding:4px 9px; font-size:15px; min-height:32px; line-height:1; }
.mapbtn.hbtn { font-size:15px; }
@media (max-width:460px) { .hbtn .lbl { display:none; } .bar { width:44px; } header .title span { display:none; } }
main { display:flex; flex-direction:column; overflow:hidden; padding:0; }
#stage, #stage.hasbg { flex:none; display:grid; grid-template-columns:96px 1fr; grid-template-areas:"pic bub" "pic turn"; gap:6px 10px; align-items:start; padding:10px; min-height:0; height:auto; border-radius:0 0 14px 14px; }
#stage #bigwrap, #stage.hasbg #bigwrap { grid-area:pic; width:96px; aspect-ratio:1; align-self:start; }
#stage .bubble, #stage.hasbg .bubble { grid-area:bub; width:auto; min-height:7.2em; max-height:34vh; overflow-y:auto; padding:8px 12px; }
#stage .turn { grid-area:turn; width:auto; padding:6px 10px; font-size:14px; }
#stage #viewbtn { display:none; }
#bigname { font-size:12px; padding:4px 6px; }
#who { font-size:12px; }
#speech, #speech.narr { font-size:17px; line-height:1.45; }
#stage.hasbg { min-height:0 !important; justify-content:initial; }
#cast { flex:none; margin:6px 0 4px; gap:6px; }
#cast .m { width:46px; } #cast img { width:42px; height:42px; } #cast .m { font-size:10px; }
#log { flex:1; min-height:0; overflow-y:auto; padding:8px 14px 10px; border-top:1px solid var(--line); }
footer { padding:8px 12px calc(8px + env(safe-area-inset-bottom)); }
#actions { margin-bottom:6px; gap:6px; }
#actions button { padding:6px 10px; font-size:14px; }
#menupanel { position:fixed; inset:0; z-index:62; background:rgba(6,10,16,.8); display:flex; align-items:center; justify-content:center; padding:16px; }
#menupanel.hidden, #mainmenu.hidden { display:none; }
.menubox { width:min(380px,100%); background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:14px 16px 16px; display:flex; flex-direction:column; gap:8px; }
.menuhead { display:flex; align-items:center; justify-content:space-between; }
.menuhead h2 { margin:0; font-size:1.1rem; }
.menurow label { font-size:14px; color:var(--ink); }
#mainmenu { display:flex; align-items:center; justify-content:center; padding:20px; background:radial-gradient(ellipse at 50% 0, #26354a, var(--bg) 70%); }
body.dead #mainmenu { background:#080405; }
.mmcard { border:1px solid var(--line); border-radius:12px; padding:12px 14px; margin:10px 0; background:rgba(255,255,255,.03); }
.mmcard h3 { margin:0 0 2px; color:var(--gold); }
.mmcard .sub { color:var(--dim); font-size:13px; margin:0 0 8px; }
.mmcard .row { display:flex; gap:8px; flex-wrap:wrap; }
.mmcard.dead h3 { color:#e04a3f; }
#orbwait { display:flex; align-items:center; gap:10px; margin:10px 0; color:#cfe8ff; font-size:.95rem; }
#orbwait.hidden { display:none; }
.hourglass { font-size:1.8rem; display:inline-block; animation:flip 1.6s ease-in-out infinite; }
@keyframes flip { 0%,40% { transform:rotate(0); } 60%,100% { transform:rotate(180deg); } }
#orbpanel.pending .orbbox { min-height:0; }
#stage, #stage.hasbg { padding-top:58px; }
#stage > #loccap { position:absolute; top:10px; left:10px; right:10px; display:flex; align-items:baseline; gap:10px; padding:0; pointer-events:none; text-shadow:0 1px 6px #000, 0 0 12px #000; }
#loccap b { font-size:17px; color:#fff4d6; }
#loccap .ex { font-size:12px; color:#e7dcc3; opacity:.85; }
body.dead #loccap .ex { display:none; }
.pacerow { display:flex; flex-direction:column; gap:6px; }
.pacebar { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--dim); }
.pacebar input { flex:1; padding:0; margin:0; accent-color:var(--gold); }
#skip.tapnow { color:var(--gold); font-size:13px; animation:glow 1.4s infinite; }

#journalpanel, #progresspanel { position:fixed; inset:0; z-index:61; background:rgba(6,10,16,.86); display:flex; justify-content:center; align-items:stretch; }
#journalpanel.hidden, #progresspanel.hidden { display:none; }
.jbox { width:min(640px,100%); background:var(--panel); border-left:1px solid var(--line); border-right:1px solid var(--line); padding:12px 14px calc(14px + env(safe-area-inset-bottom)); display:flex; flex-direction:column; gap:8px; overflow:hidden; }
.jtabs { display:flex; gap:6px; flex:none; }
.jtabs button { flex:1; padding:7px 6px; font-size:13px; }
.jtabs button.on { background:var(--gold); color:#1b1306; border-color:var(--gold); font-weight:bold; }
#jbody, #pbody { flex:1; overflow-y:auto; min-height:0; font-size:15px; }
#jbody h4 { margin:14px 0 4px; font-size:12px; letter-spacing:.07em; text-transform:uppercase; color:var(--gold); border-bottom:1px solid var(--line); padding-bottom:3px; }
#jbody p { margin:0 0 6px; color:var(--dim); }
#jbody p b { color:var(--ink); }
#jbody p.you { color:#c7d8ee; text-align:right; }
#jbody p.narr { font-style:italic; }
#jbody p.note, #jbody p.act { color:var(--gold); font-style:italic; }
.jorb { border:1px solid #2c4a6a; background:#0f1722; border-radius:10px; padding:10px 12px; margin:8px 0; }
.jorb .meta { font-size:12px; color:#8aa4be; margin-bottom:4px; }
.jorb button { margin-top:6px; }
.jempty { color:var(--dim); font-style:italic; padding:16px 4px; }
.pgrid { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:8px 0; }
.pcell { border:1px solid var(--line); border-radius:10px; padding:8px 10px; background:rgba(255,255,255,.03); }
.pcell small { display:block; color:var(--dim); font-size:11px; letter-spacing:.05em; text-transform:uppercase; }
.pcell b { font-size:20px; }
.pjourney { display:flex; gap:4px; margin:6px 0 2px; }
.pjourney i { flex:1; height:8px; border-radius:4px; background:#1d2733; }
.pjourney i.done { background:var(--gold); } .pjourney i.here { background:#6fbf73; }
.pnote { color:var(--dim); font-size:13px; margin:6px 0; }

.bpip { display:block; width:36px; height:4px; margin:2px auto 0; border-radius:2px; background:#1d2733; overflow:hidden; }
.bpip b { display:block; height:100%; }
h4.gh { margin:14px 0 2px; font-size:12px; letter-spacing:.07em; text-transform:uppercase; color:var(--gold); }
svg.chart { width:100%; height:auto; background:rgba(255,255,255,.03); border:1px solid var(--line); border-radius:8px; }
.ckey { display:flex; flex-wrap:wrap; gap:4px 12px; font-size:12px; color:var(--dim); margin:4px 0; }
.ckey i { display:inline-block; width:10px; height:3px; margin-right:4px; vertical-align:middle; border-radius:2px; }

/* ---------- phones: bigger text, faces down the side, compact speech box ---------- */
@media (max-width:640px) {
  header { padding:6px 8px; gap:6px; }
  .hbtn { min-width:44px; min-height:44px; font-size:24px; padding:2px 6px; }
  header .stats { gap:8px; font-size:17px; }
  header .title b { font-size:15px; }
  main { display:grid; grid-template-columns:78px 1fr; grid-template-rows:auto 1fr; }
  #stage, #stage.hasbg { grid-column:1 / -1; grid-template-columns:70px 1fr; grid-template-areas:"pic bub" "turn turn"; padding:34px 8px 8px; gap:4px 8px; }
  #stage > #loccap { top:6px; left:8px; right:8px; }
  #loccap b { font-size:16px; } #loccap .ex { display:none; }
  #stage #bigwrap, #stage.hasbg #bigwrap { width:70px; }
  #bigname { display:none; }
  #stage .bubble, #stage.hasbg .bubble { min-height:4.6em; max-height:24vh; padding:6px 10px; background:rgba(14,20,28,.9); }
  #speech, #speech.narr { font-size:19px; line-height:1.4; }
  #who { font-size:14px; }
  #stage .turn { font-size:15px; padding:5px 8px; max-height:5.5em; overflow-y:auto; }
  #cast { grid-column:1; grid-row:2; flex-direction:column; align-items:center; justify-content:flex-start; gap:8px; margin:0; padding:8px 0; overflow-y:auto; border-top:1px solid var(--line); border-right:1px solid var(--line); }
  #cast .m { width:66px; font-size:12px; color:var(--ink); opacity:.85; }
  #cast img { width:56px; height:56px; border:3px solid var(--c); margin:0 auto; opacity:.8; }
  #cast .m.on { opacity:1; } #cast .m.on img { opacity:1; box-shadow:0 0 0 3px color-mix(in srgb, var(--c) 45%, transparent), 0 0 14px var(--c); }
  .bpip { width:48px; height:5px; }
  #log { grid-column:2; grid-row:2; font-size:17px; line-height:1.45; padding:8px 12px 10px; }
  #log p, #log div { font-size:inherit; }
  #actions button { font-size:16px; padding:9px 12px; }
  #jbody, #pbody { font-size:18px; line-height:1.5; }
  #jbody h4, h4.gh { font-size:14px; }
  .jtabs button { font-size:15px; padding:10px 6px; }
  .jorb .meta, .pnote, .ckey { font-size:15px; }
  .pcell small { font-size:12px; } .pcell b { font-size:24px; }
}
@media (max-width:640px) {
  header .title { display:none; }
  header .stats { margin-right:auto; }
  .mapbtn.hbtn { font-size:24px; }
  #cast { gap:4px; padding:6px 0; }
  #cast .m { font-size:11px; line-height:1.1; }
  #cast img { width:46px; height:46px; border-width:3px; }
  .bpip { margin-top:1px; }
}
#sheet .stats { display:grid; gap:7px; margin-top:6px; }
@media (max-width:640px) {
  .sheettext { font-size:18px; line-height:1.5; }
  .sheettext h2 { font-size:30px; }
  .sheettext h3 { font-size:15px; margin-top:20px; }
  #sheet .stat { grid-template-columns:110px 1fr 28px; font-size:17px; gap:10px; }
  .traits li { font-size:17px; padding:4px 14px; }
  .bondline { font-size:17px; }
  .sheettext .mood, .sheettext .dim, .sheettext .role { font-size:17px; }
  .sheettext li { font-size:17px; margin-bottom:4px; }
}

#infopanel { position:fixed; inset:0; z-index:63; background:rgba(6,10,16,.82); display:flex; align-items:center; justify-content:center; padding:16px; }
#infopanel.hidden { display:none; }
.irow { display:flex; justify-content:space-between; gap:12px; padding:6px 0; border-bottom:1px solid var(--line); font-size:15px; }
.irow span { color:var(--dim); }
@media (max-width:640px) { .irow { font-size:17px; } .hbtn { min-width:40px; min-height:44px; } header { gap:4px; padding:6px 6px; } header .stats { gap:6px; } .bar { width:34px; } }
@media (max-width:400px) { header .bar { display:none; } }
.aboutbtn { display:flex; align-items:center; gap:10px; text-align:left; width:100%; } .aboutbtn small { color:var(--dim); margin-left:6px; }
#svvid { position:absolute; left:0; top:0; max-width:none; transform-origin:0 0; will-change:transform; object-fit:cover; opacity:0; pointer-events:none; display:block; user-select:none; }

#dlg { position:fixed; inset:0; z-index:90; background:rgba(4,7,11,.8); display:flex; align-items:center; justify-content:center; padding:18px; }
#dlg.hidden { display:none; }
.dlgbox { width:min(420px,100%); background:var(--panel); border:1px solid var(--gold); border-radius:14px; padding:18px 18px 14px; box-shadow:0 10px 40px rgba(0,0,0,.6); }
.dlgbox h2 { margin:0 0 8px; font-size:20px; color:var(--gold); }
.dlgbox p { margin:0 0 16px; font-size:16px; line-height:1.45; color:var(--ink); }
.dlgbtns { display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; }
.dlgbtns button { padding:10px 16px; font-size:16px; }
.dlgbtns #dlgok { background:var(--gold); color:#1b1306; border-color:var(--gold); font-weight:bold; }
.dlgbtns #dlgok.danger { background:#a8432f; border-color:#a8432f; color:#fff; }
@media (max-width:640px) { .dlgbox p { font-size:18px; } .dlgbtns button { flex:1; min-height:46px; } }

.cutscene{position:fixed;inset:0;z-index:50;background:#000;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .6s}
.cutscene.in{opacity:1}.cutscene.out{opacity:0}
.cutscene video{max-width:100%;max-height:100%;width:auto;height:100%;object-fit:contain}
.cutscene button{position:absolute;top:calc(env(safe-area-inset-top,0px) + 14px);right:14px;font-size:16px;padding:10px 18px;border-radius:20px;border:1px solid #fff6;background:#000a;color:#fff;cursor:pointer}

/* Desktop and tablet: the cast stands in a column on the left, as on the phone */
@media (min-width:641px) {
  main { display:grid; grid-template-columns:92px 1fr; grid-template-rows:max-content minmax(0,1fr); }
  #stage { grid-column:1 / -1; }
  #cast { grid-column:1; grid-row:2; flex-direction:column; align-items:center; justify-content:flex-start; gap:8px; margin:0; padding:10px 0; overflow-y:auto; overflow-x:hidden; border-top:1px solid var(--line); border-right:1px solid var(--line); }
  #cast .m { width:80px; font-size:13px; color:var(--ink); opacity:.85; }
  #cast img { width:54px; height:54px; border:3px solid var(--c); margin:0 auto; opacity:.8; }
  #cast .m.on { opacity:1; } #cast .m.on img { opacity:1; box-shadow:0 0 0 3px color-mix(in srgb, var(--c) 45%, transparent), 0 0 14px var(--c); }
  #cast .bpip { width:54px; }
  #log { grid-column:2; grid-row:2; padding:10px 14px; }
}

/* Dark, slim scrollbars everywhere (the default light ones looked out of place) */
:root { color-scheme: dark; }
* { scrollbar-width: thin; scrollbar-color: #3a4757 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #3a4757; border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: #55677c; }
*::-webkit-scrollbar-corner { background: transparent; }
#cast { overflow-x:hidden; }

@media (min-width:641px) and (max-height:820px) {
  #cast { gap:4px; padding:6px 0; }
  #cast img { width:44px; height:44px; border-width:3px; }
  #cast .m { font-size:12px; line-height:1.1; }
  #cast .bpip { width:44px; margin-top:1px; }
  #stage .bubble, #stage.hasbg .bubble { min-height:4.4em; }
  #stage #bigwrap, #stage.hasbg #bigwrap { width:76px; }
  #stage { padding-bottom:6px !important; }
  #bigname { display:none; }
}

.cluelist { margin:6px 0 10px; padding-left:20px; } .cluelist li { margin:6px 0; line-height:1.4; }

/* Actions: inline on wide screens; on a phone, one button that opens a pop-up list over the story */
#actions { position:relative; }
#actions .actlist { display:contents; }
#acttoggle { width:100%; font-size:17px; padding:11px 12px; margin-bottom:6px; }
#actions .actlist.menu { display:none; position:absolute; left:0; right:0; bottom:calc(100% + 4px); max-height:52vh; overflow-y:auto; flex-direction:column; gap:6px; padding:8px; background:var(--panel); border:1px solid var(--gold); border-radius:12px; box-shadow:0 -10px 28px #000c; z-index:30; }
#actions .actlist.menu.open { display:flex; }
#actions .actlist.menu button { width:100%; text-align:left; }
#xferpanel { position:fixed; inset:0; z-index:63; background:rgba(6,10,16,.82); display:flex; align-items:center; justify-content:center; padding:16px; }
#xferpanel.hidden, #xferin.hidden { display:none; }
.xfercode { font:700 34px/1.2 ui-monospace,Menlo,Consolas,monospace; letter-spacing:.12em; text-align:center; color:#ffd27a; background:#10151c; border:1px solid var(--gold); border-radius:10px; padding:14px 8px; margin:10px 0; user-select:all; }
#havecode { color:#e8b24a; }
[hidden] { display:none !important; }

/* =====================================================================================
   Version 0.11: text size, history fold, speaker modes, standard phrases, arrival cards,
   briefing, help, hover tips, and the two-pane layout for tablets and computers
   ===================================================================================== */
:root { --fs: 1; }
#speech, #speech.narr { font-size:calc(19px * var(--fs)); }
#who { font-size:calc(13px * var(--fs)); }
#stage .turn { font-size:calc(15px * var(--fs)); }
#say { font-size:calc(17px * var(--fs)); }
#actions button { font-size:calc(15px * var(--fs)); }

/* history: small and quiet by default, open it to read back */
#histwrap { display:flex; flex-direction:column; min-height:0; min-width:0; grid-column:2; grid-row:2; }
#loghead { flex:none; display:flex; justify-content:space-between; align-items:center; width:100%; background:transparent; border:0; border-top:1px solid var(--line); border-radius:0; color:var(--dim); font-size:calc(12px * var(--fs)); padding:5px 6px; letter-spacing:.04em; text-transform:uppercase; }
#loghead:hover:not(:disabled) { color:var(--gold); }
#log { flex:1; min-height:0; font-size:calc(13px * var(--fs)); line-height:1.4; color:var(--dim); opacity:.85; border-top:0; padding-top:4px; }
body.logopen #log { font-size:calc(16px * var(--fs)); opacity:1; }
#log p.live { color:var(--ink); }

/* who is shown speaking: top only (default), history only, or both */
body.sp-hist #speech, body.sp-hist #who { display:none; }
body.sp-hist .bubble, body.sp-hist #stage.hasbg .bubble { min-height:0; padding:4px 8px; background:transparent; border:0; backdrop-filter:none; }
body.sp-hist #log, body.sp-hist.logopen #log { font-size:calc(19px * var(--fs)); color:var(--ink); opacity:1; }
body.sp-hist #loghead { display:none; }

/* things you can say in one tap */
#actions .actlist button.phrase { font-style:italic; color:#cfe0f2; border-style:dashed; }
#actions .actlist button.phrase:first-of-type { margin-top:6px; }

/* small map that opens the big one */
.minimap { display:flex; flex-direction:column; align-items:center; gap:2px; padding:3px; width:64px; background:rgba(10,14,20,.78); border:2px solid #b89a54; border-radius:8px; color:var(--ink); font-size:11px; backdrop-filter:blur(3px); }
.minimap img { width:100%; height:44px; object-fit:cover; border-radius:4px; display:block; }
body.dead .minimap { border-color:#6b727a; }
#stage > #minimap2 { position:absolute; top:6px; right:8px; z-index:3; }
#colL, #colR { display:contents; }
#scenepic, #sidecard { display:none; }

/* arrival and problem cards, briefing, help */
#intro, #arrival { position:fixed; inset:0; z-index:70; background:rgba(5,8,12,.86); display:flex; align-items:center; justify-content:center; padding:10px; overflow-y:auto; }
#intro.hidden, #arrival.hidden, #helppanel.hidden { display:none; }
.introbox, .arrbox { width:min(760px,100%); max-height:100%; overflow-y:auto; background:var(--panel); border:1px solid var(--gold); border-radius:16px; box-shadow:0 14px 60px rgba(0,0,0,.7); display:flex; flex-direction:column; }
.arrpic { position:relative; height:clamp(150px,30vh,300px); flex:none; background:#0d1218 center/cover no-repeat; border-radius:15px 15px 0 0; }
.arrpic::after { content:""; position:absolute; inset:0; border-radius:inherit; pointer-events:none; background:linear-gradient(to bottom, transparent 55%, rgba(26,34,45,.95)); }
.arrpic.tod-dawn { box-shadow:inset 0 0 0 999px rgba(255,170,110,.14); }
.arrpic.tod-beforedawn, .arrpic.tod-night { box-shadow:inset 0 0 0 999px rgba(10,20,55,.45); }
.arrpic.tod-morning { box-shadow:inset 0 0 0 999px rgba(255,235,190,.08); }
.arrpic.tod-dusk { box-shadow:inset 0 0 0 999px rgba(190,90,60,.22); }
.arrpic.tod-afternoon { box-shadow:inset 0 0 0 999px rgba(255,200,120,.08); }
.arrtod { position:absolute; top:10px; left:12px; z-index:2; padding:3px 12px; border-radius:99px; background:rgba(8,11,16,.7); border:1px solid rgba(232,178,74,.55); color:#ffe2a3; font-size:13px; letter-spacing:.08em; text-transform:uppercase; }
.arrfaces { position:absolute; right:12px; bottom:-18px; z-index:3; display:flex; gap:10px; }
.arrface { text-align:center; font-size:12px; color:var(--ink); text-shadow:0 1px 4px #000; }
.arrface img { display:block; width:84px; height:84px; object-fit:cover; border-radius:12px; border:3px solid var(--gold); background:#0d1218; box-shadow:0 4px 18px rgba(0,0,0,.7); }
.arrextra { position:absolute; left:12px; bottom:-18px; z-index:3; display:flex; align-items:center; gap:8px; padding:4px 10px 4px 4px; background:rgba(10,14,20,.88); border:1px solid var(--gold); border-radius:10px; color:var(--ink); font-size:13px; text-align:left; }
.arrextra img { width:54px; height:42px; object-fit:cover; border-radius:6px; }
.arrtext { padding:24px 20px 18px; }
.arrtext h2 { margin:0 0 6px; font-size:calc(26px * var(--fs)); color:var(--gold); }
.arrtext h3 { margin:16px 0 4px; font-size:calc(12px * var(--fs)); letter-spacing:.08em; text-transform:uppercase; color:var(--dim); font-weight:normal; }
.arrtext p, .arrtext li { font-size:calc(17px * var(--fs)); line-height:1.5; }
.arrsit { margin:0 0 4px; }
.kicker { margin:0 0 2px; color:var(--dim); font-size:13px !important; letter-spacing:.1em; text-transform:uppercase; }
.sidenote { color:var(--dim); font-size:calc(14px * var(--fs)) !important; }
.arrhint { color:#cfe8ff; font-style:italic; border-left:3px solid #4f86b8; padding-left:10px; margin:12px 0 0; }
.arrtiles { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin:12px 0 0; }
.arrtiles > div { border:1px solid var(--line); border-radius:10px; padding:6px 10px; background:rgba(255,255,255,.03); }
.arrtiles small { display:block; color:var(--dim); font-size:11px; letter-spacing:.04em; text-transform:uppercase; line-height:1.2; }
.arrtiles b { font-size:calc(22px * var(--fs)); }
.tbar { display:block; height:4px; margin-top:3px; border-radius:2px; background:#1d2733; overflow:hidden; } .tbar i { display:block; height:100%; background:linear-gradient(90deg,#c9553d,#e8b24a); }
.arrband { display:flex; gap:8px; flex-wrap:wrap; }
.bm { width:84px; text-align:center; font-size:12px; line-height:1.15; }
.bm img { width:52px; height:52px; border-radius:50%; object-fit:cover; border:3px solid var(--c); display:block; margin:0 auto 3px; }
.bm small { display:block; color:var(--dim); font-size:11px; } .bm.gone img { filter:grayscale(1) brightness(.5); }
.arrbtns { display:flex; gap:10px; justify-content:flex-end; margin-top:18px; }
.arrbtns button { padding:12px 22px; font-size:17px; }
.introfoot { flex-wrap:wrap; display:flex; justify-content:space-between; align-items:center; gap:12px; padding:10px 20px 14px; border-top:1px solid var(--line); color:var(--dim); font-size:14px; }
.introfoot label { display:flex; align-items:center; gap:10px; margin:0; } .introfoot input[type=range] { accent-color:var(--gold); width:min(220px,40vw); }
.introdots { display:flex; gap:6px; } .introdots i { width:9px; height:9px; border-radius:50%; background:#2a3644; } .introdots i.on { background:var(--gold); }
.picks { display:grid; grid-template-columns:repeat(auto-fill,minmax(calc(120px * var(--fs)),1fr)); gap:10px; margin:12px 0; }
.pick { display:flex; flex-direction:column; align-items:center; text-align:center; gap:2px; padding:10px 6px; margin:0; border:2px solid var(--c); border-radius:12px; background:rgba(255,255,255,.04); color:var(--ink); }
.pick input { display:none; } .pick img { width:72px; height:72px; border-radius:50%; object-fit:cover; margin-bottom:4px; } .pick small { color:var(--dim); font-size:12px; line-height:1.25; }
.fld { display:block; margin:12px 0 0; color:var(--ink); font-size:calc(15px * var(--fs)); } .fld input[type=text], .fld select { width:100%; margin-top:4px; padding:10px; font:inherit; color:var(--ink); background:#0d1218; border:1px solid var(--line); border-radius:8px; }
.namerow { display:flex; gap:8px; } .namerow input { flex:1; padding:8px; font:inherit; color:var(--ink); background:#0d1218; border:1px solid var(--line); border-radius:8px; }
#menupanel select { font:inherit; color:var(--ink); background:#0d1218; border:1px solid var(--line); border-radius:6px; padding:6px; width:100%; margin-top:4px; }
#helppanel { position:fixed; inset:0; z-index:64; background:rgba(6,10,16,.86); display:flex; justify-content:center; align-items:stretch; }
#helpbody { flex:1; overflow-y:auto; font-size:calc(16px * var(--fs)); line-height:1.5; } #helpbody p { margin:2px 0 8px; }
#tip { position:fixed; z-index:200; max-width:260px; padding:6px 10px; font:13px/1.3 system-ui,sans-serif; color:#ffeccb; background:#0b0f14; border:1px solid var(--gold); border-radius:8px; pointer-events:none; box-shadow:0 4px 16px rgba(0,0,0,.6); }
#tip.hidden { display:none; }
.obj { margin:4px 0 8px; padding-left:20px; } .obj li { margin:4px 0; font-size:calc(15px * var(--fs)); line-height:1.4; }
.ach { display:flex; flex-wrap:wrap; gap:6px; } .ach span { padding:3px 11px; border-radius:99px; border:1px solid #6e5a2c; background:rgba(232,178,74,.12); color:#ffe2a3; font-size:calc(13px * var(--fs)); }
#sidecard h3 { margin:14px 0 4px; font-size:13px; letter-spacing:.08em; text-transform:uppercase; color:var(--gold); }
@media (max-width:640px) { .arrtiles { grid-template-columns:repeat(2,1fr); } .arrface img { width:64px; height:64px; } .arrbtns button { flex:1; } }

/* ---- tablets in portrait and small laptops: use the full width, not a column in the middle ---- */
@media (min-width:641px) { #game { max-width:none; margin:0; } }

/* ---- wide screens (tablet landscape, computers): story and choices on the left, picture, map and progress on the right ---- */
@media (min-width:900px) {
  #game { display:grid; grid-template-columns:minmax(0,1.1fr) minmax(0,1fr); grid-template-rows:auto auto minmax(0,1fr) auto; }
  #game > header, #game > .mock { grid-column:1 / -1; }
  main { display:contents; }
  #colL { grid-column:1; grid-row:3; display:flex; flex-direction:column; min-height:0; padding:14px 18px 6px 16px; gap:10px; }
  #colR { grid-column:2; grid-row:3 / span 2; display:flex; flex-direction:column; min-height:0; overflow-y:auto; padding:14px 16px 12px 4px; gap:12px; }
  #game > footer { grid-column:1; grid-row:4; padding:8px 18px calc(10px + env(safe-area-inset-bottom)) 16px; }
  #stage, #stage.hasbg { background-image:none !important; flex:0 0 auto; min-height:0; display:flex; flex-direction:row; flex-wrap:wrap; align-content:flex-start; align-items:flex-start; gap:12px 16px; padding:0; border-radius:0; cursor:default; }
  #stage.hasbg::before { display:none; }
  #stage > video.bgvid, #stage #viewbtn, #stage > #loccap, #stage > #minimap2 { display:none !important; }
  #stage #bigwrap, #stage.hasbg #bigwrap { width:150px; flex:none; }
  #bigname { display:block; }
  #stage .bubble, #stage.hasbg .bubble { flex:1 1 280px; width:auto; min-height:11em; max-height:none; padding:14px 18px; background:var(--panel); backdrop-filter:none; }
  #speech, #speech.narr { font-size:calc(23px * var(--fs)); line-height:1.5; }
  #who { font-size:calc(14px * var(--fs)); }
  #stage .turn { flex:1 1 100%; font-size:calc(17px * var(--fs)); max-height:none; }
  #histwrap { grid-column:auto; grid-row:auto; flex:1 1 auto; max-height:none; }
  #scenepic { display:block; position:relative; flex:none; width:100%; aspect-ratio:16 / 10; max-height:46vh; border-radius:14px; overflow:hidden; background:#0d1218 center/cover no-repeat; border:1px solid var(--line); isolation:isolate; }
  #scenepic > video.bgvid { position:absolute; inset:0; z-index:-1; }
  #scenepic::before { content:""; position:absolute; inset:0; z-index:0; background:linear-gradient(to bottom, rgba(8,11,16,.05) 40%, rgba(8,11,16,.85)); pointer-events:none; }
  #scenecap { position:absolute; left:14px; bottom:10px; z-index:2; display:flex; flex-direction:column; text-shadow:0 1px 6px #000, 0 0 12px #000; }
  #scenecap b { font-size:calc(21px * var(--fs)); color:#fff4d6; } #timeofday { font-size:13px; color:#ffe2a3; letter-spacing:.1em; text-transform:uppercase; }
  #scenepic > #minimap { position:absolute; right:10px; top:10px; z-index:3; width:96px; } #scenepic > #minimap img { height:66px; }
  #wherebtn { position:absolute; right:10px; bottom:10px; z-index:3; padding:6px 12px; font-size:13px; background:rgba(10,14,20,.78); border-color:rgba(232,178,74,.55); }
  #cast { grid-column:auto; grid-row:auto; flex:none; flex-direction:row; flex-wrap:wrap; justify-content:center; align-items:flex-start; gap:10px; margin:0; padding:0; overflow:visible; border:0; }
  #cast .m { width:86px; font-size:13px; } #cast img { width:66px; height:66px; } #cast .bpip { width:58px; }
  #sidecard { display:block; flex:none; border:1px solid var(--line); border-radius:12px; padding:4px 16px 14px; background:rgba(255,255,255,.03); }
  #bubble #skip { font-size:14px; }
}
@media (min-width:900px) and (max-height:700px) { #scenepic { max-height:34vh; } #cast img { width:54px; height:54px; } #stage .bubble { min-height:8em; } }

/* time-passes notice */
#timenote { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 6; padding: 9px 12px; border-radius: 10px; background: rgba(20,24,34,.92); color: #f1ead8; border: 1px solid #6a7b8c; font-size: .92em; line-height: 1.35; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .3s, transform .3s; }
#timenote.show { opacity: 1; transform: none; }
#timenote.warn { border-color: #d9a441; background: rgba(60,44,12,.94); }
#timenote.bad { border-color: #d0584a; background: rgba(70,20,16,.95); }
#clockwrap.lowtime, #clockwrap.lowtime * { color:#ff8a7a; font-weight:700; }

/* Intro screen wallpaper: the world's own picture, kept pale so the writing stays easy to read.
   public/backdrops/[dead/]intro_wall.jpg if there is one, else title.jpg, else stage0.jpg. */
#intro { background-image:linear-gradient(rgba(5,8,12,.6),rgba(5,8,12,.82)), var(--wall, none); background-size:cover; background-position:center; }
.introbox { background-image:linear-gradient(color-mix(in srgb, var(--panel) 70%, transparent), color-mix(in srgb, var(--panel) 82%, transparent)), var(--wall, none); background-size:cover; background-position:center; }

.introctl { display:flex; flex-wrap:wrap; align-items:center; gap:8px 22px; } .introctl input[type=range] { width:min(150px,32vw); }
.introfoot { position:sticky; bottom:0; z-index:3; background:var(--panel); } /* the text and sound sliders stay in view on every page, even on a phone */

.introfoot { flex-direction:column; align-items:stretch; justify-content:flex-start; gap:8px; padding:10px 16px 12px; }
.introrow { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.introfoot .arrbtns { margin:0; } .introfoot .arrbtns button { padding:10px 20px; font-size:16px; }
.introctl input[type=range] { width:min(150px,30vw); }
@media (max-width:640px) { .introfoot .arrbtns { flex:1; justify-content:flex-end; } .introfoot .arrbtns button { flex:0 1 auto; } }
.pick { font-size:calc(16px * var(--fs)); } .pick small { font-size:calc(12px * var(--fs)); } /* the character cards follow the Text size slider too */

/* leaderboard and stats under the result card */
#lbbox { margin:8px 0; }
#lbbox .lbstat { margin:6px 0; }
#lbbox .lbrow { display:block; margin:6px 0; }
#lbbox .lbrow input { display:block; margin-top:4px; width:100%; max-width:22em; }
#lbbox .lblist { margin:8px 0; padding-left:1.6em; }
#lbbox .lblist li { margin:2px 0; }
#lbbox .lblist small { opacity:.65; margin-left:6px; }
#lbbox .lbnone { opacity:.7; }

/* v52: Orb button, Orb confirmation, Status of the quest */
#orbbtn { border-color:var(--gold); color:var(--gold); white-space:nowrap; }
#orbbtn b { font-size:12px; margin-left:2px; }
#orbbtn.hidden { display:none; }
#actions .actlist button.orbact { border-color:var(--gold); color:var(--gold); }
#orbconfirm { position:fixed; inset:0; z-index:70; background:rgba(6,10,16,.82); display:flex; align-items:center; justify-content:center; padding:16px; }
#orbconfirm.hidden { display:none; }
.ocbox { background:#1b1f2b; border:1px solid var(--gold); border-radius:14px; padding:18px 20px; max-width:420px; width:100%; }
.ocbox h2 { margin:0 0 8px; color:var(--gold); font-size:20px; }
.ocbox p { margin:6px 0 14px; line-height:1.4; }
.ocbtns { display:flex; gap:10px; justify-content:flex-end; }
.ocbtns button { min-height:44px; padding:8px 16px; }
.qlist { list-style:none; margin:6px 0; padding:0; }
.qlist li { display:grid; grid-template-columns:26px 1fr; gap:2px 8px; padding:7px 0; border-bottom:1px solid var(--line); }
.qlist .qm { font-size:18px; line-height:1.2; text-align:center; }
.qlist li.done .qm { color:#7fcf8a; } .qlist li.now .qm { color:var(--gold); } .qlist li.todo { opacity:.6; }
.qlist small { grid-column:2; color:var(--dim); font-size:13px; }
.srow { display:grid; grid-template-columns:44px 1fr; gap:10px; padding:8px 0; border-bottom:1px solid var(--line); align-items:center; }
.srow img { width:44px; height:44px; border-radius:50%; object-fit:cover; border:2px solid var(--c,#999); }
.srow.gone img { filter:grayscale(1) opacity(.6); }
.srow b { display:block; } .srow span { display:block; color:var(--dim); font-size:13px; }
.srow .where { color:var(--text); } .srow.gone .where { color:#e8a070; }
.foodnote { color:var(--dim); font-size:13px; margin:4px 0 8px; }

/* v54: one clear Menu with icons and words; the old icon row is hidden but still drives the same panels */
.srcbtn { display:none !important; }
#navwrap { position:relative; flex:none; }
#navbtn { font-size:15px; font-weight:600; padding:6px 12px; min-height:36px; white-space:nowrap; border-color:var(--gold); }
#navlist { position:absolute; top:calc(100% + 6px); left:0; z-index:58; width:min(340px, 92vw); background:#1b1f2b; border:1px solid var(--gold); border-radius:12px; padding:6px; box-shadow:0 10px 30px rgba(0,0,0,.55); }
#navlist.hidden { display:none; }
#navlist button { display:flex; align-items:center; gap:12px; width:100%; text-align:left; background:transparent; border:0; border-radius:8px; padding:8px 10px; min-height:48px; color:var(--text); font:inherit; cursor:pointer; }
#navlist button:hover, #navlist button:focus-visible { background:rgba(255,255,255,.08); outline:none; }
#navlist .ni { font-size:22px; width:30px; text-align:center; flex:none; }
#navlist .nt { display:flex; flex-direction:column; min-width:0; }
#navlist .nt b { font-size:15px; }
#navlist .nt small { color:var(--dim); font-size:12px; line-height:1.25; }
#navlist button[hidden] { display:none; }
#navbtn.dot::after { content:''; display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--gold); margin-left:6px; vertical-align:middle; }
@media (max-width:460px) { #navbtn { padding:6px 10px; font-size:14px; } #orbbtn .lbl { display:inline !important; } }
@media (min-width:900px) { #navbtn { font-size:17px; min-height:44px; padding:6px 16px; } #navlist { width:380px; } #navlist .nt b { font-size:17px; } #navlist .nt small { font-size:14px; } }

#setupbtn { font-size:17px; font-weight:700; padding:7px 16px; min-height:40px; white-space:nowrap; border-color:var(--gold); background:rgba(232,178,74,.12); }
@media (max-width:460px) { #setupbtn { font-size:15px; padding:6px 10px; } }
@media (min-width:900px) { #setupbtn { font-size:19px; min-height:46px; padding:6px 20px; } }
@media (max-width:640px) {
  #setupbtn, #navbtn, #orbbtn { font-size:13px !important; min-width:0 !important; min-height:40px !important; padding:4px 8px !important; }
  #orbbtn .lbl { display:none !important; }
  #orbbtn { font-size:18px !important; padding:4px 8px !important; }
  #orbbtn b { font-size:12px; }
  header .stats { gap:4px; font-size:14px; }
}
@media (max-width:640px) { #navlist { width:calc(100vw - 96px); } }
.speakto{margin:.4rem 0 .8rem;padding:.55rem 1rem;border-radius:999px;border:1px solid var(--c,#c9a64e);background:transparent;color:inherit;font-size:1rem;cursor:pointer}
.speakto:hover{background:var(--c,#c9a64e);color:#111}
/* Setup panel: never taller than the screen; scrolls inside if it has to */
#menupanel { padding:max(8px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom)); }
.menubox { max-height:calc(100vh - 16px); max-height:calc(100dvh - 16px); overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; }
.menubox .menuhead { position:sticky; top:-14px; background:var(--panel); z-index:1; padding:4px 0; }
/* Title and "where you are" match the Setup and Menu buttons */
header .title { font-size:17px; font-weight:700; }
header .title span { font-weight:600; }
@media (min-width:900px) { header .title { font-size:19px; } }
@media (max-width:460px) { header .title { font-size:15px; } header .title span { display:inline !important; } }
@media (max-width:640px) { header .title { font-size:13px !important; } }
/* Food, days and morale: same size as the title and buttons; the bar is the band's morale (red low, green high) */
header .stats { font-size:17px; gap:18px; }
header .stats b { font-size:1.1em; }
header .stats .slbl { color:var(--dim); font-size:.8em; }
header .stats .bar { width:96px; height:14px; }
@media (min-width:900px) { header .stats { font-size:19px; } header .stats .bar { width:120px; height:16px; } }
@media (max-width:640px) { header .stats { font-size:13px !important; gap:8px; } header .stats .slbl { display:none; } header .stats .bar { width:40px; height:10px; } }

.whisper { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-bottom:6px; }
.whisper.hidden { display:none; }
.whisper .wlbl { font-size:calc(13px * var(--fs)); color:var(--muted, #9aa3ad); margin-right:2px; }
.whisper .wbtn { padding:6px 12px; border-radius:16px; border:1px solid var(--c, var(--line)); background:#0d1218; color:var(--ink); font:inherit; font-size:calc(14px * var(--fs)); cursor:pointer; }
.whisper .wbtn.on { background:var(--c, #345); color:#0b0f14; font-weight:600; }
#who { cursor:pointer; }

#whisperbox { position:fixed; left:50%; transform:translateX(-50%); bottom:90px; width:min(92vw,460px); z-index:40; background:#101820; border:1px solid var(--c, var(--line)); border-radius:12px; padding:10px 12px; box-shadow:0 8px 28px rgba(0,0,0,.6); }
#whisperbox.hidden { display:none; }
#whisperbox .wbtitle { font-size:calc(14px * var(--fs)); color:var(--c, var(--ink)); margin-bottom:6px; font-weight:600; }
#whisperbox .wbrow { display:flex; gap:6px; }
#whisperbox input { flex:1; margin:0; padding:10px; font:inherit; font-size:calc(16px * var(--fs)); color:var(--ink); background:#0d1218; border:1px solid var(--line); border-radius:8px; }

.roadtag { display:inline-block; margin-left:6px; padding:1px 8px; border-radius:10px; font-size:.62em; letter-spacing:.04em; text-transform:uppercase; vertical-align:middle; border:1px solid currentColor; }
.roadtag.hidden { display:none; }
.roadtag[data-tier="easy"] { color:#7fc08a; } .roadtag[data-tier="medium"] { color:#e8b24a; } .roadtag[data-tier="hard"] { color:#e07a5f; }
.roadtag[data-tier="extreme"] { color:#c46bd6; } .roadtag[data-tier="insane"] { color:#ff4d6d; }

#shopbox { position:fixed; inset:0; z-index:60; display:flex; align-items:center; justify-content:center; background:rgba(5,8,12,.78); padding:14px; }
#shopbox.hidden { display:none; }
.shopcard { background:#101820; border:1px solid var(--line, #2a3642); border-radius:14px; padding:18px; width:min(94vw,460px); max-height:92vh; overflow:auto; color:var(--ink); font-size:calc(16px * var(--fs)); }
.shopcard h3 { margin:0 0 8px; }
.packs { display:grid; gap:8px; margin:12px 0; }
.pack { display:grid; grid-template-columns:auto 1fr; grid-template-areas:"pp ps" "pp pl"; gap:0 12px; text-align:left; padding:10px 14px; border-radius:10px; border:1px solid var(--line, #2a3642); background:#0d1218; color:var(--ink); font:inherit; cursor:pointer; }
.pack:hover { border-color:#e8b24a; }
.pack .pp { grid-area:pp; font-size:1.4em; align-self:center; color:#e8b24a; } .pack .ps { grid-area:ps; font-weight:600; } .pack .pl { grid-area:pl; font-size:.85em; opacity:.75; }
.testnote { color:#e8b24a; } .fakecard { background:#0d1218; border:1px dashed #556; border-radius:8px; padding:10px; margin:10px 0; }
.buylink { color:#e8b24a; }
