/* Beast Frontier - pixel UI */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; background: #0c0f14; overflow: hidden;
  font-family: 'VT323', 'Courier New', monospace; font-size: 18px; color: #e7ebf3;
  -webkit-font-smoothing: none; overscroll-behavior: none;
}
canvas#game { display: block; image-rendering: pixelated; image-rendering: crisp-edges; background: #0c0f14; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

.hidden { display: none !important; }
.mobileOnly { display: none; }
#rotateHint { display: none; }
.head, h1, h2, .logo, .key, .keycap, .barLabel, #levelTag, .panelHead, .rTitle, .tabTitle {
  font-family: 'Press Start 2P', 'Courier New', monospace;
}

/* ---------- shared pixel panel ---------- */
.panel {
  background: #171a24;
  border: 2px solid #c8a860;
  box-shadow: 0 0 0 2px #0b0a10, 0 0 0 4px #7a6236, 0 0 0 6px #0b0a10, 0 12px 30px rgba(0, 0, 0, 0.6);
  padding: 18px 20px;
  color: #e7ebf3;
  position: relative;
}
.panel::before {
  content: ""; position: absolute; inset: 3px; pointer-events: none;
  border: 1px solid rgba(255, 233, 160, 0.12);
}
button {
  font-family: 'VT323', 'Courier New', monospace; font-size: 17px; letter-spacing: 0.5px;
  background: #2b3244; color: #fff; border: 2px solid #0b0a10; padding: 5px 12px; cursor: pointer;
  box-shadow: inset 0 0 0 1px #4a5570, 0 3px 0 #0b0a10;
  position: relative; top: 0;
}
button:hover:not(:disabled) { background: #384158; }
button:active:not(:disabled) { top: 2px; box-shadow: inset 0 0 0 1px #4a5570, 0 1px 0 #0b0a10; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
input {
  font-family: 'VT323', 'Courier New', monospace; font-size: 20px;
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 10, 16, 0.72); z-index: 50;
}
#charCreate { background: #10141c; }
#titleCanvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.create-panel { width: 420px; text-align: center; z-index: 1; background: rgba(23, 26, 36, 0.94); }
.logo { margin: 4px 0 6px; line-height: 1; }
.logo-top {
  font-size: 30px; color: #ffd24a; letter-spacing: 2px;
  text-shadow: 2px 2px 0 #7a4a00, 4px 4px 0 #0b0a10;
}
.logo-bottom {
  font-size: 22px; color: #7be0c0; letter-spacing: 4px; margin-top: 8px;
  text-shadow: 2px 2px 0 #1a4a40, 4px 4px 0 #0b0a10;
}
.create-panel .sub { margin: 6px 0 16px; font-size: 17px; color: #9aa5b8; }
.field { display: block; margin-bottom: 14px; text-align: left; }
.field > span { display: block; font-family: 'Press Start 2P', monospace; font-size: 8px; text-transform: uppercase; letter-spacing: 1px; color: #c8a860; margin-bottom: 7px; }
.field input {
  width: 100%; padding: 6px 10px; border: 2px solid #0b0a10; box-shadow: inset 0 0 0 1px #3a4358;
  background: #0f131b; color: #fff; outline: none;
}
.field input:focus { box-shadow: inset 0 0 0 1px #c8a860; }
.rolled-ability {
  border: 2px dashed #3a4358; padding: 12px; min-height: 64px;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px;
  background: #0f131b;
}
.rolled-name { font-family: 'Press Start 2P', monospace; font-size: 12px; text-shadow: 2px 2px 0 #0b0a10; }
.rolled-desc { font-size: 16px; color: #aab4c6; line-height: 1.1; }
button.primary {
  width: 100%; padding: 10px; margin-top: 8px; font-family: 'Press Start 2P', monospace; font-size: 11px;
  background: #e0a622; color: #2a1c00; box-shadow: inset 0 0 0 1px #ffe08a, 0 4px 0 #7a4a00;
}
button.primary:hover:not(:disabled) { background: #ffd24a; }
.hint { font-size: 15px; color: #6c7690; margin: 14px 0 0; line-height: 1.3; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; color: #e7ebf3; }
#hud .panel, #hud .iconBtn, #hud input, #hud .close, #hud #hotbar { pointer-events: auto; }
#hud .mobileCtl { pointer-events: auto; }

.statFrame {
  position: absolute; top: 12px; left: 12px; width: 236px;
  background: rgba(12, 14, 22, 0.82); padding: 8px 10px 6px;
  border: 2px solid #c8a860; box-shadow: 0 0 0 1px #0b0a10, inset 0 0 0 1px #0b0a10;
}
.barRow { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.barLabel { width: 20px; font-size: 7px; color: #c8a860; text-shadow: 1px 1px 0 #0b0a10; }
.bar { position: relative; flex: 1; height: 16px; background: #1a1420; border: 2px solid #0b0a10; overflow: hidden; }
.bar .fill { height: 100%; width: 0%; transition: width 0.15s; }
.bar .ticks {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), rgba(0, 0, 0, 0.35) calc(10% - 1px), rgba(0, 0, 0, 0.35) 10%);
}
.bar .fill::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(255, 255, 255, 0.28); }
.hpbar .fill { background: linear-gradient(180deg, #ff6a5c 0 50%, #c92f24 50% 100%); position: relative; }
.apbar .fill { background: linear-gradient(180deg, #7bc4ff 0 50%, #2f7fc9 50% 100%); position: relative; }
.xpbar { height: 8px; }
.xpbar .fill { background: linear-gradient(180deg, #ffe45c 0 50%, #c9a30f 50% 100%); position: relative; }
.xpbar .fill::after { height: 2px; }
.barText { position: absolute; right: 5px; top: -3px; font-size: 15px; line-height: 16px; text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000, 1px 0 0 #000; }
#levelTag { margin-top: 2px; font-size: 8px; color: #ffd24a; text-shadow: 1px 1px 0 #0b0a10; }

#creditsTag {
  position: absolute; top: 12px; right: 12px; display: flex; align-items: center; gap: 4px;
  background: rgba(12, 14, 22, 0.82); border: 2px solid #c8a860; box-shadow: 0 0 0 1px #0b0a10, inset 0 0 0 1px #0b0a10;
  padding: 4px 10px; font-size: 18px; line-height: 20px;
}
#creditsVal { color: #ffd24a; }
.coinIcon { width: 10px; height: 10px; background: #ffd24a; box-shadow: inset 0 0 0 2px #e0a622, 0 0 0 1px #5a3e00; display: inline-block; margin-right: 4px; }
.dayIcon { margin-left: 8px; width: 18px; height: 18px; }

/* ---------- hotbar ---------- */
#hotbar { position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.slot {
  width: 54px; height: 54px; background: rgba(12, 14, 22, 0.88); border: 2px solid #c8a860;
  box-shadow: 0 0 0 1px #0b0a10, inset 0 0 0 1px #0b0a10, 0 3px 0 #0b0a10;
  position: relative; display: flex; align-items: center; justify-content: center;
}
.slot canvas { width: 32px; height: 32px; }
.slot .key {
  position: absolute; bottom: -8px; right: -6px; font-size: 6px; color: #ffe9a0; background: #1c1f2c;
  border: 1px solid #c8a860; box-shadow: 0 0 0 1px #0b0a10, 0 2px 0 #0b0a10; padding: 3px 4px 2px; line-height: 1;
}
.slot .ap { position: absolute; top: -8px; left: -6px; font-size: 14px; line-height: 12px; color: #7bc4ff; background: #0f131b; border: 1px solid #2f7fc9; padding: 1px 3px 0; box-shadow: 0 0 0 1px #0b0a10; }
.slot .ap:empty { display: none; }
.slot .ap.noap { color: #ff6a5c; border-color: #c92f24; }
.slot .cd { position: absolute; inset: 0; display: none; pointer-events: none; }
.slot .tip {
  display: none; position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); width: 220px;
  background: #171a24; border: 2px solid #c8a860; box-shadow: 0 0 0 2px #0b0a10; padding: 8px 10px; text-align: left; z-index: 5;
  font-size: 16px; line-height: 1.15;
}
.slot .tip b { display: block; font-family: 'Press Start 2P', monospace; font-size: 8px; margin-bottom: 6px; text-shadow: 1px 1px 0 #0b0a10; }
.slot .tip .tipMeta { display: block; color: #7bc4ff; margin-bottom: 4px; }
.slot .tip .tipDesc { display: block; color: #aab4c6; }
.slot:hover .tip { display: block; }

#interactPrompt {
  position: absolute; bottom: 126px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; font-size: 20px; color: #ffe9a0;
  background: rgba(12, 14, 22, 0.85); border: 2px solid #c8a860; box-shadow: 0 0 0 1px #0b0a10; padding: 3px 12px 3px 6px;
  animation: promptIn 0.2s ease-out;
}
@keyframes promptIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.keycap {
  font-family: 'Press Start 2P', monospace; font-size: 9px; color: #1c1f2c; background: #ffe9a0;
  border: 1px solid #0b0a10; box-shadow: 0 2px 0 #7a6236; padding: 5px 6px 4px; line-height: 1;
}

/* ---------- toasts ---------- */
#toasts { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast {
  background: rgba(12, 14, 22, 0.92); border: 2px solid #3a4358; box-shadow: 0 0 0 1px #0b0a10;
  padding: 3px 14px; font-size: 19px; animation: fadeUp 3s ease forwards; white-space: nowrap;
}
.toast.levelup { border-color: #ffd24a; color: #ffd24a; font-family: 'Press Start 2P', monospace; font-size: 10px; padding: 8px 16px; }
.toast.quest { border-color: #7bc4ff; color: #cfe8ff; }
@keyframes fadeUp { 0% { opacity: 0; transform: translateY(6px); } 10% { opacity: 1; transform: translateY(0); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- panels ---------- */
.iconBtn {
  position: absolute; bottom: 12px; right: 12px; width: 44px; height: 44px;
  background: rgba(12, 14, 22, 0.88); border: 2px solid #c8a860; color: #fff; font-size: 20px; cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px #0b0a10, inset 0 0 0 1px #0b0a10, 0 3px 0 #0b0a10;
}
.floatPanel { position: absolute; width: 320px; max-height: 440px; overflow-y: auto; }
#inventory { bottom: 66px; right: 12px; }
#npcPanel { top: 50%; left: 50%; transform: translate(-50%, -50%); width: 380px; }
.panelHead { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 12px; font-size: 10px; color: #ffd24a; text-shadow: 1px 1px 0 #0b0a10; padding-bottom: 8px; border-bottom: 1px solid #3a4358; }
.close { cursor: pointer; color: #9aa5b8; font-family: 'VT323', monospace; font-size: 18px; }
.close:hover { color: #fff; }

.invGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.invItem { background: #0f131b; border: 2px solid #0b0a10; box-shadow: inset 0 0 0 1px #2c3446; padding: 6px 4px; text-align: center; }
.invItem canvas { width: 32px; height: 32px; }
.invItem .cnt { font-size: 16px; color: #ffd24a; }
.invItem .nm { font-size: 14px; color: #9aa5b8; margin-top: 1px; line-height: 1; }

.npcList { display: flex; flex-direction: column; gap: 8px; }
.npcRow { background: #0f131b; border: 2px solid #0b0a10; box-shadow: inset 0 0 0 1px #2c3446; padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 17px; }
.npcRow button { padding: 3px 9px; font-size: 16px; }
.questDesc { font-size: 16px; color: #aab4c6; margin: 2px 0 8px; line-height: 1.15; }
.recipeCard { background: #0f131b; border: 2px solid #0b0a10; box-shadow: inset 0 0 0 1px #2c3446; padding: 8px 10px; margin-bottom: 8px; }
.recipeCard .rTitle { font-size: 8px; margin-bottom: 6px; color: #ffe9a0; text-shadow: 1px 1px 0 #0b0a10; line-height: 1.4; }
.recipeCard .rDesc { font-size: 16px; color: #9aa5b8; margin-bottom: 4px; }
.recipeCard .rNeeds { font-size: 16px; color: #7bc4ff; margin-bottom: 6px; }
.rTitle { font-family: 'Press Start 2P', monospace; font-size: 8px; line-height: 1.5; }

#chatWrap { position: absolute; bottom: 12px; left: 12px; width: 340px; }
#chatLog { max-height: 120px; overflow-y: auto; font-size: 17px; margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
#chatLog div { background: rgba(10, 13, 19, 0.6); padding: 1px 6px; line-height: 1.1; }
#chatLog .sys { color: #ffd24a; }
#chatInputRow { display: flex; align-items: stretch; gap: 6px; }
#chatInput { width: 100%; flex: 1 1 auto; min-width: 0; padding: 4px 8px; border: 2px solid #0b0a10; box-shadow: inset 0 0 0 1px #2c3446; background: rgba(12, 14, 22, 0.88); color: #fff; outline: none; }
#chatInput:focus { box-shadow: inset 0 0 0 1px #c8a860; }
#chatClose {
  flex: 0 0 auto; background: rgba(12, 14, 22, 0.88); border: 2px solid #c8a860; display: flex;
  align-items: center; justify-content: center; cursor: pointer; color: #9aa5b8;
}
#chatClose:hover { color: #fff; }

#deathOverlay { background: rgba(40, 6, 6, 0.55); }
#deathOverlay .deathPanel { text-align: center; border-color: #c92f24; box-shadow: 0 0 0 2px #0b0a10, 0 0 0 4px #5a1108, 0 0 0 6px #0b0a10, 0 12px 30px rgba(0, 0, 0, 0.6); padding: 22px 34px; }
#deathOverlay h2 { color: #ff5a4a; margin: 6px 0 8px; font-size: 14px; text-shadow: 2px 2px 0 #3a0808; }
#deathOverlay p { margin: 0; font-size: 19px; color: #e7c7c2; }
#respawnTimer { color: #ffd24a; }
.skullIcon {
  width: 32px; height: 32px; margin: 0 auto 6px; background: #e8e2d0;
  clip-path: polygon(25% 0, 75% 0, 100% 25%, 100% 70%, 80% 70%, 80% 100%, 20% 100%, 20% 70%, 0 70%, 0 25%);
  position: relative;
}
.skullIcon::before, .skullIcon::after { content: ""; position: absolute; top: 35%; width: 8px; height: 8px; background: #2a2020; }
.skullIcon::before { left: 20%; } .skullIcon::after { right: 20%; }

#controlsHint { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); font-size: 15px; color: #5a6478; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0f131b; }
::-webkit-scrollbar-thumb { background: #3a4358; border: 1px solid #0b0a10; }

/* =====================================================================
   MOBILE / TOUCH (public/mobile.js owns the JS side; body.mobile is set
   there via feature-detection, before first paint of game content).
   Desktop (no .mobile class) is untouched by everything below.
   ===================================================================== */
body.mobile { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.mobile input, body.mobile textarea { -webkit-user-select: text; user-select: text; }
body.mobile canvas#game { touch-action: none; }
body.mobile .mobileOnly { display: flex; }
body.mobile #controlsHint, body.mobile #hotbar { display: none; }
body.mobile #interactPrompt { display: none; } /* mirrored by the mobile Interact button's own label */

/* ---- rotate hint (portrait only; game stays playable underneath) ---- */
#rotateHint {
  position: fixed; top: calc(104px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 45; pointer-events: none; background: rgba(12, 14, 22, 0.88); border: 2px solid #c8a860;
  box-shadow: 0 0 0 1px #0b0a10; padding: 6px 14px; font-size: 14px; color: #ffe9a0;
  max-width: 78vw; text-align: center;
}
body.mobile.portrait #rotateHint { display: block; }

/* ---- top bar: shrink stat/credit frames, move inv+chat toggles up top ---- */
body.mobile .statFrame {
  width: min(46vw, 220px); padding: 6px 8px 5px; top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left));
}
body.mobile .barLabel { font-size: 6px; width: 16px; }
body.mobile .bar { height: 13px; }
body.mobile .barText { font-size: 12px; }
body.mobile #levelTag { font-size: 7px; }
body.mobile #creditsTag {
  top: calc(8px + env(safe-area-inset-top)); right: calc(110px + env(safe-area-inset-right));
  padding: 4px 8px; font-size: 14px;
}
body.mobile #toasts { top: calc(96px + env(safe-area-inset-top)); max-width: 58vw; }
body.mobile .toast { font-size: 15px; white-space: normal; text-align: center; }

body.mobile #invToggle, body.mobile #chatToggle {
  position: absolute; top: calc(8px + env(safe-area-inset-top)); bottom: auto;
  width: 44px; height: 44px; font-size: 19px;
}
body.mobile #invToggle { right: calc(8px + env(safe-area-inset-right)); }
body.mobile #chatToggle { right: calc(58px + env(safe-area-inset-right)); }

/* ---- chat: collapsed by default, opened via #chatToggle / focus ---- */
body.mobile #chatWrap {
  display: none; position: fixed; left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right));
  bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; z-index: 33;
}
body.mobile #chatWrap.chatOpen { display: block; }
body.mobile #chatLog { max-height: 30vh; touch-action: pan-y; overscroll-behavior: contain; }
body.mobile #chatClose { width: 40px; height: 40px; font-size: 20px; }

/* ---- panels: bigger, centered, touch-friendly ---- */
body.mobile .panel { max-width: 94vw; }
body.mobile .floatPanel {
  width: min(94vw, 480px); max-height: 78vh; left: 50%; right: auto; bottom: auto; top: 50%;
  transform: translate(-50%, -50%); overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain;
}
body.mobile #npcPanel { width: min(94vw, 480px); }
body.mobile button { min-height: 42px; padding: 9px 14px; font-size: 18px; }
body.mobile button.primary { min-height: 46px; font-size: 12px; }
body.mobile input { min-height: 42px; font-size: 18px; }
body.mobile .close { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }
body.mobile .invGrid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
body.mobile .invItem { padding: 10px 6px; }
body.mobile .npcRow { flex-wrap: wrap; }
body.mobile .npcRow button, body.mobile .recipeCard button { min-height: 40px; }

/* ---- character creation panel: fit small screens ---- */
body.mobile .create-panel { width: min(92vw, 420px); max-height: 90vh; overflow-y: auto; padding: 16px 18px; }

/* ---- death overlay ---- */
body.mobile .deathPanel { width: min(90vw, 380px); padding: 20px 22px; }

/* =====================================================================
   Touch controls: virtual joystick (left) + action buttons (right).
   Built by mobile.js as children of #hud so they inherit its
   show/hide state automatically (hidden pre-game, hidden under
   #deathOverlay / #charCreate which sit at a higher z-index).
   ===================================================================== */
#mobileJoystickZone {
  position: absolute; left: 0; top: 0; bottom: 0; width: 54%; z-index: 20; touch-action: none;
}
#mobileJoystickBase {
  position: fixed; width: 104px; height: 104px; margin: -52px 0 0 -52px;
  border: 2px solid rgba(200, 168, 96, 0.55); border-radius: 50%;
  background: rgba(12, 14, 22, 0.35); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  opacity: 0; transition: opacity 0.1s; pointer-events: none;
}
#mobileJoystickBase.visible { opacity: 1; }
#mobileJoystickThumb {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%; background: rgba(200, 168, 96, 0.75); box-shadow: 0 0 0 2px rgba(11, 10, 16, 0.6);
  will-change: transform;
}

#mobileButtons {
  position: absolute; right: calc(10px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom));
  width: 234px; height: 200px; z-index: 20;
}
.mBtn, .mBtn:active {
  /* override the generic button{position:relative;top:0} / button:active{top:2px} press animation -
     left as "top" it over-constrains top+height+bottom and the browser silently drops bottom,
     pinning every circular button to the top of #mobileButtons instead of its bottom-right spot. */
  position: absolute; top: auto;
}
.mBtn {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 1px; background: rgba(12, 14, 22, 0.72); border: 2px solid #c8a860;
  box-shadow: 0 0 0 1px #0b0a10, inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 3px 0 rgba(0, 0, 0, 0.4);
  color: #ffe9a0; font-family: 'Press Start 2P', monospace; touch-action: none; -webkit-user-select: none; user-select: none;
}
.mBtn:active { background: rgba(60, 50, 30, 0.85); }
.mBtnAttack { right: 0; bottom: 0; width: 78px; height: 78px; font-size: 24px; border-color: #ff5a4a; }
.mBtnAbility { right: 92px; bottom: 4px; width: 58px; height: 58px; font-size: 11px; }
.mBtnSkill { right: 148px; bottom: 62px; width: 54px; height: 54px; font-size: 11px; }
.mBtnPotion { right: 4px; bottom: 96px; width: 52px; height: 52px; font-size: 10px; color: #ff8a80; border-color: #ff8a80; }
.mBtnInteract {
  right: 60px; bottom: 150px; width: 56px; height: 56px; font-size: 12px; color: #1c1f2c; background: #ffe9a0;
  opacity: 0; pointer-events: none; transition: opacity 0.12s;
}
.mBtnInteract.active { opacity: 1; pointer-events: auto; }
.mBtnAp {
  position: absolute; top: -7px; left: -6px; font-size: 9px; line-height: 1; color: #7bc4ff; background: #0f131b;
  border: 1px solid #2f7fc9; padding: 2px 3px; box-shadow: 0 0 0 1px #0b0a10;
}
.mBtnCount {
  position: absolute; bottom: -7px; right: -6px; font-size: 9px; line-height: 1; color: #ffe9a0; background: #1c1f2c;
  border: 1px solid #c8a860; padding: 2px 4px; box-shadow: 0 0 0 1px #0b0a10;
}
.mBtnCd { position: absolute; inset: 0; display: none; pointer-events: none; border-radius: 50%; overflow: hidden; }
.mBtnLabel {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 8px; white-space: nowrap;
  background: rgba(12, 14, 22, 0.9); border: 2px solid #c8a860; box-shadow: 0 0 0 1px #0b0a10;
  padding: 4px 8px; font-family: 'VT323', monospace; font-size: 16px; color: #ffe9a0;
}

/* narrow screens (portrait phones): the top row (statFrame ... credits ... chat/inv icons) is
   tuned for landscape-width canvases and doesn't fit side-by-side under ~480px - drop the
   credits tag under the icon row instead of squeezing it between statFrame and the icons. */
@media (max-width: 480px) {
  body.mobile #creditsTag {
    top: calc(58px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right));
  }
  body.mobile .statFrame { width: min(58vw, 220px); }
}

/* short landscape phones: pull the cluster in a bit so it doesn't crowd the top edge */
@media (max-height: 420px) {
  #mobileButtons { width: 210px; height: 170px; }
  .mBtnAttack { width: 68px; height: 68px; }
  .mBtnAbility { right: 84px; bottom: 4px; width: 52px; height: 52px; }
  .mBtnSkill { right: 134px; bottom: 54px; width: 48px; height: 48px; }
  .mBtnPotion { right: 4px; bottom: 82px; width: 46px; height: 46px; }
  .mBtnInteract { right: 54px; bottom: 128px; width: 50px; height: 50px; }
  body.mobile .statFrame { width: min(40vw, 190px); }
}
