/* Silent Adventure — pixel UI: dark slate panels with rounded corners (as in the concept art), ice-blue and gold accents. */
@font-face { font-family: "Handjet"; font-display: swap; font-weight: 500; src: url("fonts/handjet-cyrillic-500-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Handjet"; font-display: swap; font-weight: 500; src: url("fonts/handjet-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Handjet"; font-display: swap; font-weight: 700; src: url("fonts/handjet-cyrillic-700-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Handjet"; font-display: swap; font-weight: 700; src: url("fonts/handjet-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
    --ink: #121319;
    --ink-2: #20212b;
    --ink-3: #2c2e3b;
    --line: #4a4c5e;
    --line-2: #6c6e86;
    --text: #f4f1e8;
    --muted: #b4b2a8;
    --ice: #82e0ff;
    --ice-2: #47c7f8;
    --aurora: #ab93ed;
    --gold: #f2c230;
    --ok: #7ae05a;
    --warn: #ffb347;
    --danger: #ff5a6a;
    --px: 3px;
    --ui: "Handjet", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--text); font-family: var(--ui); font-weight: 500; -webkit-font-smoothing: none; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
h2, h3 { margin: 0;  }

/* ------------------------------------------------------------ buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border: 0; font-size: 23px;  letter-spacing: 0.02em; text-decoration: none; color: #111218;
    background: linear-gradient(180deg, #b6eeff, var(--ice) 45%, var(--ice-2));
    box-shadow: 0 0 0 var(--px) #111218, inset 0 calc(-1 * var(--px)) 0 #2a8ab8, inset 0 var(--px) 0 #e8fbff, 0 6px 0 var(--px) rgba(0, 0, 0, 0.35);
    transition: transform 120ms, filter 120ms;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--px) #111218, inset 0 var(--px) 0 #2a8ab8, 0 2px 0 var(--px) rgba(0, 0, 0, 0.35); }
.btn[disabled] { filter: grayscale(0.85) brightness(0.7); cursor: not-allowed; transform: none; }
.btn.ghost { color: var(--text); background: var(--ink-3); box-shadow: 0 0 0 var(--px) #111218, inset 0 calc(-1 * var(--px)) 0 #20212b, inset 0 var(--px) 0 var(--line-2), 0 5px 0 var(--px) rgba(0, 0, 0, 0.3); }
.btn.ghost.danger { color: #ffc0c6; }
.btn.big { padding: 14px 30px; font-size: 34px; }
.btn.hotel { color: #f4e2c0; background: #4a1a20; box-shadow: 0 0 0 var(--px) #111218, inset 0 calc(-1 * var(--px)) 0 #2a0a10, inset 0 var(--px) 0 #8a3a3a, 0 5px 0 var(--px) rgba(0, 0, 0, 0.3); }
.btn.sm { padding: 5px 10px; font-size: 20px; }

/* ------------------------------------------------------------ screens */
#menu-bg { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.screen { position: fixed; inset: 0; display: none; z-index: 2; }
.screen.on { display: flex; }
#screen-boot, #screen-menu, #screen-creator, #screen-help, #screen-settings { align-items: center; justify-content: center; flex-direction: column; padding: 16px; }
#screen-game { z-index: 3; background: #10182e; }
#screen-game.on ~ #menu-bg { display: none; }

.logo { display: flex; flex-direction: column; align-items: center; line-height: 0.95; text-shadow: 0 4px 0 #111218, 0 0 24px rgba(130, 224, 255, 0.35); }
.logo span { font-size: 34px; letter-spacing: 0.35em; color: var(--muted); text-transform: uppercase; }
.logo b { font-size: 60px; color: var(--ice); }
.logo.big span { font-size: clamp(21px, 3.9vw, 34px); }
.logo.big b { font-size: clamp(54px, 11.5vw, 118px); display: flex; }
.logo.big b i { font-style: normal; display: inline-block; animation: wave 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * 0.11s);
    color: var(--ice); text-shadow: 0 -3px 0 #e8fbff, 0 5px 0 #2a6a9a, 0 9px 0 #111218, 0 0 26px rgba(130, 224, 255, 0.45); }
.logo.big b i:nth-child(odd) { color: #a8ecff; }
@keyframes wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
#boot-status { margin: 22px 0 14px; color: var(--muted); font-size: 23px; text-align: center; max-width: 520px; }
#boot-status.error { color: #ffc0c6; }
.loader { width: 220px; height: 12px; background: var(--ink-2); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 var(--px) var(--line); overflow: hidden; }
.loader i { display: block; width: 40%; height: 100%; background: linear-gradient(90deg, var(--ice-2), var(--aurora)); animation: load 1.2s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
body.ready #screen-boot { display: none; }

.menu-card { display: flex; flex-direction: column; align-items: center; gap: 14px; animation: rise 600ms cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(0.96); } }
.tagline { margin: 0; color: var(--muted); font-size: clamp(18px, 2.6vw, 23px); text-align: center; }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; min-width: 260px; }
.menu-buttons .btn { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; background: rgba(36, 38, 50, 0.8); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line); }
.chip img { width: 28px; height: 28px; border-radius: 4px; image-rendering: auto; }
.chip small { color: var(--gold); }
.menu-foot { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: rgba(163, 172, 214, 0.7); font-size: 20px; }

.panel-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px; background: rgba(24, 25, 33, 0.94); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 var(--px) var(--line), 0 18px 40px rgba(0, 0, 0, 0.5); animation: rise 380ms both; }
.panel-card.wide { width: min(860px, 100%); }
.panel-card header, .win header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.help p, .help li { color: #e6e2d6; line-height: 1.45; font-size: 22px; }
.help h3 { margin: 14px 0 6px; color: var(--ice); }
.help .note { color: var(--muted); font-size: 20px; }
.range { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; }
.range input { width: 60%; accent-color: var(--ice); }
.check { display: flex; gap: 10px; align-items: center; margin: 12px 0; }

/* ------------------------------------------------------------ creator */
.creator { display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: start; }
.cr-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0; background: radial-gradient(circle at 50% 70%, #3c3e4e, #20212b 70%); box-shadow: inset 0 0 0 var(--px) var(--line); }
.cr-preview canvas { width: 120px; height: 192px; }
.cr-turn { display: flex; gap: 8px; }
.cr-rows { display: flex; flex-direction: column; gap: 8px; }
.cr-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; }
.cr-row > span { color: var(--muted); font-size: 21px; }
.sw { display: flex; flex-wrap: wrap; gap: 6px; }
.sw button { width: 22px; height: 22px; border: 0; background: var(--c); box-shadow: 0 0 0 2px #111218, inset 0 -3px 0 rgba(0, 0, 0, 0.25); transition: transform 100ms; }
.sw button:hover { transform: translateY(-2px); }
.sw button.on { box-shadow: 0 0 0 2px #111218, 0 0 0 4px var(--ice); }
.arrows { display: flex; align-items: center; gap: 10px; }
.arrows b { min-width: 150px; text-align: center; }
.row-btns { display: flex; gap: 12px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
@media (max-width: 640px) { .creator { grid-template-columns: 1fr; } .cr-preview canvas { width: 90px; height: 144px; } .cr-row { grid-template-columns: 96px 1fr; } .arrows b { min-width: 0; flex: 1; } }

/* ------------------------------------------------------------ game layers */
#game { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
#vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 rgba(255, 30, 60, 0); }
#vignette.hit { animation: hit 450ms ease-out; }
@keyframes hit { 0% { box-shadow: inset 0 0 120px rgba(255, 30, 60, 0.55); } 100% { box-shadow: inset 0 0 0 rgba(255, 30, 60, 0); } }

#hud { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 400ms; }
#hud.on { opacity: 1; }
#hud button, #hud canvas { pointer-events: auto; }
.hud-player { position: absolute; left: 12px; top: 12px; display: flex; gap: 10px; align-items: center; padding: 8px 12px 8px 8px; background: rgba(22, 23, 31, 0.82); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line); }
.hud-face { width: 48px; height: 36px; background: #3c3e4e; box-shadow: inset 0 0 0 2px var(--line-2); }
.hud-bars { display: flex; flex-direction: column; gap: 4px; min-width: 170px; }
.hud-name { display: flex; justify-content: space-between; align-items: center; font-size: 21px; }
.hud-name b { color: #111218; background: var(--gold); padding: 0 6px; font-size: 20px; }
.bar { position: relative; height: 14px; background: #2a1520; box-shadow: 0 0 0 2px #111218; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; transition: width 250ms; }
.bar.hp i { background: linear-gradient(180deg, #ff8a8a, #e8304a 60%, #a8202a); }
.bar.xp { height: 6px; background: #1a1a3a; }
.bar.xp i { background: linear-gradient(90deg, var(--ice-2), var(--aurora)); }
.bar.xp.big { height: 16px; margin: 6px 0; }
.bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; text-shadow: 0 1px 0 #000; }
#hud.low .bar.hp { animation: pulse-red 0.8s infinite; }
@keyframes pulse-red { 50% { box-shadow: 0 0 0 2px #111218, 0 0 12px #ff3a4a; } }
.hud-silver { display: flex; align-items: center; gap: 6px; font-size: 21px; color: #ffe6a0; }
.hud-silver.pulse { animation: pop 300ms; }
@keyframes pop { 50% { transform: scale(1.18); } }
.coin { display: inline-block; width: 12px; height: 12px; background: radial-gradient(circle at 35% 35%, #ffffff, #d8dce8 45%, #8a90a8); box-shadow: 0 0 0 1px #3a3f58; border-radius: 50%; vertical-align: middle; }

.hud-right { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-clock { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: rgba(22, 23, 31, 0.82); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line); }
.hud-clock b { font-size: 26px; }
.hud-clock small { color: var(--muted); max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.minimap { width: 120px; height: 120px; border-radius: 50%; box-shadow: 0 0 0 var(--px) #111218, 0 0 0 6px var(--line), 0 6px 14px rgba(0, 0, 0, 0.4); cursor: pointer; }
.hud-buttons { display: grid; grid-template-columns: repeat(3, 36px); gap: 6px; }
.hud-buttons button { width: 36px; height: 36px; border: 0; font-size: 26px; background: rgba(36, 38, 50, 0.92); box-shadow: 0 0 0 2px #111218, inset 0 -3px 0 #17181f, inset 0 2px 0 var(--line-2); transition: transform 100ms; }
.hud-buttons button:hover { transform: translateY(-2px); }

.hotbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 6px; padding: 6px; background: rgba(22, 23, 31, 0.82); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line); }
.buffs { position: absolute; left: 12px; top: 92px; display: flex; flex-direction: column; gap: 4px; font-size: 20px; }
.buffs span { padding: 3px 8px; background: rgba(22, 23, 31, 0.75); box-shadow: inset 0 0 0 2px var(--line); }

.slot { position: relative; width: 46px; height: 46px; border: 0; padding: 0; background: #20212b; box-shadow: inset 0 0 0 2px #111218, inset 0 0 0 4px var(--ink-3); display: flex; align-items: center; justify-content: center; }
.slot img { width: 32px; height: 32px; pointer-events: none; }
.slot em { position: absolute; right: 3px; bottom: 1px; font-style: normal; font-size: 20px; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; }
.slot small { position: absolute; left: 4px; top: 1px; font-size: 18px; color: var(--muted); }
.slot .upg, .upg { color: var(--gold); font-style: normal; }
.slot .upg { position: absolute; right: 3px; top: 1px; font-size: 18px; text-shadow: 1px 1px 0 #000; }
.slot.has:hover { box-shadow: inset 0 0 0 2px #111218, inset 0 0 0 4px var(--line-2); }
.grid .slot, .eq-col .slot { touch-action: pan-y; -webkit-touch-callout: none; }
.slot.lifted { opacity: 0.45; }
.hint.moving { color: var(--gold); animation: pop 900ms infinite; }
.slot.sel { box-shadow: inset 0 0 0 2px #111218, inset 0 0 0 4px var(--ice); }
.slot.hotrow { background: #2a2c38; }
.slot.eq .lbl { left: 0; right: 0; top: auto; bottom: -15px; text-align: center; font-size: 18px; }
.slot.eq { margin-bottom: 14px; }

/* ------------------------------------------------------------ notifications */
#toasts { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 6; width: min(520px, 90vw); }
.toast { padding: 8px 14px; background: rgba(24, 25, 33, 0.94); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line-2); font-size: 21px; text-align: center; animation: drop 260ms cubic-bezier(.2, .9, .3, 1.3); }
.toast.ok { box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--ok); }
.toast.warn { box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--warn); }
.toast.out { opacity: 0; transform: translateY(-10px); transition: 350ms; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(0.95); } }
#loot { position: absolute; right: 14px; bottom: 90px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; }
.loot-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 6px; background: rgba(22, 23, 31, 0.82); box-shadow: inset 0 0 0 2px var(--line); font-size: 21px; animation: slide 300ms cubic-bezier(.2, .9, .3, 1.2); }
.loot-row img { width: 24px; height: 24px; }
.loot-row .xp-ico { color: var(--aurora); width: 24px; text-align: center; }
.loot-row.out { opacity: 0; transform: translateX(30px); transition: 400ms; }
.loot-row.bump { animation: loot-bump 220ms ease-out; }
@keyframes loot-bump { 40% { transform: scale(1.08); } }
@keyframes slide { from { opacity: 0; transform: translateX(40px); } }
#banner { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; width: min(560px, 92vw); will-change: transform, opacity; contain: layout paint; }
#banner.show { animation: banner 4.2s ease forwards; }
#banner small { color: var(--gold); letter-spacing: 0.2em; font-size: 20px; }
#banner b { display: block; font-size: clamp(36px, 6.5vw, 60px); color: #ffffff; text-shadow: 0 4px 0 #111218, 0 0 6px rgba(130, 224, 255, 0.45); }
#banner p { margin: 6px 0 0; color: #e6e2d6; text-shadow: 0 2px 0 #111218; font-size: 22px; }
/* only opacity and transform: the compositor animates them without relayout or repaint of the text */
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 12px) scale(1.04); } 12%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -8px); } }
.levelup { position: fixed; top: 30%; left: 50%; transform: translateX(-50%); text-align: center; z-index: 9; pointer-events: none; animation: lvl 3.6s ease forwards; }
.levelup small { color: var(--ice); letter-spacing: 0.25em; font-size: 22px; }
.levelup b { display: block; font-size: 109px; color: var(--gold); text-shadow: 0 6px 0 #6a4a10, 0 0 30px rgba(242, 194, 48, 0.7); }
.levelup p { margin: 0; color: #fff; text-shadow: 0 2px 0 #000; }
@keyframes lvl { 0% { opacity: 0; transform: translate(-50%, 20px) scale(0.6); } 10% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 18%, 80% { transform: translate(-50%, 0) scale(1); opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -20px); } }
#death { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: radial-gradient(circle, rgba(60, 10, 30, 0.55), rgba(8, 4, 16, 0.85)); z-index: 8; text-align: center; }
#death.on { display: flex; animation: fade 500ms; }
#death b { font-size: 62px; color: #ff6a7a; text-shadow: 0 4px 0 #2a0a10; }
#death p { color: #f0d8e0; }
#death .lost { color: var(--warn); }
@keyframes fade { from { opacity: 0; } }
#conn { position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%); display: none; gap: 8px; align-items: center; padding: 8px 14px; background: rgba(24, 25, 33, 0.94); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--warn); z-index: 7; }
#conn.on { display: flex; }
.spin { width: 12px; height: 12px; border: 3px solid var(--ice); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#drag-ghost { position: fixed; z-index: 30; pointer-events: none; display: none; transform: translate(-50%, -50%) scale(1.15); }
#drag-ghost.on { display: block; }
#drag-ghost img { width: 40px; height: 40px; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.4)); }

/* ------------------------------------------------------------ windows */
#panel { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; z-index: 10; background: rgba(10, 10, 14, 0.45); padding: 12px; }
#panel.on { display: flex; }
.win { width: min(640px, 100%); max-height: calc(100% - 8px); display: flex; flex-direction: column; background: rgba(26, 27, 35, 0.97); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 var(--px) var(--line), 0 20px 50px rgba(0, 0, 0, 0.55); }
.win.enter { animation: winIn 240ms cubic-bezier(.2, .9, .3, 1.25); }
@keyframes winIn { from { opacity: 0; transform: scale(0.92) translateY(10px); } }
.win header { padding: 12px 14px 0; margin-bottom: 8px; }
.win h2 { font-size: 34px; color: var(--ice); text-shadow: 0 2px 0 #111218; }
.win .x { width: 32px; height: 32px; border: 0; background: var(--ink-3); box-shadow: inset 0 0 0 2px var(--line); font-size: 23px; }
.win-body { padding: 4px 14px 16px; overflow: auto; }
.win.w-bag { width: min(760px, 100%); }
.win.w-wide { width: min(900px, 100%); }
.win.w-small { width: min(460px, 100%); }
.win.w-map { width: min(1180px, 100%); }
.win h3 { margin: 14px 0 8px; color: var(--ice); font-size: 23px; }
.hint { color: var(--muted); font-size: 20px; margin: 8px 0; }

.bag { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.paperdoll { position: relative; display: flex; justify-content: center; padding: 10px 0; background: radial-gradient(circle at 50% 65%, #3c3e4e, #20212b 70%); box-shadow: inset 0 0 0 2px var(--line); min-height: 284px; }
.paperdoll .doll { width: 80px; height: 128px; margin-top: 56px; }
.eq-col { position: absolute; top: 10px; display: flex; flex-direction: column; gap: 2px; }
.eq-col.l { left: 8px; } .eq-col.r { right: 8px; }
.mini-stats { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mini-stats li { display: flex; justify-content: space-between; padding: 4px 8px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); font-size: 20px; }
.mini-stats span { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(8, 46px); gap: 4px; }
.details { margin-top: 8px; padding: 10px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--line); min-height: 86px; }
.details.empty { color: var(--muted); font-size: 20px; display: flex; align-items: center; }
.d-head { display: flex; align-items: center; gap: 10px; }
.d-head img { width: 40px; height: 40px; }
.d-head small { display: block; color: var(--muted); }
.details p { margin: 6px 0 0; font-size: 21px; color: #e6e2d6; }
.d-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
@media (max-width: 720px) { .bag { grid-template-columns: 1fr; } .grid { grid-template-columns: repeat(8, minmax(30px, 1fr)); } .grid .slot { width: auto; aspect-ratio: 1; height: auto; } .slot img { width: 26px; height: 26px; } }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.tab { padding: 6px 10px; border: 0; font-size: 20px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); color: var(--muted); }
.tab.on { color: #111218; background: var(--ice); box-shadow: inset 0 -3px 0 #2a8ab8; }
.wallet { margin-left: auto; display: flex; align-items: center; gap: 6px; color: #ffe6a0; }
.recipes { display: flex; flex-direction: column; gap: 6px; }
/* crafting: groups by material, a "can make" switch and a search */
.gchips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; scrollbar-width: thin; }
.gchip { flex: none; padding: 4px 10px; border: 0; font-size: 18px; color: var(--muted); background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); white-space: nowrap; cursor: pointer; }
.gchip small { color: var(--gold); font-size: 15px; }
.gchip.on { color: #111218; background: var(--gold); box-shadow: inset 0 -3px 0 #a8801a; }
.gchip.on small { color: #3a2a08; }
.craft-tools { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.craft-tools .check { margin: 0; font-size: 18px; }
.craft-q { flex: 1 1 180px; min-width: 0; padding: 6px 10px; font: inherit; font-size: 18px; color: var(--text, #f0ece0); background: #14151c; border: 0; box-shadow: inset 0 0 0 2px var(--ink-3); }
.craft-q { user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.craft-q:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ice); }
.r-group { display: flex; flex-direction: column; gap: 6px; }
.r-group h4 { margin: 8px 0 0; font-size: 18px; color: var(--gold); font-weight: normal; letter-spacing: 0.5px; }
.r-group h4 small { color: var(--muted); font-size: 15px; }
.recipe[hidden], .r-group[hidden] { display: none; }
.recipe { display: grid; grid-template-columns: minmax(170px, 1.2fr) 2fr auto; gap: 10px; align-items: center; padding: 8px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); }
.recipe.ok { box-shadow: inset 0 0 0 2px #3a6a4a; }
.r-out { display: flex; gap: 8px; align-items: center; }
.r-out img { width: 32px; height: 32px; }
.r-out small { display: block; color: var(--muted); font-size: 20px; }
.r-in { display: flex; flex-wrap: wrap; gap: 6px; }
.ing { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px 2px 2px; background: #2a1a2a; box-shadow: inset 0 0 0 1px #5a2a3a; font-size: 20px; color: #ffb0b8; }
.ing.have { background: #18301e; box-shadow: inset 0 0 0 1px #2e5a36; color: #b8f0a8; }
.ing img { width: 20px; height: 20px; }
.r-act { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.warn { color: var(--warn); font-size: 20px; }
@media (max-width: 640px) { .recipe { grid-template-columns: 1fr; } .r-act { justify-content: flex-start; } }

.char-head { display: flex; gap: 14px; align-items: center; }
.char-head .doll { width: 60px; height: 96px; background: radial-gradient(circle at 50% 65%, #3c3e4e, #20212b 70%); box-shadow: inset 0 0 0 2px var(--line); padding: 4px; }
.char-head > div { flex: 1; }
.cname { font-size: 34px; }
.char-head small { display: block; color: var(--muted); }
.pts { margin: 4px 0 0; font-size: 21px; }
.pts b { color: var(--gold); }
.stats { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.stat { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 8px 10px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); }
.stat small { display: block; color: var(--muted); font-size: 20px; }
.stat .val { font-size: 34px; color: var(--ice); min-width: 30px; text-align: right; }
.kills, .top { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.kills li, .top li { display: flex; justify-content: space-between; padding: 4px 8px; background: var(--ink-2); font-size: 20px; }
.tips { padding-left: 18px; margin: 0; color: #e6e2d6; font-size: 21px; line-height: 1.45; }
.board-top { color: var(--muted); }
.board-top b { color: var(--ok); }

.npc-talk { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; padding: 8px; background: #2a2c38; box-shadow: inset 0 0 0 2px var(--line); }
.npc-talk p { margin: 0; color: #e8ecff; font-size: 21px; line-height: 1.4; }
.npc-face { width: 40px; height: 64px; flex-shrink: 0; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.ware { display: grid; grid-template-columns: 32px 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); }
.ware img { width: 32px; height: 32px; }
.ware small { display: flex; align-items: center; gap: 4px; color: #ffe6a0; }
.sell { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.sell-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 8px; align-items: center; padding: 4px 8px 4px 4px; background: var(--ink-2); }
.sell-row small { display: flex; gap: 4px; align-items: center; color: #ffe6a0; }

.wardrobe { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.wardrobe .creator { grid-template-columns: 140px 1fr; }
.wardrobe .cr-preview canvas { width: 90px; height: 144px; }
.wardrobe .cr-row { grid-template-columns: 110px 1fr; }
.hats { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.hat { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 0; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); font-size: 20px; }
.hat canvas { width: 50px; height: 45px; }
.hat small { color: #ffe6a0; display: flex; gap: 4px; align-items: center; }
.hat.owned small { color: var(--ok); }
.hat.locked { opacity: 0.65; }
@media (max-width: 820px) { .wardrobe { grid-template-columns: 1fr; } }

.worldmap { display: grid; grid-template-columns: 1fr 230px; gap: 14px; }
/* the world map: a window onto the relief that zooms and drags */
.map-view { position: relative; height: min(68vh, calc(100vh - 210px)); min-height: 260px; overflow: hidden; background: #16314a; box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line); touch-action: none; }
.map-view canvas { display: block; width: 100%; height: 100%; cursor: grab; image-rendering: pixelated; touch-action: none; }
.map-view canvas:active { cursor: grabbing; }
.map-tools { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.map-tools .pxb { width: 38px; height: 38px; font-size: 22px; display: grid; place-items: center; }
.map-help { position: absolute; left: 8px; bottom: 6px; right: 56px; font-size: 14px; color: rgba(255, 255, 255, 0.7); text-shadow: 0 1px 0 #000; pointer-events: none; }
.map-pop { position: absolute; z-index: 2; min-width: 200px; max-width: min(300px, calc(100% - 12px)); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: rgba(18, 19, 25, 0.96); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line-2), 0 6px 0 rgba(0, 0, 0, 0.35); font-size: 17px; }
.map-pop[hidden] { display: none; }
.map-pop b { color: var(--ice); font-size: 19px; }
.map-pop small { color: var(--muted); font-size: 15px; }
.map-pop .hint { margin: 0; font-size: 15px; }
.map-pop .pop-note { color: var(--gold); }
.pop-land { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 16px; }
.pop-land i { width: 12px; height: 12px; box-shadow: 0 0 0 2px #111218; }
.pop-land small { color: var(--gold) !important; }
.map-pop .pop-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pop-name { padding: 5px 8px; font: inherit; font-size: 17px; color: var(--text); background: #14151c; border: 0; box-shadow: inset 0 0 0 2px var(--ink-3); user-select: text; -webkit-user-select: text; }
.pop-name:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ice); }
.map-side h3 { margin: 0 0 6px; font-size: 21px; color: var(--ice); }
.marks { display: flex; flex-direction: column; gap: 4px; max-height: 32vh; overflow-y: auto; margin-bottom: 10px; }
.marks small { color: var(--muted); font-size: 15px; }
.mark-row { display: flex; gap: 4px; }
.mark-row button { border: 0; font: inherit; font-size: 17px; color: var(--text); background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); cursor: pointer; }
.mark-go { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 4px 8px; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mark-go i { flex: none; width: 10px; height: 10px; background: #ffb347; border-radius: 50%; }
.mark-row.on .mark-go i { background: #ff6a3a; }
.mark-t { width: 34px; color: #ffb347 !important; }
.legend-box summary { cursor: pointer; font-size: 19px; color: var(--muted); margin-bottom: 6px; }
.hud-target { position: absolute; left: 50%; top: calc(var(--st, 10px) + 6px); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 6px; border: 0; font: inherit; font-size: 17px; color: #ffe0b0; background: rgba(22, 23, 31, 0.82); box-shadow: inset 0 0 0 2px #7a5a2a; cursor: pointer; pointer-events: auto; max-width: 46vw; }
.hud-target i { font-style: normal; color: #ff8a3a; display: inline-block; transition: transform 200ms; }
.hud-target b { font-weight: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-target[hidden] { display: none; }
html.touch .hud-target { left: auto; right: var(--sr); transform: none; font-size: 15px; max-width: 42vw; }
@media (max-width: 720px) { .map-view { height: 56vh; } .marks { max-height: 20vh; } }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 20px; }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 14px; height: 14px; box-shadow: 0 0 0 2px #111218; }
.legend small { color: var(--gold); margin-left: auto; }
@media (max-width: 720px) { .worldmap { grid-template-columns: 1fr; } }

.emotes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.emotes button { font-size: 36px; padding: 12px; border: 0; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); transition: transform 100ms; }
.emotes button:hover { transform: scale(1.12); }
.keys p { color: #e6e2d6; font-size: 21px; line-height: 1.5; }

/* ------------------------------------------------------------ touch */
#touch { position: absolute; inset: auto 0 0 0; height: 0; display: none; }
#touch.on { display: block; }
.joy { position: absolute; left: 22px; bottom: 26px; width: 132px; height: 132px; border-radius: 50%; background: rgba(36, 38, 50, 0.45); box-shadow: inset 0 0 0 3px rgba(130, 224, 255, 0.35); touch-action: none; }
.joy i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(130, 224, 255, 0.55); box-shadow: 0 0 0 3px #111218; }
.tbtns { position: absolute; right: 18px; bottom: 26px; display: grid; grid-template-columns: 72px 56px; grid-template-rows: 56px 56px; gap: 10px; }
.tbtns button { border: 0; border-radius: 50%; font-size: 31px; background: rgba(36, 38, 50, 0.7); box-shadow: 0 0 0 3px #111218, inset 0 0 0 3px var(--line-2); touch-action: none; }
.tbtns [data-act="atk"] { grid-row: span 2; width: 72px; height: 72px; align-self: center; font-size: 39px; background: rgba(232, 72, 74, 0.6); }
.tbtns [data-act="use"].ready { background: rgba(122, 224, 90, 0.7); animation: pop 900ms infinite; }

#ask { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: rgba(10, 10, 14, 0.55); padding: 16px; }
#ask.on { display: flex; }
#ask p { font-size: 23px; line-height: 1.4; }
#debug { position: absolute; right: 12px; bottom: 12px; z-index: 6; padding: 4px 8px; font-size: 20px; background: rgba(22, 23, 31, 0.85); box-shadow: inset 0 0 0 2px var(--line); pointer-events: none; }

/* ---- v2: quest tracker, Silent's dialogue, farm, pets, waystones, fishing ---- */
.quest-track { position: absolute; left: 12px; top: 105px; width: 250px; text-align: left; display: grid; gap: 2px; padding: 7px 10px 9px; color: #fff; font: inherit; cursor: pointer; background: rgba(22, 23, 31, 0.82); border: 0; box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line); position: absolute; overflow: hidden; }
.quest-track small { color: var(--ice); font-size: 17px; letter-spacing: 0.08em; }
.quest-track b { font-size: 21px; color: var(--gold); }
.quest-track span { font-size: 18px; color: #e6e2d6; }
.quest-track i { position: absolute; left: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, #7ae05a, #f2c230); transition: width 0.4s; }
.quest-track:hover { box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--gold); }
.quest-track.done b { color: #7ae05a; font-size: 18px; }
.buffs { top: 176px; }
.levelup.quest { top: 9%; z-index: 30; }
.levelup.quest b { font-size: 60px; color: #9fe8ff; text-shadow: 0 4px 0 #1a3a6a, 0 0 24px rgba(140, 216, 255, 0.6); }
#fish-hint { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 7; padding: 10px 18px; font-size: 29px; color: #1a1020; background: #ffd23a; box-shadow: 0 0 0 4px #1a1020, 0 6px 0 4px #8a6a10; pointer-events: none; animation: bob 0.35s ease-in-out infinite alternate; }
@keyframes bob { from { transform: translate(-50%, 0); } to { transform: translate(-50%, -6px); } }
.silent { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: start; }
.silent-face { background: radial-gradient(circle at 50% 40%, #2c3d8a, #141a44); box-shadow: inset 0 0 0 2px var(--line); padding: 10px; display: grid; place-items: center; }
.silent-face canvas { width: 120px; height: 192px; image-rendering: pixelated; }
.silent-talk .say { min-height: 84px; margin: 0 0 10px; padding: 10px 12px; font-size: 22px; line-height: 1.45; color: #f0f4ff; background: #2a2c38; box-shadow: inset 0 0 0 2px var(--line); position: relative; }
.silent-talk .say::before { content: ''; position: absolute; left: -10px; top: 20px; border: 6px solid transparent; border-right: 6px solid var(--line); }
.quest-box { padding: 10px 12px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--gold); display: grid; gap: 6px; margin-bottom: 10px; }
.quest-box small { color: var(--ice); }
.quest-box b { color: var(--gold); font-size: 25px; }
.quest-box p { margin: 0; color: #e8ecff; line-height: 1.4; }
.quest-box .reward { color: #ffe6a0; }
.quest-box.done { box-shadow: inset 0 0 0 2px #7ae05a; }
.topics { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 640px) { .silent { grid-template-columns: 1fr; } .silent-face canvas { width: 60px; height: 96px; } }
.journal { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.journal li { padding: 8px 10px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); }
.journal li p { margin: 4px 0 0; font-size: 20px; color: #e6e2d6; }
.journal li span { float: right; color: var(--gold); }
.journal li.done b { color: #7ae05a; }
.journal li.now { box-shadow: inset 0 0 0 2px var(--gold); }
.journal li.later { opacity: 0.55; }
.farm { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.plot { padding: 8px; display: grid; gap: 5px; justify-items: center; text-align: center; background: linear-gradient(#3a2414, #2a180c); box-shadow: inset 0 0 0 2px #6a4426; }
.plot img { width: 32px; height: 32px; image-rendering: pixelated; }
.plot.ripe { box-shadow: inset 0 0 0 2px #7ae05a, 0 0 12px rgba(122, 224, 90, 0.35); }
.plot .bar { width: 100%; }
.plot small { color: #e8dcc0; }
.seed-pick { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.seed-pick .slot { width: 36px; height: 36px; }
.pet-card { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px; margin-bottom: 6px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); }
.pet-card.on { box-shadow: inset 0 0 0 2px var(--gold); }
.pet-card canvas, .pet-ware canvas { width: 56px; height: 49px; image-rendering: pixelated; }
.pet-card b small { color: var(--gold); }
.pet-card > div > small { display: block; color: #e6e2d6; font-size: 18px; margin: 2px 0 4px; }
.pet-btns { display: flex; gap: 4px; }
.pet-ware { grid-template-columns: 56px 1fr auto; grid-column: 1 / -1; }
.pet-ware small { color: #e6e2d6 !important; }
.way-dot { width: 14px; height: 14px; margin: 0 9px; background: #8ad8ff; box-shadow: 0 0 10px #8ad8ff; transform: rotate(45deg); }


/* ---- chat and players online ---- */
.chat { position: absolute; left: 12px; bottom: 14px; width: min(400px, 36vw); display: flex; flex-direction: column; gap: 6px; z-index: 5; pointer-events: none; }
.chat-log { max-height: 190px; overflow: hidden; display: flex; flex-direction: column; gap: 2px; font-size: 20px; line-height: 1.3; }
.chat-line { padding: 2px 8px; background: rgba(22, 23, 31, 0.62); text-shadow: 0 1px 0 #000; overflow-wrap: anywhere; transition: opacity 600ms; }
.chat-line b { color: #ffd36a; font-weight: normal; }
.chat-line.mine b { color: #9fe8ff; }
.chat-line.sys { color: #b8c0e0; font-style: italic; }
.chat-line.sys.join b { color: #7ae05a; }
.chat-line.sys.leave b { color: #c8a0a0; }
.chat-line.old { opacity: 0; }
.chat-input { display: none; gap: 6px; }
.chat-input input { flex: 1; min-width: 0; padding: 7px 10px; font: inherit; font-size: 21px; color: #fff; background: rgba(22, 23, 31, 0.92); border: 0; outline: 0; box-shadow: inset 0 0 0 2px var(--ice); }
.chat-input button { width: 38px; border: 0; color: #111218; font-size: 21px; background: var(--ice); cursor: pointer; }
.chat.open { pointer-events: auto; }
.chat.open .chat-input { display: flex; }
.chat.open .chat-log { overflow-y: auto; max-height: 240px; padding-right: 4px; }
.chat.open .chat-line.old { opacity: 1; }
.online-list { grid-column: 1 / -1; margin-top: 10px; }
.online-list h3 { margin: 0 0 6px; font-size: 21px; color: var(--ice); }
.online-list small { color: var(--muted); }
.online-names { display: flex; flex-wrap: wrap; gap: 6px; }
.online-names span { padding: 3px 8px; font-size: 20px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); }
.online-names b { color: var(--gold); font-weight: normal; }

/* ================================================================ HUD v3: pixel buttons and safe layout
   Safe areas: phone notches (env) and the buttons Discord draws over the top of the Activity on phones
   (the whole top bar in portrait, the "Leave" button at the top right in landscape). */
:root {
    --sl: max(8px, env(safe-area-inset-left)); --sr: max(8px, env(safe-area-inset-right));
    --st: max(8px, env(safe-area-inset-top)); --sb: max(8px, env(safe-area-inset-bottom));
    --dl: 0px; --dr: 0px;    /* extra room under Discord's own buttons: left and right halves of the top edge */
}
html.in-discord.touch { --dl: 52px; --dr: 52px; }
/* landscape: Discord keeps a strip with its "Leave" button along the right edge, the whole height */
@media (orientation: landscape) {
    html.in-discord.touch { --dl: 0px; --dr: 0px;
        --sr: calc(max(8px, env(safe-area-inset-right)) + 64px); --sl: calc(max(8px, env(safe-area-inset-left)) + 12px); }
}

.pxb { position: relative; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; background: #262836;
    box-shadow: 0 0 0 2px #111218, inset -3px -3px 0 #17181f, inset 3px 3px 0 #6c6e86; transition: transform 80ms, filter 80ms; touch-action: manipulation; }
.pxb:hover { filter: brightness(1.15); }
.pxb:active { transform: translateY(2px); box-shadow: 0 0 0 2px #111218, inset 3px 3px 0 #17181f, inset -3px -3px 0 #2a3670; }
.pxi { width: 28px; height: 28px; pointer-events: none; }
.only-compact { display: none !important; }

.hud-player { left: var(--sl); top: calc(var(--st) + var(--dl)); }
.quest-track { left: var(--sl); top: calc(var(--st) + var(--dl) + 107px); bottom: auto; }
.buffs { left: var(--sl); top: calc(var(--st) + var(--dl) + 178px); }
.hud-right { right: var(--sr); top: calc(var(--st) + var(--dr)); }
.hud-buttons { grid-template-columns: repeat(3, 40px); gap: 6px; }
.hud-buttons button.pxb { width: 40px; height: 40px; font-size: 0; background: #262836; }
.hotbar { bottom: var(--sb); }
#toasts { top: calc(var(--st) + max(var(--dl), var(--dr)) + 6px); }
#panel { padding: calc(var(--st) + max(var(--dl), var(--dr))) var(--sr) var(--sb) var(--sl); }
.chat { left: var(--sl); bottom: calc(var(--sb) + 4px); width: clamp(220px, calc(50vw - 240px), 400px); }
#debug { right: var(--sr); bottom: var(--sb); }

.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.menu-grid .pxb.tile { width: auto; height: auto; padding: 12px 6px 10px; display: flex; flex-direction: column; gap: 6px; font-size: 20px; }
.menu-grid .pxi { width: 42px; height: 42px; }

/* narrow desktop windows: chat above the hotbar */
@media (max-width: 900px) { html:not(.touch) .chat { bottom: 86px; width: min(400px, calc(100vw - 24px)); } }

/* ---- phones and tablets */
html.touch .joy { left: calc(var(--sl) + 8px); bottom: calc(var(--sb) + 8px); width: 124px; height: 124px; border-radius: 0;
    background: rgba(36, 38, 50, 0.42); box-shadow: 0 0 0 3px rgba(22, 23, 31, 0.8), inset 0 0 0 3px rgba(130, 224, 255, 0.35); }
html.touch .joy i { width: 52px; height: 52px; margin: -26px; border-radius: 0; background: rgba(130, 224, 255, 0.6); box-shadow: 0 0 0 3px #111218, inset -4px -4px 0 rgba(30, 80, 120, 0.6), inset 4px 4px 0 rgba(230, 250, 255, 0.6); }
html.touch .tbtns { right: calc(var(--sr) + 6px); bottom: calc(var(--sb) + 6px); grid-template-columns: 76px 54px; grid-template-rows: 54px 54px; gap: 10px; }
html.touch .tbtns .pxb { width: 54px; height: 54px; border-radius: 0; background: rgba(38, 40, 52, 0.88); }
html.touch .tbtns .pxb.big { grid-row: span 2; width: 76px; height: 76px; align-self: center; background: rgba(176, 52, 60, 0.9);
    box-shadow: 0 0 0 2px #111218, inset -4px -4px 0 #6a1a24, inset 4px 4px 0 #ff8a8a; }
html.touch .tbtns .pxb.big .pxi { width: 42px; height: 42px; }
html.touch .tbtns [data-act="use"].ready { background: rgba(70, 160, 60, 0.92); animation: pop 900ms infinite; }
html.touch .hud-player { transform: scale(0.8); transform-origin: top left; }
html.touch .quest-track { top: calc(var(--st) + var(--dl) + 89px); width: 210px; padding: 5px 8px 7px; }
html.touch .quest-track small, html.touch .quest-track span { font-size: 16px; }
html.touch .quest-track b { font-size: 18px; }
html.touch .buffs { top: calc(var(--st) + var(--dl) + 148px); font-size: 17px; }
html.touch .hud-clock { padding: 4px 8px; }
html.touch .hud-clock b { font-size: 21px; }
html.touch .hud-clock small { display: none; }
html.touch .minimap { width: 96px; height: 96px; }
html.touch .hud-buttons { grid-template-columns: repeat(3, 38px); gap: 6px; }
html.touch .hud-buttons button.pxb { width: 38px; height: 38px; }
html.touch .hud-buttons [data-open="inventory"] { display: none; }   /* the bag has its own big button */
html.touch #loot { right: var(--sr); bottom: calc(var(--sb) + 150px); }
html.touch #conn { bottom: calc(var(--sb) + 150px); }

/* portrait phone: hotbar and chat above the controls */
@media (orientation: portrait) {
    html.touch .hotbar { bottom: calc(var(--sb) + 146px); transform: translateX(-50%); padding: 4px; gap: 4px; }
    html.touch .hotbar .slot { width: 38px; height: 38px; }
    html.touch .chat { left: var(--sl); bottom: calc(var(--sb) + 200px); width: min(330px, calc(100vw - 24px)); }
    html.touch .chat-log { max-height: 84px; font-size: 17px; }
    html.touch #loot { bottom: calc(var(--sb) + 200px); }
}
/* landscape phone (short screen): hotbar between the controls, compact menu */
@media (orientation: landscape) {
    html.touch .hotbar { left: calc(50% + (var(--sl) - var(--sr)) / 2); bottom: var(--sb); transform: translateX(-50%); padding: 4px; gap: 4px; }
    html.touch .hotbar .slot { width: min(40px, calc((100vw - 400px - var(--sl) - var(--sr)) / 8 - 4px)); height: min(40px, calc((100vw - 400px - var(--sl) - var(--sr)) / 8 - 4px)); }
    html.touch .chat { left: calc(50% + (var(--sl) - var(--sr)) / 2); transform: translateX(-50%); bottom: calc(var(--sb) + 52px); width: min(420px, calc(100vw - 420px - var(--sl) - var(--sr))); }
    html.touch .chat-log { max-height: 66px; font-size: 17px; }
    html.touch #loot { right: calc(var(--sr) + 160px); bottom: calc(var(--sb) + 56px); }
}
@media (orientation: landscape) and (max-height: 560px) {
    html.touch .hud-right { flex-direction: row-reverse; align-items: flex-start; gap: 6px; }
    html.touch .hud-right > .hud-clock { position: absolute; right: 0; top: calc(100% + 6px); }
    html.touch .minimap { width: 78px; height: 78px; }
    html.touch .hud-buttons { grid-template-columns: 38px; }
    html.touch .hud-buttons button.pxb { display: none; }
    html.touch .hud-buttons button.pxb[data-chat], html.touch .hud-buttons button.pxb[data-open="map"] { display: grid; }
    html.touch .hud-buttons .only-compact { display: grid !important; }
    html.touch .quest-track { width: 190px; }
    html.touch .buffs { display: none; }
}
html.touch .chat.open { left: var(--sl); right: var(--sr); transform: none; top: calc(var(--st) + max(var(--dl), var(--dr))); bottom: auto; width: auto; z-index: 20; }
html.touch .chat.open .chat-log { max-height: 30vh; }
@media (orientation: landscape) and (max-height: 560px) {
    .menu-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
    .menu-grid .pxb.tile { padding: 8px 4px 6px; font-size: 17px; }
    .menu-grid .pxi { width: 32px; height: 32px; }
}

/* ================================================================ v4: satiety, wear, shield, storage, Silent's inspector */
.bar.sat { height: 6px; background: #2a2210; }
.bar.sat i { background: linear-gradient(90deg, #c8802a, #f2c230); }
.bar.sat.low i { background: linear-gradient(90deg, #a83a2a, #e86a3a); animation: pulse-red 1s infinite; }
.bar.stam { height: 5px; background: #10222a; }
.bar.stam i { background: linear-gradient(90deg, #4ab8e8, #bfe9ff); transition: width 0.08s linear; }
.bar.stam.short i { background: linear-gradient(90deg, #3a6a88, #6a9ab8); }
.bar.stam.flash { animation: stam-flash 0.45s; }
@keyframes stam-flash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 2px #e86a3a; } }
.altar-item { width: 100%; text-align: left; cursor: pointer; border: 0; font: inherit; color: inherit; grid-template-columns: 1fr; }
.altar-item.sel { box-shadow: inset 0 0 0 2px #b89aff; }
.echo-dot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 10px currentColor; flex: none; }
.ing-ico { width: 18px; height: 18px; vertical-align: middle; image-rendering: pixelated; }
.lands li.mastery .bar.xp { margin: 4px 0; }
.lands li.mastery .m-lvl { color: var(--gold); float: right; }
.slot .dur { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; background: #1a1020; pointer-events: none; }
.slot .dur i { display: block; height: 100%; background: #7ae05a; }
.slot .dur.low i { background: #f2c230; }
.slot .dur.zero { background: #a8202a; }
.slot.broken img { filter: grayscale(1) brightness(0.6); }
.bar.dur-bar { width: 100%; height: 8px; }
.bar.dur-bar i { background: linear-gradient(90deg, #f2c230, #7ae05a); }
.sat-note { color: var(--warn); font-style: normal; }
.bank-grid { max-height: 38vh; overflow-y: auto; padding-right: 4px; }
.inspect { margin-top: 12px; }
.inspect h3 { margin-top: 4px; }
.inspect-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.inspect-row .hint { margin: 0; }
.slot.inspect-cell { width: 56px; height: 56px; flex-shrink: 0; box-shadow: inset 0 0 0 2px #111218, inset 0 0 0 4px var(--gold); background: #2a2c38; }
.inspect-grid { grid-template-columns: repeat(auto-fill, 46px); max-height: 150px; overflow-y: auto; }
html.touch .tbtns { grid-template-columns: 54px 76px 54px; }
html.touch .tbtns .pxb.blk { grid-column: 1; grid-row: 2; }
html.touch .tbtns .pxb.big { grid-column: 2; grid-row: 1 / span 2; }
html.touch .tbtns [data-act="use"] { grid-column: 3; grid-row: 1; }
html.touch .tbtns [data-act="bag"] { grid-column: 3; grid-row: 2; }
html.touch .tbtns .pxb.blk.off { display: none; }
html.touch .tbtns .pxb.dash { grid-column: 1; grid-row: 1; background: rgba(40, 90, 120, 0.9); }
.tbtns .pxb.blk:active { background: rgba(90, 140, 220, 0.95); }
/* phones: small rows in the right column under the minimap, never over the hero in the middle of the screen */
html.touch #loot { top: calc(var(--st) + var(--dr) + 176px); bottom: auto; right: var(--sr); max-width: 42vw; gap: 3px; }
html.touch .loot-row { font-size: 15px; padding: 2px 8px 2px 4px; gap: 5px; max-width: 100%; }
html.touch .loot-row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.touch .loot-row img { width: 18px; height: 18px; }
html.touch .loot-row .xp-ico { width: 18px; }
@media (orientation: landscape) { html.touch #loot { top: calc(var(--st) + var(--dr) + 112px); max-width: 30vw; } }
@media (orientation: landscape) and (max-height: 560px) { html.touch #loot { top: calc(var(--st) + var(--dr) + 92px); right: calc(var(--sr) + 50px); } }

/* v4: daily bounties on the village board */
.bounties { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.bounty { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 4px; }
.bounty > div { flex: 1; min-width: 0; }
.bounty b { display: block; }
.bounty small { display: block; opacity: 0.75; margin: 1px 0 4px; }
.bounty .bar { position: relative; height: 14px; background: #1a1428; border: 1px solid #000; }
.bounty .bar i { position: absolute; inset: 0 auto 0 0; background: #c89a2a; }
.bounty .bar span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 14px; }
.bounty.done { opacity: 0.6; }
.bounty em { color: #7ae05a; font-style: normal; white-space: nowrap; }

/* ------------------------------------------------------------ concept-style rounding */
.hotbar { border-radius: 12px; }
.slot { border-radius: 7px; }
.hud-player, .hud-clock, .hud-quest, .quest-btn, .win, .toast, .hud-buttons button, .chat-box { border-radius: 10px; }

/* ------------------------------------------------------------ progression: climate, hints, the Book of the Wanderer */
.clim { position: absolute; left: 50%; bottom: calc(var(--sb, 0px) + 92px); transform: translateX(-50%); padding: 5px 12px; font-size: 20px; color: #e8f4ff; background: rgba(22, 23, 31, 0.84); box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px var(--line); border-radius: 10px; pointer-events: none; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
.clim:not(.on) { display: none; }
.clim.cold { box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px #7ad8ff; }
.clim.heat { box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px #ff8a3a; }
.clim.bad { color: #ffd0c0; animation: clim-pulse 1.2s ease-in-out infinite; }
@keyframes clim-pulse { 50% { background: rgba(90, 20, 20, 0.9); } }
html.touch .clim { font-size: 15px; padding: 3px 9px; bottom: calc(var(--sb, 0px) + 202px); }
#screen-game::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.2s; z-index: 4; }
#screen-game.bite-cold::after { opacity: 1; background: radial-gradient(ellipse at center, transparent 55%, rgba(170, 220, 255, 0.45) 100%); }
#screen-game.bite-heat::after { opacity: 1; background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 110, 40, 0.38) 100%); }
.toast.hint { box-shadow: 0 0 0 var(--px) #111218, inset 0 0 0 2px #c9a2ff; color: #efe4ff; max-width: min(560px, calc(100vw - 32px)); }
.chat-line.hint { color: #d8c4ff; font-style: italic; }
.chat-line.hint.old { opacity: 0; }
.quest-track .qt-story { font-style: normal; font-size: 17px; color: #d8c4ff; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 3px; margin-top: 2px; }
.levelup.story small { color: #d8c4ff; }
.book-tabs { position: sticky; top: -2px; z-index: 2; background: var(--ink, #16171f); padding-bottom: 6px; }
.book .chapter { margin-bottom: 12px; }
.book .chapter h3 { margin: 6px 0; color: var(--gold); }
.book .chapter h3 small { color: var(--muted); font-size: 17px; }
.book .chapter.done h3 { color: var(--ok); }
.book .chapter.closed { opacity: 0.6; }
.book .journal li.locked { opacity: 0.75; }
.book .journal li .bar { margin-top: 6px; }
.book .soft, .lands .soft { color: var(--muted); font-size: 17px; }
.world-state { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 10px; margin-bottom: 10px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); font-size: 19px; border-radius: 8px; }
.world-state .ok, .lands .ok { color: var(--ok); }
.guide .g-top { display: grid; gap: 6px; margin-bottom: 8px; }
.guide input[type=search] { font: inherit; font-size: 20px; padding: 6px 10px; background: var(--ink-2); color: #fff; border: 0; box-shadow: inset 0 0 0 2px var(--ink-3); border-radius: 8px; }
.guide .g-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.guide .g-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 10px; }
.guide .g-list { display: grid; gap: 3px; max-height: 52vh; overflow-y: auto; align-content: start; }
.guide .g-item { display: flex; align-items: center; gap: 8px; padding: 3px 6px; font: inherit; font-size: 19px; color: #e6e2d6; text-align: left; background: var(--ink-2); border: 0; box-shadow: inset 0 0 0 2px var(--ink-3); border-radius: 6px; cursor: pointer; }
.guide .g-item img { width: 28px; height: 28px; image-rendering: pixelated; }
.guide .g-item.sel { box-shadow: inset 0 0 0 2px var(--gold); }
.guide .g-info { max-height: 52vh; overflow-y: auto; padding: 4px 8px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); border-radius: 8px; }
.guide .g-info h4 { margin: 8px 0 4px; color: var(--ice); }
.guide .g-src { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 18px; }
.guide .g-src small { font-size: 16px; color: var(--muted); }
.lands { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.lands li { padding: 6px 9px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--ink-3); border-radius: 8px; opacity: 0.7; }
.lands li.seen { opacity: 1; }
.lands li b { display: block; }
.lands li small { color: var(--gold); font-size: 16px; }
.lands li p { margin: 3px 0 0; font-size: 17px; }
.lands .cold { color: #9fe0ff; }
.lands .heat { color: #ffa060; }
@media (max-width: 640px) {
    .guide .g-body { grid-template-columns: 1fr; }
    .guide .g-list { max-height: 30vh; }
    .guide .g-info { max-height: none; }
}

/* ------------------------------------------------------------ Alex, the AI companion */
.chat-line.ai b { color: #d8b4ff; }
.chat-line .ai-tag { font-style: normal; font-size: 0.75em; padding: 0 4px; margin-right: 5px; color: #f0e4ff; background: rgba(90, 40, 150, 0.85); border-radius: 4px; }

/* ---- talking with the people of the dream (lore.py) */
.w-talk { width: min(720px, 96vw); }
.talk { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: stretch; }
.talk-face { background: radial-gradient(circle at 50% 45%, #3a3e5a, #171a2c 75%); box-shadow: inset 0 0 0 2px var(--line); padding: 8px; display: grid; place-items: center; }
.talk-face canvas { width: 100px; height: 160px; image-rendering: pixelated; }
.talk.story .talk-face { box-shadow: inset 0 0 0 2px var(--gold); }
.talk-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.talk-line { margin: 0; flex: 1; color: #eef1ff; font-size: 22px; line-height: 1.45; padding: 10px 12px; background: var(--ink-2); box-shadow: inset 0 0 0 2px var(--line); }
.talk-nav { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.talk-nav small { margin-right: auto; color: var(--ice); }
.lore-note { margin: 0; color: #ffe6a0; font-size: 19px; }
.win header h2 small { font-size: 0.62em; color: var(--ice); margin-left: 6px; }
.npc-talk .talk-btn { margin-left: auto; flex: none; }
.journal.lore li.done p { color: #dfe4ff; }
@media (max-width: 560px) {
  .talk { grid-template-columns: 1fr; }
  .talk-face canvas { width: 70px; height: 112px; }
  .talk-line { font-size: 20px; }
}

/* ---- the guardians of the memories (bosses.py) */
.boss-bar { position: absolute; left: 50%; top: calc(var(--safe-top, 0px) + 10px); transform: translate(-50%, -140%); width: min(560px, 70vw); z-index: 30;
  padding: 6px 10px 8px; background: rgba(16, 12, 26, 0.88); box-shadow: inset 0 0 0 2px #6a4aa8, 0 4px 0 rgba(0,0,0,0.35); transition: transform .35s ease; pointer-events: none; }
.boss-bar.on { transform: translate(-50%, 0); }
.boss-bar .bb-name { display: flex; align-items: baseline; gap: 8px; justify-content: center; }
.boss-bar .bb-name b { color: #e8d8ff; font-size: 24px; }
.boss-bar .bb-name small { color: #b8a8d8; font-size: 17px; }
.boss-bar .bb-track { height: 10px; margin-top: 4px; background: #3a1424; box-shadow: inset 0 0 0 2px #1a0a12; }
.boss-bar .bb-track span { display: block; height: 100%; background: linear-gradient(#ff6a8a, #c8244a); transition: width .25s; }
.boss-bar.shield .bb-track span { background: linear-gradient(#e8d8ff, #9a7ae8); }
.boss-bar .bb-pips { display: flex; gap: 5px; justify-content: center; margin-top: 4px; }
.boss-bar .bb-pips i { width: 10px; height: 10px; transform: rotate(45deg); background: #2a2238; box-shadow: inset 0 0 0 2px #6a4aa8; }
.boss-bar .bb-pips i.on { background: #c8a0ff; }
.boss-say { position: absolute; left: 50%; top: calc(var(--safe-top, 0px) + 96px); transform: translateX(-50%); width: min(620px, 86vw); text-align: center; z-index: 31;
  opacity: 0; transition: opacity .35s; pointer-events: none; text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,0,0,0.8); }
.boss-say.show { opacity: 1; }
.boss-say b { display: block; color: #c8a0ff; font-size: 20px; letter-spacing: 1px; }
.boss-say p { margin: 2px 0 0; color: #fff; font-size: 26px; line-height: 1.3; font-style: italic; }
.ending-choices { display: grid; gap: 8px; margin: 8px 0; }
.ending-choices .btn { font-size: 22px; padding: 10px; }
.epilogue { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px;
  background: radial-gradient(circle at 50% 40%, #1a1830, #05050a 75%); animation: ep-in 1.2s ease; }
.epilogue.out { opacity: 0; transition: opacity .9s; }
@keyframes ep-in { from { opacity: 0; } to { opacity: 1; } }
.epilogue .ep-page { max-width: 760px; text-align: center; }
.epilogue.turn .ep-page { animation: ep-in 1s ease; }
.epilogue .ep-page p { color: #eef0ff; font-size: 28px; line-height: 1.5; margin: 0; }
.epilogue .ep-end h1 { color: #f2c230; font-size: 64px; margin: 0; letter-spacing: 6px; }
.epilogue .ep-end h2 { color: #c8b8ff; font-size: 28px; margin: 4px 0 18px; font-weight: 500; }
.epilogue .ep-title { font-size: 24px !important; }
.epilogue .ep-title b { color: #f2c230; }
.epilogue .ep-stats { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 22px; color: #b8bcd8; font-size: 21px; }
.epilogue .ep-stats b { color: #fff; }
@media (max-width: 560px) {
  .boss-bar .bb-name b { font-size: 20px; }
  .boss-say p { font-size: 21px; }
  .epilogue .ep-page p { font-size: 22px; }
  .epilogue .ep-end h1 { font-size: 46px; }
  .epilogue .ep-stats { grid-template-columns: 1fr; }
}

/* inside Discord, before it is known which game the Activity opens: a plain dark screen, nothing of Adventure */
body.discord-boot { background: #050406; }
body.discord-boot #menu-bg { display: none; }
body.discord-boot #screen-boot { background: #050406; }
.logo b.neutral { font-size: 44px; color: #8a8478; letter-spacing: 0.3em; text-transform: uppercase; }
