/* SIR: Door to Door. A sarkari-file look: manila paper, red tape, blue stamp ink. */
:root {
  --ink: #2a1d14; --paper: #f6efdc; --manila: #e2c48c; --manila-d: #c9a466; --red: #b5172b; --tape: #c0392b; --stamp: #1d3f8f; --green: #1f7a3a;
  --sky: #cfe3f0; --dark: #1d1712; --glass: rgba(30, 22, 16, .82); --line: rgba(42, 29, 20, .18); --warn: #c25a00; --info: #1d5f9f;
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b2118; color: var(--ink); font-family: Nunito, system-ui, sans-serif; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; cursor: pointer; color: inherit; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid rgba(0,0,0,.25); border-bottom-width: 2px; border-radius: 4px; background: #fff8; font: 600 12px/1.5 Nunito, sans-serif; }
.hidden { display: none !important; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .45s; z-index: 40; }
#fade.on { opacity: 1; }
#loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 10px; background: #2b2118; color: #f6efdc; z-index: 50; transition: opacity .5s; }
#loading b { font: 700 34px Playfair Display, Georgia, serif; }
#loading.gone { opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- HUD (walking) */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.h-left { position: absolute; top: calc(10px + var(--st)); left: calc(10px + var(--sl)); display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.h-clock, .h-pill, .v-clock { background: var(--glass); color: #fff; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 15px; box-shadow: 0 2px 8px #0005; white-space: nowrap; }
.h-clock b, .v-clock b { font-variant-numeric: tabular-nums; }
.h-clock.low, .v-clock.low { background: #9a1a1a; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.h-right { position: absolute; top: calc(10px + var(--st)); right: calc(10px + var(--sr)); display: flex; gap: 8px; align-items: flex-start; }
#minimap { width: 200px; height: 140px; border-radius: 10px; background: #e8d9b6; border: 2px solid #fff8; box-shadow: 0 2px 8px #0005; }
.h-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--glass); color: #fff; font-size: 16px; box-shadow: 0 2px 8px #0005; flex: none; }
.h-bottom { position: absolute; left: 50%; bottom: calc(14px + var(--sb)); transform: translateX(-50%); display: flex; gap: 10px; }
.act { border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 800; font-size: 16px; background: var(--paper); box-shadow: 0 3px 0 var(--manila-d), 0 6px 14px #0006; }
.act.knock { background: #ffd45c; animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.act kbd { margin-left: 4px; }
body.touch .act kbd { display: none; }
.bubble { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); max-width: min(520px, 80vw); background: #fff; padding: 10px 16px; border-radius: 16px; font-weight: 700; box-shadow: 0 4px 16px #0006; pointer-events: none; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -10px; border: 10px solid transparent; border-top-color: #fff; border-bottom: 0; transform: translateX(-50%); }
.skip { position: absolute; right: calc(14px + var(--sr)); bottom: calc(16px + var(--sb)); border: 0; border-radius: 999px; padding: 10px 16px; background: var(--glass); color: #fff; font-weight: 800; }
.doorline { position: absolute; left: 50%; bottom: calc(70px + var(--sb)); transform: translateX(-50%); width: min(720px, 92vw); background: var(--paper); border-radius: 14px; padding: 14px 18px; box-shadow: 0 6px 20px #0007; font-size: 17px; line-height: 1.4; }
.doorline button { margin-top: 10px; }

/* ---------------------------------------------------------------- the visit */
#visit { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#visit > * { pointer-events: auto; }
.v-top { position: absolute; top: calc(10px + var(--st)); left: calc(10px + var(--sl)); right: calc(430px + var(--sr)); display: flex; gap: 8px; align-items: center; pointer-events: none; }
.v-top > * { pointer-events: auto; }
.v-house { background: var(--paper); border-radius: 12px; padding: 4px 12px; display: flex; flex-direction: column; line-height: 1.15; box-shadow: 0 2px 8px #0004; min-width: 0; }
.v-house b { font-family: Playfair Display, Georgia, serif; font-size: 16px; white-space: nowrap; }
.v-house span { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-mood { background: var(--glass); color: #fff; border-radius: 999px; padding: 6px 10px; font-size: 14px; white-space: nowrap; }
.v-top .h-btn { margin-left: auto; }
.v-top #b-vpause { margin-left: 0; }
.dlg { position: absolute; left: calc(12px + var(--sl)); right: calc(432px + var(--sr)); bottom: calc(12px + var(--sb)); min-height: 96px; background: var(--paper); border-radius: 16px; padding: 12px 14px 12px 12px; display: flex; gap: 12px; align-items: flex-start; box-shadow: 0 6px 22px #0008; border: 2px solid var(--manila-d); cursor: pointer; }
.dlg-ph { width: 64px; height: 80px; border-radius: 8px; object-fit: cover; background: #ddd; flex: none; border: 2px solid #fff; box-shadow: 0 1px 4px #0004; }
.dlg-ph.nb { background: #f2d7a0; }
.dlg-body { flex: 1; min-width: 0; }
.dlg-who { display: block; font-size: 13px; color: var(--red); text-transform: uppercase; letter-spacing: .04em; }
.dlg-txt { margin: 4px 0 0; font-size: 17px; line-height: 1.42; max-height: 7.2em; overflow-y: auto; }
.dlg-more { position: absolute; right: 12px; bottom: 8px; color: var(--red); animation: bob 1s infinite; }
u.fact, .fact { text-decoration: underline 2px #e0a020; text-underline-offset: 3px; cursor: pointer; border-radius: 4px; }
u.fact:hover, .fact:hover { background: #ffe9a8; }
.fact.pinned { background: #ffe9a8; text-decoration-color: #b07a00; }
body.nohints u.fact { text-decoration: none; }
.panel { position: absolute; top: calc(10px + var(--st)); right: calc(10px + var(--sr)); bottom: calc(12px + var(--sb)); width: 410px; background: var(--paper); border-radius: 16px; box-shadow: 0 6px 22px #0008; display: flex; flex-direction: column; overflow: hidden; border: 2px solid var(--manila-d); }
.tabs { display: flex; background: var(--manila); border-bottom: 2px solid var(--manila-d); flex: none; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 2px 6px; font-size: 18px; display: flex; flex-direction: column; align-items: center; gap: 1px; position: relative; }
.tabs button span { font-size: 12px; font-weight: 800; }
.tabs button.on { background: var(--paper); box-shadow: inset 0 3px 0 var(--red); }
.tabs i { position: absolute; top: 4px; right: 12%; min-width: 17px; height: 17px; border-radius: 9px; background: var(--red); color: #fff; font: 800 11px/17px Nunito; font-style: normal; padding: 0 4px; }
.tabs i:empty { display: none; }
.tab-body { flex: 1; overflow-y: auto; padding: 10px 12px 16px; -webkit-overflow-scrolling: touch; }
.qlist { display: flex; flex-direction: column; gap: 7px; }
.q { text-align: left; border: 0; border-radius: 12px; padding: 10px 12px; background: #fff; box-shadow: 0 2px 0 var(--line); font-weight: 700; font-size: 15px; line-height: 1.3; }
.q:hover { background: #fff7dd; }
.q.kind { border-left: 4px solid var(--green); }
.q.pushy { border-left: 4px solid var(--warn); }
.q.pushy::after { content: '⚠ pushy'; float: right; font-size: 11px; color: var(--warn); margin-left: 6px; }
.q.new { animation: newq .6s; }
@keyframes newq { from { background: #ffe9a8; transform: translateX(8px); } }
.q.end { background: var(--red); color: #fff; }
.q:disabled { opacity: .45; }
.sec { margin: 14px 0 6px; font: 800 12px Nunito; text-transform: uppercase; letter-spacing: .06em; color: #7a5a3a; display: flex; justify-content: space-between; align-items: center; }
.btn2 { border: 0; border-radius: 10px; padding: 9px 12px; background: var(--manila); font-weight: 800; box-shadow: 0 2px 0 var(--manila-d); }
.btn2.wide { width: 100%; }
.btn2.red { background: var(--red); color: #fff; box-shadow: 0 2px 0 #7a0f1d; }
.btn2.green { background: var(--green); color: #fff; box-shadow: 0 2px 0 #0f4a22; }
.empty { opacity: .65; font-size: 14px; padding: 10px 0; }
.hint { font-size: 13px; opacity: .75; margin: 4px 0 8px; line-height: 1.35; }

/* roll entries and decisions */
.roll-entry { background: #fff; border-radius: 12px; padding: 8px; margin-bottom: 10px; box-shadow: 0 2px 0 var(--line); border: 1px solid #e8dcc0; }
.re-top { display: flex; gap: 8px; align-items: flex-start; }
.sl { font: 800 12px Nunito; background: var(--ink); color: #fff; border-radius: 6px; padding: 2px 6px; }
.re-ph { width: 46px; height: 58px; object-fit: cover; border-radius: 4px; border: 1px solid #ccc; cursor: pointer; }
.re-txt { display: flex; flex-direction: column; font-size: 13px; line-height: 1.35; min-width: 0; }
.re-txt b { font-size: 15px; }
.epicno { font: 700 11px ui-monospace, Menlo, monospace; opacity: .7; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chip { border: 1.5px solid #d8c8a8; background: #fbf7ec; border-radius: 999px; padding: 4px 9px; font-size: 13px; font-weight: 800; }
.chip.on { background: var(--stamp); border-color: var(--stamp); color: #fff; }
.chip.on.asd { background: #7a1a1a; border-color: #7a1a1a; }
.chip.on.refer { background: var(--warn); border-color: var(--warn); }
.sub { font-size: 12px; font-weight: 800; color: #7a5a3a; margin: 8px 0 0; }
.f8 { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 800; margin-top: 6px; }
.f8 input { width: 18px; height: 18px; }
.newp { background: #fff; border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; border: 1px dashed #c9a466; }
.newp b { font-size: 15px; }
.submit { position: sticky; bottom: -16px; background: var(--paper); padding: 10px 0 4px; }

/* papers */
.docgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.dthumb { border: 0; background: #fff; border-radius: 10px; padding: 8px; text-align: left; box-shadow: 0 2px 0 var(--line); position: relative; }
.dthumb .ic { font-size: 22px; }
.dthumb b { display: block; font-size: 13px; line-height: 1.2; }
.dthumb small { font-size: 12px; opacity: .7; }
.dthumb.flag::after { content: '!'; position: absolute; top: 6px; right: 8px; background: var(--warn); color: #fff; border-radius: 50%; width: 18px; height: 18px; font: 900 12px/18px Nunito; text-align: center; }
.dthumb.unseen { box-shadow: 0 0 0 2px #e0a020; }

/* the phone app */
.phone { background: #1d1d22; border-radius: 22px; padding: 12px; color: #fff; }
.phone h5 { margin: 0 0 8px; display: flex; justify-content: space-between; font-size: 15px; }
.phone h5 small { opacity: .6; font-weight: 400; }
.seg { display: flex; gap: 4px; margin-bottom: 8px; }
.seg button { flex: 1; border: 0; border-radius: 8px; padding: 7px 4px; background: #33333b; color: #ddd; font-size: 12px; font-weight: 800; }
.seg button.on { background: #e8762d; color: #fff; }
.who { display: flex; flex-wrap: wrap; gap: 5px; }
.who button { border: 0; border-radius: 999px; padding: 5px 10px; background: #33333b; color: #fff; font-size: 13px; font-weight: 700; }
.applog { margin-top: 10px; background: #0f0f12; border-radius: 12px; padding: 8px 10px; min-height: 90px; font: 13px/1.45 ui-monospace, Menlo, monospace; color: #c8f0d8; max-height: 260px; overflow-y: auto; }
.applog p { margin: 0 0 8px; }
.applog .q2 { color: #8aa; }
.applog .warn { color: #ffd27a; }
.searching::after { content: '…'; animation: dots 1s infinite; }
@keyframes dots { 33% { content: '.'; } 66% { content: '..'; } }

/* notes */
.finding { border-radius: 10px; padding: 8px 10px; margin-bottom: 7px; font-size: 14px; line-height: 1.35; background: #fff; border-left: 4px solid var(--warn); }
.finding.variation { border-left-color: var(--info); }
.factchips { display: flex; flex-wrap: wrap; gap: 5px; }
.fchip { background: #fff; border-radius: 8px; padding: 3px 8px; font-size: 13px; border: 1px solid #e0d0b0; }
.fchip small { opacity: .6; }
.clue { background: #fff; border-radius: 10px; padding: 8px 10px; margin-bottom: 7px; font-size: 14px; line-height: 1.35; }
.rules { font-size: 13px; line-height: 1.45; padding-left: 18px; }

/* toasts */
.toasts { position: absolute; left: 50%; top: calc(64px + var(--st)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 30; margin-left: -205px; }
.toast { background: var(--glass); color: #fff; border-radius: 12px; padding: 8px 14px; font-weight: 700; font-size: 14px; max-width: min(460px, 60vw); box-shadow: 0 4px 14px #0006; animation: tin .25s; }
.toast.warn { background: #b45000; }
.toast.info { background: #1d4f8f; }
.toast.good { background: #1f6a35; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
#hud .toasts { margin-left: 0; }

/* overlays: documents, the old roll, results */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(20, 14, 10, .78); display: flex; flex-direction: column; padding: calc(10px + var(--st)) calc(10px + var(--sr)) calc(10px + var(--sb)) calc(10px + var(--sl)); }
.dv-bar { display: flex; gap: 8px; align-items: center; color: #fff; flex: none; flex-wrap: wrap; }
.dv-bar b { font-family: Playfair Display, Georgia, serif; font-size: 18px; }
.tool { border: 0; border-radius: 999px; padding: 8px 14px; background: #ffffff22; color: #fff; font-weight: 800; }
.tool.on { background: #ffd45c; color: var(--ink); }
.tool.close { margin-left: auto; background: #fff; color: var(--ink); width: 40px; height: 40px; padding: 0; }
.dv-tip { font-size: 13px; opacity: .85; }
.dv-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; overflow: auto; -webkit-overflow-scrolling: touch; perspective: 1200px; padding: 10px 0; }
.dv-stage > * { flex: none; }
.dv-stage > :first-child { margin-top: auto; }
.dv-stage > :last-child { margin-bottom: auto; }
.dv-out { flex: none; color: #fff; text-align: center; min-height: 22px; font-weight: 700; }
#docview.mag .fld, #docview.mag .ph { cursor: zoom-in; }
.doc { position: relative; width: min(560px, 92vw); background: #fff; border-radius: 14px; padding: 14px 16px; box-shadow: 0 10px 40px #000a; animation: flipin .45s cubic-bezier(.2, .8, .3, 1.2); overflow: hidden; font-size: 14px; }
@keyframes flipin { from { transform: rotateX(55deg) translateY(40px) scale(.8); opacity: 0; } }
.doc .wm { position: absolute; inset: 0; display: grid; place-items: center; font: 900 34px Nunito; color: rgba(181, 23, 43, .1); transform: rotate(-18deg); pointer-events: none; letter-spacing: .1em; white-space: nowrap; }
.doc header { display: flex; flex-direction: column; gap: 1px; margin-bottom: 10px; }
.doc header b { font-size: 16px; letter-spacing: .03em; }
.doc header small { font-size: 11px; opacity: .7; }
.doc .row { display: flex; gap: 12px; align-items: flex-start; }
.doc .ph { width: 96px; height: 120px; object-fit: cover; border-radius: 6px; border: 1px solid #bbb; flex: none; }
.doc .cols { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld { display: flex; flex-direction: column; padding: 3px 6px; border-radius: 6px; cursor: pointer; position: relative; }
.fld:hover { background: #fff3c8; }
.fld span { font-size: 11px; opacity: .65; text-transform: uppercase; letter-spacing: .04em; }
.fld b { font-size: 15px; }
.fld.pinned { background: #ffe9a8; }
.fld.tp b { font-weight: 900; letter-spacing: .01em; text-shadow: .4px .3px 0 rgba(20, 40, 120, .35); }
.fld.tp.shown b { background: linear-gradient(transparent 45%, rgba(255, 255, 255, .95) 45%, rgba(240, 240, 235, .95) 85%, transparent 85%); color: #0d2a80; }
.fld.tp.shown::after { content: '⚠ overwritten: whitener under the ink'; font-size: 11px; color: var(--warn); font-weight: 800; }
.fld.ok.shown::after { content: '✓ looks genuine'; font-size: 11px; color: var(--green); font-weight: 800; }
.doc footer { display: flex; justify-content: space-between; font-size: 12px; margin-top: 10px; opacity: .8; align-items: center; }
.doc .num { font: 800 15px ui-monospace, Menlo, monospace; color: var(--stamp); }
.doc.epic { background: linear-gradient(160deg, #f8f8ff, #e9eef8); border: 2px solid #9bb0d0; }
.doc.aad { background: linear-gradient(180deg, #fff 0, #fff 70%, #fff6ea 100%); border: 1px solid #ddd; }
.doc.aad header { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc .bar { height: 6px; flex: 1; border-radius: 3px; min-width: 40px; }
.doc .bar.o { background: #f39a3c; } .doc .bar.g { background: #2f8f46; }
.doc .qrbox { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.doc .qr { width: 92px; height: 92px; }
.doc .scan { border: 0; border-radius: 8px; background: var(--stamp); color: #fff; font-weight: 800; padding: 6px 8px; font-size: 12px; }
.doc .aadnum { justify-content: center; font: 800 20px ui-monospace, Menlo, monospace; letter-spacing: .12em; border-top: 2px solid #c0122a; padding-top: 6px; }
.doc.cert { background: #fffdf4; border: 6px double #b8902a; }
.doc.cert header { align-items: center; text-align: center; }
.doc.cert .ph { position: absolute; right: 16px; top: 64px; width: 70px; height: 88px; }
.doc .seal { width: 54px; height: 54px; border-radius: 50%; border: 2px dashed #8a2a8a; color: #8a2a8a; display: grid; place-items: center; font-size: 10px; font-weight: 900; transform: rotate(-12deg); }
.doc .sign { font-family: Georgia, serif; font-style: italic; }
.doc.book { background: #fdf2c8; border: 2px solid #c9a466; }
.doc.book.ration { background: #ffe0e6; border-color: #d48a9a; }
.doc.gen { background: #f6f8f2; border: 2px solid #a8b49a; }
.doc.gen.pension { background: #e9f4e6; }
.doc.ticket { background: #e8f2f8; border: 2px dashed #7aa0c0; width: min(420px, 92vw); }
.doc.letter { background: #fffaf0; font-family: Georgia, serif; }
.doc .dnote { margin: 8px 0 0; font-size: 12px; font-style: italic; opacity: .8; }
.qrres { background: #0f0f12; color: #c8f0d8; border-radius: 12px; padding: 10px 14px; font: 13px/1.5 ui-monospace, Menlo, monospace; margin: 8px auto 0; width: min(560px, 92vw); text-align: left; }
.qrres .warn { color: #ffd27a; }
.oldroll { width: min(760px, 96vw); background: #efe3c2; border-radius: 6px; padding: 14px; box-shadow: 0 10px 40px #000a; font-family: 'Courier New', ui-monospace, monospace; color: #3a2a1a; }
.oldroll header { display: flex; flex-direction: column; margin-bottom: 8px; }
.oldroll table { width: 100%; border-collapse: collapse; font-size: 13px; }
.oldroll th, .oldroll td { border-bottom: 1px dotted #a08a60; padding: 5px 4px; text-align: left; }
.oldroll tr[data-fact] { cursor: pointer; }
.oldroll tr:hover { background: #fff3c8; }
.oldroll tr.pinned { background: #ffe9a8; }

/* result card */
#stampview { align-items: center; justify-content: center; overflow-y: auto; }
.stamp-card { position: relative; width: min(640px, 96vw); max-height: 100%; overflow-y: auto; background: var(--paper); border-radius: 16px; padding: 18px; box-shadow: 0 10px 40px #000a; animation: flipin .4s; }
.stamp-card h3 { margin: 0 0 4px; font: 700 22px Playfair Display, Georgia, serif; }
.stamp { position: absolute; right: 18px; top: 14px; border: 4px solid var(--stamp); color: var(--stamp); padding: 4px 10px; border-radius: 8px; font: 900 20px Nunito; transform: rotate(-10deg); animation: stampin .4s cubic-bezier(.2, 2, .4, 1); opacity: .85; }
.stamp.bad { border-color: var(--red); color: var(--red); }
@keyframes stampin { from { transform: rotate(-10deg) scale(2.4); opacity: 0; } }
.res-row { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.res-row .ok { color: var(--green); font-weight: 900; }
.res-row .no { color: var(--red); font-weight: 900; }
.res-row .pts { margin-left: auto; font-weight: 900; white-space: nowrap; }
.res-row small { display: block; opacity: .8; }
.res-sum { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin: 10px 0; }
.res-sum div { background: #fff; border-radius: 10px; padding: 6px 8px; font-size: 13px; }
.res-sum b { display: block; font-size: 17px; }
.lesson { background: #e8f0ff; border-left: 4px solid var(--stamp); border-radius: 8px; padding: 8px 10px; font-size: 14px; line-height: 1.4; margin: 10px 0; }

/* coach */
.coach { position: fixed; z-index: 15; left: 50%; top: calc(64px + var(--st)); transform: translateX(-50%); width: min(460px, 90vw); background: #ffd45c; color: var(--ink); border-radius: 14px; padding: 12px 14px; box-shadow: 0 6px 22px #0008; font-weight: 700; display: flex; gap: 10px; align-items: center; animation: tin .3s; }
.coach p { margin: 0; flex: 1; font-size: 15px; line-height: 1.35; }
.coach button { border: 0; border-radius: 10px; padding: 8px 12px; background: var(--ink); color: #fff; font-weight: 800; flex: none; }
body.visiting .coach { left: calc(50% - 205px); }

#rotate { display: none; position: fixed; inset: 0; z-index: 60; background: #2b2118; color: #f6efdc; place-content: center; text-align: center; gap: 10px; }
#rotate b { font-size: 60px; }
@media (orientation: portrait) and (pointer: coarse) { body.playing #rotate { display: grid; } }

/* ---------------------------------------------------------------- menus */
#ui { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
.screen { position: absolute; inset: 0; display: none; pointer-events: auto; overflow-y: auto; padding: calc(16px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl)); }
.screen.on { display: flex; }
#title { align-items: center; gap: 24px; background: linear-gradient(90deg, rgba(30, 20, 12, .82) 0, rgba(30, 20, 12, .55) 48%, rgba(30, 20, 12, 0) 75%); }
.t-main { max-width: 560px; color: #fff; }
.kicker { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 13px; color: #ffd45c; margin: 0 0 6px; }
.logo { margin: 0 0 10px; line-height: .9; }
.logo .sir { display: block; font: 900 92px Nunito, sans-serif; color: #fff; letter-spacing: .04em; text-shadow: 4px 4px 0 var(--red); }
.logo .d2d { display: inline-block; font: 700 40px Playfair Display, Georgia, serif; background: var(--paper); color: var(--ink); padding: 2px 14px; border-radius: 6px; transform: rotate(-2deg); box-shadow: 4px 4px 0 var(--red); }
.lead { font-size: 17px; line-height: 1.5; margin: 14px 0; text-shadow: 0 1px 3px #000a; }
.challenge:empty { display: none; }
.challenge { background: #ffd45c; color: var(--ink); border-radius: 10px; padding: 8px 12px; margin: 8px 0; font-weight: 700; }
.menu { display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.menu .row { display: flex; gap: 8px; }
.menu .row button { flex: 1; }
.menu button, .sheet button.primary, .buttons button { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 800; font-size: 16px; background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--manila-d); }
.menu button.primary, button.primary { background: var(--red) !important; color: #fff !important; box-shadow: 0 3px 0 #7a0f1d !important; font-size: 18px; }
button.big { width: 100%; padding: 14px; }
.disclaimer { font-size: 12px; opacity: .8; margin-top: 14px; line-height: 1.4; }
.disclaimer a { color: #ffd45c; }
.t-side { margin-left: auto; width: 300px; display: flex; flex-direction: column; gap: 10px; align-self: center; }
.sheet { margin: auto; background: var(--paper); border-radius: 18px; padding: 18px; box-shadow: 0 10px 40px #000a; width: min(560px, 100%); }
.sheet.wide { width: min(900px, 100%); }
.sheet.narrow { width: min(420px, 100%); }
.sheet header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet h2 { margin: 0; font: 700 26px Playfair Display, Georgia, serif; flex: 1; }
.ghost { border: 0; background: none; font-weight: 800; color: var(--red); padding: 8px; }
#pause, #settings, #help, #handbook, #cases, #end, #you { background: rgba(20, 14, 10, .6); }
.help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.help h4 { margin: 0 0 6px; color: var(--red); }
.help p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
body.touch .key-only, body:not(.touch) .touch-only { display: none; }
.handbook { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; font-size: 14px; line-height: 1.5; }
.handbook h4 { margin: 0 0 6px; color: var(--red); }
.handbook ol, .handbook ul { padding-left: 18px; margin: 0; }
.handbook li { margin-bottom: 5px; }
.handbook .src { grid-column: 1 / -1; font-size: 12px; opacity: .75; }
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); gap: 10px; font-weight: 700; }
.set-row select, .set-row input[type=range] { font: inherit; }
.seg2 { display: flex; gap: 4px; }
.seg2 button { border: 1.5px solid #d8c8a8; background: #fff; border-radius: 999px; padding: 4px 10px; font-weight: 800; font-size: 13px; }
.seg2 button.on { background: var(--stamp); color: #fff; border-color: var(--stamp); }
.you-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.you-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.you-pick button { border: 2px solid #e0d0b0; background: #fff; border-radius: 14px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 800; font-size: 13px; }
.you-pick button img { width: 72px; height: 90px; object-fit: cover; border-radius: 8px; }
.you-pick button small { font-weight: 600; opacity: .7; font-size: 11px; }
.you-pick button.on { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.you-form label { display: flex; flex-direction: column; font-weight: 800; gap: 4px; }
.you-form input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 2px solid #e0d0b0; background: #fff; -webkit-user-select: text; user-select: text; }
.brief { font-size: 14px; line-height: 1.5; background: #fff; border-radius: 12px; padding: 10px 12px; margin: 12px 0; border-left: 4px solid var(--red); }
.brief p { margin: 0 0 6px; }
.end-big { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.end-big b { font: 900 54px Nunito; color: var(--red); }
.end-big span { font: 700 22px Playfair Display, Georgia, serif; }
.end-list { margin: 10px 0; }
.end-list div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 14px; gap: 10px; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.e-board { font-size: 14px; }
.casebook { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.casebook div { background: #fff; border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.casebook div.seen { border-left: 4px solid var(--green); }
.casebook div:not(.seen) { opacity: .55; }
/* The title's side column (with Like and Share) is hidden on phones; this menu Share stands in for it. */
.menu .row button.t-share { display: none; }
.aq-acct, .aq-like, .aq-board { background: rgba(255, 255, 255, .92); border-radius: 14px; padding: 10px; }

/* ---------------------------------------------------------------- phones */
@media (max-width: 900px) {
  .panel { width: 46%; }
  .v-top { right: calc(46% + 20px + var(--sr)); }
  .dlg { right: calc(46% + 22px + var(--sr)); }
  .toasts { margin-left: -23%; }
  body.visiting .coach { left: 27%; }
  .help { grid-template-columns: 1fr 1fr; }
  .t-side { display: none; }
  .menu .row button.t-share { display: block; }
}
@media (max-height: 500px) {
  .logo .sir { font-size: 58px; } .logo .d2d { font-size: 26px; }
  .lead { font-size: 14px; margin: 8px 0; }
  .menu button { padding: 9px 12px; font-size: 14px; }
  .menu button.primary { font-size: 15px; }
  .kicker { font-size: 11px; }
  #minimap { width: 130px; height: 91px; }
  .h-clock, .h-pill, .v-clock { font-size: 13px; padding: 4px 9px; }
  .h-btn { width: 34px; height: 34px; font-size: 14px; }
  .act { padding: 9px 14px; font-size: 14px; }
  .dlg { min-height: 0; padding: 8px 10px; gap: 8px; }
  .dlg-ph { width: 44px; height: 55px; }
  .dlg-txt { font-size: 14px; max-height: 5.8em; line-height: 1.35; }
  .tabs button { padding: 5px 2px 3px; font-size: 15px; }
  .tabs button span { font-size: 10px; }
  .q { padding: 8px 10px; font-size: 13.5px; }
  .tab-body { padding: 8px 9px 12px; }
  .v-house b { font-size: 14px; } .v-house span { display: none; }
  .v-mood { font-size: 12px; padding: 4px 8px; }
  .doc { font-size: 12px; padding: 10px 12px; }
  .doc .ph { width: 70px; height: 88px; }
  .fld b { font-size: 13px; }
  .doc header b { font-size: 14px; }
  .sheet { padding: 12px; }
  .sheet h2 { font-size: 20px; }
  .help, .handbook { grid-template-columns: 1fr 1fr; gap: 10px; }
  .help p, .handbook { font-size: 12.5px; }
  .you-pick button img { width: 52px; height: 65px; }
  .coach { top: calc(48px + var(--st)); padding: 8px 10px; } .coach p { font-size: 13px; }
  .doorline { font-size: 14px; padding: 10px 12px; bottom: calc(58px + var(--sb)); }
  .bubble { top: 14%; font-size: 14px; }
  .stamp-card { padding: 12px; }
  .res-row { font-size: 12.5px; padding: 5px 0; }
  .lesson { font-size: 12.5px; }
  .end-big b { font-size: 40px; }
}
@media (max-height: 360px) {
  .h-left .h-pill:last-child { display: none; }
  #minimap { width: 110px; height: 77px; }
  .dlg-txt { max-height: 4.1em; }
  .v-mood { display: none; }
}
@media (max-width: 600px) and (orientation: portrait) {
  .help, .handbook, .you-grid { grid-template-columns: 1fr; }
  #title { background: rgba(30, 20, 12, .7); }
}
@media (max-height: 500px) {
  #title { align-items: flex-start; }
  .t-main { margin: auto 0; }
  body.visiting .coach { left: calc(8px + var(--sl)); transform: none; width: calc(54% - 24px); top: calc(46px + var(--st)); }
  .tab-body .hint { font-size: 11.5px; margin: 2px 0 5px; }
  .btn2 { padding: 6px 10px; font-size: 13px; }
  .submit { padding: 6px 0 2px; }
  .roll-entry { padding: 6px; margin-bottom: 7px; }
  .re-ph { width: 36px; height: 45px; }
  .chip { padding: 3px 7px; font-size: 12px; }
  .sec { margin: 9px 0 4px; }
  .overlay { padding-top: calc(6px + var(--st)); padding-bottom: calc(4px + var(--sb)); }
  .dv-bar { flex-wrap: nowrap; gap: 6px; }
  .dv-bar b { font-size: 15px; flex: none; }
  .tool { padding: 6px 11px; font-size: 13px; flex: none; }
  .tool.close { width: 34px; height: 34px; }
  .dv-tip { flex: 1; min-width: 0; font-size: 11.5px; line-height: 1.25; }
  .dv-stage { padding: 6px 0; }
  .dv-out { min-height: 0; font-size: 13px; }
  .doc { width: min(660px, 96vw); padding: 9px 12px; }
  .doc header { margin-bottom: 6px; }
  .doc .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
  .doc .cols > .num, .doc .cols > p.fld { grid-column: 1 / -1; }
  .doc.cert .cols { padding-right: 78px; }
  .doc.cert .ph { top: 52px; width: 60px; height: 75px; }
  .doc .qr { width: 70px; height: 70px; }
  .doc footer { margin-top: 6px; }
  .doc .aadnum { font-size: 16px; padding-top: 4px; }
  .fld { padding: 2px 6px; }
  .fld span { font-size: 10px; }
  .oldroll { padding: 10px; }
  .oldroll table { font-size: 12px; }
  .oldroll th, .oldroll td { padding: 3px 4px; }
  #pause .menu { display: grid; grid-template-columns: 1fr 1fr; max-width: none; }
  #pause .menu .primary { grid-column: 1 / -1; }
  #pause .sheet header { margin-bottom: 8px; }
  .you-pick { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .you-pick button { padding: 4px 2px; font-size: 12px; }
  .you-pick button small { font-size: 10px; line-height: 1.2; text-align: center; }
  .you-grid { gap: 8px 12px; grid-template-areas: 'pick name' 'pick brief' 'go brief' '. brief'; grid-template-rows: auto auto auto 1fr; }
  .you-form { display: contents; }
  .you-pick { grid-area: pick; } .you-form label { grid-area: name; } .you-form .brief { grid-area: brief; margin: 0; } .you-form .big { grid-area: go; align-self: start; }
  .brief { font-size: 12.5px; line-height: 1.4; margin: 8px 0; padding: 8px 10px; }
  .end-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .end-list div { padding: 3px 0; font-size: 13px; }
  #end .buttons { position: sticky; bottom: -12px; background: var(--paper); margin: 8px -12px -12px; padding: 8px 12px 12px; border-radius: 0 0 18px 18px; box-shadow: 0 -6px 10px -6px #0003; }
  #end .buttons button { padding: 9px 14px; font-size: 14px; }
}
@media (max-height: 320px) {
  .lead { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
}
@media (max-height: 360px) {
  .logo .sir { font-size: 44px; } .logo .d2d { font-size: 20px; }
  .lead { font-size: 12.5px; line-height: 1.4; }
  .disclaimer { font-size: 10.5px; margin-top: 8px; }
  .menu { gap: 6px; } .menu .row { gap: 6px; }
}
