/**
 * PocketSkills - In-game HUD: status plates, minimap column, controls,
 * minigames, toasts and the always-open bottom chat.
 */

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

#game-view, .chat {
  color: var(--text);
}

#game-view {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #07090c;
}

/* the world canvas is lower resolution and filtered up by the compositor (smooth graphics) */
#game-canvas, #overlay-canvas {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
}

/* Names, bars and texts: full resolution, never catches taps */
#overlay-canvas { pointer-events: none; }

/* --- Top-left status ------------------------------------------------------- */

.hud-top {
  --hud-card-w: 178px; /* the avatar plate and the gold & gems card share this width */
  position: absolute;
  top: calc(var(--sat) + 8px);
  left: calc(var(--sal) + 8px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  z-index: 5;
  pointer-events: none;
}

.hud-top > * {
  pointer-events: auto;
}

.profile-plate {
  box-sizing: border-box;
  width: var(--hud-card-w);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  text-align: left;
}

#hud-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background: radial-gradient(circle at 50% 35%, #3f6e8f, #1a2e3d);
  border: 1px solid var(--frame-dark);
}

.profile-text { width: 112px; }

.profile-text strong {
  display: block;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #9dff9d;
  text-shadow: 0 1px 0 #000;
}

.profile-text small {
  color: var(--text-dim);
  font-size: 11px;
}

/* Tibia-style health & mana bars */
.vital {
  position: relative;
  display: block;
  width: 108px;
  height: 11px;
  margin-top: 2px;
  border: 1px solid #000;
  border-radius: 2px;
  background: #1a0f0a;
  overflow: hidden;
}

.vital i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
}

.vital.hp i { background: linear-gradient(180deg, #3cdc3c, #1c8a1c); }
.vital.mp i { background: linear-gradient(180deg, #4a8cff, #1c4ab0); }
/* experience to the next level: just a thin gold bar (the numbers are in the character sheet) */
.vital.xp { height: 5px; }
.vital.xp i { background: linear-gradient(180deg, #ffe27a, #d8a420); transition: width 0.4s ease-out; }

.vital b {
  position: relative;
  display: block;
  font-size: 9px;
  line-height: 10px;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 0 #000;
}

.wallet-plate {
  box-sizing: border-box;
  width: var(--hud-card-w); /* always as wide as the avatar plate above, whatever the amounts */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  overflow: hidden;
}

.wallet-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wallet-item {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: 12px;
  text-shadow: 0 1px 0 #000;
}

.gem-button i {
  font-style: normal;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #2f8ab0;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

.hud-conditions {
  display: flex;
  gap: 3px;
  pointer-events: none;
}

.hud-conditions:empty { display: none; }

.condition-icon {
  pointer-events: auto;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(20, 14, 9, 0.85);
  border: 1px solid var(--frame);
}

.hud-buffs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.buff-chip {
  pointer-events: auto;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 2px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(20, 14, 9, 0.85);
  border: 1px solid var(--frame);
  color: var(--text);
  text-shadow: 0 1px 0 #000;
}

/* --- Right column: minimap + buttons --------------------------------------- */

.hud-side {
  position: absolute;
  top: calc(var(--sat) + 8px);
  right: calc(var(--sar) + 8px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 5;
  pointer-events: none; /* the empty space of the column lets taps reach the map */
}

.hud-side > *, .side-buttons > * {
  pointer-events: auto;
}

.minimap-frame {
  position: relative;
  padding: 3px;
  border-radius: 6px;
  background: linear-gradient(180deg, #5a4430, #2e2218);
  border: 1px solid var(--frame-dark);
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 3px 8px rgba(0, 0, 0, 0.5);
}

#minimap {
  touch-action: none;
  cursor: grab;
  display: block;
  width: 104px;
  height: 104px;
  border-radius: 3px;
  background: #000;
  image-rendering: pixelated;
}

.floor-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 26px;
  padding: 1px 5px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border-radius: 4px;
  background: #3a2b1e;
  border: 1px solid var(--frame-dark);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}

/* Minimap zoom: two small stone buttons on the left edge of the frame */
.minimap-zoom {
  position: absolute;
  left: -4px;
  top: -4px;
  display: flex;
  gap: 2px;
}

.minimap-zoom button {
  width: 22px;
  height: 20px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  color: #f6ead0;
  border-radius: 4px;
  border: 1px solid var(--frame-dark);
  background: linear-gradient(180deg, var(--frame-light), var(--frame) 55%, #33261a);
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 1px 0 rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 0 #000;
}

.minimap-zoom button:disabled { opacity: 0.45; }

/* the globe on the other top corner opens the world map (WorldMapPanel) */
.minimap-globe {
  position: absolute;
  right: -4px;
  top: -4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 20px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid var(--frame-dark);
  background: linear-gradient(180deg, var(--frame-light), var(--frame) 55%, #33261a);
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 1px 0 rgba(0, 0, 0, 0.45);
}

/* sun / moon dial (WorldClock) to the left of the minimap, the rain icon under it */
.world-clock {
  position: absolute;
  top: 0;
  right: calc(100% + 4px);
  display: grid;
  justify-items: center;
  gap: 3px;
  pointer-events: auto;
}

#hud-clock {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
}

.clock-time {
  padding: 1px 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--text);
  border-radius: 3px;
  background: rgba(12, 8, 5, 0.8);
  text-shadow: 0 1px 0 #000;
}

.weather-chip {
  display: grid;
  place-items: center;
  width: 24px;
  height: 22px;
  border-radius: 4px;
  background: rgba(20, 14, 9, 0.85);
  border: 1px solid var(--frame);
}

.floor-badge.under { background: #4a2a5a; }

/* protection zone sign, bottom-left of the minimap */
.zone-badge {
  position: absolute;
  left: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #3a2b1e;
  border: 1px solid var(--frame-dark);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
.floor-badge.above { background: #2a4a6a; }

.location-label {
  max-width: 132px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  text-align: right;
  color: var(--text);
  border-radius: 4px;
  background: rgba(12, 8, 5, 0.7);
  text-shadow: 0 1px 0 #000;
}

.side-buttons {
  display: grid;
  grid-template-columns: 46px 46px;
  gap: 6px;
  pointer-events: none; /* only the buttons themselves catch taps */
}

/* the main column ends with the Menu (and the staff crown); the second column on the left, from the
   Equipment row down: Guild, then News */
.side-buttons > :not(.side-extra) { grid-column: 2; }
.side-extra { grid-column: 1; grid-row: 2 / span 7; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.side-extra > * { pointer-events: auto; }

.side-buttons .stone-btn {
  width: 46px;
  height: 46px;
  padding: 0;
}

.btn-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 16px;
  border-radius: 9px;
  border: 1px solid #000;
  background: #3a2b1e;
  color: #fff;
}

.btn-badge:empty { display: none; }

/* --- Battle list and party (HudLists.js), under the boons on the left --- */
.hud-list {
  width: 152px;
  border-radius: 6px;
  background: rgba(20, 14, 9, 0.82);
  border: 1px solid #000;
  box-shadow: inset 0 0 0 1px var(--frame), 0 3px 8px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.hud-list-head {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  text-align: left;
  background: linear-gradient(180deg, rgba(90, 68, 48, 0.9), rgba(46, 34, 24, 0.9));
  border-bottom: 1px solid #000;
}

.hud-list-head b { color: var(--text-dim); font-weight: 700; }
.hud-list-head .fold { margin-left: auto; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid #f2dca8; }
.hud-list.folded .fold { transform: rotate(180deg); }
.hud-list.folded .hud-list-rows { display: none; }

.hud-list-rows {
  max-height: 123px;          /* five rows; swipe or scroll for the rest */
  padding-bottom: 3px;        /* the last row's frame stays clear of the rounded bottom corners */
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
}

.list-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-template-rows: auto 3px;
  column-gap: 5px;
  align-items: center;
  width: 100%;
  height: 24px;
  padding: 2px 6px 2px 3px;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
}

.list-row > .px-icon, .list-row > canvas { grid-row: 1 / 3; width: 20px; height: 20px; }
.list-name { font-size: 10px; font-weight: 700; color: #f0e6d0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 0 #000; }
.list-row.player .list-name { color: #7dff7d; }
.list-row.npc .list-name { color: #ffe14d; }
.list-row.focus { outline: 1px solid #3a9cff; outline-offset: -1px; padding: 2px 6px 4px 3px; } /* the NPC you picked: blue, like the red of a target */
.list-row.target { outline: 1px solid #ff2020; outline-offset: -1px; padding: 2px 6px 4px 3px; } /* a thin red frame over everything, the health bar clear inside it */
.list-hp { display: block; height: 3px; background: #000; }
.list-hp > b { display: block; height: 100%; background: #36c03a; }
.list-row .list-name { grid-column: 2; grid-row: 1; }
.list-row .list-hp { grid-column: 2; grid-row: 2; }
.list-row.party { grid-template-columns: 14px 1fr auto; }
.list-row.party.far { opacity: 0.5; }
.list-kick { grid-column: 3; grid-row: 1 / 3; width: 18px; height: 18px; font-size: 13px; line-height: 1; color: #ffb8a8; }
.hud-list-head .party-leave + .fold { margin-left: 6px; }
#party-head { cursor: pointer; }
.party-leave { margin-left: auto; padding: 0 6px; font-size: 9px; color: #ffb8a8; border: 1px solid rgba(0, 0, 0, 0.5); border-radius: 3px; }

/* the arrow beside the backpack folds every button below it away (UIManager.setSideCollapsed) */
.bag-wrap { position: relative; }

.side-toggle {
  position: absolute;
  left: -18px;                /* flush against the backpack button */
  top: 50%;
  width: 18px;
  height: 30px;
  margin-top: -15px;
  display: grid;
  place-items: center;
  border-radius: 4px 0 0 4px;
  border: 1px solid #000;
  border-right: 0;
  background: linear-gradient(180deg, #5a4430, #2e2218);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}

.side-toggle i {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid #f2dca8; /* up: fold the buttons into the backpack */
  transition: transform 0.15s;
}

.side-buttons.collapsed .side-toggle i { transform: rotate(180deg); }
.side-buttons.collapsed > :not(.bag-wrap) { display: none; }
.side-buttons.collapsed { grid-template-columns: 46px; }
.side-buttons.collapsed > .bag-wrap { grid-column: 1; }
.btn-badge.full { background: #c4321e; }

/* --- Controls ---------------------------------------------------------------- */

.hud-controls {
  position: absolute;
  left: calc(var(--sal) + 12px);
  right: calc(var(--sar) + 12px);
  bottom: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 6;
}

#joystick-zone {
  position: relative;
  width: 132px;
  height: 132px;
  pointer-events: auto;
  touch-action: none;
}

#joystick-base {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 112px;
  height: 112px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 14, 9, 0.35), rgba(20, 14, 9, 0.6));
  border: 2px solid rgba(232, 184, 58, 0.35);
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.25);
  opacity: 0.75;
  transition: opacity 0.15s;
}

#joystick-base.active { opacity: 1; }

#joystick-base.floating {
  position: fixed;
  z-index: 20;
}

#joystick-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50px;
  height: 50px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f6d67a, #c89a2a 60%, #7a5a12);
  border: 2px solid #3a2a0a;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
}

/* Arrow pad (Settings > Controls > Arrows): one zone, 8 directions, the pressed arrows glow */
#dpad-zone {
  position: relative;
  width: 132px;
  height: 132px;
  pointer-events: auto;
  touch-action: none;
}

.dpad-arrow {
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  border: 1px solid var(--frame-dark);
  background: linear-gradient(180deg, rgba(90, 68, 48, 0.85), rgba(46, 34, 24, 0.85));
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 2px 5px rgba(0, 0, 0, 0.5);
  opacity: 0.8;
}

.dpad-arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border: 9px solid transparent;
  border-bottom: 12px solid var(--gold);
  border-top-width: 0;
  transform: translate(-50%, -60%);
  filter: drop-shadow(0 1px 0 #000);
}

.dpad-arrow[data-dir="up"] { left: 45px; top: 2px; }
.dpad-arrow[data-dir="down"] { left: 45px; bottom: 2px; transform: rotate(180deg); }
.dpad-arrow[data-dir="left"] { left: 2px; top: 45px; transform: rotate(-90deg); }
.dpad-arrow[data-dir="right"] { right: 2px; top: 45px; transform: rotate(90deg); }

.dpad-arrow.on {
  opacity: 1;
  background: linear-gradient(180deg, #8a6a3e, #4e3a24);
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 10px rgba(232, 184, 58, 0.5);
}

/* the two quick slots (Q / E) around the action button: a small arc on its left */
.hotkeys {
  position: absolute;
  right: 86px;
  bottom: 4px;
  width: 104px;
  height: 104px;
  pointer-events: none;
}

.hotkey {
  position: absolute;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--frame-dark);
  background: radial-gradient(circle at 40% 30%, #5a4430, #2e2218 70%);
  box-shadow: inset 0 0 0 2px rgba(232, 184, 58, 0.25), 0 3px 8px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  touch-action: none;
  overflow: hidden;
}

.hotkey[data-hotkey="0"] { left: 28px; bottom: 0; }   /* Q: just left of the action button */
.hotkey[data-hotkey="1"] { right: 2px; top: 0; }      /* E: above it, to the left */
.hotkey.empty::before { content: "+"; font-size: 22px; font-weight: 700; color: rgba(242, 220, 168, 0.45); }
.hotkey.none-left .hotkey-icon { filter: grayscale(1) brightness(0.6); }
.hotkey-count { position: absolute; right: 7px; bottom: 5px; font-size: 10px; color: #fff; text-shadow: -1px -1px 0 #000, 1px 1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.hotkey-key { position: absolute; left: 8px; top: 4px; font-size: 9px; font-style: normal; font-weight: 700; color: var(--gold); text-shadow: 0 1px 0 #000; }
html.touch .hotkey-key { display: none; } /* the Q / E letters are keyboard keys: only on desktop */
/* cooldown: a dark sweep that unwinds (--cd 1 -> 0) */
.hotkey-cd { position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: conic-gradient(rgba(0, 0, 0, 0.62) calc(var(--cd, 0) * 360deg), transparent 0); }

.action-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.action-label {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border-radius: 4px;
  background: rgba(12, 8, 5, 0.75);
  text-shadow: 0 1px 0 #000;
  white-space: nowrap;
}

.action-label:empty { visibility: hidden; }

#action-btn {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid var(--frame-dark);
  background: radial-gradient(circle at 40% 30%, #6b5136, #3a2b1e 65%, #241a12);
  box-shadow: inset 0 0 0 3px rgba(232, 184, 58, 0.35), inset 0 2px 0 var(--bevel-hi), 0 4px 10px rgba(0, 0, 0, 0.55);
  touch-action: none;
  transition: transform 0.06s, box-shadow 0.15s;
}

#action-btn:active { transform: scale(0.95); }

#action-btn.ready {
  box-shadow: inset 0 0 0 3px #e8b83a, inset 0 2px 0 var(--bevel-hi), 0 0 14px rgba(232, 184, 58, 0.55), 0 4px 10px rgba(0, 0, 0, 0.55);
}

#action-btn.locked { box-shadow: inset 0 0 0 3px #a8402e, 0 4px 10px rgba(0, 0, 0, 0.55); }
#action-btn.busy { box-shadow: inset 0 0 0 3px #6fb8ff, 0 0 16px rgba(111, 184, 255, 0.55); }
#action-btn.idle .px-slot { opacity: 0.35; }

/* --- Minigames ---------------------------------------------------------------- */

.minigame {
  position: absolute;
  left: 50%;
  bottom: 158px;
  width: min(86%, 360px);
  transform: translateX(-50%);
  z-index: 8;
}

.mg-frame {
  padding: 8px 10px 10px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(58, 43, 30, 0.97), rgba(30, 22, 15, 0.97));
  border: 1px solid var(--frame-dark);
  box-shadow: inset 0 0 0 2px var(--frame), inset 0 3px 0 var(--bevel-hi), 0 6px 16px rgba(0, 0, 0, 0.6);
}

.mg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mg-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 15px;
  color: var(--gold);
  text-shadow: 0 1px 0 #000;
}

.mg-close {
  width: 26px;
  height: 26px;
  font-size: 18px;
  border-radius: 4px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.3);
}

.mg-hint {
  min-height: 16px;
  margin: 2px 0 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.mg-hint.bite {
  color: #ff6a50;
  font-weight: 700;
  animation: pulse 0.35s ease-in-out infinite alternate;
}

@keyframes pulse { to { transform: scale(1.06); } }

.reel-river {
  position: relative;
  height: 36px;
  border-radius: 4px;
  border: 2px solid #1a120c;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 2px, transparent 2px 14px),
    linear-gradient(180deg, #2f6fb0, #1f4f86);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.reel-window {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  border-radius: 3px;
  border: 2px solid #e8b83a;
  background: rgba(232, 184, 58, 0.22);
  box-shadow: 0 0 8px rgba(232, 184, 58, 0.5);
}

.reel-window.on {
  border-color: #9dff7a;
  background: rgba(157, 255, 122, 0.25);
  box-shadow: 0 0 10px rgba(157, 255, 122, 0.6);
}

.reel-fish {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0;
  height: 0;
}

.reel-fish .px-slot {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  filter: brightness(0.15) drop-shadow(0 0 3px rgba(255, 255, 255, 0.6));
}

.meter {
  height: 10px;
  margin-top: 8px;
  border-radius: 3px;
  border: 1px solid #000;
  background: #1a120c;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(180deg, #9dff7a, #3f9f2a);
}

.meter-fill.low { background: linear-gradient(180deg, #ffb06a, #c4501e); }

.strike-bar {
  position: relative;
  height: 28px;
  border-radius: 4px;
  border: 2px solid #1a120c;
  background: linear-gradient(180deg, #5a5048, #3a332d);
  overflow: hidden;
}

.strike-bar.wood { background: linear-gradient(180deg, #7a5230, #4e3119); }

.strike-notch {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 216, 74, 0.55), rgba(255, 170, 40, 0.35));
  border-left: 2px solid #ffd84a;
  border-right: 2px solid #ffd84a;
}

.strike-stage {
  position: relative;
  padding-top: 30px; /* room for the swinging tool */
}

/* the ore chunk / log slides along the bar like the fish in the reel duel */
.strike-cursor {
  position: absolute;
  top: 50%;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7));
}

.strike-cursor::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.55);
  z-index: -1;
}

.strike-cursor.hit { animation: strike-hit 0.25s ease-out; }
.strike-cursor.glance { animation: strike-glance 0.25s ease-out; }

/* the best tool you carry hangs over the target zone and swings on every strike */
.strike-tool {
  position: absolute;
  top: 0;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  transform-origin: 80% 85%;
  transition: left 0.15s ease-out;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7));
}

.strike-tool.swing { animation: tool-swing 0.25s ease-in; }

@keyframes tool-swing {
  0% { transform: rotate(0deg); }
  45% { transform: rotate(-55deg) translateY(4px); }
  100% { transform: rotate(0deg); }
}

@keyframes strike-hit {
  0% { transform: translateY(-50%) scale(1.45); filter: brightness(2) drop-shadow(0 0 8px #ffd84a); }
  100% { transform: translateY(-50%) scale(1); }
}

@keyframes strike-glance {
  0%, 100% { transform: translateY(-50%); }
  30% { transform: translate(-4px, -50%); }
  60% { transform: translate(4px, -50%); }
}

/* --- Controls layout editor ------------------------------------------------------- */

.layout-bar {
  position: absolute;
  left: 50%;
  top: calc(var(--sat) + 120px);
  width: min(90%, 340px);
  padding: 10px 12px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  text-align: center;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(58, 43, 30, 0.97), rgba(30, 22, 15, 0.97));
  border: 1px solid var(--frame-dark);
  box-shadow: inset 0 0 0 2px var(--frame), 0 6px 16px rgba(0, 0, 0, 0.6);
  z-index: 30;
}

.layout-bar p { font-size: 12px; color: var(--text-dim); }

.layout-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.layout-part { flex: 1; text-align: left; font-size: 12px; font-weight: 700; color: var(--gold); }

.layout-edit #joystick-zone, .layout-edit #dpad-zone, .layout-edit .action-wrap, .layout-edit .hotkey {
  border-radius: 12px;
}

.layout-edit #joystick-zone, .layout-edit #dpad-zone, .layout-edit .action-wrap, .layout-edit .hotkey,
.layout-edit #hud-profile, .layout-edit .wallet-plate, .layout-edit .hud-list {
  outline: 2px dashed var(--gold);
  outline-offset: 4px;
  touch-action: none;
}

.layout-edit .layout-selected { outline: 3px solid #ffe08a; }
/* while placing them, the battle and party lists show even when empty */
.layout-edit .hud-list.hidden { display: block !important; }
.layout-edit .layout-bar { cursor: move; touch-action: none; z-index: 32; }

.layout-edit .hud-controls { z-index: 31; }

/* --- Examine card (long-press / right-click / L) ------------------------------- */

.look-card {
  position: absolute;
  left: 50%;
  top: calc(var(--sat) + 168px);
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(72%, 320px);
  padding: 8px 12px 8px 8px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(58, 43, 30, 0.96), rgba(30, 22, 15, 0.96));
  border: 1px solid var(--frame-dark);
  box-shadow: inset 0 0 0 2px var(--frame), inset 0 3px 0 var(--bevel-hi), 0 6px 16px rgba(0, 0, 0, 0.6);
  z-index: 7;
  animation: look-in 0.16s ease-out;
}

@keyframes look-in { from { opacity: 0; transform: translate(-50%, -6px) scale(0.96); } }

#look-icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: radial-gradient(circle at 50% 40%, #4a3826, #1a120c);
  border: 1px solid var(--frame-dark);
}

.look-body { min-width: 0; }
.look-body strong { display: block; font-family: var(--font-title); font-size: 15px; color: var(--gold); text-shadow: 0 1px 0 #000; }
.look-body p { font-size: 11.5px; line-height: 1.35; color: var(--text-dim); }
.look-body p.tone-good { color: var(--good); }
.look-body p.tone-warn { color: var(--bad); }
.look-body p.tone-muted { color: var(--text-muted); font-style: italic; }

/* --- Toasts (Tibia-style status messages) ------------------------------------- */

/* Tibia's mid-screen messages (a private message while you are not on that tab): cyan, fading out */
.screen-messages {
  position: absolute;
  left: 50%;
  top: 38%;
  width: min(92%, 520px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 7;
  pointer-events: none;
  text-align: center;
}

.screen-message {
  font-size: 15px;
  font-weight: 700;
  color: #ffb04a;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  overflow-wrap: anywhere;
  animation: screen-message 5s ease-in forwards;
}

@keyframes screen-message { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

.toasts {
  position: absolute;
  left: 50%;
  bottom: 152px;
  width: min(92%, 440px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 7;
  pointer-events: none;
}

.toast {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  animation: toast-in 0.15s ease-out, toast-out 0.6s ease-in forwards 3.2s;
}

.toast.info { color: #ffffff; }
.toast.success { color: var(--good); }
.toast.warning { color: var(--warn); }
.toast.error { color: var(--bad); }
.toast.legendary { color: var(--legend); }
.toast.private { color: #5ff7f7; }

@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

/* --- Chat (always open, full width at the bottom) ------------------------------ */

.chat {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(var(--chat-h) + var(--sab));
  padding: 0 calc(var(--sar) + 4px) calc(var(--sab) + 4px) calc(var(--sal) + 4px);
  background: linear-gradient(180deg, #2e2218, #1a130d);
  border-top: 2px solid var(--frame-dark);
  box-shadow: inset 0 1px 0 var(--frame-light);
  z-index: 10;
}

/* Drag the grip on the chat's top edge to resize it (height saved per device) */
.chat-grip {
  position: absolute;
  z-index: 2;
  padding: 0;
  left: 50%;
  top: -9px;
  width: 54px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 7px;
  border: 1px solid var(--frame-dark);
  background: linear-gradient(180deg, var(--frame-light), var(--frame));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  touch-action: none;
  cursor: ns-resize;
  z-index: 11;
}

.chat-grip::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 4px;
  height: 4px;
  border-top: 1px solid rgba(255, 230, 180, 0.6);
  border-bottom: 1px solid rgba(255, 230, 180, 0.6);
}

.chat-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding-top: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tab.dragging { transform: translateY(-3px) scale(1.06); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6); color: var(--gold); z-index: 1; }

.chat-tab {
  position: relative;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid var(--frame-dark);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: #241a12;
}

.chat-tab.private { flex: none; color: #8fd0ff; }
.chat-tab.private span { display: inline-block; max-width: 84px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

.tab-close {
  margin-left: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.chat-tab.active {
  color: var(--text);
  background: #3a2b1e;
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}

.tab-dot {
  display: none;
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff5a40;
}

.chat-tab.unread .tab-dot { display: block; }

.chat-clear {
  margin-left: auto;
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 6px;
  border: 1px solid var(--frame-dark);
  background: rgba(8, 6, 4, 0.72);
  font-size: 11.5px;
  line-height: 1.4;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.chat-msg { color: #d9d2c0; overflow-wrap: anywhere; }
.chat-msg time { color: var(--text-muted); margin-right: 4px; }
.chat-msg .sender { font-weight: 700; color: #ffe14d; }
.chat-msg.player .sender { color: #9dff9d; }
.chat-msg.player .text { color: #ffffff; }
.chat-msg.npc .text { color: #ffe14d; }
.chat-msg.pm .text { color: #5ff7f7; }
.chat-msg.guild.player .text { color: #e3ccff; }
.chat-msg.party.player .text { color: #ffb04a; }
.chat-tab.party { color: #ffb04a; }
.chat-tab.guild { color: #c79aff; }
.chat-crown { vertical-align: -1px; }
.chat-msg.system .text { color: #ffffff; white-space: pre-line; }
.chat-msg.broadcast .text { color: #ff5a40; font-weight: 700; }
.role-tag { font-weight: 700; }

.chat-form {
  display: flex;
  gap: 4px;
  padding-top: 4px;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid var(--frame-dark);
  background: #0c0805;
  color: var(--text);
  font-size: 16px; /* prevents iOS zoom on focus */
  outline: none;
}

.chat-form input:focus {
  border-color: var(--gold-dark);
}

/* --- Loading screen ------------------------------------------------------------ */

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0b0806;
  z-index: 100;
}

.loading-card {
  display: grid;
  gap: 6px;
  text-align: center;
}

.loading-card strong { display: block; }

.loading-card span { color: var(--text-dim); }

.loading { transition: opacity 0.35s ease; }
.loading.done { opacity: 0; pointer-events: none; }

.loading-bar {
  width: min(70vw, 260px);
  height: 14px;
  margin: 4px auto 0;
  padding: 2px;
  border-radius: 4px;
  border: 1px solid #000;
  background: #1a120c;
  box-shadow: inset 0 0 0 1px #4a3826, 0 2px 6px rgba(0, 0, 0, 0.6);
}

.loading-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, #f6d67a, #c89a2a 60%, #8a6614);
  box-shadow: 0 0 8px rgba(232, 184, 58, 0.5);
  transition: width 0.25s ease;
}

/* Desktop (no touch screen, see InputManager): no on-screen movement / action button,
   the chat floats bottom-left instead of spanning the whole window */
html:not(.touch) #joystick-zone, html:not(.touch) #dpad-zone, html:not(.touch) .action-wrap { display: none !important; }
html:not(.touch) .hotkeys { right: 0; } /* desktop: no action button, the quick slots take its corner (keys Q / E) */

@media (min-width: 900px) {
  html:not(.touch) #app { position: relative; }
  html:not(.touch) .chat {
    position: absolute;
    left: calc(var(--sal) + 8px);
    bottom: 8px;
    width: min(640px, 46vw);
    height: var(--chat-h);
    padding-bottom: 4px;
    border: 2px solid var(--frame-dark);
    border-radius: 6px;
    background: linear-gradient(180deg, rgba(46, 34, 24, 0.94), rgba(26, 19, 13, 0.94));
  }
  html:not(.touch) .minigame { bottom: calc(var(--chat-h) + 40px); }
  html:not(.touch) .toasts { bottom: calc(var(--chat-h) + 30px); }
}

/* Landscape phones: tighter chat & controls */
/* shorter screens (laptops, small phones): slimmer side buttons so they clear the action button */
@media (min-height: 521px) and (max-height: 820px) {
  .side-buttons { gap: 4px; grid-template-columns: 40px 40px; }
  .side-buttons.collapsed { grid-template-columns: 40px; }
  .side-extra { gap: 4px; }
  .side-buttons .stone-btn { width: 40px; height: 40px; }
}

@media (max-height: 520px) {
  :root { --chat-h: 128px; }
  #minimap { width: 84px; height: 84px; }
  .hud-side {
    display: grid;
    grid-template-areas: "buttons map" ". label";
    align-items: start;
    justify-items: end;
    gap: 6px;
  }
  .minimap-frame { grid-area: map; }
  .location-label { grid-area: label; }
  .side-buttons { grid-area: buttons; grid-auto-flow: column; grid-auto-columns: 40px; grid-template-columns: none; }
  .side-buttons > :not(.side-extra), .side-buttons.collapsed > .bag-wrap { grid-column: auto; }
  .side-extra { grid-column: auto; grid-row: auto; flex-direction: row; } /* landscape: one row, the extras at its end */
  .side-buttons.collapsed { grid-template-columns: none; }
  .side-toggle i { transform: rotate(-90deg); } /* landscape: the buttons fold to the left */
  .hud-buffs { flex-direction: row; flex-wrap: wrap; max-width: 340px; } /* boons side by side, clear of the stick */
  /* landscape: the battle list and the party sit in a second column beside the avatar, clear of the stick */
  .hud-top { display: grid; grid-template-columns: auto 152px; column-gap: 6px; align-items: start; }
  .hud-top > :not(.hud-list) { grid-column: 1; }
  #battle-list { grid-column: 2; grid-row: 1 / span 3; }
  #party-list { grid-column: 2; grid-row: 4 / span 3; }
  .hud-list-rows { max-height: 72px; }
  .side-buttons.collapsed .side-toggle i { transform: rotate(90deg); }
  .side-buttons .stone-btn { width: 40px; height: 40px; }
  #joystick-zone, #dpad-zone { width: 112px; height: 112px; }
  .dpad-arrow { width: 36px; height: 36px; }
  .dpad-arrow[data-dir="up"], .dpad-arrow[data-dir="down"] { left: 38px; }
  .dpad-arrow[data-dir="left"], .dpad-arrow[data-dir="right"] { top: 38px; }
  #joystick-base { width: 96px; height: 96px; }
  #action-btn { width: 70px; height: 70px; }
  .minigame { bottom: 96px; }
  .look-card { top: calc(var(--sat) + 8px); width: min(40%, 300px); }
  .toasts { bottom: 100px; }
}

/* --- Login screen (Tibia client style), over the live world --- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(20, 14, 8, 0.55), rgba(6, 4, 2, 0.92));
  backdrop-filter: blur(3px);
}

.login-card {
  width: min(360px, 100%);
  padding: 18px 18px 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, #3a2b1e, #22180f);
  border: 2px solid var(--frame-dark);
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 10px 30px rgba(0, 0, 0, 0.7);
}

.login-card h1 { margin: 0 0 10px; text-align: center; line-height: 0; }

/* the game's logo (icons/logo.png, painted at 2x by npm run sprites): crisp pixels at any size */
.game-logo { display: block; width: min(287px, 100%); height: auto; margin: 0 auto; image-rendering: pixelated; filter: drop-shadow(0 0 10px rgba(232, 184, 58, 0.25)); }

.login-card h2 { margin: 0 0 10px; font-size: 15px; color: var(--text); text-align: center; }
.login-links { display: flex; justify-content: space-between; gap: 10px; }
.link-btn { padding: 2px 0; border: 0; background: none; color: var(--gold); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.login-error.ok { color: var(--good); }
.login-form, #login-chars { display: grid; gap: 10px; }
.login-card label { display: grid; gap: 4px; font-size: 12px; color: var(--text-dim); }

.login-card input:not([type="checkbox"]) {
  padding: 9px 10px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: #120c07;
  border: 1px solid var(--frame-dark);
  border-radius: 4px;
}

.login-card .login-remember { display: flex; align-items: center; gap: 6px; }
.login-card input.masked { -webkit-text-security: disc; }
.login-error { min-height: 1em; margin: 0; color: #ff6a5a; font-size: 12px; }
.login-char-list { display: grid; gap: 6px; }

.login-char {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  color: var(--text);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--frame);
}

.login-char small { color: var(--text-dim); }

/* "Use on…" mode (Game.startUse): a hint over the map; tapping it cancels */
.use-hint {
  position: absolute;
  left: 50%;
  top: calc(var(--sat, 0px) + 96px);
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(86vw, 420px);
  padding: 7px 14px;
  border: 1px solid var(--gold, #e8b83a);
  border-radius: 6px;
  background: rgba(20, 14, 8, 0.88);
  color: #fff3c8;
  font: 600 13px/1.3 system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  animation: use-pulse 1.4s ease-in-out infinite;
}
@keyframes use-pulse { 50% { border-color: #fff3c8; } }
body.use-mode #game-canvas { cursor: crosshair; }
