:root {
  --amber: #e8a54b; --amber2: #f3d9a4; --ink: #0c1113; --panel: rgba(14, 19, 21, 0.82); --line: rgba(232, 165, 75, 0.28);
  --txt: #e6dfd2; --dim: #8f8a80; --bad: #ff6b55; --good: #9fe08a; --spore: #7ff0d8;
  --font: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Arial Narrow", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
/* scrollbars match the UI (otherwise the OS draws its own light grey ones with arrow buttons) */
:root { color-scheme: dark; }
* { scrollbar-width: thin; scrollbar-color: rgba(232, 165, 75, .35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }   /* Safari, which ignores scrollbar-color */
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(232, 165, 75, .35); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(232, 165, 75, .6); }
::-webkit-scrollbar-button { display: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0f11; color: var(--txt); font-family: var(--font); user-select: none; }
canvas#game { position: fixed; inset: 0; display: block; cursor: crosshair; }
#ui { position: fixed; inset: 0; pointer-events: none; }
/* screen effects as compositor layers (no per-frame canvas fill) */
#fx, #fx i { position: fixed; inset: 0; pointer-events: none; }
#fx i { opacity: 0; will-change: opacity; }
#fx .vig { background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, .72) 100%); }
#fx .hurt { background: rgb(160, 20, 10); }
#fx .lowhp { background: radial-gradient(ellipse at center, rgba(120, 0, 0, 0) 35%, rgba(120, 0, 0, .6) 100%); }
.hidden { display: none !important; }
body.title #ui > *:not(#overlay) { display: none !important; }

/* stats */
#stats { position: absolute; left: 18px; top: 16px; width: 250px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.stat { display: grid; grid-template-columns: 64px 1fr 28px; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.stat .lbl { color: var(--dim); }
.stat .val { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: rgba(255, 255, 255, 0.07); border-radius: 2px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .5); }
.bar i { display: block; height: 100%; width: 50%; transition: width .2s; }
.s-hp .bar i { background: linear-gradient(90deg, #8e2a22, #e0553f); }
.s-food .bar i { background: linear-gradient(90deg, #7a5a22, #e0a548); }
.s-water .bar i { background: linear-gradient(90deg, #234f6e, #57a7d8); }
.s-stam .bar i { background: linear-gradient(90deg, #4f5a3a, #a9c07a); }

/* clock */
#clock { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); text-align: center; padding: 8px 22px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; min-width: 150px; }
#clock .day { font-size: 12px; letter-spacing: .3em; color: var(--dim); }
#clock .day b { color: var(--amber); font-size: 20px; letter-spacing: 0; margin-left: 4px; }
#c-phase { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; }
#c-time { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
#c-where { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); font-size: 11px; color: var(--dim); letter-spacing: .04em; white-space: nowrap; }
#c-where:empty { display: none; }
#c-dial { position: absolute; right: 8px; top: 8px; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line); }
#c-sun { position: absolute; inset: 0; }
#c-sun::after { content: ''; position: absolute; left: 50%; top: -3px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 6px var(--amber); }
#clock.night { border-color: rgba(127, 240, 216, .35); }
#clock.night #c-phase { color: var(--spore); text-shadow: 0 0 8px rgba(127, 240, 216, .5); }
#clock.raid { border-color: rgba(255, 90, 70, .7); animation: pulse 1.6s infinite; }
#clock.raid #c-phase { color: #ff8a70; text-shadow: 0 0 10px rgba(255, 90, 70, .6); }

/* objective */
#objective { position: absolute; left: 18px; top: 150px; width: 250px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 6px; font-size: 13px; line-height: 1.45; }
#objective .h, #transmit .h, .panel .h { font-size: 10px; letter-spacing: .25em; text-transform: uppercase; color: var(--amber); margin-bottom: 4px; }
#objective b { color: var(--amber2); font-weight: 600; }
#objective .ok { color: var(--good); }
#objective .warn { color: #ff9a80; font-weight: 600; }
#objective .dim { color: var(--dim); }

/* minimap */
#mapwrap { position: absolute; right: 16px; top: 14px; width: 200px; height: 200px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); transition: all .25s; }
#mapwrap canvas { width: 100%; height: 100%; display: block; }
#mapwrap .mlbl { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: var(--dim); letter-spacing: .1em; }
#mapwrap.big { width: min(70vh, 640px); height: min(70vh, 640px); right: 50%; top: 50%; transform: translate(50%, -50%); }

/* transmit */
#lastsave { position: absolute; right: 18px; top: 218px; font-size: 11px; color: var(--dim); letter-spacing: .04em; text-shadow: 0 1px 2px #000; white-space: nowrap; }
#mapwrap.big ~ #lastsave { display: none; }
#transmit { position: absolute; right: 16px; top: 240px; width: 220px; padding: 10px 14px; background: rgba(40, 10, 8, .82); border: 1px solid rgba(255, 90, 70, .5); border-radius: 6px; animation: pulse 1.2s infinite; }
#transmit .h { color: #ff8a70; }
#t-time { font-size: 30px; font-variant-numeric: tabular-nums; color: #ffd0c0; }
#transmit .bar i { background: linear-gradient(90deg, #8e2a22, #ff7a5a); }
#transmit .bh { font-size: 11px; color: var(--dim); margin-top: 5px; letter-spacing: .08em; text-transform: uppercase; }
#transmit .bh span { color: #ffd0c0; }
@keyframes pulse { 50% { box-shadow: 0 0 22px rgba(255, 80, 60, .35); } }

/* hotbar */
#hbwrap { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 16px; pointer-events: auto; }
#hotbar { display: flex; gap: 6px; }
.slot { position: relative; width: 58px; height: 58px; background: var(--panel); border: 1px solid rgba(255, 255, 255, .1); border-radius: 6px; display: grid; place-items: center; cursor: pointer; transition: transform .1s; }
.slot img { width: 40px; height: 40px; }
.slot.sel { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), 0 0 18px rgba(232, 165, 75, .35); transform: translateY(-4px); }
.slot .k { position: absolute; left: 4px; top: 2px; font-size: 10px; color: var(--dim); }
.slot .n { position: absolute; right: 4px; bottom: 2px; font-size: 12px; color: var(--amber2); }
.slot .nm { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--amber2); opacity: 0; transition: opacity .15s; }
.slot.sel .nm { opacity: 1; }
#offhand::after { content: 'OFF HAND'; position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 8px; letter-spacing: .12em; color: var(--dim); white-space: nowrap; }
#offhand.empty { background: rgba(14, 19, 21, .4); border-style: dashed; cursor: default; }
#offhand.empty img { visibility: hidden; }
#offhand.lit { border-color: #ff9a4a; box-shadow: inset 0 0 14px rgba(255, 140, 60, .45); }
#offhand.lit::after { color: #ffb070; }
#offhand.down img, #offhand.stow img { opacity: .4; transform: translateY(5px); filter: grayscale(.6); transition: all .15s; }
#offhand.stow img { opacity: .55; }

#keys { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-size: 11px; color: var(--dim); white-space: nowrap; letter-spacing: .04em; }
#keys b { color: var(--txt); font-weight: 600; margin-left: 10px; padding: 0 4px; border: 1px solid rgba(255, 255, 255, .15); border-radius: 3px; }
#keys .k-on { color: var(--amber2); font-weight: 600; }

/* log */
#log { position: absolute; left: 18px; bottom: 40px; width: 380px; display: flex; flex-direction: column; gap: 4px; }
.msg { font-size: 13px; padding: 5px 10px; background: rgba(10, 14, 16, .7); border-left: 2px solid var(--dim); border-radius: 3px; transition: opacity 1s; text-shadow: 0 1px 2px #000; }
.msg.good { border-color: var(--good); } .msg.bad { border-color: var(--bad); color: #ffd6cc; } .msg.warn { border-color: var(--amber); }
.msg.fade { opacity: 0; }

/* object info: fixed in the bottom-right corner so it never covers what you're looking at */
#tip { position: fixed; right: 16px; bottom: 40px; width: 240px; padding: 9px 12px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 6px; font-size: 12px; line-height: 1.45; }
@media (max-width: 1100px) { #tip { bottom: auto; top: 240px; width: 200px; } }
.stat.low .lbl, .stat.low .val { color: #ffb08a; }
.stat.low .bar { animation: lowbar 1.4s ease-in-out infinite; }
.stat.crit .lbl, .stat.crit .val { color: #ff6b55; }
.stat.crit .bar { animation-duration: .6s; }
@keyframes lowbar { 50% { box-shadow: 0 0 0 1px rgba(255, 107, 85, .8), 0 0 10px rgba(255, 107, 85, .5); } }
#tip b { color: var(--amber2); } #tip .dim, .dim { color: var(--dim); }

/* craft panel */
#menus { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(1080px, 96vw); height: min(600px, 84vh); display: flex; gap: 10px; pointer-events: auto; }
#menus > .panel:not(#details) { flex: 1; min-width: 0; }
.panel { position: relative; height: 100%; background: rgba(14, 19, 21, .95); border: 1px solid var(--line); border-radius: 8px; pointer-events: auto; display: flex; flex-direction: column; box-shadow: 0 20px 80px rgba(0, 0, 0, .6); }
.ph { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; letter-spacing: .25em; text-transform: uppercase; color: var(--amber); }
.ph .st { flex: 1; font-size: 11px; letter-spacing: .1em; color: var(--dim); }
.ph .x { background: none; border: 0; color: var(--dim); font-size: 18px; cursor: pointer; }
#inv-grid { flex: 1; min-height: 0; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; align-content: start; overflow: auto; }
.bag-hint { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--dim); }
.cell.cur, .rec.cur { border-color: var(--amber); box-shadow: inset 0 0 0 1px rgba(232, 165, 75, .35); }
#details { flex: 0 0 290px; }
#det-body { padding: 14px 16px; overflow: auto; min-height: 0; font-size: 13px; line-height: 1.45; }
#det-body .dh { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
#det-body .dh img { width: 56px; height: 56px; flex: 0 0 auto; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); border-radius: 5px; padding: 4px; }
#det-body .nm { font-size: 17px; letter-spacing: .05em; color: var(--amber2); }
#det-body .own { font-size: 11px; color: var(--dim); letter-spacing: .06em; margin-top: 2px; }
#det-body .ds { margin: 0 0 10px; color: var(--txt); }
#det-body .facts { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#det-body .facts li { padding: 5px 9px; background: rgba(0, 0, 0, .28); border-left: 2px solid var(--amber); border-radius: 3px; color: var(--amber2); font-size: 12px; }
#det-body .facts li::first-letter { text-transform: uppercase; }
#det-body .mk { font-size: 12px; color: var(--dim); margin-bottom: 8px; }
#det-body .use { font-size: 12px; color: var(--good); }
.cell { position: relative; aspect-ratio: 1; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); border-radius: 4px; display: grid; place-items: center; }
.cell img { width: 80%; }
.cell .n { position: absolute; right: 3px; bottom: 1px; font-size: 11px; color: var(--amber2); }
.cell.usable { cursor: pointer; border-color: rgba(159, 224, 138, .35); }
.cell:hover { background: rgba(232, 165, 75, .12); }
.recs { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 14px 0; }
.tabs button { flex: 1; padding: 8px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); color: var(--dim); font-family: var(--font); letter-spacing: .15em; text-transform: uppercase; font-size: 12px; cursor: pointer; border-radius: 4px 4px 0 0; }
.tabs button.on { color: var(--amber); border-color: var(--line); background: rgba(232, 165, 75, .1); }
#rec-list { overflow: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.rec { cursor: default; display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 8px 10px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(255, 255, 255, .06); border-radius: 5px; }
.rec.ok { border-color: rgba(159, 224, 138, .3); }
.rec.locked .ic { filter: grayscale(1) brightness(.45); }
.rec.locked .nm { color: var(--dim); }
.rec .ic { width: 48px; height: 48px; }
.rec .nm { font-size: 15px; letter-spacing: .05em; }
.rec .ds { font-size: 12px; color: var(--dim); margin: 2px 0 5px; }
.rq { display: flex; flex-wrap: wrap; gap: 6px; }
.req, .stn { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; padding: 1px 6px 1px 2px; border-radius: 3px; background: rgba(0, 0, 0, .3); }
.req img { width: 18px; height: 18px; }
.have { color: var(--good); } .need { color: var(--bad); }
.stn { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 6px; margin-left: 6px; border: 1px solid currentColor; }
.rec button, .btns button { font-family: var(--font); letter-spacing: .15em; text-transform: uppercase; cursor: pointer; border-radius: 4px; }
.rec button { padding: 8px 16px; background: var(--amber); color: #1a1208; border: 0; font-weight: 700; }
.rec .act { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 132px; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty span { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }
.rec .qty button { padding: 4px 9px; background: rgba(255, 255, 255, .06); color: var(--txt); border: 1px solid rgba(255, 255, 255, .15); font-weight: 400; font-size: 13px; }
.rec .qty button.mx { flex: 1; font-size: 11px; padding: 5px 6px; }
.rec .qty button:hover:not(:disabled) { border-color: var(--amber); color: var(--amber2); }
.rec .qty button:disabled { background: rgba(255, 255, 255, .03); color: rgba(255, 255, 255, .25); }
.rec button:disabled { background: rgba(255, 255, 255, .08); color: var(--dim); cursor: default; }

/* overlays */
#overlay { position: absolute; inset: 0; display: none; place-items: center; pointer-events: auto; background: radial-gradient(ellipse at center, rgba(5, 8, 10, .35), rgba(5, 8, 10, .85)); }
#overlay.show { display: grid; }
.screen { text-align: center; max-width: 640px; padding: 30px; }
.screen.loading { min-width: 360px; }
#overlay:has(.screen.travel) { background: radial-gradient(ellipse at center, rgba(12, 14, 16, .9), rgba(6, 8, 10, .97)); }
.screen.travel { max-width: none; width: min(1240px, 96vw); padding: 18px; text-align: left; }
.tv-layout { display: flex; gap: 22px; align-items: stretch; }
.tv-sheet { position: relative; flex: 1 1 auto; min-width: 0; aspect-ratio: 640 / 440; max-height: 84vh; background-size: 100% 100%; border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(120, 96, 60, .5), 0 0 0 5px rgba(30, 24, 18, .9), 0 0 0 6px rgba(120, 96, 60, .35), 0 16px 40px rgba(0, 0, 0, .6); }
.tv-side { flex: 0 0 290px; display: flex; flex-direction: column; gap: 14px; }
.tv-side h2 { font-size: 26px; margin: 0; }
.tv-card { background: var(--panel); border: 1px solid rgba(255, 255, 255, .1); border-radius: 8px; padding: 14px 16px; font-size: 13px; line-height: 1.45; }
.tv-card p { margin: 6px 0 10px; color: var(--txt); }
.tv-card p.dim { color: var(--dim); margin-bottom: 0; }
.tv-kind { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.tv-name { font-size: 20px; font-weight: 700; color: var(--amber2); margin-top: 2px; }
.tv-row { display: flex; justify-content: space-between; padding: 4px 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.tv-row span { color: var(--dim); }
.tv-row b { color: var(--txt); font-weight: 600; }
.tv-side .btns button { width: 100%; min-width: 0; }
.tv-legend { position: absolute; left: 12px; top: 12px; background: rgba(226, 208, 168, .92); color: #3a2a18; border: 1px solid rgba(70, 50, 28, .6); border-radius: 4px; padding: 7px 10px 8px; font-size: 11px; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); pointer-events: none; }
.tv-legend .lg-h { font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: 10px; margin-bottom: 4px; border-bottom: 1px solid rgba(70, 50, 28, .35); padding-bottom: 3px; }
.tv-legend .lg-g { display: grid; grid-template-columns: auto auto; gap: 2px 12px; }
.tv-legend .lg-g div { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
@media (max-width: 900px) { .tv-layout { flex-direction: column; } .tv-side { flex-basis: auto; } }
.tv-fog, .tv-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.tv-map path { fill: none; stroke: rgba(40, 26, 14, .55); stroke-width: 2.4; stroke-dasharray: 7 5; stroke-linecap: round; }
.tv-map path.on { stroke: rgba(170, 52, 34, .95); stroke-width: 3; }
.tv-map .node { cursor: pointer; }
.tv-map .node .hit { fill: transparent; }
.tv-map .node .dot { stroke: rgba(30, 20, 12, .85); stroke-width: 2; }
.tv-map .node .dot.unvisited { fill-opacity: .55; stroke-dasharray: 2 2; }
.tv-map .node .ring { fill: none; stroke: #f4ead6; stroke-width: 1.6; stroke-dasharray: 3 3; }
.tv-map .node.sel .dot, .tv-map .node:hover .dot { stroke: #f4ead6; stroke-width: 2.6; }
.tv-map text { fill: #f1e6cf; font-family: Bahnschrift, "Segoe UI", sans-serif; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-anchor: middle; paint-order: stroke; stroke: rgba(24, 16, 8, .9); stroke-width: 3.2px; pointer-events: none; }
.ld-bar { height: 6px; margin: 22px auto 18px; width: 320px; max-width: 80vw; background: rgba(255, 255, 255, .08); border-radius: 3px; overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 3%; background: linear-gradient(90deg, #b8742c, var(--amber)); box-shadow: 0 0 12px rgba(232, 165, 75, .5); transition: width .15s linear; }
.ld-tip { font-size: 13px; color: var(--dim); max-width: 420px; margin: 0 auto; line-height: 1.5; }
.screen h1 { font-size: clamp(54px, 9vw, 112px); margin: 0; letter-spacing: .12em; font-weight: 700; color: #efe6d6; text-shadow: 0 0 40px rgba(232, 165, 75, .25), 0 4px 0 rgba(0, 0, 0, .6); line-height: .9; }
.screen h1 span { display: block; font-size: .42em; letter-spacing: .62em; color: var(--amber); margin-top: 10px; padding-left: .62em; }
.screen h2 { font-size: 40px; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 10px; color: var(--amber2); }
.screen.dead h2 { color: var(--bad); }
.screen.won h2 { color: var(--spore); text-shadow: 0 0 30px rgba(127, 240, 216, .4); }
.tag { letter-spacing: .3em; text-transform: uppercase; font-size: 12px; color: var(--dim); margin-top: 18px; }
.story { font-size: 16px; line-height: 1.6; color: #cfc6b8; margin: 26px auto; max-width: 540px; }
.story em { color: var(--spore); font-style: normal; }
.stats { color: var(--dim); letter-spacing: .1em; margin: 10px 0 22px; }
.btns { display: flex; gap: 12px; justify-content: center; }
.btns.col { flex-direction: column; align-items: center; }
.btns button { min-width: 200px; padding: 13px 26px; font-size: 15px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .2); color: var(--txt); }
.btns button:hover { border-color: var(--amber); color: var(--amber2); }
.btns button.primary { background: var(--amber); color: #1a1208; border-color: var(--amber); font-weight: 700; }
.btns button.primary:hover { background: #f4b862; color: #1a1208; }
.slots { margin: 22px auto 0; max-width: 560px; text-align: left; }
.slots .h { font-size: 10px; letter-spacing: .25em; text-transform: uppercase; color: var(--amber); margin-bottom: 6px; }
.slot-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 9px 12px; margin-bottom: 6px; background: rgba(14, 19, 21, .78); border: 1px solid rgba(255, 255, 255, .08); border-radius: 5px; }
.slot-row:hover { border-color: var(--line); }
.slot-row .sn { font-size: 16px; letter-spacing: .06em; color: var(--txt); }
.slot-row .sm { font-size: 12px; color: var(--dim); margin-top: 2px; }
.slot-row button { font-family: var(--font); letter-spacing: .12em; text-transform: uppercase; font-size: 12px; padding: 8px 14px; border-radius: 4px; cursor: pointer; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .05); color: var(--txt); }
.slot-row button.primary { background: var(--amber); border-color: var(--amber); color: #1a1208; font-weight: 700; }
.slot-row button.del:hover, .slot-row button.del.confirm { border-color: var(--bad); color: var(--bad); }
.slot-row button.del.confirm { background: rgba(255, 107, 85, .12); }
.btns button:disabled { opacity: .4; cursor: default; }
.notice { margin: 14px auto 0; max-width: 520px; font-size: 13px; color: #ffb39f; }
.storage-note { margin: 16px auto 0; max-width: 520px; font-size: 11.5px; line-height: 1.5; color: var(--dim); }
.storage-note b { color: var(--amber2); font-weight: 600; }
/* F3 profiler: left edge, mid-height, see-through so it doesn't hide the game */
#prof { position: fixed; left: 18px; top: 50%; transform: translateY(-40%); z-index: 50; pointer-events: none; white-space: pre; font: 10.5px/1.3 Consolas, "Cascadia Mono", monospace; color: #dff; background: rgba(0, 0, 0, .18); padding: 6px 8px; border-radius: 4px; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.hint, .help { margin-top: 26px; font-size: 12px; color: var(--dim); letter-spacing: .06em; line-height: 1.9; }
.help b { color: var(--txt); }

/* ---------- touch controls (beta) ---------- */
canvas#game { touch-action: none; }
#touchui { position: fixed; inset: 0; pointer-events: none; z-index: 5; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.title #touchui > :not(#rotate), body:not(.touch) #touchui { display: none; }
#touchui button { pointer-events: auto; touch-action: none; font-family: var(--font); color: var(--txt); background: rgba(14, 19, 21, .62); border: 1px solid rgba(255, 255, 255, .22); border-radius: 50%; font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 0; backdrop-filter: blur(2px); }
#touchui button.on, #touchui button:active { background: rgba(232, 165, 75, .55); color: #1a1208; border-color: var(--amber); }
#joy { position: fixed; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); background: rgba(14, 19, 21, .3); display: none; }
#joy.on { display: block; }
#joy i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(232, 165, 75, .55); border: 1px solid var(--amber); }
#tbtns { position: fixed; right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); width: 210px; height: 200px; }
#tbtns button { position: absolute; width: 50px; height: 50px; }
#tbtns .big { width: 82px; height: 82px; right: 0; bottom: 0; font-size: 14px; background: rgba(120, 60, 30, .55); border-color: rgba(232, 165, 75, .6); }
#tbtns .b1 { right: 94px; bottom: 4px; } #tbtns .b2 { right: 86px; bottom: 62px; } #tbtns .b3 { right: 46px; bottom: 108px; } #tbtns .b4 { right: -2px; bottom: 120px; }
#tbtns .b5 { right: 148px; bottom: 30px; } #tbtns .b6 { right: 140px; bottom: 90px; } #tbtns .b7 { right: 96px; bottom: 144px; }
#tsys { position: fixed; top: calc(146px + env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right)); display: flex; gap: 6px; }
#tsys button { border-radius: 6px; height: 30px; min-width: 44px; padding: 0 8px; font-size: 10px; }
#rotate { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; background: rgba(8, 10, 12, .94); color: var(--txt); font-size: 15px; line-height: 1.6; pointer-events: auto; z-index: 20; }
#rotate b { color: var(--amber2); font-size: 18px; }
@media (orientation: portrait) { body.touch #rotate { display: flex; } }
/* compact HUD for small touch screens */
body.touch #keys { display: none; }
body.touch #stats { left: calc(8px + env(safe-area-inset-left)); top: calc(8px + env(safe-area-inset-top)); width: 168px; padding: 6px 9px; font-size: 10px; }
body.touch .stat { gap: 6px; margin: 1px 0; font-size: 10px; grid-template-columns: 50px 1fr 22px; }
body.touch #clock { top: 6px; padding: 3px 12px 5px; min-width: 104px; }
body.touch #clock .day { font-size: 9px; } body.touch #clock .day b { font-size: 14px; }
body.touch #c-phase { font-size: 12px; } body.touch #c-time { font-size: 10px; } body.touch #c-where { font-size: 9px; margin-top: 2px; padding-top: 2px; }
body.touch #objective { left: calc(8px + env(safe-area-inset-left)); top: calc(96px + env(safe-area-inset-top)); width: 172px; padding: 5px 9px; font-size: 10.5px; line-height: 1.35; max-height: 34vh; overflow: hidden; }
body.touch #mapwrap { right: calc(8px + env(safe-area-inset-right)); top: calc(8px + env(safe-area-inset-top)); width: 118px; height: 118px; }
body.touch #mapwrap .mlbl { display: none; }
body.touch #mapwrap.big { right: 50%; top: 50%; transform: translate(50%, -50%); width: min(86vh, 560px); height: min(86vh, 560px); z-index: 6; }
body.touch #lastsave { right: calc(10px + env(safe-area-inset-right)); top: calc(129px + env(safe-area-inset-top)); font-size: 9.5px; }
body.touch #transmit { right: calc(8px + env(safe-area-inset-right)); top: calc(184px + env(safe-area-inset-top)); width: 170px; padding: 6px 9px; }
body.touch #log { left: 50%; transform: translateX(-50%); top: 58px; bottom: auto; width: min(360px, 46vw); font-size: 10.5px; }
body.touch #log > :nth-last-child(n+3) { display: none; }
body.touch .msg { font-size: 10.5px; padding: 2px 7px; background: rgba(10, 14, 16, .55); }
body.touch #tip { display: none; }
body.touch #hbwrap { bottom: calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
body.touch #hotbar { gap: 4px; }
body.touch #offhand { width: 44px; height: 44px; flex: 0 0 auto; } body.touch #offhand img { width: 30px; height: 30px; }
body.touch #offhand::after { display: none; }
body.touch #hotbar .slot { width: 44px; height: 44px; }
body.touch #hotbar .slot img { width: 30px; height: 30px; }
body.touch #hotbar { max-width: calc(100vw - 552px); min-width: 150px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
body.touch #hotbar .slot { flex: 0 0 auto; }
body.touch #hotbar .slot .nm { display: none; }
body.touch #menus { left: 0; top: 0; transform: none; width: 100vw; height: 100vh; gap: 0; }
body.touch #menus .panel { border-radius: 0; }
body.touch #details { flex-basis: 220px; border-left: 0; }
body.touch #det-body { padding: 10px; font-size: 12px; } body.touch #det-body .dh img { width: 40px; height: 40px; } body.touch #det-body .nm { font-size: 14px; }
body.touch .screen { padding: 14px; }
body.touch .screen h2 { font-size: 26px; }
body.touch .btns button { min-width: 160px; padding: 10px 18px; }
body.touch #inv-grid { padding: 8px; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
body.touch .rec { grid-template-columns: 36px 1fr auto; gap: 8px; padding: 6px 8px; }
body.touch .rec .ic { width: 36px; height: 36px; }
body.touch .rec .nm { font-size: 13px; } body.touch .rec .ds { font-size: 11px; }
body.touch .rec .act { min-width: 112px; }
body.touch #rec-list, body.touch #inv-grid, body.touch .slots { touch-action: pan-y; -webkit-overflow-scrolling: touch; }
/* menus on small screens: scroll instead of clipping, two columns of buttons, clear of the notch */
body.touch #overlay.show { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; }
body.touch #overlay .screen { margin: 0 auto; }
body.touch #overlay .screen:not(.travel):not(.title-screen) { padding-top: 18px; }
body.touch .btns.col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 560px; margin: 0 auto; }
body.touch .btns.col button { min-width: 0; padding: 9px 12px; font-size: 12px; }
body.touch .screen h2 { margin-bottom: 4px; }
body.touch #menus { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); box-sizing: border-box; }
/* touch controls get out of the way of menus and the crafting panel */
body.t-busy #tbtns, body.t-busy #tsys, body.t-busy #joy { display: none; }
body.t-bigmap #tbtns, body.t-bigmap #joy { display: none; }
body.touch .screen .help, body.touch .title-screen .hint { display: none; }
/* pause, death and win screens: a near-solid backdrop so the text reads clearly over the game */
#overlay:has(.screen:not(.title-screen):not(.travel):not(.loading)) { background: radial-gradient(ellipse at center, rgba(10, 13, 15, .9), rgba(6, 8, 10, .96)); }
/* no text selection, magnifier, callout menu or grey tap flash on long presses (Safari needs the -webkit- forms) */
html, body, canvas, #ui, #touchui, #overlay { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* title screen: story on the left, buttons and saves on the right, sized to fit without scrolling */
.screen.title-screen { max-width: 1180px; width: min(1180px, 94vw); max-height: 100vh; overflow: hidden; display: grid; grid-template-columns: 1.15fr 1fr; gap: clamp(24px, 4vw, 64px); align-items: center; text-align: left; padding: clamp(12px, 3vh, 30px) 24px; box-sizing: border-box; }
.title-screen .tl-left { text-align: center; }
.title-screen h1 { font-size: clamp(40px, min(8vw, 15vh), 112px); }
.title-screen .tag { margin-top: clamp(8px, 2vh, 18px); }
.title-screen .story { font-size: clamp(12px, 2.3vh, 16px); margin: clamp(10px, 3vh, 26px) auto 0; }
.title-screen .tl-right { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 40px); }
.title-screen .tl-right .btns { justify-content: stretch; }
.title-screen .tl-right .btns button { flex: 1; min-width: 0; }
.title-screen .slots { margin: clamp(10px, 2.5vh, 22px) 0 0; max-width: none; min-height: 0; overflow-y: auto; flex: 0 1 auto; padding-right: 4px; }
.title-screen .notice, .title-screen .storage-note { max-width: none; margin-left: 0; margin-right: 0; }
.title-screen .storage-note { margin-top: clamp(8px, 2vh, 16px); }
.title-screen .hint { margin-top: clamp(8px, 2vh, 20px); }
.title-screen .ver { position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); font-size: 10.5px; line-height: 1.5; letter-spacing: .06em; color: var(--dim); text-align: left; opacity: .75; pointer-events: none; }
@media (max-width: 640px) and (orientation: portrait) { .screen.title-screen { grid-template-columns: 1fr; overflow-y: auto; } }
body.touch .title-screen .slot-row { padding: 6px 9px; }
body.touch .title-screen .slot-row button { padding: 6px 9px; font-size: 10.5px; }
body.touch .title-screen .storage-note { font-size: 10.5px; }
@media (max-width: 1000px) { .title-screen .slot-row { grid-template-columns: 1fr 1fr 1fr; row-gap: 6px; } .title-screen .slot-row .si { grid-column: 1 / -1; } .title-screen .slot-row .sn { font-size: 14px; display: inline; } .title-screen .slot-row .sm { display: inline; margin-left: 8px; font-size: 11px; } }
/* creative mode panel (dev channel only, js/dev.js) */
#devpanel { position: absolute; right: 16px; top: 240px; width: 236px; pointer-events: auto; font-size: 12px; z-index: 5; }
body.title #devpanel { display: none; }
#mapwrap.big ~ #devpanel { display: none; }
#dev-tab { float: right; font: 600 11px var(--font); letter-spacing: .15em; color: #ff9ad0; background: var(--panel); border: 1px solid rgba(255, 120, 200, .5); border-radius: 4px; padding: 3px 8px; cursor: pointer; }
#dev-body { clear: both; margin-top: 4px; padding: 8px 10px; background: rgba(14, 19, 21, .94); border: 1px solid rgba(255, 120, 200, .45); border-radius: 6px; display: flex; flex-direction: column; gap: 4px; }
#dev-body.hidden { display: none; }
#dev-body .h { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: #ff9ad0; margin-top: 4px; }
#dev-body .dim { color: var(--dim); letter-spacing: 0; text-transform: none; }
#dev-body label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#dev-body .row { display: flex; gap: 4px; }
#dev-body .row > * { flex: 1; min-width: 0; }
#dev-body button, #dev-body select { font: 12px var(--font); color: var(--txt); background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .15); border-radius: 3px; padding: 3px 4px; cursor: pointer; }
#dev-body button:hover { border-color: #ff9ad0; }
#dev-body select option { background: #151b1d; }
.devtag { margin-bottom: 10px; padding: 6px 10px; border: 1px solid rgba(255, 120, 200, .5); border-radius: 4px; color: #ff9ad0; font-size: 12px; }
