@font-face { font-family: 'Pixelify Sans'; src: url('/assets/fonts/pixelify-latin.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  --ink: #3f2631; --ink2: #5b3a45; --cream: #fdf0d0; --cream2: #f1dcae; --cream3: #e6c88e;
  --wood: #bd6c4a; --wood-d: #8a4a35; --green: #6dbb5a; --green-d: #3f8a3f; --gold: #f7c948; --gold-d: #b8862b;
  --red: #d8453b; --blue: #4f8ad8; --sky: #bfe9ff;
  --font: 'Pixelify Sans', ui-monospace, 'Courier New', monospace;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2e5a3a; font-family: var(--font); color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; cursor: crosshair; }
img, canvas { image-rendering: pixelated; }
[hidden] { display: none !important; }
button, input { font-family: inherit; }

/* ---------- panels & buttons ---------- */
.panel { background: var(--cream); border: 3px solid var(--ink); border-radius: 8px; box-shadow: inset 0 -4px 0 var(--cream2), 0 4px 0 rgba(30, 14, 24, .3); }
.btn {
  appearance: none; cursor: pointer; font-size: 17px; font-weight: 600; color: #fff; padding: 9px 16px;
  background: var(--green); border: 3px solid var(--ink); border-radius: 8px; box-shadow: inset 0 -4px 0 var(--green-d), 0 3px 0 rgba(30, 14, 24, .35);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .3); transition: transform .06s;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--green-d), 0 1px 0 rgba(30, 14, 24, .35); }
.btn:disabled { filter: grayscale(.8) brightness(.9); cursor: not-allowed; opacity: .75; }
.btn.big { font-size: 20px; padding: 12px 22px; }
.btn.small { font-size: 14px; padding: 5px 10px; border-width: 2px; border-radius: 6px; }
.btn.gold { background: var(--gold); color: var(--ink); text-shadow: none; box-shadow: inset 0 -4px 0 var(--gold-d), 0 3px 0 rgba(30, 14, 24, .35); }
.btn.blue { background: var(--blue); box-shadow: inset 0 -4px 0 #2f5fa8, 0 3px 0 rgba(30, 14, 24, .35); }
.btn.red { background: var(--red); box-shadow: inset 0 -4px 0 #9d2a24, 0 3px 0 rgba(30, 14, 24, .35); }
.btn.ghost { background: var(--cream2); color: var(--ink); text-shadow: none; box-shadow: inset 0 -3px 0 var(--cream3), 0 3px 0 rgba(30, 14, 24, .3); }
.coin { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0 0 18%, var(--gold) 20% 62%, var(--gold-d) 64%); border: 2px solid var(--ink); vertical-align: -3px; flex: none; }
.coin.sm { width: 14px; height: 14px; border-width: 2px; vertical-align: -2px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; padding: calc(10px + var(--safe-t)) 12px calc(10px + var(--safe-b)); }
#hud > * { pointer-events: none; }
#hud .panel, #hud button, #hud input, .hud-tl .panel, .icon-btns, #hotbar .slot { pointer-events: auto; }
.hud-tl { position: absolute; left: 12px; top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; gap: 8px; }
.profile { display: flex; gap: 8px; align-items: center; padding: 6px 12px 8px 6px; min-width: 210px; }
.profile img { width: 48px; height: 48px; background: #b9e08e; border: 3px solid var(--ink); border-radius: 6px; }
.profile .who { flex: 1; min-width: 0; }
.profile .row { display: flex; align-items: baseline; gap: 6px; }
.profile b { font-size: 18px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl { font-size: 13px; background: var(--ink); color: var(--cream); padding: 0 6px; border-radius: 4px; }
.xpbar { position: relative; margin-top: 4px; height: 14px; background: var(--cream3); border: 2px solid var(--ink); border-radius: 4px; overflow: hidden; }
.xpbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#9bf07f, #52b23d); transition: width .3s; }
.xpbar span { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 11px; color: var(--ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .6); }
.gold { display: flex; align-items: center; gap: 8px; padding: 5px 14px 7px; width: fit-content; font-size: 20px; }

#quest { max-width: 270px; padding: 7px 11px 9px; font-size: 15px; line-height: 1.3; background: #fff3c7; border-color: var(--ink); animation: questpulse 2.4s ease-in-out infinite; }
#quest b { color: var(--wood-d); }
@keyframes questpulse { 50% { box-shadow: inset 0 -4px 0 var(--cream2), 0 4px 0 rgba(30, 14, 24, .3), 0 0 0 3px rgba(247, 201, 72, .55); } }
@media (max-width: 760px) { #quest { max-width: 200px; font-size: 13px; padding: 5px 8px 7px; } }

.hud-tr { position: absolute; right: 12px; top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.info { display: flex; gap: 12px; padding: 6px 12px 8px; font-size: 16px; align-items: center; }
.icon-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 330px; }
.ibtn { width: 42px; height: 42px; font-size: 20px; line-height: 1; cursor: pointer; background: var(--cream); border: 3px solid var(--ink); border-radius: 8px; box-shadow: inset 0 -4px 0 var(--cream2), 0 3px 0 rgba(30, 14, 24, .3); padding: 0; }
.ibtn:hover { background: #fff7e0; }
.ibtn:active { transform: translateY(2px); }
.ibtn.off { opacity: .55; }
.emote-pop { display: flex; gap: 4px; padding: 6px; pointer-events: auto !important; }
.emote-pop button { font-size: 24px; background: none; border: 0; cursor: pointer; padding: 2px 5px; border-radius: 6px; }
.emote-pop button:hover { background: var(--cream2); }

#prompt { position: absolute; left: 50%; bottom: calc(112px + var(--safe-b)); transform: translateX(-50%); padding: 6px 14px 8px; font-size: 17px; white-space: nowrap; }
#prompt kbd, .kbd { display: inline-block; min-width: 22px; text-align: center; background: var(--ink); color: var(--cream); border-radius: 4px; padding: 0 5px; margin-right: 6px; font-family: var(--font); }
#visitbar { position: absolute; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); padding: 6px 14px 8px; font-size: 16px; display: flex; gap: 10px; align-items: center; pointer-events: auto !important; }

#hotbar { position: absolute; left: 50%; bottom: calc(12px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 6px; padding: 7px; background: rgba(63, 38, 49, .88); border: 3px solid var(--ink); border-radius: 10px; box-shadow: 0 4px 0 rgba(0, 0, 0, .3); max-width: 100vw; pointer-events: auto !important; }
.slot { position: relative; width: 62px; height: 62px; background: var(--cream); border: 3px solid var(--ink2); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -4px 0 var(--cream2); }
.slot img { width: 46px; height: 46px; }
.slot.sel { border-color: var(--gold); background: #fff3c7; box-shadow: inset 0 -4px 0 #f1dcae, 0 0 0 3px var(--ink), 0 0 12px 2px rgba(247, 201, 72, .75); transform: translateY(-5px); }
.slot .key { position: absolute; left: 3px; top: 0; font-size: 12px; color: var(--ink2); }
.slot .cnt { position: absolute; right: 4px; bottom: 1px; font-size: 15px; font-weight: 700; color: var(--ink); text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff, 0 -1px 0 #fff; }
.slot.empty img { opacity: .35; filter: grayscale(1); }
.slot .water { position: absolute; left: 5px; right: 5px; bottom: 4px; height: 7px; background: var(--cream3); border: 2px solid var(--ink); border-radius: 3px; overflow: hidden; }
.slot .water i { display: block; height: 100%; background: linear-gradient(#aee4ff, #4f9be8); }

#chat { position: absolute; left: 12px; bottom: calc(12px + var(--safe-b)); width: min(360px, 36vw); display: flex; flex-direction: column; gap: 6px; }
#chatlog { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; max-height: 190px; overflow: hidden; font-size: 15px; pointer-events: none; }
#chatlog .line { background: rgba(40, 24, 36, .62); color: #fff; padding: 2px 8px; border-radius: 5px; width: fit-content; max-width: 100%; word-break: break-word; animation: fadeline 1s 12s forwards; }
#chatlog .line b { color: #ffd84a; } #chatlog .line.me b { color: #b9f0a0; } #chatlog .line.sys { color: #bde6ff; font-style: italic; }
#chat.focus #chatlog .line { animation: none; opacity: 1; }
@keyframes fadeline { to { opacity: 0; } }
#chatinput { pointer-events: none; width: 100%; padding: 6px 10px; font-size: 16px; color: var(--ink); background: var(--cream); border: 3px solid var(--ink); border-radius: 8px; outline: none; opacity: .0; transition: opacity .15s; }
#chat.focus #chatinput, #chatinput:focus { opacity: 1; pointer-events: auto; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 20px; overflow: auto; background: linear-gradient(rgba(20, 14, 28, .35), rgba(20, 14, 28, .6)); touch-action: pan-y; }
.logo { text-align: center; color: #fff; text-shadow: 0 4px 0 #3f2631; }
.logo-sub { letter-spacing: .3em; font-size: 14px; opacity: .9; margin-bottom: 4px; }
.logo h1 { margin: 0; font-size: clamp(56px, 11vw, 112px); line-height: .88; letter-spacing: .02em; color: #ffe27a; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink), 0 10px 0 rgba(0, 0, 0, .25); }
.logo p { margin: 16px 0 0; font-size: clamp(15px, 2.2vw, 20px); }
.card { padding: 18px 22px 16px; width: min(440px, 94vw); }
.card.wide { width: min(560px, 94vw); }
.card h2 { margin: 0 0 12px; font-size: 22px; }
.wallets { display: flex; flex-direction: column; gap: 8px; }
.wbtn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; font-size: 18px; font-weight: 600; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 8px; cursor: pointer; box-shadow: inset 0 -4px 0 #e9e3d2, 0 3px 0 rgba(30, 14, 24, .3); text-align: left; }
.wbtn:hover { background: #fff8e2; }
.wbtn img { width: 28px; height: 28px; border-radius: 6px; image-rendering: auto; }
.wbtn .dot { width: 28px; height: 28px; border-radius: 6px; background: #ab9ff2; flex: none; }
.wbtn small { margin-left: auto; font-weight: 400; opacity: .6; font-size: 13px; }
.status { min-height: 22px; margin-top: 10px; font-size: 15px; text-align: center; color: var(--ink2); }
.status.err { color: var(--red); }
.fine { margin: 10px 0 0; font-size: 13px; line-height: 1.35; color: var(--ink2); text-align: center; }
.credits { color: #fff; font-size: 13px; opacity: .85; text-shadow: 0 2px 0 #3f2631; text-align: center; }
.credits a { color: #ffe27a; }
#resume { margin-bottom: 10px; }
.field { display: block; font-size: 16px; margin: 8px 0 4px; }
.field input { display: block; width: 100%; margin-top: 4px; padding: 9px 12px; font-size: 19px; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 8px; outline: none; user-select: text; }
.field input:focus { border-color: var(--blue); }
.skins { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 6px 0 4px; }
.skin { aspect-ratio: 1; background: #b9e08e; border: 3px solid var(--ink2); border-radius: 8px; cursor: pointer; padding: 0; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12); display: flex; align-items: center; justify-content: center; }
.skin img { width: 86%; height: 86%; }
.skin.sel { border-color: var(--gold); box-shadow: 0 0 0 3px var(--ink), 0 0 12px rgba(247, 201, 72, .9); background: #d6f2a8; }
#btn-create { width: 100%; margin-top: 10px; }

/* ---------- modals ---------- */
#modal-root:empty { display: none; }
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(20, 12, 24, .5); touch-action: pan-y; }
.modal { position: relative; width: min(620px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.modal.narrow { width: min(460px, 100%); }
.modal > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 10px 18px; background: var(--wood); color: #fff; border-bottom: 3px solid var(--ink); text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.modal > header h3 { margin: 0; font-size: 22px; }
.modal .x { appearance: none; width: 34px; height: 34px; font-size: 18px; font-weight: 700; cursor: pointer; color: var(--ink); background: var(--cream); border: 3px solid var(--ink); border-radius: 8px; text-shadow: none; }
.modal .body { padding: 14px 16px 16px; overflow: auto; touch-action: pan-y; }
.tabs { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.tab { appearance: none; cursor: pointer; font-size: 16px; font-weight: 600; padding: 6px 14px; color: var(--ink); background: var(--cream2); border: 3px solid var(--ink); border-radius: 8px 8px 0 0; box-shadow: inset 0 -3px 0 var(--cream3); }
.tab.on { background: #fff; box-shadow: none; transform: translateY(2px); }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row-i { display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: #fff8e6; border: 3px solid var(--cream3); border-radius: 8px; }
.row-i.locked { opacity: .55; }
.row-i img { width: 44px; height: 44px; flex: none; }
.row-i .t { flex: 1; min-width: 0; }
.row-i .t b { display: block; font-size: 18px; }
.row-i .t small { display: block; font-size: 14px; color: var(--ink2); }
.row-i .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.price { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.trend.up { color: #2f9d3f; } .trend.down { color: var(--red); }
.sumbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; padding: 8px 12px; background: var(--cream2); border-radius: 8px; font-size: 17px; }
.note { font-size: 14px; color: var(--ink2); margin: 10px 2px 0; line-height: 1.4; }
.grid-inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.cell { position: relative; background: #fff8e6; border: 3px solid var(--cream3); border-radius: 8px; padding: 6px 4px 4px; text-align: center; font-size: 13px; }
.cell img { width: 44px; height: 44px; } .cell b { position: absolute; right: 6px; top: 2px; font-size: 16px; }
.empty-msg { text-align: center; padding: 24px 8px; color: var(--ink2); font-size: 17px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-size: 17px; margin: 8px 0; }
.kv span:nth-child(odd) { color: var(--ink2); }
.addr { font-family: ui-monospace, monospace; font-size: 14px; word-break: break-all; background: var(--cream2); padding: 6px 8px; border-radius: 6px; user-select: text; }
.help-list { margin: 0; padding-left: 20px; font-size: 16px; line-height: 1.6; }
.help-list li { margin-bottom: 4px; }
.sk { display: inline-block; width: 34px; height: 34px; vertical-align: middle; background: #b9e08e; border: 2px solid var(--ink2); border-radius: 6px; padding: 1px; }
.sk img { width: 100%; height: 100%; }

/* ---------- toasts & banners ---------- */
#toasts { position: fixed; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { padding: 6px 14px 8px; font-size: 17px; border: 3px solid var(--ink); border-radius: 8px; background: var(--cream); box-shadow: 0 4px 0 rgba(0, 0, 0, .25); animation: toastin .18s ease-out, toastout .4s 2.6s forwards; max-width: 90vw; text-align: center; }
.toast.bad { background: #ffd9d3; } .toast.good { background: #d9f6c8; } .toast.soft { background: #fff3d1; font-size: 15px; }
@keyframes toastin { from { transform: translateY(-10px); opacity: 0; } }
@keyframes toastout { to { opacity: 0; transform: translateY(-6px); } }
#banner { position: fixed; left: 0; right: 0; top: 0; z-index: 60; padding: 10px 14px; text-align: center; font-size: 17px; background: var(--red); color: #fff; border-bottom: 3px solid var(--ink); }
#banner button { margin-left: 12px; }
#levelup { position: fixed; left: 50%; top: 24%; transform: translate(-50%, -50%); z-index: 35; text-align: center; pointer-events: none; animation: lvl 3.4s forwards; }
#levelup .big { font-size: clamp(38px, 7vw, 64px); color: #ffe27a; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
#levelup .sub { font-size: 20px; color: #fff; text-shadow: 0 3px 0 var(--ink); margin-top: 6px; }
@keyframes lvl { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 20% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%); } }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
#joy { position: absolute; left: calc(22px + env(safe-area-inset-left, 0px)); bottom: calc(96px + var(--safe-b)); width: 128px; height: 128px; border-radius: 50%; background: rgba(253, 240, 208, .28); border: 3px solid rgba(63, 38, 49, .55); pointer-events: auto; touch-action: none; }
#joyknob { position: absolute; left: 36px; top: 36px; width: 56px; height: 56px; border-radius: 50%; background: rgba(253, 240, 208, .85); border: 3px solid var(--ink); }
.tbtns { position: absolute; right: calc(18px + env(safe-area-inset-right, 0px)); bottom: calc(96px + var(--safe-b)); display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 10px; pointer-events: none; }
.tbtn { pointer-events: auto; width: 62px; height: 62px; border-radius: 50%; font-size: 15px; font-weight: 700; color: var(--ink); background: var(--cream); border: 3px solid var(--ink); box-shadow: inset 0 -4px 0 var(--cream2), 0 3px 0 rgba(0, 0, 0, .3); touch-action: none; }
.tbtn.big { width: 84px; height: 84px; background: var(--gold); box-shadow: inset 0 -5px 0 var(--gold-d), 0 3px 0 rgba(0, 0, 0, .3); font-size: 18px; }
.tbtn.small { width: 46px; height: 46px; font-size: 18px; }
body.touch #hotbar { bottom: calc(8px + var(--safe-b)); }
body.touch .slot { width: 52px; height: 52px; } body.touch .slot img { width: 38px; height: 38px; } body.touch .slot .key { display: none; }
body.touch #prompt { bottom: calc(86px + var(--safe-b)); }
body.touch #chat { display: none; }
body.touch #chat.focus { display: flex; position: fixed; left: 8px; right: 8px; width: auto; bottom: 8px; z-index: 30; }

@media (max-width: 760px) {
  .profile { min-width: 0; } .profile b { max-width: 80px; }
  .info { font-size: 14px; gap: 8px; padding: 4px 8px 6px; }
  .icon-btns { max-width: 200px; } .ibtn { width: 36px; height: 36px; font-size: 17px; }
  #chat { width: min(250px, 54vw); bottom: calc(86px + var(--safe-b)); }
  .slot { width: 46px; height: 46px; } .slot img { width: 34px; height: 34px; } #hotbar { gap: 4px; padding: 5px; }
  .modal .body { padding: 10px; } .row-i { flex-wrap: wrap; } .row-i .acts { width: 100%; justify-content: flex-start; }
}
@media (max-height: 520px) {
  .logo p, .logo-sub { display: none; } .screen { gap: 10px; padding: 10px; } .logo h1 { font-size: 44px; } .card { padding: 10px 14px; }
  .fine { display: none; }
}
