:root { --cream:#f6ecd6; --navy:#2b3a67; --rose:#e98aa0; --amber:#f4c27a; --sky:#a9d4f0; --paper2:#efe0bd; --bw: clamp(16px, 3.8vh, 28px);
  --f-round: "Trebuchet MS", sans-serif; --f-serif: serif; --u: clamp(14px, 2.5vh, 21px); }
#ui { font-family: var(--f-round); font-size: var(--u); color: var(--navy); }
#ui * { box-sizing: border-box; }
#ui .hide { display: none !important; }
#ui img { -webkit-user-drag: none; }

/* panels & buttons */
.panel { border: var(--bw) solid transparent; border-image: url(../assets/ui-panel.webp) 64 fill / var(--bw) stretch; padding: 2px 4px; color: var(--navy); filter: drop-shadow(0 6px 10px rgba(30,30,60,.35)); }
.btn { position: relative; display: flex; align-items: center; justify-content: center; gap: .4em; min-height: 46px; min-width: 46px; padding: 0 6px;
  border: 12px solid transparent; border-image: url(../assets/ui-button.webp) 40 fill / 12px stretch;
  cursor: pointer; font-weight: 800; color: var(--navy); text-shadow: 0 1px 0 rgba(255,255,255,.7); transition: transform .12s, filter .12s; user-select: none; }
.btn:hover, .btn.kf { filter: brightness(1.1) saturate(1.1); transform: scale(1.04); }
.btn.kf { outline: 3px solid var(--rose); outline-offset: -2px; border-radius: 16px; }
.btn:active { transform: scale(.93, .88); filter: brightness(.95); }
.btn.dis { opacity: .45; filter: grayscale(.7); cursor: default; pointer-events: none; }
.btn.primary { filter: hue-rotate(-20deg) saturate(1.2); }
.btn.small { font-size: .85em; }
.btn .bl { white-space: nowrap; }
@keyframes pop { 0% { transform: scale(.9); opacity: 0 } 70% { transform: scale(1.03); opacity: 1 } 100% { transform: scale(1) } }
.pop { animation: pop .22s ease-out; }
.out { opacity: 0; transition: opacity .18s; }

/* title */
.title { position: absolute; inset: 0; overflow: hidden; background: #1d2440; cursor: pointer; transition: opacity .6s; }
.title.out { opacity: 0; pointer-events: none; }
.t-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: kb 26s ease-in-out infinite alternate; }
@keyframes kb { from { transform: scale(1) } to { transform: scale(1.12) translate(-1.5%, 1%) } }
.t-logo { position: absolute; left: 4%; top: 4%; width: 45%; max-height: 33%; animation: drop .9s cubic-bezier(.3,1.5,.5,1) both; pointer-events: none; }
.t-logo img { width: 100%; max-height: 33vh; object-fit: contain; object-position: left top; display: block; animation: float 4s ease-in-out infinite 1s; filter: drop-shadow(0 4px 8px rgba(40,50,90,.35)); }
@keyframes drop { 0% { transform: translateY(-120%) scale(.9); opacity: 0 } 100% { transform: none; opacity: 1 } }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
.t-prompt { position: absolute; left: 30%; right: 30%; bottom: 9%; text-align: center; white-space: nowrap; font-size: calc(var(--u) * 1.35); font-weight: 900; color: var(--cream);
  -webkit-text-stroke: 5px var(--navy); paint-order: stroke fill; text-shadow: 0 3px 0 var(--navy); animation: pulse 1.6s ease-in-out infinite; pointer-events: none; }
@keyframes pulse { 0%,100% { opacity: .65; transform: scale(1) } 50% { opacity: 1; transform: scale(1.05) } }
.pp { position: absolute; bottom: -10%; width: calc(var(--s) * 2.4vh); height: calc(var(--s) * 1.7vh); background: var(--cream); border-radius: 2px; box-shadow: 0 0 6px rgba(255,255,255,.6);
  opacity: .8; animation: drift 12s linear infinite; pointer-events: none; }
.pp.rose { background: #f8d0da; }
@keyframes drift { 0% { transform: translate(0,0) rotate(0); opacity: 0 } 10% { opacity: .85 } 100% { transform: translate(18vw,-115vh) rotate(540deg); opacity: 0 } }

/* HUD */
.hud { position: absolute; left: 72px; top: 8px; display: flex; flex-direction: column; gap: 6px; pointer-events: none !important; }
.hud > * { pointer-events: none; }
.hudcard, .chip, .objective, .interact, .toast { background: linear-gradient(#fbf3df, var(--cream)); border: 2px solid #cdb888; box-shadow: 0 3px 0 rgba(120,90,50,.25), 0 6px 10px rgba(40,40,80,.2); }
.hudcard { padding: 4px 12px 6px; border-radius: 10px; transform: rotate(-.8deg); min-width: 8.5em; }
.hc-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-weight: 900; line-height: 1.25; }
.hc-day { font-size: 1.15em; } .hc-clock { font-size: 1.05em; }
.hc-row.small { font-size: .85em; font-weight: 700; align-items: center; }
.inkbar { width: 3.2em; height: 7px; border-radius: 4px; background: #d9c9a2; overflow: hidden; } .inkbar i { display: block; height: 100%; background: var(--navy); transition: width .5s; }
.chips { display: flex; gap: 6px; }
.chip { display: flex; align-items: center; gap: 5px; padding: 2px 10px 2px 4px; border-radius: 99px; font-weight: 900; font-size: 1.1em; position: relative; min-height: 28px; }
.chip .ci { width: 1.5em; height: 1.5em; object-fit: contain; }
.dot { position: absolute; right: 0; top: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--rose); border: 2px solid var(--cream); }
.objective { position: absolute; left: 290px; right: 80px; top: 8px; margin: 0 auto; width: fit-content; max-width: calc(100% - 370px); box-sizing: border-box; padding: 5px 18px; border-radius: 99px; font-weight: 800; text-align: center; font-size: .95em;
  background: linear-gradient(#fbd9e0, #f1b8c6); border-color: #d98aa0; pointer-events: none !important; }
.mini { position: absolute; right: 10px; top: 64px; border-radius: 50%; padding: 6px; background: radial-gradient(#f2e3bd, #d9c08a); border: 3px solid #b99a62; box-shadow: 0 4px 10px rgba(30,30,60,.35), inset 0 0 8px rgba(120,80,30,.4); pointer-events: none !important; }
.mini canvas { display: block; border-radius: 50%; }
.interact { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); padding: 8px 22px; border-radius: 99px; font-weight: 900; font-size: 1.15em; white-space: nowrap; pointer-events: none !important; }
.toasts { position: absolute; left: 50%; top: calc(8px + 2.9em + 12px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none !important; }
.toast { padding: 6px 18px; border-radius: 99px; font-weight: 800; max-width: 70vw; text-align: center; animation: slidein .3s cubic-bezier(.3,1.4,.5,1); transition: opacity .3s, transform .3s; }
.toast.gone { opacity: 0; transform: translateY(-10px); }
@keyframes slidein { from { transform: translateY(-24px); opacity: 0 } to { transform: none; opacity: 1 } }
.banner { position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%); padding: .5em 2.4em; font-size: calc(var(--u) * 1.8); font-weight: 900; color: var(--cream);
  background: linear-gradient(#ee98ac, #d97a94); border: 3px solid var(--navy); border-radius: 8px; box-shadow: 0 6px 0 var(--navy), 0 10px 20px rgba(0,0,0,.3); text-shadow: 0 2px 0 var(--navy), 0 0 6px var(--navy); pointer-events: none !important; max-width: 80vw; text-align: center; }
.banner.show { animation: slamin .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes slamin { 0% { transform: translate(-50%,-50%) scale(2.4); opacity: 0 } 100% { transform: translate(-50%,-50%) scale(1); opacity: 1 } }
.fade { position: absolute; inset: 0; background: #1d2440; opacity: 0; pointer-events: none !important; }

/* dialogue */
.dlgwrap { position: absolute; inset: 0; pointer-events: auto; }
.dlg { position: absolute; left: 50%; bottom: 3%; transform: translateX(-50%); width: 62%; min-height: 28vh; display: flex; gap: 10px; align-items: center; }
.dlg.pop { animation: popx .22s ease-out; }
@keyframes popx { 0% { transform: translateX(-50%) scale(.9); opacity: 0 } 70% { transform: translateX(-50%) scale(1.03); opacity: 1 } 100% { transform: translateX(-50%) scale(1) } }
.cameo { border-radius: 50%; background-size: 260% auto; background-position: 50% 6%; background-repeat: no-repeat; background-color: #f8e9c8; border: 3px solid #b99a62; box-shadow: 0 2px 5px rgba(60,40,20,.4), inset 0 0 6px rgba(120,80,30,.3); flex: none; }
.cameo.sil { filter: brightness(0) opacity(.35); }
.dcam { width: 16vh; height: 16vh; }
.dcol { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; }
.plate { display: flex; align-items: baseline; gap: 10px; }
.pname { font-weight: 900; font-size: 1.2em; color: var(--navy); background: linear-gradient(transparent 60%, rgba(233,138,160,.5) 60%); padding: 0 6px; }
.prole { font-size: .8em; opacity: .75; font-weight: 700; }
.dtext { font-family: var(--f-serif); font-size: 1.05em; line-height: 1.55; margin-top: 4px; white-space: pre-wrap; min-height: 4.6em; font-weight: 600; }
.more { position: absolute; right: 4px; bottom: -2px; font-size: .9em; color: var(--rose); animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(3px) } }
.dopts { position: absolute; right: 0; bottom: calc(100% + 6px); display: flex; flex-direction: column; gap: 2px; align-items: stretch; min-width: 40%; max-width: 100%; }
.dopts .btn { justify-content: flex-start; padding: 0 10px; animation: slidein .22s both; }
.dopts .btn .bl { white-space: normal; text-align: left; line-height: 1.2; }

/* modals */
.modal { position: absolute; inset: 0; background: rgba(29,36,64,.5); display: flex; align-items: center; justify-content: center; pointer-events: auto; }
.modal .panel { width: 90%; height: 90%; display: flex; flex-direction: column; position: relative; }
.mhead { display: flex; align-items: center; gap: 10px; padding: 0 2px 2px; flex: none; min-height: 46px; }
.mtitle { font-weight: 900; font-size: 1.25em; margin-right: auto; text-shadow: 0 1px 0 #fff; }
.tabs { display: flex; gap: 6px; }
.tab { opacity: .75; } .tab.on { opacity: 1; filter: hue-rotate(-25deg) saturate(1.3); }
.xbtn { font-size: 1.5em; width: 46px; padding: 0; }
.mbody { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 2px; overflow: hidden; }
.empty { margin: auto; font-weight: 800; opacity: .6; text-align: center; }
.list, .rgrid2, .detail, .plist, .items, .frags { overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: #c9b48a transparent; }
.list { width: 38%; flex: none; display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.detail { flex: 1; min-width: 0; padding: 4px 8px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.card { justify-content: flex-start; gap: 8px; text-align: left; flex: none; }
.card.sel { filter: hue-rotate(-20deg) saturate(1.4) brightness(1.05); }
.cicon { width: 1.8em; height: 1.8em; object-fit: contain; flex: none; }
.ctext { min-width: 0; } .cft { font-size: .85em; line-height: 1.2; }
.ctags { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.cstamp { width: 24px; height: 24px; object-fit: contain; }
.tag { font-size: .65em; padding: 0 6px; border-radius: 99px; background: #fff; border: 1px solid #b99a62; white-space: nowrap; }
.tag.late { background: var(--amber); } .tag.broken { background: #f8d0da; }
.row { display: flex; gap: 10px; justify-content: center; padding: 2px 0; flex: none; flex-wrap: wrap; }
.envelope { position: relative; flex: 1; min-height: 18vh; background: linear-gradient(135deg, #fbf3df, #ecd9b0); border: 2px solid #c4a872; border-radius: 6px; box-shadow: 0 3px 8px rgba(80,50,20,.3); overflow: hidden; animation: pop .22s; }
.flap { position: absolute; left: 0; right: 0; top: 0; height: 52%; background: linear-gradient(#e9d5a6, #f1e1bc); clip-path: polygon(0 0, 100% 0, 50% 100%); opacity: .8; }
.env-to { position: absolute; left: 10%; bottom: 14%; font-weight: 900; font-size: 1.25em; font-family: var(--f-serif); }
.env-from { position: absolute; right: 8%; bottom: 10%; font-size: .85em; font-family: var(--f-serif); text-align: right; }
.env-to small, .env-from small { display: block; font-size: .65em; opacity: .65; font-family: var(--f-round); }
.seal { position: absolute; left: 50%; top: 40%; width: 2.6em; height: 2.6em; margin: -1.3em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f4a7b9, #d26a86 70%); color: #fde9ee; display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 5px rgba(90,20,40,.4), inset 0 0 0 3px rgba(255,255,255,.25); font-size: 1.1em; }
.env-stamp { position: absolute; right: 6%; top: 8%; width: 28%; max-width: 110px; transform: rotate(-12deg); opacity: .92; mix-blend-mode: multiply; }
.stamp-note { display: none; }
.letter { flex: 1; background: repeating-linear-gradient(transparent 0 1.75em, rgba(110,150,190,.35) 1.75em calc(1.75em + 1px)), #fbf4e0; border: 1px solid #cdb888; border-radius: 4px; padding: .6em 1em; font-family: var(--f-serif); line-height: 1.75em; box-shadow: 0 3px 8px rgba(80,50,20,.25); overflow-y: auto; animation: pop .22s; }
.letter h3 { margin: 0 0 .2em; font-size: 1.1em; line-height: 1.75em; color: var(--navy); } .letter p { margin: 0; }
.lsign { text-align: right; font-style: italic; }
.confirm { margin: auto; text-align: center; font-weight: 800; max-width: 90%; } .warn { font-size: 2em; color: var(--rose); }
.sub { font-weight: 900; text-align: center; padding-top: 2px; }
.stamps { display: flex; gap: 14px; justify-content: center; flex: 1; align-items: center; flex-wrap: wrap; }
.stampbtn { flex-direction: column; width: 17vh; min-width: 80px; padding: 6px 0; border-image: none; background: radial-gradient(#fff6e3, #ecd9b0); border: 3px solid #c4a872; border-radius: 18px; }
.stampbtn img { width: 11vh; height: 11vh; min-width: 56px; min-height: 56px; object-fit: contain; }
.stampbtn.cur { box-shadow: 0 0 0 3px var(--rose); }
.rgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; flex: 1; overflow-y: auto; padding: 4px; }
.rbtn, .pbtn { flex-direction: column; border-image: none; background: rgba(255,250,235,.8); border: 2px solid #c4a872; border-radius: 12px; padding: 4px 2px; }
.rbtn .bl, .pbtn .bl { font-size: .75em; }
.rc, .pc { width: 8vh; height: 8vh; min-width: 40px; min-height: 40px; }
.rgrid2 { width: 40%; flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: start; padding: 4px; }
.pbtn.sel { border-color: var(--rose); box-shadow: 0 0 0 2px var(--rose); }
.slam { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(246,236,214,.35); }
.slam-stamp { position: relative; z-index: 2; width: min(46vh, 300px); transform: rotate(-12deg); mix-blend-mode: multiply; animation: slamst .32s cubic-bezier(.3,1.5,.5,1) both; }
@keyframes slamst { 0% { transform: rotate(-12deg) scale(2.2); opacity: 0 } 60% { transform: rotate(-12deg) scale(.92); opacity: 1 } 100% { transform: rotate(-12deg) scale(1); opacity: 1 } }
.slam-fx { position: absolute; z-index: 1; background-repeat: no-repeat; pointer-events: none; }
.shake { animation: shake .3s linear; }
@keyframes shake { 0%,100% { transform: translate(0) } 20% { transform: translate(-6px,3px) } 40% { transform: translate(6px,-3px) } 60% { transform: translate(-4px,2px) } 80% { transform: translate(3px,-2px) } }
.items { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 4px 6px; }
.irow { display: flex; align-items: center; gap: 12px; background: rgba(255,250,235,.8); border: 2px solid #cdb888; border-radius: 12px; padding: 4px 10px; flex: none; }
.iicon { width: 2.6em; height: 2.6em; object-fit: contain; flex: none; }
.itext { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .9em; } .itext span { font-size: .85em; opacity: .75; }
.icount { font-weight: 900; font-size: 1.2em; }
.shopbtn { align-self: center; flex: none; }

/* journal */
.dtop { display: flex; gap: 12px; align-items: center; } .bigcam { width: 13vh; height: 13vh; min-width: 70px; min-height: 70px; }
.dname { font-size: 1.3em; font-weight: 900; } .mrow { display: flex; gap: 10px; align-items: center; } .face { font-size: 1.5em; } .hearts { color: var(--rose); font-size: 1.15em; letter-spacing: 2px; }
.kv { display: flex; gap: 8px; font-size: .9em; line-height: 1.35; } .kv b { flex: none; color: #8a6a3a; } .kv span { font-family: var(--f-serif); font-weight: 600; }
.rels { display: flex; gap: 12px; flex-wrap: wrap; } .rel { display: flex; align-items: center; gap: 6px; font-size: .8em; flex-wrap: wrap; } .rel b { color: #8a6a3a; }
.mc { width: 34px; height: 34px; border-width: 2px; } .relbar { width: 48px; height: 7px; background: #d9c9a2; border-radius: 4px; overflow: hidden; } .relbar i { display: block; height: 100%; }
.prow { font-size: .9em; line-height: 1.45; padding: 4px 8px; border-bottom: 1px dashed #cdb888; font-family: var(--f-serif); font-weight: 600; } .prow.serif { font-style: italic; }
.plist { flex: 1; padding: 4px 8px; } .dtag { background: var(--amber); border-radius: 99px; font-size: .75em; padding: 0 8px; margin-right: 8px; font-family: var(--f-round); }
.dhead { font-weight: 900; margin-top: 8px; color: var(--rose); text-shadow: 0 1px 0 #fff; }
.frags { flex: 1; display: flex; flex-direction: column; gap: 6px; } .fcount { text-align: center; font-weight: 900; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(30%, 1fr)); gap: 10px; padding: 4px; }
.slot { min-height: 11vh; padding: 8px 10px; background: #fbf4e0; border: 1px dashed #b99a62; font-family: var(--f-serif); font-size: .85em; line-height: 1.5; text-align: center; display: flex; align-items: center; justify-content: center; opacity: .6; transform: rotate(var(--r)); clip-path: polygon(0 4%, 6% 0, 20% 3%, 40% 0, 62% 4%, 82% 0, 100% 3%, 98% 40%, 100% 70%, 97% 100%, 70% 97%, 45% 100%, 20% 96%, 0 100%, 2% 60%); }
.slot p { margin: 0; } .slot.found { opacity: 1; box-shadow: 0 0 14px 4px rgba(244,194,122,.8); animation: glow 3s ease-in-out infinite; }
@keyframes glow { 50% { filter: brightness(1.08) drop-shadow(0 0 6px #f4c27a) } }

/* newspaper */
.news { background: rgba(29,36,64,.6); }
.sheet { width: 82%; height: 88%; background: repeating-linear-gradient(90deg, transparent 0 49.8%, rgba(0,0,0,.05) 50%, transparent 50.2%), #eadfc2; border: 3px double #6a5a3a; box-shadow: 0 10px 30px rgba(0,0,0,.5); padding: 2.2vh 3vw; font-family: var(--f-serif); color: #2a2a2a; display: flex; flex-direction: column; overflow: hidden; }
.sheet.slide { animation: slideup .4s cubic-bezier(.2,1.2,.4,1); }
@keyframes slideup { from { transform: translateY(60%); opacity: 0 } to { transform: none; opacity: 1 } }
.np-title { text-align: center; font-weight: 900; font-size: 2.1em; letter-spacing: .15em; border-bottom: 3px double #3a3020; padding-bottom: 2px; }
.np-date { text-align: center; font-size: .85em; border-bottom: 1px solid #3a3020; padding: 2px; margin-bottom: 6px; }
.np-head { font-size: 1.6em; font-weight: 900; line-height: 1.3; padding: 4px 0 8px; border-bottom: 1px solid #3a3020; }
.np-cols { column-count: 2; column-gap: 2vw; column-rule: 1px solid #8a7a5a; padding-top: 6px; overflow: hidden; flex: 1; font-size: .95em; line-height: 1.5; } .np-cols p { margin: 0 0 .6em; break-inside: avoid; }
.np-tap { text-align: center; font-family: var(--f-round); font-weight: 800; font-size: .85em; opacity: .7; animation: pulse 1.6s infinite; }
.end .np-tap { position: absolute; bottom: 7%; left: 0; right: 0; color: var(--cream); -webkit-text-stroke: 4px var(--navy); paint-order: stroke fill; }

/* ending */
.end { background: radial-gradient(#3a4a80, #1d2440); }
.ecard { width: 70%; max-height: 70%; padding: 5vh 5vw; background: repeating-linear-gradient(transparent 0 2em, rgba(110,150,190,.3) 2em calc(2em + 1px)), #fbf4e0; border: 2px solid #cdb888; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); text-align: center; opacity: 0; transform: translateY(10px); font-family: var(--f-serif); }
.ecard.in { opacity: 1; transform: none; transition: opacity 1s, transform 1s; }
.etext { font-size: 1.25em; line-height: 2em; font-weight: 700; color: var(--navy); }
.etext.last { font-size: 1.6em; color: #b44d6a; } .etext.title { font-size: 2em; font-weight: 900; }
.esub { white-space: pre-line; margin-top: 1em; font-family: var(--f-round); font-weight: 800; line-height: 1.6; }
