:root {
  --ui-bg: rgba(20, 22, 20, 0.82);
  --ui-edge: #3a3f36;
  --ui-text: #cdd0c4;
  --ui-dim: #7e8474;
  --accent: #b7c27a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/cinzel.woff2') format('woff2');
}
html, body {
  height: 100%;
  background: #0c0d0b;
  overflow: hidden;
  font-family: "Cinzel", Georgia, serif; /* unified RPG font across UI + canvas */
  color: var(--ui-text);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#game-wrap { position: fixed; inset: 0; }

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: pointer;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

#clock {
  background: var(--ui-bg);
  border: 1px solid var(--ui-edge);
  border-radius: 4px;
  padding: 8px 12px;
  line-height: 1.3;
  text-shadow: 0 1px 2px #000;
}
#day { font-size: 13px; color: var(--ui-dim); letter-spacing: 1px; }
#time { font-size: 22px; font-weight: bold; color: var(--ui-text); }
#season { font-size: 12px; color: var(--accent); letter-spacing: 2px; text-transform: uppercase; }
#health {
  position: relative;
  margin-top: 5px;
  width: 120px; height: 12px;
  background: #2a1414;
  border: 1px solid #5a2f2f;
  border-radius: 6px;
  overflow: hidden;
}
#health-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #c93b34, #e06b54); transition: width .15s; }
#health-txt { position: absolute; inset: 0; text-align: center; font-size: 9px; line-height: 12px; color: #fff; text-shadow: 0 1px 1px #000; }
/* prayer-points orb/bar — sits right under health, mirrors its shape in prayer blue.
   Clickable (opens the prayer menu); glows while any prayer is active (.praying). */
#prayer {
  position: relative; margin-top: 4px;
  width: 120px; height: 12px;
  background: #141e2a; border: 1px solid #2f455a; border-radius: 6px; overflow: hidden;
  cursor: pointer;
}
#prayer.praying { border-color: #6fc6f0; box-shadow: 0 0 7px #56b6e688, inset 0 0 4px #56b6e644; }
#prayer-fill { height: 100%; width: 0; background: linear-gradient(90deg, #2f7ec7, #56b6e6); transition: width .15s; }
#prayer-txt { position: absolute; inset: 0; text-align: center; font-size: 9px; line-height: 12px; color: #fff; text-shadow: 0 1px 1px #000; }
#energy {
  position: relative; margin-top: 4px;
  width: 120px; height: 12px;
  background: #2a2a14; border: 1px solid #5a5a2f; border-radius: 6px; overflow: hidden;
}
#energy-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #c9a834, #ecd24a); transition: width .15s; }
#energy-fill.low { background: linear-gradient(90deg, #c0392b, #e67e22); }
#energy-txt.empty { color: #ff6b5e; animation: energyPulse 0.9s ease-in-out infinite; }
@keyframes energyPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
#energy-txt { position: absolute; inset: 0; text-align: center; font-size: 9px; line-height: 12px; color: #1a1a1a; text-shadow: 0 1px 1px rgba(255,255,255,.3); }

#cash {
  background: var(--ui-bg);
  border: 1px solid var(--ui-edge);
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 18px;
  font-weight: bold;
  color: #d8c98a;
  text-shadow: 0 1px 2px #000;
}

/* ---------- Hotbar ---------- */
#hotbar {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  max-width: 96vw;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: auto;
  z-index: 9; /* above the inventory/panels (z-8) so you can drag/tap tools onto slots while the backpack is open */
}
.slot {
  width: 54px; height: 54px;
  background: var(--ui-bg);
  border: 2px solid var(--ui-edge);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: border-color .12s, transform .12s;
}
.slot:hover { border-color: #5a6150; }
.slot.active { border-color: var(--accent); transform: translateY(-4px); }
.slot.dragging { opacity: .45; }
.slot.dragover { outline: 2px dashed #fff; outline-offset: -2px; }
.slot.picked { outline: 2px solid #ffd24a; outline-offset: -2px; box-shadow: 0 0 8px #ffd24a88; }
.slot.empty { border-style: dashed; border-color: #44493e; opacity: .65; } /* unfilled hotbar slot */
.inv-item.picked { outline: 2px solid #ffd24a; box-shadow: 0 0 8px #ffd24a88; } /* a backpack tool picked to place in the hotbar */
.slot .ico { font-size: 24px; line-height: 1; filter: saturate(.6); }
.slot .fist { opacity: .3; font-size: 22px; line-height: 1; } /* empty-slot fists hint */
.slot.active .fist { opacity: 1; } /* brightens when fists are the selected "tool" */
.slot .lbl { font-size: 9px; color: var(--ui-dim); margin-top: 3px; letter-spacing: .5px; }
.slot .key { position: absolute; top: 2px; left: 4px; font-size: 10px; color: var(--ui-dim); }
.slot .qty { position: absolute; bottom: 2px; right: 4px; font-size: 11px; color: #d8c98a; font-weight: bold; }

#hud-right { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
#hud-right button { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1; padding: 0; background: var(--ui-bg); border: 1px solid var(--ui-edge); border-radius: 7px; cursor: pointer; transition: border-color .12s; } /* uniform HUD icon buttons */
#editor-btn.on { border-color: var(--accent); background: #2a3320; }
/* admin map-editor palette (built dynamically, admin-only) */
#map-editor { position: fixed; bottom: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-wrap: wrap; gap: 5px; max-width: 92vw; justify-content: center; background: rgba(13,15,10,0.93); border: 1px solid var(--ui-edge); border-radius: 9px; padding: 7px; z-index: 40; box-shadow: 0 4px 14px #000a; }
.me-swatch { background: var(--ui-bg); border: 1px solid var(--ui-edge); color: var(--ui-text); font-size: 12px; padding: 5px 9px; border-radius: 6px; cursor: pointer; }
.me-swatch.on { border-color: var(--accent); background: #2a3320; }
#hud-right button:hover { border-color: var(--accent); }
#minimap { position: fixed; top: 54px; right: 10px; width: 144px; height: 144px; border: 2px solid var(--ui-edge); border-radius: 6px; background: #0d0f0a; z-index: 7; pointer-events: none; box-shadow: 0 2px 8px #0007; }
@media (max-width: 640px) { #minimap { width: 104px; height: 104px; top: 48px; } }
@media (hover: none) and (pointer: coarse) { #minimap { display: none; } } /* hide the minimap on touch / mobile devices */
#online {
  background: var(--ui-bg); border: 1px solid var(--ui-edge); border-radius: 4px;
  padding: 5px 9px; font-size: 11px; letter-spacing: .5px; text-shadow: 0 1px 2px #000;
}
#online.on { color: #7fd06a; border-color: #3f6a35; }
#online.off { color: var(--ui-dim); }
#inv-btn {
  background: var(--ui-bg);
  border: 1px solid var(--ui-edge);
  border-radius: 4px;
  font-size: 20px;
  padding: 5px 9px;
  cursor: pointer;
  line-height: 1;
}
#inv-btn:hover { border-color: #5a6150; }
#logout-btn {
  background: var(--ui-bg); border: 1px solid var(--ui-edge); border-radius: 4px;
  font-size: 16px; padding: 5px 9px; line-height: 1; cursor: pointer; color: var(--ui-dim);
}
#logout-btn:hover { border-color: #6a3f35; color: #e0a090; }

/* ---------- Inventory / Shop / Trader / Skills / Quests panels ---------- */
#shop, #trader, #skills, #quests, #market, #bank, #friends, #prayers {
  position: absolute; inset: 0;
  background: rgba(6, 8, 6, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 8;
}
/* Backpack DOCKED to the right edge (RuneScape-style): the world stays visible and playable
   behind it — no dim backdrop. Sits below the minimap (top 54px + 144px) and above the hotbar. */
#inventory {
  position: absolute; top: 208px; right: 10px; bottom: 74px; left: auto;
  display: flex; align-items: flex-start; justify-content: flex-end;
  background: none; pointer-events: none;   /* clicks pass through to the game except on the panel itself */
  z-index: 8;
}
#inventory .inv-box { width: min(340px, 86vw); max-height: 100%; pointer-events: auto; }
@media (max-width: 640px) { #inventory { top: 162px; } } /* smaller minimap on phones (104px @ top 48) */
#inventory.hidden, #shop.hidden, #trader.hidden, #skills.hidden, #quests.hidden, #market.hidden, #bank.hidden, #friends.hidden, #prayers.hidden, #map-editor.hidden { display: none; }
/* store open: ONE unified panel — the Buy section (wares) sits above the Sell section
   (your sellable stacks) inside #shop; the whole body scrolls (mobile-friendly) */
#shop-body { max-height: 72vh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px; }
.shop-divider { border-top: 1px solid #6b5836; margin: 14px -4px 0; }            /* bronze rule between Buy and Sell */
.shop-sell-grid .inv-item { cursor: pointer; }
.shop-sellall-row { text-align: center; padding-top: 9px; }
.inv-item.selling { position: relative; outline: 2px solid rgba(243,198,58,.55); cursor: pointer; }
.ii-sell { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 10px; font-weight: 700; color: #f3c63a; background: rgba(0,0,0,.45); text-shadow: 0 1px 1px #000; pointer-events: none; border-radius: 0 0 5px 5px; }
#bank-body { display: flex; flex-direction: column; gap: 6px; max-height: 76vh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px; } /* the ONE scroller — the zones inside grow naturally (nested per-zone scrollbars read as a broken panel on short screens) */
/* wide bank panel: vault and backpack side by side so the 64-slot grid uses screen WIDTH instead of scrolling */
#bank .inv-box { width: min(940px, 96vw); }
#trader .inv-box { width: min(720px, 96vw); } /* Armoury: 5 gear sections × 3 tiers — wider so the grids breathe */
#trader .inv-grid { grid-template-columns: repeat(3, 1fr); } /* exactly 3 tiers per row, spanning the full panel (auto-fill would leave the cells clustered left) */
.bank-cols { display: flex; gap: 14px; align-items: flex-start; }
.bank-col { flex: 2; min-width: 0; }      /* vault gets ~2/3 of the width: 64 slots lay out ~10 wide × 7 tall */
.bank-col-bag { flex: 1; }
@media (max-width: 700px) { .bank-cols { flex-direction: column; } .bank-col, .bank-col-bag { width: 100%; } } /* phones: stack back to a column */

/* player marketplace */
#market-btn { background: var(--ui-bg); border: 1px solid var(--ui-edge); border-radius: 4px; font-size: 16px; padding: 4px 8px; cursor: pointer; }
#market-btn:hover { border-color: #5a6150; }
#market-coins { color: #ffd84a; font-size: 14px; }
#market-tabs { display: flex; gap: 6px; margin: 8px 0 10px; }
.mk-tab { flex: 1; background: #20251c; border: 1px solid var(--ui-edge); color: var(--ui-dim); border-radius: 5px; padding: 7px 0; font-family: inherit; font-size: 12px; cursor: pointer; }
.mk-tab.sel { border-color: var(--accent); color: var(--ui-text); background: #2a3122; }
#market-body { display: flex; flex-direction: column; gap: 7px; max-height: 64vh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px; }
.mk-note { font-size: 11px; color: var(--ui-dim); line-height: 1.4; margin-bottom: 4px; }
.mk-row { display: flex; align-items: center; gap: 9px; background: #20251c; border: 1px solid var(--ui-edge); border-radius: 5px; padding: 7px 9px; }
.mk-row .ii-ico { font-size: 20px; filter: saturate(.7); }
.mk-info { flex: 1; font-size: 13px; color: var(--ui-text); min-width: 0; }
.mk-sub { display: block; font-size: 10px; color: var(--ui-dim); margin-top: 2px; }
.mk-qty, .mk-price { width: 56px; background: #14160f; border: 1px solid var(--ui-edge); color: var(--ui-text); border-radius: 4px; padding: 5px; font-family: inherit; font-size: 12px; }
.mk-act { background: #2a3122; border: 1px solid var(--accent); color: var(--ui-text); border-radius: 5px; padding: 6px 12px; font-family: inherit; font-size: 12px; cursor: pointer; }
.mk-act:hover { background: #38402c; }
.mk-act.danger { border-color: #a23b34; }
.mk-act.danger:hover { background: #4a2420; }
/* GE offer-setup inputs: dark theme to match the panel (were defaulting to white) */
#market input, #market select { background: #14160f; border: 1px solid var(--ui-edge); color: var(--ui-text); border-radius: 4px; padding: 6px 8px; font-family: inherit; font-size: 13px; box-sizing: border-box; }
#market input:focus, #market select:focus { outline: none; border-color: var(--accent); }
#market input::-webkit-outer-spin-button, #market input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* ---- Grand Exchange: marketplace grid (browse ALL items, no dropdown) ---- */
#market .inv-box { width: min(1040px, 96vw); max-height: 92vh; }
.ge-wrap { display: flex; min-height: 58vh; }
.ge-side { width: 168px; flex-shrink: 0; border-right: 1px solid #6b5836; padding-right: 8px; margin-right: 12px; }
.ge-sh { font-size: 10px; letter-spacing: 2px; color: var(--ui-dim); text-transform: uppercase; margin: 4px 8px 7px; }
.ge-cat { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 6px; color: var(--ui-text); font-size: 14px; cursor: pointer; margin-bottom: 3px; border: 1px solid transparent; }
.ge-cat:hover { background: #20251c; }
.ge-cat.on { background: #2a3122; border-color: var(--accent); color: #e8efcf; }
.ge-ci { width: 20px; text-align: center; filter: saturate(.7); }
.ge-badge { color: #6fce58; font-size: 9px; margin-left: auto; }
.ge-main { flex: 1; min-width: 0; }
.ge-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ge-search { flex: 1; background: #14160f; border: 1px solid var(--ui-edge); color: var(--ui-text); border-radius: 6px; padding: 9px 12px; font-family: inherit; font-size: 14px; }
.ge-search:focus { outline: none; border-color: var(--accent); }
.ge-count { font-size: 12px; color: var(--ui-dim); white-space: nowrap; }
.ge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ge-card { background: #181510; border: 1px solid #3a3228; border-radius: 8px; padding: 11px 10px; text-align: center; box-shadow: inset 0 2px 4px #0007, inset 0 1px 0 #ffffff0a; cursor: pointer; transition: border-color .12s, transform .1s; }
.ge-card:hover { border-color: #c9a13a; transform: translateY(-2px); }
.ge-ico { width: 58px; height: 58px; margin: 2px auto 7px; background: #0e0c08; border: 1px solid #2e281f; border-radius: 8px; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 2px 5px #0009; font-size: 30px; }
.ge-ico img { width: 40px; height: 40px; image-rendering: pixelated; filter: saturate(.92); }
.ge-nm { font-size: 15px; color: var(--ui-text); font-weight: 700; }
.ge-ty { font-size: 9px; letter-spacing: 1.5px; color: var(--ui-dim); text-transform: uppercase; margin-bottom: 5px; }
.ge-pr { font-size: 18px; color: #ffe06a; font-weight: 700; text-shadow: 0 1px 2px #000; }
.ge-bs { display: flex; justify-content: center; gap: 12px; font-size: 12px; color: var(--ui-dim); margin: 6px 0 9px; }
.ge-bs b { color: #ffe06a; }
.coin-ico { width: 1em; height: 1em; vertical-align: -0.14em; display: inline-block; } /* low-poly gold coin, sized to the surrounding text */
.ge-acts { display: flex; gap: 7px; }
.ge-cbuy, .ge-csell { flex: 1; padding: 8px 0; border-radius: 6px; font-family: inherit; font-size: 12px; font-weight: 700; letter-spacing: 1px; cursor: pointer; border: 1px solid; }
.ge-cbuy { background: #2a3a22; border-color: #5a7a40; color: #cfe6b0; }
.ge-cbuy:hover { background: #35472b; }
.ge-csell { background: #3a2420; border-color: #6a3f35; color: #e0a090; }
.ge-csell:hover { background: #4a2e28; }
.ge-detail { max-width: 470px; }
.ge-dhead { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--ui-edge); }
.ge-dhead .ii-ico { font-size: 22px; }
@media (max-width: 620px) { .ge-side { width: 116px; margin-right: 8px; } .ge-cat { font-size: 12px; padding: 8px 7px; } .ge-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; } }
#quests-btn { background: var(--ui-bg); border: 1px solid var(--ui-edge); border-radius: 4px; font-size: 16px; padding: 4px 8px; cursor: pointer; }
#quests-btn:hover { border-color: #5a6150; }
#quests-body { display: flex; flex-direction: column; gap: 7px; padding: 2px; max-height: 60vh; overflow-y: auto; }
.q-section { font-size: 11px; color: var(--ui-dim); text-transform: uppercase; letter-spacing: .5px; margin: 6px 0 2px; }
.q-row { display: flex; align-items: center; gap: 9px; background: #20251c; border: 1px solid var(--ui-edge); border-radius: 5px; padding: 7px 9px; }
.q-row.done { opacity: .55; border-color: #3f6a35; }
.q-check { font-size: 15px; width: 18px; text-align: center; }
.q-text { flex: 1; font-size: 12px; color: var(--ui-text); }
.q-reward { font-size: 11px; color: #ffe14a; }
.q-prog { font-size: 11px; color: var(--ui-dim); }
#quest-tracker {
  position: absolute; top: 92px; left: 12px; z-index: 6; pointer-events: none;
  background: var(--ui-bg); border: 1px solid var(--ui-edge); border-left: 3px solid #ffe14a;
  border-radius: 4px; padding: 6px 10px; font-size: 12px; color: var(--ui-text);
  text-shadow: 0 1px 2px #000; max-width: 60vw;
}
#quest-tracker.hidden { display: none; }
#quest-tracker .qt-label { color: #ffe14a; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
#skills-total { color: #d8c98a; font-size: 14px; }
#skills-btn { background: var(--ui-bg); border: 1px solid var(--ui-edge); border-radius: 4px; font-size: 16px; padding: 4px 8px; cursor: pointer; }
#skills-btn:hover { border-color: #5a6150; }
#skills-body { display: flex; flex-direction: column; gap: 9px; padding: 4px 2px; }
.skill-row { display: flex; align-items: center; gap: 10px; }
.skill-ico { font-size: 22px; width: 26px; text-align: center; }
.skill-meta { flex: 1; }
.skill-name { font-size: 13px; color: var(--ui-text); display: flex; justify-content: space-between; margin-bottom: 3px; }
.skill-lvl { color: #ffe14a; font-weight: 700; }
.skill-bar { height: 7px; background: #20251c; border: 1px solid var(--ui-edge); border-radius: 4px; overflow: hidden; }
.skill-fill { height: 100%; background: linear-gradient(90deg, #4a9a3a, #6fce58); }
/* ---------- Prayer panel: points bar + toggle rows (active glows blue, locked greys out) ---------- */
#prayers-lvl { color: #8fd0f0; font-size: 14px; }
#prayer-btn { background: var(--ui-bg); border: 1px solid var(--ui-edge); border-radius: 4px; font-size: 16px; padding: 4px 8px; cursor: pointer; }
#prayer-btn:hover { border-color: #5a6150; }
/* painterly icon buttons + menu rows (Vertex Imagen PNGs) */
#prayer-btn img, #bestiary-btn img { display: block; border-radius: 4px; }
#prayer-btn, #bestiary-btn { padding: 3px; line-height: 0; }
#prayers-points { position: relative; height: 16px; background: #141e2a; border: 1px solid #2f455a; border-radius: 8px; overflow: hidden; margin: 0 2px 10px; }
#prayers-points-fill { height: 100%; width: 0; background: linear-gradient(90deg, #2f7ec7, #56b6e6); transition: width .15s; }
#prayers-points-txt { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; color: #fff; text-shadow: 0 1px 1px #000; }
#prayers-body { display: flex; flex-direction: column; gap: 6px; padding: 2px; max-height: 62vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pray-row { display: flex; align-items: center; gap: 9px; background: #20251c; border: 1px solid var(--ui-edge); border-radius: 6px; padding: 8px 10px; cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s; }
.pray-row:hover { border-color: #5a6150; }
.pray-row.active { border-color: #56b6e6; background: #1c2a36; box-shadow: inset 0 0 10px #2f7ec744, 0 0 6px #56b6e633; }
.pray-row.active:hover { border-color: #8fd0f0; }
.pray-row.locked { opacity: .45; cursor: not-allowed; filter: saturate(.4); }
.pray-row.locked:hover { border-color: var(--ui-edge); }
.pray-ico { width: 34px; height: 34px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.pray-ico img { display: block; }
.pray-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pray-name { font-size: 13px; font-weight: 700; color: var(--ui-text); text-shadow: 0 1px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pray-row.active .pray-name { color: #bfe6fa; }
.pray-fx { font-size: 10px; color: var(--ui-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pray-lvl { flex: 0 0 auto; font-size: 11px; font-weight: 700; color: #9a8048; letter-spacing: .5px; }
.pray-row.active .pray-lvl { color: #56b6e6; }
#shop-cash, #trader-cash { color: #d8c98a; font-size: 15px; }
.inv-item.owned { border-color: var(--accent); }
.inv-item .ii-eq { font-size: 9px; color: var(--accent); margin-top: 2px; }
.gear-sell {
  margin-top: 4px; background: #3a2420; border: 1px solid #6a3f35; color: #e0a090;
  font-family: inherit; font-size: 9px; padding: 2px 6px; border-radius: 4px; cursor: pointer;
}
.gear-sell:hover { background: #4a2e28; }
.inv-item .ii-price { font-size: 10px; color: #8fcf6a; margin-top: 2px; }
.shop-allbtn {
  background: #2a3a22; border: 1px solid #5a7a40; color: #cfe6b0;
  font-family: inherit; font-size: 12px; padding: 6px 12px; border-radius: 5px;
  cursor: pointer; margin-top: 4px;
}
.shop-allbtn:hover { background: #35472b; }
.inv-box {
  width: min(452px, 93vw);
  background: linear-gradient(#2b2620, #1f1a14);   /* warm stone panel (RuneScape vibe) */
  border: 2px solid #6b5836;                        /* bronze/gold frame */
  border-radius: 10px;
  padding: 12px 14px 16px;
  box-shadow: 0 12px 44px #000c, inset 0 1px 0 #ffffff14, inset 0 0 30px #00000045;
  max-height: 92vh;                       /* never taller than the screen (mobile) */
  overflow-y: auto;                       /* scroll the whole panel if it overflows */
  -webkit-overflow-scrolling: touch;      /* momentum scrolling on iOS */
}
.inv-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 16px; letter-spacing: 2px; color: #e8c860;          /* gold title */
  text-transform: uppercase; margin: -2px -4px 12px; padding: 2px 6px 9px;
  border-bottom: 1px solid #6b5836; text-shadow: 0 1px 2px #000;
}
.inv-head button {
  background: none; border: none; color: var(--ui-dim);
  font-size: 18px; cursor: pointer; font-family: inherit;
}
.inv-section-title { font-size: 11px; color: var(--ui-dim); letter-spacing: 2px; margin: 12px 0 6px; text-transform: uppercase; }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; } /* responsive cells stretch to fill the panel width (mobile-friendly, not compressed) */
.inv-item {
  position: relative;                       /* corner badges (.lvl-badge / .ii-sell) anchor to their cell */
  background: #181510; border: 1px solid #3a3228; border-radius: 5px;
  padding: 8px 6px; text-align: center;
  box-shadow: inset 0 2px 4px #0007, inset 0 1px 0 #ffffff0a;   /* recessed RS slot */
}
.seed-cell { padding-top: 22px; } /* clear headroom so the level badge never sits on the crop icon */
.lvl-badge { position: absolute; top: 4px; left: 4px; font-size: 9px; font-weight: 800; letter-spacing: .5px; padding: 1px 5px; border-radius: 4px; background: #24301e; border: 1px solid #4a5a3a; color: #9fd06a; }
.lvl-badge.lk { background: #32201c; border-color: #6a3a2c; color: #e08a6a; }
.inv-item .ii-ico { font-size: 22px; filter: saturate(.7); }
.inv-item .ii-name { font-size: 10px; color: var(--ui-dim); margin-top: 3px; }
.inv-item .ii-qty { font-size: 14px; color: #ffe06a; font-weight: bold; text-shadow: 0 1px 2px #000; }
.inv-empty { color: var(--ui-dim); font-size: 12px; padding: 4px 2px; }
.inv-item.clickable { cursor: pointer; transition: border-color .12s, transform .1s; }
/* Bank vault: a fixed 64-slot grid you drag (or tap) stacks in/out of */
.bank-zone { padding: 7px; border-radius: 7px; background: #0e0c08; box-shadow: inset 0 2px 7px #0009; transition: background .12s, box-shadow .12s; } /* no own scrollbar — #bank-body scrolls */
.bank-zone.dragover { background: #2a3a1e66; box-shadow: inset 0 0 0 2px #7fe04a99; }
.bank-empty { background: #14110c; border: 1px solid #2e281f; min-height: 22px; box-shadow: inset 0 2px 3px #0006; }
.bank-cell { cursor: grab; -webkit-user-select: none; user-select: none; touch-action: none; }
.bank-cell.dragging { opacity: .4; }
.inv-item.clickable:hover { border-color: #c9a13a; box-shadow: inset 0 2px 4px #0007, 0 0 8px #c9a13a55; transform: translateY(-2px); }
.inv-item.clickable:active { transform: translateY(0); }

/* Backpack: every cell a uniform square — icon centred, quantity as a corner badge, name on hover only */
.inv-item.bag { padding: 0; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.inv-item.bag .ii-ico { font-size: 26px; line-height: 1; margin: 0; display: flex; align-items: center; justify-content: center; }
.inv-item.bag .ii-ico img { width: 26px; height: 26px; }
.inv-item.bag .ii-qty { position: absolute; top: 1px; left: 3px; margin: 0; font-size: 11px; font-weight: bold; color: #ffe06a; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.inv-item.bag.equipped { outline: 2px solid var(--accent); outline-offset: -2px; }
.inv-item.bag:not(.empty-cell):hover::after { /* :not(.empty-cell) -> no blank tooltip box over empty slots */
  content: attr(data-name); position: absolute; bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
  background: #0d0f0a; border: 1px solid var(--ui-edge); color: var(--ui-text); font-size: 11px;
  padding: 3px 8px; border-radius: 5px; white-space: nowrap; z-index: 30; pointer-events: none; box-shadow: 0 2px 8px #000a;
}
/* worn-equipment slots at the top of the inventory (RuneScape-style) */
.equip-slots { display: flex; gap: 8px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--ui-edge); }
.eq-slot { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 10px; background: #15170f; border: 1px solid var(--ui-edge); border-radius: 6px; }
.eq-slot.clickable { cursor: pointer; transition: border-color .12s, background .12s; }
.eq-slot.filled { border-color: var(--accent); }
.eq-slot.clickable:hover { background: #1c2018; }
.eq-ico { font-size: 22px; line-height: 1; }
.eq-ico .eq-ph { opacity: .3; filter: grayscale(1); }
.eq-lbl { font-size: 12px; color: var(--ui-text); }
.eq-slot:not(.filled) .eq-lbl { color: var(--ui-dim); font-style: italic; }
.inv-item.bag.empty-cell { background: #14110c; border: 1px solid #2e281f; cursor: default; box-shadow: inset 0 2px 3px #0006; } /* empty backpack slot */
.inv-item.dragover { outline: 2px dashed var(--accent); outline-offset: -2px; }
.inv-item.dragging { opacity: .45; }

/* ---------- Username (title) ---------- */
#username, #password {
  background: #15170f;
  border: 2px solid #5a6150;
  color: var(--ui-text);
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 1px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 10px;
  width: 240px;
  outline: none;
}
#username:focus, #password:focus { border-color: var(--accent); }
#title-desc { max-width: min(560px, 86vw); text-align: center; color: #cfd4bd; font-size: 14.5px; line-height: 1.65; margin: -8px 0 14px; text-shadow: 0 1px 3px #000; }
#title-online { display: flex; align-items: center; gap: 7px; color: #d8e0c2; font-size: 13px; letter-spacing: 1.5px; margin-bottom: 16px; text-shadow: 0 1px 3px #000; }
#title-online b { color: #9fd06a; font-size: 15px; }
#title-online .dot { width: 8px; height: 8px; border-radius: 50%; background: #7fd06a; box-shadow: 0 0 8px #7fd06aa8; animation: onlinePulse 2.4s ease-in-out infinite; }
@keyframes onlinePulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
#login-note { color: #a8b092; font-size: 12px; letter-spacing: 2px; font-variant: small-caps; margin-bottom: 10px; text-shadow: 0 1px 3px #000; }
#login-error { color: #e06b54; font-size: 12px; min-height: 16px; margin-bottom: 8px; }
#auth-toggle { margin-top: 12px; font-size: 12px; color: var(--ui-dim); }
#auth-toggle a { color: var(--accent); cursor: pointer; text-decoration: underline; }
#start-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Chat ---------- */
#chat {
  position: absolute;
  left: 12px; bottom: 84px;
  width: min(320px, 56vw);
  display: flex; flex-direction: column;
  gap: 4px;
  z-index: 6;
}
#chat.hidden { display: none; }
#chat-log {
  display: flex; flex-direction: column;
  gap: 2px;
  max-height: 150px;
  overflow: hidden;
  font-size: 12px;
  text-shadow: 0 1px 2px #000;
}
#chat-log .cm { background: rgba(20,22,20,0.5); border-radius: 4px; padding: 2px 7px; align-self: flex-start; }
#chat-log .cm b { color: var(--accent); }
#chat-log .cm.sys { color: var(--ui-dim); font-style: italic; }
#chat-input {
  background: var(--ui-bg);
  border: 1px solid var(--ui-edge);
  color: var(--ui-text);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 5px;
  outline: none;
  opacity: 0.55;
  transition: opacity .15s, border-color .15s;
}
#chat-input:focus { opacity: 1; border-color: var(--accent); }

/* ---------- Mobile layout: keep the hotbar to one row + clear of chat/buttons ---------- */
@media (max-width: 640px) {
  #hotbar { flex-wrap: nowrap; gap: 4px; bottom: 10px; max-width: 100vw; }
  .slot { width: 40px; height: 40px; border-width: 1px; }
  .slot .lbl { display: none; }
  .slot .ico { font-size: 19px; }
  .slot .key { font-size: 8px; }
  .slot .qty { font-size: 10px; }
  /* chat sits above the single-row hotbar, compact, and never covers it */
  #chat { left: 8px; bottom: 60px; width: 56vw; }
  #chat-log { max-height: 84px; }
  #chat-input { font-size: 12px; padding: 5px 8px; }
  /* action buttons stack on the right, clear of the hotbar */
  #touch-actions { bottom: 58px; right: 8px; gap: 8px; }
  .tbtn.round { width: 58px; height: 58px; }
  #t-buy { width: 50px; height: 50px; }
  #touch-zoom { top: 92px; }
  #tz-out, #tz-in { width: 38px; height: 38px; }
  #clock { padding: 6px 9px; }
  #day, #season { font-size: 10px; }
  #time { font-size: 18px; }
  #health, #prayer, #energy { width: 96px; }
  /* HUD buttons (incl. 🎒 inventory) must stay reachable on narrow screens: let them wrap, keep them touch-sized */
  #hud-right { flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 62vw; }
  #hud-right button { width: 34px; height: 34px; font-size: 16px; padding: 0; }
  #online { font-size: 11px; padding: 2px 5px; }
  #cash { font-size: 13px; }
}

/* ---------- Touch controls (mobile only) ---------- */
#touch-zoom, #touch-actions { position: absolute; display: none; gap: 10px; z-index: 5; }
body.touch #touch-actions { display: flex; } /* zoom +/- buttons stay hidden — pinch-to-zoom covers it */
#touch-zoom { top: 64px; right: 12px; flex-direction: column; }
#touch-actions { bottom: 84px; right: 14px; align-items: center; }

.tbtn {
  background: var(--ui-bg);
  border: 2px solid var(--ui-edge);
  color: var(--ui-text);
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 1px 2px #000;
}
.tbtn:active { background: #38402c; transform: translateY(1px); }
.tbtn.round {
  width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
#tz-out, #tz-in { width: 44px; height: 44px; padding: 0; font-size: 22px; }
#t-action { display: none; } /* Use button hidden on mobile (msg 1655) — tap-to-use already covers it */
#t-buy { border-color: #d8c98a; color: #d8c98a; width: 60px; height: 60px; font-size: 14px; }
.tbtn.hidden { display: none; }

/* ---------- Hint ---------- */
#hint {
  position: absolute;
  bottom: 88px; left: 50%;
  transform: translateX(-50%);
  background: var(--ui-bg);
  border: 1px solid var(--ui-edge);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ui-text);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}
#hint.show { opacity: 1; }

/* prominent toast (important notices like running out of energy) */
#toast {
  position: absolute;
  top: 76px; left: 50%;
  transform: translate(-50%, -10px);
  background: rgba(28, 18, 16, 0.92);
  border: 1px solid #7a3f33;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px; font-weight: 600;
  color: #ffd9cf;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 2px #000;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  max-width: 86vw; text-align: center;
  z-index: 9;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Title ---------- */
/* Title / loading screen — a translucent vignette over the LIVE rendered valley (the world
   draws underneath and the camera drifts slowly pre-login), not an opaque wall. */
#title {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 38%, rgba(9,11,8,.42) 0%, rgba(8,10,8,.66) 52%, rgba(4,6,4,.94) 100%);
  box-shadow: inset 0 0 220px 60px rgba(0,0,0,.6);   /* cinematic corner vignette */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity .6s;
}
#title.hidden { opacity: 0; pointer-events: none; }
/* the title vignette is TRANSLUCENT (live world behind) — keep the in-game HUD from bleeding
   through it until the game actually starts */
body:has(#title:not(.hidden)) :is(#hud, #hotbar, #chat, #minimap, #map-name, #touch-actions, #touch-zoom, #quest-tracker) { visibility: hidden; }
#title h1 {
  font-size: 68px;
  letter-spacing: 16px;
  margin-left: 16px;                                  /* optically recentre the tracked-out caps */
  background: linear-gradient(180deg, #f2e6b8 0%, #d8c273 45%, #a9853f 78%, #d8c273 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(20, 16, 4, .9)) drop-shadow(0 8px 22px rgba(0, 0, 0, .8));
}
#title .tag {
  color: #b9c2a2;
  font-variant: small-caps;
  letter-spacing: 7px;
  margin: 10px 0 0;
  font-size: 15px;
  text-shadow: 0 1px 3px #000;
}
/* thin gold rule with a centre ornament between the wordmark and the login block */
.title-rule { display: flex; align-items: center; gap: 12px; width: min(360px, 72vw); margin: 18px 0 30px; color: #c9a13a; font-size: 12px; text-shadow: 0 0 6px #c9a13a66; }
.title-rule::before, .title-rule::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #c9a13a99); }
.title-rule::after { background: linear-gradient(90deg, #c9a13a99, transparent); }
#start-btn {
  background: linear-gradient(180deg, rgba(58,50,30,.92), rgba(38,32,20,.92));
  border: 1px solid #c9a13a;
  color: #ecd88f;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 3px;
  padding: 13px 46px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,236,170,.18);
  text-shadow: 0 1px 2px #000;
  transition: box-shadow .2s, border-color .2s, transform .1s, background .2s;
}
#start-btn:hover { border-color: #ecd88f; box-shadow: 0 4px 24px rgba(201,161,58,.35), inset 0 1px 0 rgba(255,236,170,.22); background: linear-gradient(180deg, rgba(70,60,34,.95), rgba(44,37,22,.95)); }
#start-btn:active { transform: translateY(2px); }
/* gentle staggered entrance (skipped for reduced-motion users) */
@media (prefers-reduced-motion: no-preference) {
  #title h1, #title .tag, .title-rule, #title-desc, #title-online, #login-note, #start-btn, #title .controls { animation: titleIn .8s cubic-bezier(.2,.7,.2,1) both; }
  #title .tag { animation-delay: .12s; }
  .title-rule { animation-delay: .22s; }
  #login-note { animation-delay: .3s; }
  #start-btn { animation-delay: .38s; }
  #title .controls { animation-delay: .55s; }
  .title-rule span { animation: ornamentSpin 14s linear infinite; display: inline-block; }
}
@keyframes titleIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ornamentSpin { to { transform: rotate(360deg); } }
/* character customizer on the title screen */
#customize {
  margin-top: 18px;
  width: 440px; max-width: 90vw;
  border: 1px solid #3a4030;
  border-radius: 8px;
  background: rgba(20,23,17,0.6);
}
#customize > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  color: #c4cba0;
  font-size: 13px;
  letter-spacing: 1px;
  text-align: center;
}
#customize > summary::-webkit-details-marker { display: none; }
#customize-body {
  display: flex;
  gap: 14px;
  padding: 4px 14px 14px;
  align-items: flex-start;
}
#avatar {
  flex: 0 0 auto;
  width: 120px; height: 170px;
  background: radial-gradient(circle at 50% 60%, #23271d 0%, #14160f 100%);
  border: 1px solid #3a4030;
  border-radius: 6px;
  image-rendering: pixelated;
}
#custom-opts { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cust-row { display: flex; flex-direction: column; gap: 4px; }
.cust-label { color: var(--ui-dim); font-size: 11px; letter-spacing: 1px; }
.cust-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.cust-sw {
  width: 22px; height: 22px;
  border: 2px solid #2a2f22;
  border-radius: 5px;
  cursor: pointer;
  padding: 0;
}
.cust-sw.text {
  width: auto; height: 22px;
  padding: 0 8px;
  background: #2a2f22;
  color: #c4cba0;
  font-family: inherit;
  font-size: 11px;
  text-transform: capitalize;
}
.cust-sw.sel { border-color: #e8c33a; box-shadow: 0 0 0 1px #e8c33a; }
#title .controls {
  margin-top: 44px;
  padding-top: 14px;
  border-top: 1px solid rgba(201,161,58,.18);        /* hairline echoing the title rule */
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 560px;
  color: #7e8570;
  font-size: 11.5px;
  text-shadow: 0 1px 2px #000;
}
#title .controls b { color: #c9b26a; font-weight: 600; }

/* ---------- Wallet connect: picker modal + mobile deep-links ---------- */
#wallet-modal-list { max-height: 62vh; overflow-y: auto; -webkit-overflow-scrolling: touch; } /* many wallets / short screens -> the list scrolls, the modal doesn't overflow */
#wallet-modal .wallet-opt { min-height: 48px; -webkit-tap-highlight-color: transparent; }     /* comfortable tap target */
#wallet-list { width: min(340px, 88vw); }
/* deep-link buttons: reopen this page inside a wallet app's in-app browser (mobile, no injected wallet) */
.mw-note { color: var(--ui-dim); font-size: 12px; letter-spacing: .5px; margin: 16px 0 8px; text-align: center; }
.mw-sub { color: #6e7463; font-size: 10px; margin-top: 8px; text-align: center; line-height: 1.5; }
.mw-link {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; margin: 6px 0; padding: 12px 14px;
  background: #2a3122; border: 1px solid #5a6150; border-radius: 8px;
  color: #e8e2d0; font-size: 15px; letter-spacing: 1px; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.mw-link:active { background: #38402c; transform: translateY(1px); }

/* ---------- Title screen on phones (portrait) ---------- */
@media (max-width: 640px) {
  #title {
    justify-content: flex-start;            /* top-anchored + scrollable: centred flex clips the top when content overflows */
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 10vh 18px 28px;
    padding: max(10vh, calc(env(safe-area-inset-top) + 36px)) 18px calc(28px + env(safe-area-inset-bottom));
  }
  #title h1 { font-size: clamp(34px, 12vw, 52px); letter-spacing: 7px; margin-left: 7px; text-align: center; }
  #title .tag { font-size: 12px; letter-spacing: 3px; margin: 6px 0 26px; text-align: center; }
  #login-note { font-size: 12px; line-height: 1.5; text-align: center; padding: 0 6px; }
  #login-error { font-size: 12px; text-align: center; }
  #start-btn { width: min(340px, 100%); min-height: 54px; padding: 14px 20px; font-size: 18px; letter-spacing: 2px; }
  #wallet-list { width: min(340px, 100%); }
  #customize { width: 100%; }
  #title .controls { margin-top: 26px; flex-direction: column; gap: 10px; font-size: 11px; line-height: 1.6; text-align: center; max-width: 100%; padding: 0 4px; }
  /* wallet picker modal: never taller than the screen, close button easy to hit */
  #wallet-modal > div { max-height: 84vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #wallet-modal-list { max-height: 52vh; }
  #wallet-modal-close { min-width: 44px; min-height: 44px; }
}
