:root {
  --font: "Helvetica Neue", Arial, sans-serif;
  --amber: #f2b45a;
  --amber2: #ffd890;
  --ink: #0b0f14;
  --red: #d8423a;
  --green: #5fbf6a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #030507; overflow: hidden; }
body { font-family: var(--font); color: #ece6da; user-select: none; -webkit-user-select: none; }
.hidden { display: none !important; }

#app {
  position: absolute; left: 50%; top: 50%;
  width: 396px; height: 704px;
  transform-origin: 50% 50%;
  overflow: hidden; background: #05080b;
}
#scene, #scene > * { position: absolute; inset: 0; }
#bg { width: 100%; height: 100%; object-fit: cover; filter: brightness(.85) saturate(.9); transition: transform 1.2s ease; }
#visitorWrap { top: 70px; height: 390px; bottom: auto; display: flex; justify-content: center; align-items: flex-end; pointer-events: none; transition: transform .45s cubic-bezier(.3,.8,.3,1); transform-origin: 50% 12%; }
/* every portrait is drawn at the same height (the figures fill their pictures top to bottom), so a disguise
   (square picture) and its true form (2:3 picture) show the figure at the same size and place */
#visitor { height: 100%; width: auto; max-width: none; flex: none; object-fit: contain; object-position: 50% 100%; opacity: 0; filter: brightness(.95) contrast(1.05); transform-origin: 50% 100%; }
#visitor.in { animation: vin .7s cubic-bezier(.2,.8,.3,1) forwards; }
#visitor.here { opacity: 1; animation: breathe 4.2s ease-in-out infinite; }
#visitor.outL { animation: voutL .9s ease-in forwards; }
#visitor.outR { animation: voutR .9s ease-in forwards; }
@keyframes vin { from { opacity: 0; transform: translateX(60px) scale(.96); filter: blur(4px) brightness(.4); } to { opacity: 1; transform: none; filter: brightness(.95) contrast(1.05); } }
@keyframes breathe { 0%,100% { transform: scale(1,1); } 50% { transform: scale(1.004,1.012) translateY(-1px); } }
@keyframes voutL { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(-120px) scale(.9); filter: brightness(.3) blur(3px); } }
@keyframes voutR { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(120px) scale(.92); filter: brightness(.3) blur(3px); } }
@keyframes twitch { 0% { transform: translateX(4px) skewX(3deg); filter: hue-rotate(40deg) contrast(1.5) brightness(1.3); } 50% { transform: translateX(-5px) scaleY(1.02); filter: invert(.15) contrast(1.4); } 100% { transform: none; } }
#scene.observing #visitorWrap { transform: scale(1.55) translateY(12px); }
#scene.observing #bg { transform: scale(1.08); }
#spot { pointer-events: none; opacity: 0; transition: opacity .4s; background: radial-gradient(circle at 50% 30%, rgba(255,240,200,.10) 0, rgba(255,240,200,.04) 90px, rgba(0,0,0,.78) 170px, rgba(0,0,0,.9) 100%); }
#scene.observing #spot { opacity: 1; }
canvas { position: absolute; left: 0; top: 0; width: 396px; height: 704px; pointer-events: none; }
#fxTop { z-index: 40; }

/* panels & buttons: 9-slice art. The pictures have transparent margins around the plate, so the
   slices are measured in picture pixels and the margins are pushed outside the box with an outset:
   the visible frame sits exactly on the element's edges. */
.panel {
  position: absolute;
  border: 14px solid transparent;
  border-image-source: url(assets/ui-panel.webp);
  border-image-slice: 156 72 178 72 fill;
  border-image-width: 39px 18px 44.5px 18px;
  border-image-outset: 22.5px 1.5px 28px 1.5px;
  border-image-repeat: stretch;
  background: none;
  box-shadow: 0 8px 22px rgba(0,0,0,.55);
  border-radius: 8px;
}
.btn {
  position: relative; font-family: var(--font); font-weight: 900; color: #f3ead8; letter-spacing: .02em;
  border: 10px solid transparent;
  border-image-source: url(assets/ui-button.webp);
  border-image-slice: 180 56 179 55 fill;
  border-image-width: 72px 22.4px 71.6px 22px;
  border-image-outset: 51.6px 2.4px 52.4px 2px;
  border-image-repeat: stretch;
  background: transparent; padding: 0 6px; min-height: 46px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  text-shadow: 0 2px 0 #000, 0 0 6px rgba(0,0,0,.8);
  transition: transform .08s ease, filter .12s ease;
  outline: none; border-radius: 16px;
}
.btn img { width: 26px; height: 26px; object-fit: contain; filter: drop-shadow(0 2px 2px #000); pointer-events: none; flex: none; }
.btn span, .btn b, .btn i { pointer-events: none; }
.btn:active, .btn.pressed { transform: scale(.94); filter: brightness(1.3); }
@media (hover: hover) { .btn:hover { filter: brightness(1.15); } }
.btn.focus { filter: brightness(1.25); transform: scale(1.04); outline: 3px solid var(--amber2); outline-offset: 2px; }
.btn[disabled], .btn.off { filter: grayscale(1) brightness(.55); cursor: default; }
.btn.on { filter: brightness(1.45) drop-shadow(0 0 7px rgba(255,214,140,.85)); }
#actions .btn.wait { filter: brightness(.6) saturate(.6); }
.btn .hint { position: absolute; right: -4px; top: -8px; font-style: normal; font-size: 11px; font-weight: 800; background: #1b2128; color: var(--amber2); border: 1px solid var(--amber); border-radius: 5px; padding: 0 4px; line-height: 15px; display: none; text-shadow: none; }
body.kb .btn .hint.has, body.pad .btn .hint.has { display: block; }
.nowrap span, #actions .btn span, #titleBtns .btn span, .btn.mid span, .btn.wide span, .btn.skip span { white-space: nowrap; }

/* HUD */
#hud { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 10; }
.plate { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 5px 12px; font-weight: 900; font-size: 16px; background: linear-gradient(180deg, rgba(28,33,40,.9), rgba(10,12,16,.9)); border: 1px solid rgba(242,180,90,.55); border-radius: 8px; box-shadow: 0 3px 10px rgba(0,0,0,.6); text-shadow: 0 2px 0 #000; }
.plate.small { font-size: 16px; color: var(--amber2); }
.plate .sep { color: var(--amber); }
.coin { color: var(--amber); font-size: 13px; }

/* dialog */
#dialog { left: 8px; right: 8px; top: 426px; height: 140px; padding: 4px 8px; z-index: 12; cursor: pointer; }
#speaker { position: absolute; left: -6px; top: -44px; font-weight: 900; font-size: 14px; color: var(--amber2); text-shadow: 0 2px 0 #000; padding: 3px 12px; background: linear-gradient(180deg, rgba(30,34,40,.95), rgba(12,14,18,.95)); border: 1px solid rgba(242,180,90,.6); border-radius: 7px 7px 7px 2px; box-shadow: 0 3px 8px rgba(0,0,0,.6); white-space: nowrap; }
#dtext { font-size: 15px; line-height: 1.42; text-shadow: 0 1px 2px #000; white-space: pre-wrap; overflow-y: auto; height: 100%; scrollbar-width: none; }
#dtext::-webkit-scrollbar { display: none; }
#dtext .you { color: #9fc3dc; font-size: 14px; }
#dtext .note { color: #eadbb8; }
#dmore { position: absolute; right: 2px; bottom: -6px; font-size: 11px; color: var(--amber); animation: blink 1s infinite; display: none; }
@keyframes blink { 50% { opacity: .2; } }

/* actions */
#actions { position: absolute; left: 8px; right: 8px; top: 574px; z-index: 12; display: flex; flex-direction: column; gap: 10px; }
#actions .row { display: flex; gap: 8px; }
#actions .act { flex: 1; height: 50px; font-size: 15px; min-width: 0; }
#actions .big { flex: 1; height: 58px; font-size: 18px; min-width: 0; }
#pips { position: absolute; left: 50%; bottom: -13px; transform: translateX(-50%); font-size: 8px; letter-spacing: 2px; line-height: 12px; padding: 0 3px 0 5px; color: var(--amber); background: rgba(12,14,18,.94); border: 1px solid rgba(242,180,90,.6); border-radius: 6px; text-shadow: none; white-space: nowrap; }
.approve span { color: #c9f5c4; }
.deny span { color: #ffc8c0; }
.btn.armed { animation: armed .5s ease-in-out infinite alternate; }
@keyframes armed { from { filter: brightness(1.1); } to { filter: brightness(1.7) drop-shadow(0 0 8px #fff3); } }

/* question panel: grows up from the bottom to fit its questions */
#qpanel { left: 8px; right: 8px; bottom: 8px; top: auto; z-index: 14; padding: 4px 6px 6px; display: flex; flex-direction: column; gap: 8px; animation: pop .22s cubic-bezier(.3,1.5,.5,1); }
.ptitle { font-weight: 900; font-size: 18px; color: var(--amber2); text-align: center; text-shadow: 0 2px 0 #000, 0 0 10px rgba(0,0,0,.8); padding: 2px 0 4px; }
.ptitle small { font-size: 13px; color: #cbbfa8; }
.ptitle.safe { color: #a6f0a0; font-size: 24px; animation: slam .5s cubic-bezier(.3,1.6,.5,1) both; }
.ptitle.bad { color: #ff8a7e; }
#qlist { display: flex; flex-direction: column; gap: 8px; }
#qlist .btn { min-height: 48px; justify-content: flex-start; text-align: left; font-size: 14px; font-weight: 800; line-height: 1.25; padding: 4px 30px 4px 10px; }
#qlist .btn .num { color: var(--amber); font-weight: 900; min-width: 16px; flex: none; }
#qlist .btn.asked { color: #9db08f; filter: brightness(.75); }
#qlist .btn.asked::after { content: "✓"; position: absolute; right: 8px; color: var(--green); font-size: 18px; }
.btn.wide { width: 100%; min-height: 48px; font-size: 16px; flex: none; }
@keyframes pop { from { transform: scale(.85) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* stamp */
#stamp { position: absolute; left: 50%; top: 240px; width: 170px; height: 170px; margin-left: -85px; object-fit: contain; z-index: 30; opacity: 0; pointer-events: none; }
#stamp.go { animation: stampIn .6s cubic-bezier(.2,1.6,.4,1) forwards; }
#stamp.leave { animation: stampOut .4s ease-in forwards; }
@keyframes stampIn { 0% { opacity: 0; transform: scale(2.6) rotate(-18deg); } 40% { opacity: 1; transform: scale(.92) rotate(-8deg); } 60% { transform: scale(1.04) rotate(-8deg); } 100% { opacity: .95; transform: scale(1) rotate(-8deg); } }
@keyframes stampOut { from { opacity: .95; transform: scale(1) rotate(-8deg); } to { opacity: 0; transform: scale(1.12) rotate(-8deg); } }

/* screens */
.screen { position: absolute; inset: 0; z-index: 50; }
.screen.dim { background: rgba(3,5,8,.72); animation: fadeIn .25s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { left: 12px; right: 12px; top: 70px; padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 10px; animation: pop .26s cubic-bezier(.3,1.5,.5,1); }
.modal.tall { top: 56px; bottom: 16px; }
.body { font-size: 15px; line-height: 1.55; white-space: pre-wrap; text-shadow: 0 1px 2px #000; }
ol.rules { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
ol.rules li::marker { color: var(--amber); font-weight: 900; }

/* title */
#title { background: #000; cursor: pointer; }
#titleArt { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: slowzoom 30s ease-in-out infinite alternate; }
@keyframes slowzoom { from { transform: scale(1); } to { transform: scale(1.06); } }
.titleShade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.35) 0, rgba(0,0,0,0) 35%, rgba(0,0,0,0) 60%, rgba(0,0,0,.75) 100%); }
#logo { position: absolute; left: 8%; width: 84%; top: 54px; max-height: 210px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.8)); animation: logoIn .7s cubic-bezier(.3,1.6,.5,1) both, float 5s ease-in-out .7s infinite; }
@keyframes logoIn { from { opacity: 0; transform: translateY(-60px) scale(1.2); } to { opacity: 1; transform: none; } }
@keyframes float { 50% { transform: translateY(5px); } }
#startPrompt { position: absolute; left: 0; right: 0; top: 548px; text-align: center; font-weight: 900; font-size: 18px; letter-spacing: .06em; color: #f6ecd6; text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,0,0,.9); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
#titleBtns { position: absolute; left: 24px; right: 24px; top: 596px; display: flex; gap: 12px; }
#titleBtns .btn { flex: 1; height: 52px; font-size: 15px; min-width: 0; }
/* the files opened from the title cover it: its prompt and buttons step out of the way */
body:has(#codex:not(.hidden)) #startPrompt, body:has(#codex:not(.hidden)) #titleBtns { visibility: hidden; }

/* intro */
#introScr { background: #000 url(assets/cover-bg.webp) center/cover; transition: opacity .3s; }
#introScr.pending { opacity: 0; pointer-events: none; }
#introVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.btn.skip { position: absolute; right: 12px; bottom: 24px; min-width: 110px; height: 48px; font-size: 15px; z-index: 2; padding: 0 12px; }

/* night card */
#nightCard { background: radial-gradient(circle at 50% 40%, rgba(20,30,40,.75), rgba(0,0,0,.95)); animation: fadeIn .4s; cursor: pointer; }
.nc-inner { position: absolute; left: 0; right: 0; top: 170px; text-align: center; }
#ncNight { font-size: 54px; font-weight: 900; color: #f6e8cc; letter-spacing: .08em; text-shadow: 0 4px 0 #000, 0 0 30px rgba(242,180,90,.35); animation: slam .5s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes slam { from { opacity: 0; transform: scale(2); } to { opacity: 1; transform: none; } }
#ncSub { font-size: 16px; color: #b9c4cc; margin-top: 8px; text-shadow: 0 2px 0 #000; }
#ncRadio { position: relative; margin: 34px 16px 0; padding: 6px 10px; text-align: left; animation: pop .3s .4s both; }
#ncRadio .who { font-size: 13px; font-weight: 900; color: var(--amber); margin-bottom: 4px; }
#ncLine { font-size: 16px; line-height: 1.5; }
.tapNote { position: absolute; left: 0; right: 0; top: 600px; text-align: center; font-size: 15px; font-weight: 800; color: #d8cdb6; text-shadow: 0 2px 0 #000; animation: pulse 1.6s infinite; }

/* results */
#resRows { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; --th: 54px; }
.rrow { display: flex; align-items: center; gap: 10px; padding: 4px 6px; background: rgba(0,0,0,.35); border: 1px solid rgba(242,180,90,.25); border-radius: 8px; opacity: .35; transition: opacity .3s; position: relative; }
.rrow.shown { opacity: 1; animation: pop .25s; }
.rthumb { width: var(--th); height: var(--th); border-radius: 6px; overflow: hidden; background: #111; flex: none; border: 1px solid #333; }
.rthumb img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
/* a disguise picture is square with more room around the figure: zoom it to the same head shot */
.rthumb img.sq { transform: scale(1.5); transform-origin: 50% 4%; }
.rrow.fake.shown .rthumb img { filter: sepia(1) hue-rotate(-50deg) saturate(4) contrast(1.3); animation: twitch .3s steps(3) 2; }
.rinfo { flex: 1; min-width: 0; }
.rname { font-weight: 900; font-size: 15px; text-shadow: 0 2px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rsub { font-size: 13px; color: #c9bfae; }
.rsub .tf { font-weight: 900; }
.rsub .tf.h { color: #9fd3a0; }
.rsub .tf.f { color: #ff8a7e; }
.rmark { font-size: 26px; font-weight: 900; width: 30px; text-align: center; text-shadow: 0 2px 0 #000; }
.rmark.ok { color: var(--green); }
.rmark.ng { color: var(--red); }
.rnew { position: absolute; left: calc(var(--th) - 6px); top: -6px; background: var(--amber); color: #1a1006; font-size: 11px; font-weight: 900; padding: 0 5px; border-radius: 4px; animation: slam .4s; }
#resScore { text-align: center; font-weight: 900; font-size: 16px; color: var(--amber2); text-shadow: 0 2px 0 #000; line-height: 1.5; }
#resScore .big { font-size: 24px; color: #fff3d6; }
#resScore .quote { font-size: 13px; font-weight: 700; color: #cfe0c8; margin-top: 4px; line-height: 1.4; animation: fadeIn .6s; }

/* outcome */
#outcome { background: #000; cursor: pointer; }
#ocBg { position: absolute; inset: 0; background: radial-gradient(circle at 50% 35%, #5a0d0d 0, #1a0303 55%, #000 100%); animation: fadeIn .6s; }
#outcome.complaint #ocBg { background: radial-gradient(circle at 50% 35%, #2b3440 0, #0d1116 60%, #000 100%); }
#ocImg { position: absolute; left: 50%; top: 40px; height: 420px; transform: translateX(-50%); object-fit: contain; filter: contrast(1.2) brightness(.9); }
#outcome.murder #ocImg { filter: sepia(.6) hue-rotate(-30deg) saturate(2.5) contrast(1.3) brightness(.8); animation: shake .12s 6; }
#outcome.complaint #ocImg { filter: grayscale(.7) brightness(.7); }
#outcome.murder #ocCanvas { filter: sepia(.5) hue-rotate(-30deg) saturate(2.2) contrast(1.25) brightness(.85); }
#ocCanvas { top: 0; }
@keyframes shake { 25% { transform: translate(calc(-50% + 6px), -3px); } 75% { transform: translate(calc(-50% - 6px), 3px); } }
#ocText { left: 12px; right: 12px; top: 420px; padding: 6px 10px; text-align: center; animation: pop .3s .5s both; }
#ocTitle { font-size: 30px; font-weight: 900; color: #ff5b4d; text-shadow: 0 3px 0 #000, 0 0 18px rgba(255,40,30,.5); letter-spacing: .08em; }
#outcome.complaint #ocTitle { color: #9cc4ff; text-shadow: 0 3px 0 #000; }
#ocLine { font-size: 16px; line-height: 1.5; margin-top: 6px; }
#ocWho { font-size: 14px; color: #cbb; margin-top: 6px; line-height: 1.45; }
#outcome .tapNote { top: 646px; }

/* codex */
#cxGrid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); gap: 8px; flex: 1; min-height: 0; }
.cxcard { position: relative; border-radius: 8px; overflow: hidden; background: #0c1015; border: 1px solid rgba(242,180,90,.35); cursor: pointer; padding: 0; min-height: 44px; font-family: var(--font); color: #ece6da; transition: transform .08s; }
.cxcard img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; display: block; pointer-events: none; }
.cxcard.locked img { filter: brightness(0) contrast(1); opacity: .9; }
.cxcard .cxl { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; font-size: 12px; font-weight: 900; text-align: center; background: linear-gradient(0deg, rgba(0,0,0,.9), rgba(0,0,0,0)); text-shadow: 0 1px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.cxcard.locked .cxl { color: #777; }
.cxcard.focus { box-shadow: 0 0 0 3px var(--amber2); }
.cxcard.pressed { transform: scale(.95); }
.cxcard.nope { animation: nope .3s; }
@keyframes nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.cxnum { position: absolute; left: 4px; top: 2px; font-size: 10px; color: var(--amber); font-weight: 900; text-shadow: 0 1px 0 #000; pointer-events: none; }
.cxnew { position: absolute; right: 3px; top: 3px; background: var(--amber); color: #1a1006; font-size: 10px; font-weight: 900; padding: 0 4px; border-radius: 4px; pointer-events: none; }
.cxNav { display: flex; align-items: center; gap: 8px; }
.cxNav span#cxPage { flex: 1; text-align: center; font-weight: 900; color: var(--amber2); }
.btn.sq { width: 52px; height: 48px; font-size: 18px; flex: none; }
.btn.mid { min-width: 96px; height: 48px; font-size: 15px; padding: 0 10px; }
#cxDetail { position: absolute; inset: 0; background: rgba(0,0,0,.6); z-index: 2; }
.cxdPic { position: relative; height: 290px; flex: none; display: flex; justify-content: center; overflow: hidden; border-radius: 8px; background: radial-gradient(circle at 50% 40%, rgba(90,20,20,.45), rgba(0,0,0,.2) 70%); }
.cxdPic img { height: 100%; object-fit: contain; }
.cxdPic canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.cxdName { font-size: 22px; font-weight: 900; color: #ffcf9a; text-align: center; text-shadow: 0 2px 0 #000; }
.cxdMeta { font-size: 13px; text-align: center; color: #c9bfae; }
.cxdMeta .stars { color: #ff6a55; letter-spacing: 2px; }
.cxdDesc { flex: 1; font-size: 14px; overflow-y: auto; min-height: 0; scrollbar-width: none; }

#subtitle { position: absolute; left: 16px; right: 16px; top: 380px; z-index: 60; text-align: center; font-size: 16px; font-weight: 800; line-height: 1.45; color: #fff; text-shadow: 0 2px 0 #000, 0 0 8px #000; pointer-events: none; }
#subtitle.mid { top: 330px; }
#subtitle.top { top: 16px; }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 90; transition: opacity .35s; }
#fade.on { opacity: 1; }
#app.shake { animation: appshake .35s; }
@keyframes appshake { 20% { margin-left: 6px; } 40% { margin-left: -6px; margin-top: 3px; } 60% { margin-left: 4px; } 80% { margin-left: -3px; margin-top: -2px; } }
