/* ============================================================
   YapiCraft — HUD
   Un solo lenguaje de superficie (cristal oscuro), color solo
   con significado: oro=misión/raro · verde=botín/éxito ·
   rojo=peligro/daño · celeste=combate/info · violeta=XP.
   Animar solo en cambios de estado; HUD en reposo = HUD quieto.
   ============================================================ */

@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/baloo2-latin.woff2') format('woff2');
}

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --layer-world-feedback: 15;
  --layer-hud: 20;
  --layer-controls: 30;
  --layer-notice: 40;
  --layer-dialog: 60;
  --layer-loading: 100;

  /* Surfaces */
  --panel: rgba(11, 16, 26, 0.78);
  --panel-strong: rgba(8, 11, 19, 0.94);
  --line: rgba(148, 163, 184, 0.28);
  --line-bright: rgba(226, 232, 240, 0.5);
  --text: #f2f5f9;
  --text-dim: rgba(203, 213, 225, 0.78);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);

  /* Semantic accents — color = meaning, never decoration */
  --gold: #fbbf24;
  --good: #4ade80;
  --danger: #fb5d6c;
  --sky: #38bdf8;
  --xp: #a78bfa;

  --r-card: 12px;
  --r-chip: 8px;

  --font-display: 'Baloo 2', 'Segoe UI', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --focus-ring: #fef08a;

  /* Dock geometry shared by dock + side elements */
  --dock-width: min(520px, calc(100vw - 16px));
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: #0b1220;
  font-family: var(--font-body);
  touch-action: auto;
  user-select: none;
  -webkit-user-select: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: crosshair;
  touch-action: none;
}

#game-canvas:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

/* ============================== */
/* Center reticle cluster         */
/* ============================== */

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.65), 0 0 3px rgba(0, 0, 0, 0.4);
}

#crosshair::before {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

#crosshair::after {
  top: 50%;
  left: 0;
  height: 2px;
  width: 100%;
  transform: translateY(-50%);
}

/* Combat targeting feedback: never moves the camera. */
body.combat-mode #crosshair,
#game-root.combat-mode #crosshair {
  width: calc(22px + var(--combat-bloom, 0px));
  height: calc(22px + var(--combat-bloom, 0px));
  transition: width 0.06s linear, height 0.06s linear;
}

body.neutral-target #crosshair::before,
body.neutral-target #crosshair::after,
#game-root.neutral-target #crosshair::before,
#game-root.neutral-target #crosshair::after {
  background: #67e8f9;
  box-shadow: 0 0 0 1px #083344, 0 0 7px rgba(103, 232, 249, 0.72);
}

body.hostile-target #crosshair::before,
body.hostile-target #crosshair::after,
#game-root.hostile-target #crosshair::before,
#game-root.hostile-target #crosshair::after {
  background: #fb7185;
  box-shadow: 0 0 0 1px #4c0519, 0 0 7px rgba(251, 113, 133, 0.78);
}

#npc-target {
  position: absolute;
  top: calc(50% + 26px);
  left: 50%;
  z-index: 36;
  max-width: min(260px, 74vw);
  padding: 3px 10px;
  transform: translateX(-50%);
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

#npc-target[hidden] { display: none; }

#npc-target.neutral-target,
body.neutral-target #npc-target,
#game-root.neutral-target #npc-target {
  border-color: #22d3ee;
  color: #a5f3fc;
}

#npc-target.hostile-target,
body.hostile-target #npc-target,
#game-root.hostile-target #npc-target {
  border-color: #fb7185;
  color: #fecdd3;
}

/* Target block label: quiet, under the reticle */
#info {
  position: absolute;
  top: calc(50% + 26px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
  pointer-events: none;
  white-space: nowrap;
}

/* When aiming at an NPC, its pill owns that slot. */
body.neutral-target #info,
body.hostile-target #info,
#game-root.neutral-target #info,
#game-root.hostile-target #info {
  display: none;
}

#hit-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 37;
  width: 24px;
  height: 24px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.72);
  transition: opacity 0.08s ease-out, transform 0.08s ease-out;
  pointer-events: none;
}

#hit-marker::before,
#hit-marker::after {
  content: "";
  position: absolute;
  top: 11px;
  left: 2px;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 3px #000, 0 0 7px rgba(255, 255, 255, 0.72);
}

#hit-marker::before { transform: rotate(45deg); }
#hit-marker::after { transform: rotate(-45deg); }

#hit-marker.show,
#hit-marker.hit {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#hit-marker.headshot::before,
#hit-marker.headshot::after,
body.headshot #hit-marker::before,
body.headshot #hit-marker::after,
#game-root.headshot #hit-marker::before,
#game-root.headshot #hit-marker::after {
  height: 3px;
  background: var(--gold);
  box-shadow: 0 0 3px #451a03, 0 0 9px rgba(251, 191, 36, 0.9);
}

#mine-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  pointer-events: none;
  z-index: 12;
  box-shadow: 0 0 0 1px #000;
}

/* ============================== */
/* Top-center: time + banners     */
/* ============================== */

#topbar {
  position: absolute;
  top: calc(8px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--layer-hud);
  pointer-events: none;
}

#time-label {
  padding: 3px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 2px #000;
  box-shadow: var(--shadow);
}

/* Night danger lives on the time chip: always visible, never clipped. */
body.night-danger #time-label {
  border-color: var(--danger);
  color: #fecdd3;
  animation: soft-pulse 1.1s ease-in-out infinite;
}

#event-banner {
  position: absolute;
  top: calc(44px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  z-index: 42;
  max-width: min(480px, 92vw);
  padding: 9px 20px;
  border-radius: var(--r-card);
  border: 1px solid var(--line-bright);
  background: var(--panel-strong);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  text-shadow: 0 1px 3px #000;
  box-shadow: var(--shadow);
}

#event-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#event-banner.blood {
  background: rgba(64, 4, 18, 0.9);
  border-color: #f43f5e;
  color: #fecdd3;
}

#event-banner.combat {
  border-color: var(--sky);
  background: rgba(7, 32, 58, 0.92);
  color: #bae6fd;
}

#event-banner.achieve {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(56, 38, 5, 0.94), rgba(15, 12, 4, 0.92));
  color: #fde68a;
}

.toast {
  position: absolute;
  top: calc(96px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  z-index: var(--layer-notice);
  transition: opacity 0.2s, transform 0.2s;
  text-shadow: 0 1px 2px #000;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.rare { border-color: var(--good); color: #bbf7d0; }
.toast.ore { border-color: var(--gold); color: #fde68a; }
.toast.achieve {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(50, 36, 6, 0.9), rgba(10, 8, 3, 0.88));
  color: #fde68a;
}
.toast.combo { color: #fda4af; border-color: #fb7185; }

/* Combo: small, near the action, silent unless chaining */
#combo {
  position: absolute;
  top: calc(50% - 74px);
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: #ffe566;
  text-shadow: 0 0 10px #f90, 1px 2px 0 #000;
  opacity: 0;
  pointer-events: none;
  z-index: 35;
  transition: opacity 0.12s, transform 0.12s;
}

#combo.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#combo.pop {
  animation: combo-pop 0.18s ease-out;
}

@keyframes combo-pop {
  0% { transform: translate(-50%, -50%) scale(1.35); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

#combo.fever {
  color: var(--gold);
  text-shadow: 0 0 14px #f59e0b, 1px 2px 0 #000;
  font-size: 32px;
}

/* ============================== */
/* Top-left: goal + context       */
/* ============================== */

#hud {
  position: absolute;
  top: calc(8px + var(--safe-top));
  left: calc(10px + var(--safe-left));
  width: min(280px, 44vw);
  color: var(--text);
  text-shadow: 0 1px 2px #000;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  z-index: var(--layer-hud);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Quest card — the goal driver */
#quest-box {
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-card);
  font-size: 12px;
  line-height: 1.35;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#quest-box:empty { display: none; }

#quest-box .q-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: #fde68a;
}

#quest-box .q-prog {
  color: var(--text-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

#quest-box .q-credit {
  display: block;
  font-size: 10px;
  color: #86efac;
  margin-top: 2px;
}

#quest-box .q-bar {
  margin-top: 5px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
}

#quest-box .q-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #f59e0b);
  border-radius: 3px;
  transition: width 0.3s ease-out;
}

#quest-box .q-reward {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-dim);
}

#xp-line .xp-lv {
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(88, 60, 160, 0.55);
  border: 1px solid rgba(167, 139, 250, 0.5);
  color: #ede9fe;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
}

/* Context chips: one visual voice for every situational signal */
#context-chips {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.chip {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-shadow: 0 1px 2px #000;
}

.chip[hidden] { display: none; }

.chip-danger {
  border-color: var(--danger);
  color: #fecdd3;
  background: rgba(64, 4, 18, 0.82);
  animation: soft-pulse 1.1s ease-in-out infinite;
}

.chip-ore { border-color: #5eead4; color: #99f6e4; }
.chip-good { border-color: rgba(74, 222, 128, 0.55); color: #bbf7d0; }
.chip-streak { border-color: rgba(251, 146, 60, 0.6); color: #fdba74; }

@keyframes soft-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

#collect-line {
  font-size: 11px;
  color: var(--text-dim);
  max-width: 200px;
}

#collect-line .c-bar {
  margin-top: 3px;
  height: 4px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 2px;
  overflow: hidden;
}

#collect-line .c-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #34d399, #22d3ee);
  width: 0%;
  transition: width 0.3s ease-out;
}

#stats-line,
#tool-line {
  font-size: 11px;
  color: var(--text-dim);
}

#tool-line { color: #c4b5fd; }

/* FPS is a debug reading, not a HUD element. */
#fps {
  display: none;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-dim);
}

body.debug #fps { display: block; }

body.night #hud {
  text-shadow: 0 1px 3px #000, 0 0 8px #000;
}

/* ============================== */
/* Top-right: navigation          */
/* ============================== */

#minimap {
  position: absolute;
  top: calc(10px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid var(--line-bright);
  box-shadow: var(--shadow);
  z-index: 28;
  pointer-events: none;
  image-rendering: auto;
  background: #0b1520;
}

#online-line {
  position: absolute;
  top: calc(136px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  z-index: 28;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

#online-line[hidden] { display: none; }

#online-line.connected {
  border-color: rgba(74, 222, 128, 0.55);
  color: #bbf7d0;
}

/* ============================== */
/* Right column: feed + combat    */
/* ============================== */

#action-feed {
  position: absolute;
  right: calc(12px + var(--safe-right));
  bottom: calc(196px + var(--safe-bottom));
  width: 224px;
  z-index: 28;
  pointer-events: none;
  text-align: right;
  font-size: 11px;
  line-height: 1.35;
}

.feed-line {
  margin-top: 3px;
  padding: 3px 8px;
  background: var(--panel);
  border-radius: 6px;
  color: #e5e7eb;
  text-shadow: 0 1px 2px #000;
  animation: feedin 0.2s ease;
}

.feed-line.rare { color: #5eead4; border-right: 2px solid #5eead4; }
.feed-line.ore { color: #fde68a; border-right: 2px solid var(--gold); }
.feed-line.achieve { color: #fde68a; border-right: 2px solid var(--gold); }
.feed-line.loot { color: #86efac; border-right: 2px solid var(--good); }

@keyframes feedin {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Combat card — contractual bottom-right corner */
#combat-hud {
  position: absolute;
  right: calc(12px + var(--safe-right));
  bottom: calc(96px + var(--safe-bottom));
  z-index: 29;
  width: min(248px, calc(100vw - var(--safe-left) - var(--safe-right) - 24px));
  padding: 9px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 11px;
  line-height: 1.25;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: border-color 0.14s ease, opacity 0.14s ease;
}

/* Tool mode: the card collapses to a quiet ammo reading. */
#game-root:not(.combat-mode) #combat-hud {
  opacity: 0.72;
}

#game-root:not(.combat-mode) #combat-contract,
#game-root:not(.combat-mode) #combat-stats {
  display: none;
}

body.combat-mode #combat-hud,
#game-root.combat-mode #combat-hud,
#combat-hud.combat-mode {
  border-color: rgba(96, 165, 250, 0.75);
  background: linear-gradient(145deg, rgba(10, 25, 48, 0.92), rgba(2, 9, 20, 0.84));
}

#combat-mode {
  margin-bottom: 3px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

body.combat-mode #combat-mode,
#game-root.combat-mode #combat-mode,
#combat-mode.combat-mode {
  color: #93c5fd;
}

.combat-weapon-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

#weapon-name {
  overflow: hidden;
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combat-ammo {
  display: inline-flex;
  align-items: baseline;
  flex: 0 0 auto;
  gap: 2px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#ammo-mag {
  min-width: 1.4ch;
  color: #f8fafc;
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1;
  text-align: right;
}

#ammo-reserve {
  min-width: 1.8ch;
  font-size: 12px;
}

#combat-hud.reloading #ammo-mag,
body.reloading #combat-hud #ammo-mag,
#game-root.reloading #combat-hud #ammo-mag {
  color: #fde68a;
}

#reload-progress {
  width: 100%;
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

#reload-progress[hidden] { display: none; }

#reload-progress > i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sky), #facc15);
  transition: width 0.05s linear;
}

#ammo-hint {
  margin-top: 4px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(220, 60, 50, 0.28);
  border: 1px solid rgba(255, 120, 110, 0.6);
  color: #ffe1de;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  animation: soft-pulse 0.9s ease-in-out infinite;
}

#ammo-hint[hidden] { display: none; }

#ammo-hint kbd {
  display: inline-block;
  min-width: 16px;
  padding: 1px 5px;
  margin: 0 1px;
  border-radius: 4px;
  background: #f2f4f8;
  color: #1a1a2e;
  font-family: inherit;
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

#combat-contract {
  margin-top: 6px;
  overflow: hidden;
  color: #fde68a;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#combat-stats {
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#combat-hud.combat-kick,
#combat-hud.weapon-kick {
  animation: combat-hud-kick 0.12s ease-out;
}

@keyframes combat-hud-kick {
  0% { transform: translateY(0); }
  35% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

/* ============================== */
/* Bottom-center dock             */
/* ============================== */

#dock {
  position: absolute;
  left: 50%;
  bottom: calc(8px + var(--safe-bottom));
  transform: translateX(-50%);
  width: var(--dock-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  z-index: var(--layer-controls);
  pointer-events: none;
}

#vitals {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  pointer-events: none;
  color: #fff;
}

#hearts {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

#hearts .heart-track {
  display: flex;
  align-items: center;
  gap: 2px;
}

#hearts .heart {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 17px;
  font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

#hearts .heart.filled {
  color: #ff334f;
  text-shadow:
    0 1px 0 #7f0719,
    0 0 5px rgba(255, 45, 75, 0.72),
    0 1px 2px #000;
}

#hearts .heart.empty {
  color: #c5cad3;
  opacity: 0.7;
  font-weight: 600;
  text-shadow: 0 1px 2px #000;
}

#hearts .health-count {
  min-width: 30px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 2px #000;
}

#vitals:has(#hearts.low) {
  border-color: rgba(255, 70, 90, 0.88);
  background: rgba(62, 6, 16, 0.82);
  box-shadow: 0 0 14px rgba(255, 35, 65, 0.34);
}

#hearts.low .health-count { color: #ffb4bf; }
#hearts.no-health .health-count { color: #ff6b7e; }

#hearts .heart.gained { animation: heart-gained 0.34s ease-out; }
#hearts .heart.lost { animation: heart-lost 0.3s ease-out; }

@keyframes heart-gained {
  0% { transform: scale(0.55); }
  60% { transform: scale(1.32); }
  100% { transform: scale(1); }
}

@keyframes heart-lost {
  0% { transform: scale(1.25); color: #ff334f; opacity: 1; }
  100% { transform: scale(1); color: #c5cad3; opacity: 0.7; }
}

#food-line {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  padding-left: 8px;
  border-left: 1px solid var(--line);
  pointer-events: none;
}

/* XP strip: level badge + bar, full hotbar width */
#xp-line {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  font-size: 11px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.xp-bar {
  flex: 1;
  height: 7px;
  background: rgba(8, 11, 19, 0.65);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(167, 139, 250, 0.35);
}

.xp-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #818cf8, var(--xp), #e879f9);
  border-radius: 4px;
  transition: width 0.3s ease-out;
}

/* "So close" glow when a level is nearly done */
.xp-bar.near {
  border-color: rgba(167, 139, 250, 0.8);
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.45);
}

.xp-num {
  color: var(--text-dim);
  font-family: var(--font-body);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
}

/* Hotbar */
#hotbar {
  display: flex;
  width: max-content;
  max-width: 100%;
  gap: 4px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  pointer-events: auto;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  touch-action: pan-x pinch-zoom;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#hotbar::-webkit-scrollbar { display: none; }

.hotbar-slot {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid rgba(120, 128, 140, 0.55);
  background: rgba(15, 20, 30, 0.85);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: border-color 0.08s, transform 0.08s;
  scroll-snap-align: center;
  touch-action: manipulation;
}

.hotbar-slot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 1px #fff, inset 0 0 8px rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.hotbar-slot .swatch {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-color: #444;
}

.hotbar-slot .key {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

.hotbar-slot .count {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

.hotbar-slot.empty { opacity: 0.45; }

/* ============================== */
/* Coach: one hint at a time      */
/* ============================== */

#coach {
  position: absolute;
  left: 50%;
  bottom: calc(148px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: var(--layer-notice);
  max-width: min(360px, 88vw);
  padding: 7px 16px;
  border: 1px solid rgba(254, 240, 138, 0.5);
  border-radius: 999px;
  background: var(--panel-strong);
  color: #fef9c3;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  box-shadow: var(--shadow);
  pointer-events: none;
  animation: coach-in 0.35s ease-out;
}

#coach[hidden] { display: none; }

#coach kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 5px;
  background: #fef9c3;
  color: #1c1917;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

@keyframes coach-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================== */
/* Bottom-left: actions           */
/* ============================== */

#side-btns {
  position: absolute;
  left: calc(12px + var(--safe-left));
  bottom: calc(96px + var(--safe-bottom));
  z-index: var(--layer-controls);
  display: grid;
  grid-template-columns: repeat(2, 48px);
  gap: 6px;
  pointer-events: none;
}

.craft-btn,
.side-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  box-shadow: var(--shadow);
}

.craft-btn {
  grid-column: span 2;
  width: 102px;
  padding: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.15;
  overflow: hidden;
  border-color: rgba(255, 180, 80, 0.55);
  background: rgba(46, 29, 10, 0.82);
  color: #ffd89a;
}

.side-btn {
  width: 48px;
  height: 48px;
  padding: 2px 0 0;
  text-align: center;
  font-size: 17px;
  line-height: 1.1;
}

/* Tiny label under each icon so a child can read the buttons */
.side-btn::after {
  content: attr(data-label);
  display: block;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.combat-btn {
  border-color: rgba(96, 165, 250, 0.58);
  background: rgba(8, 24, 48, 0.78);
  color: #bfdbfe;
}

.combat-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Combat verbs only exist while a weapon is out */
#game-root:not(.combat-mode) #btn-reload,
#game-root:not(.combat-mode) #btn-next-weapon {
  display: none;
}

#btn-weapon[aria-pressed="true"] {
  border-color: #60a5fa;
  background: rgba(30, 64, 175, 0.74);
  box-shadow: inset 0 0 8px rgba(147, 197, 253, 0.2), 0 0 8px rgba(59, 130, 246, 0.24);
}

.craft-btn:active,
.side-btn:active {
  transform: scale(0.95);
  background: rgba(80, 50, 20, 0.85);
}

/* ============================== */
/* Touch UI                       */
/* ============================== */

#touch-ui {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  touch-action: none;
}

#joystick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 45%;
  height: 48%;
  pointer-events: auto;
}

#joystick-base {
  position: absolute;
  left: calc(20px + var(--safe-left));
  bottom: calc(96px + var(--safe-bottom));
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.28);
  touch-action: none;
}

#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
  border: 2px solid rgba(255, 255, 255, 0.5);
  will-change: transform;
}

#look-zone {
  position: absolute;
  right: 0;
  top: 0;
  width: 55%;
  height: 72%;
  pointer-events: auto;
  touch-action: none;
}

#action-btns {
  position: absolute;
  right: calc(14px + var(--safe-right));
  bottom: calc(96px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

#action-btns button {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(8, 11, 19, 0.5);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
}

#action-btns button:active {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.95);
}

/* ============================== */
/* Loading                        */
/* ============================== */

#loading {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(56, 189, 248, 0.14), transparent),
    linear-gradient(165deg, #0b1220 0%, #101b33 55%, #0d2b45 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--layer-loading);
  transition: opacity 0.35s ease;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-inner {
  text-align: center;
  color: #eef2f7;
  padding: 0 20px;
}

.loading-logo {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.loading-logo i {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.28);
}

.loading-logo i:nth-child(1) { background: #67bd45; }
.loading-logo i:nth-child(2) { background: #8d6e3a; transform: translateY(7px); }
.loading-logo i:nth-child(3) { background: #38bdf8; }

.loading-inner h1 {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin-bottom: 6px;
  background: linear-gradient(90deg, #86efac, #fde68a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.loading-inner p {
  opacity: 0.85;
  margin-bottom: 16px;
}

.loading-tip {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
}

.bar {
  width: 240px;
  height: 9px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  overflow: hidden;
  margin: 0 auto;
}

#load-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4ade80, #22c55e);
  border-radius: 5px;
  transition: width 0.15s ease;
}

/* ============================== */
/* World feedback overlays        */
/* ============================== */

#game-root.hurt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, transparent 40%, rgba(180, 0, 0, 0.35) 100%);
  pointer-events: none;
  z-index: var(--layer-world-feedback);
  animation: hurtflash 0.35s ease-out;
}

@keyframes hurtflash {
  from { opacity: 1; }
  to { opacity: 0; }
}

#game-root.loot-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 210, 90, 0.28) 0%, rgba(255, 180, 40, 0.1) 55%, transparent 100%);
  pointer-events: none;
  z-index: var(--layer-world-feedback);
  animation: lootflash 0.3s ease-out;
}

#game-root.rare-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(120, 230, 255, 0.4) 0%, rgba(255, 215, 90, 0.22) 50%, transparent 100%);
  pointer-events: none;
  z-index: var(--layer-world-feedback);
  animation: rareflash 0.55s ease-out;
}

/* Level-up: a golden edge glow, big but non-blocking */
#game-root.level-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, transparent 52%, rgba(251, 191, 36, 0.34) 100%);
  pointer-events: none;
  z-index: var(--layer-world-feedback);
  animation: rareflash 0.9s ease-out;
}

@keyframes lootflash {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes rareflash {
  0% { opacity: 1; }
  40% { opacity: 0.6; }
  100% { opacity: 0; }
}

body.night-danger #game-canvas {
  filter: brightness(0.92) saturate(0.9);
}

/* Floating combat text */
.float-txt {
  position: absolute;
  z-index: 45;
  pointer-events: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  transform: translate(-50%, 0);
  opacity: 0;
  transition: transform 0.85s ease-out, opacity 0.85s ease-out;
  white-space: nowrap;
}

.float-txt.go {
  opacity: 1;
  transform: translate(-50%, -48px);
}

.float-xp { color: var(--xp); font-size: 14px; }
.float-loot { color: #86efac; }
.float-crit { color: var(--gold); font-size: 18px; letter-spacing: 0.04em; }
.float-dmg { color: #f87171; }
.float-heal { color: #ff8fa3; }
.float-info { color: #e5e7eb; }

/* ============================== */
/* Collection modal               */
/* ============================== */

#discovery-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--layer-dialog);
  width: min(360px, 92vw);
  max-height: 70vh;
  max-height: 70dvh;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
  background: var(--panel-strong);
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  padding: 16px 18px;
  color: #eee;
  pointer-events: auto;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.42), 0 14px 40px rgba(0, 0, 0, 0.65);
}

#discovery-panel[hidden] { display: none; }

body.modal-open :is(#hotbar, #side-btns, #touch-ui),
body.modal-open :is(#hotbar, #side-btns, #touch-ui) * {
  pointer-events: none;
}

body.modal-open #game-canvas { pointer-events: none; }
body.modal-open #discovery-panel { pointer-events: auto; }

@supports selector(:has(*)) {
  #game-root:has(#discovery-panel:not([hidden])) > :not(#discovery-panel) {
    pointer-events: none;
  }
}

#discovery-panel h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 8px;
}

#disc-summary {
  margin-bottom: 8px;
  font-size: 12px;
  opacity: 0.85;
}

#discovery-panel .disc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 12px;
}

#discovery-panel .disc-item {
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

#discovery-panel .disc-item.missing { opacity: 0.4; }

#discovery-panel .disc-close {
  margin-top: 12px;
  width: 100%;
  min-height: 44px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: #334155;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* ============================== */
/* Desktop / mobile visibility    */
/* ============================== */

.mobile-only { display: none; }
.desktop-only { display: block; }

body.is-touch .mobile-only,
body.force-touch .mobile-only { display: block; }
body.is-touch .desktop-only,
body.force-touch .desktop-only { display: none; }
body.is-desktop .mobile-only { display: none; }
body.is-desktop .desktop-only { display: block; }

/* Safe fallback before JS assigns the authoritative input-mode class. */
@media (any-hover: none) and (any-pointer: coarse) {
  body:not(.is-desktop):not(.is-touch) .mobile-only { display: block; }
  body:not(.is-desktop):not(.is-touch) .desktop-only { display: none; }
}

button.mobile-only { display: none; }
body.is-touch button.mobile-only,
body.force-touch button.mobile-only { display: inline-block; }
body.is-touch #game-root:not(.combat-mode) #btn-next-weapon,
body.force-touch #game-root:not(.combat-mode) #btn-next-weapon { display: none; }

/* ============================== */
/* Touch layout                   */
/* ============================== */

body.is-touch #minimap,
body.force-touch #minimap {
  width: 88px;
  height: 88px;
}

body.is-touch #online-line,
body.force-touch #online-line {
  top: calc(104px + var(--safe-top));
}

body.is-touch #hud,
body.force-touch #hud {
  width: min(210px, 52vw);
  font-size: 11px;
}

body.is-touch #quest-box,
body.force-touch #quest-box {
  padding: 7px 10px;
  font-size: 11px;
}

body.is-touch #quest-box .q-title,
body.force-touch #quest-box .q-title {
  font-size: 12px;
}

/* Time chip joins the minimap cluster so the quest card owns the top-left. */
body.is-touch #topbar,
body.force-touch #topbar {
  left: auto;
  right: calc(104px + var(--safe-right));
  transform: none;
}

/* The collection bar lives inside the album (📒) on phones. */
body.is-touch #collect-line,
body.force-touch #collect-line {
  display: none;
}

/* Actions: a single column on the left edge, anchored ABOVE the joystick
   and growing upward. Secondary tier opens as a sheet ("Más"). */
body.is-touch #side-btns,
body.force-touch #side-btns {
  left: calc(10px + var(--safe-left));
  top: auto;
  bottom: calc(232px + var(--safe-bottom));
  display: flex;
  flex-direction: column-reverse;
  gap: 7px;
}

body.is-touch .craft-btn,
body.force-touch .craft-btn {
  grid-column: auto;
  width: 48px;
  height: 48px;
  font-size: 17px;
  padding: 2px 0 0;
}

body.is-touch .craft-btn::after,
body.force-touch .craft-btn::after {
  content: "craft";
  display: block;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
}

body.is-touch .combat-btn,
body.force-touch .combat-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 2px 0 0;
  font-size: 16px;
}

/* Secondary tier hides behind "Más" on touch */
body.is-touch #side-btns .tier-2,
body.force-touch #side-btns .tier-2 {
  display: none;
}

/* Open state: every action as a compact sheet */
body.is-touch #side-btns.open,
body.force-touch #side-btns.open {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  gap: 7px;
  padding: 8px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

body.is-touch #side-btns.open .tier-2,
body.force-touch #side-btns.open .tier-2 {
  display: block;
}

/* Eat is contextual on touch: only when hurt and holding apples */
body.is-touch #side-btns:not(.open) #btn-eat:not(.relevant),
body.force-touch #side-btns:not(.open) #btn-eat:not(.relevant) {
  display: none;
}

/* Interact surfaces next to the action cluster when a bed/chest is near */
body.is-touch #side-btns:not(.open) #btn-interact.relevant,
body.force-touch #side-btns:not(.open) #btn-interact.relevant {
  display: block;
  position: fixed;
  right: calc(88px + var(--safe-right));
  bottom: calc(174px + var(--safe-bottom));
  z-index: var(--layer-controls);
  border-color: rgba(254, 240, 138, 0.6);
}

body.is-touch #combat-hud,
body.force-touch #combat-hud {
  right: calc(10px + var(--safe-right));
  bottom: calc(300px + var(--safe-bottom));
  width: min(190px, 48vw);
  padding: 6px 9px;
  font-size: 10px;
}

/* Tool mode on phones: just the quiet ammo reading */
body.is-touch #game-root:not(.combat-mode) #combat-mode,
body.force-touch #game-root:not(.combat-mode) #combat-mode {
  display: none;
}

body.is-touch #game-root:not(.combat-mode) #combat-hud,
body.force-touch #game-root:not(.combat-mode) #combat-hud {
  width: min(150px, 40vw);
}

body.is-touch #weapon-name,
body.force-touch #weapon-name { font-size: 12px; }

body.is-touch #ammo-mag,
body.force-touch #ammo-mag { font-size: 18px; }

body.is-touch #combat-contract,
body.force-touch #combat-contract {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.is-touch #action-feed,
body.force-touch #action-feed {
  right: calc(10px + var(--safe-right));
  bottom: calc(392px + var(--safe-bottom));
  width: min(180px, 46vw);
}

body.is-touch #action-feed .feed-line:nth-child(n+4),
body.force-touch #action-feed .feed-line:nth-child(n+4) {
  display: none;
}

body.is-touch #coach,
body.force-touch #coach {
  bottom: calc(216px + var(--safe-bottom));
  font-size: 12px;
}

/* Dock: vitals + XP + hotbar stay one centered unit */
body.is-touch #dock,
body.force-touch #dock {
  bottom: calc(6px + var(--safe-bottom));
  gap: 4px;
}

body.is-touch #xp-line,
body.force-touch #xp-line {
  max-width: min(320px, 74vw);
}

body.is-touch #vitals,
body.force-touch #vitals {
  padding: 3px 10px;
}

body.is-touch #hearts .heart,
body.force-touch #hearts .heart {
  width: 14px;
  height: 15px;
  font-size: 14px;
}

@media (max-width: 360px) {
  #hearts { gap: 4px; }
  #hearts .heart-track { gap: 1px; }
  #hearts .heart { width: 13px; font-size: 13px; }
  #hearts .health-count { min-width: 26px; font-size: 11px; }
  #food-line { font-size: 12px; }
}

/* Desktop, narrow window */
@media (max-width: 760px) {
  body.is-desktop #side-btns {
    grid-template-columns: repeat(2, 44px);
    bottom: calc(126px + var(--safe-bottom));
  }

  body.is-desktop #combat-hud {
    bottom: calc(126px + var(--safe-bottom));
  }

  body.is-desktop #action-feed {
    bottom: calc(240px + var(--safe-bottom));
  }
}

/* Short landscape phones: shrink, never relocate */
@media (max-height: 500px) and (orientation: landscape) {
  body.is-touch #hud,
  body.force-touch #hud {
    width: min(180px, 34vw);
    font-size: 11px;
  }

  body.is-touch #minimap,
  body.force-touch #minimap {
    width: 68px;
    height: 68px;
    top: calc(8px + var(--safe-top));
    right: calc(8px + var(--safe-right));
  }

  body.is-touch #online-line,
  body.force-touch #online-line {
    top: calc(82px + var(--safe-top));
  }

  body.is-touch #side-btns,
  body.force-touch #side-btns {
    bottom: calc(186px + var(--safe-bottom));
    gap: 5px;
  }

  body.is-touch #joystick-base,
  body.force-touch #joystick-base {
    left: calc(14px + var(--safe-left));
    bottom: calc(78px + var(--safe-bottom));
    width: 96px;
    height: 96px;
  }

  body.is-touch #action-btns,
  body.force-touch #action-btns {
    right: calc(12px + var(--safe-right));
    bottom: calc(72px + var(--safe-bottom));
    gap: 8px;
  }

  body.is-touch #action-btns button,
  body.force-touch #action-btns button {
    width: 54px;
    height: 54px;
    font-size: 20px;
  }

  body.is-touch #combat-hud,
  body.force-touch #combat-hud {
    bottom: calc(150px + var(--safe-bottom));
    right: calc(80px + var(--safe-right));
    width: min(180px, 34vw);
    padding-block: 5px;
  }

  body.is-touch #combat-contract,
  body.force-touch #combat-contract {
    margin-top: 3px;
    -webkit-line-clamp: 1;
  }

  body.is-touch #combat-stats,
  body.force-touch #combat-stats { display: none; }

  body.is-touch #action-feed,
  body.force-touch #action-feed {
    bottom: calc(212px + var(--safe-bottom));
    right: calc(80px + var(--safe-right));
    width: min(170px, 32vw);
  }

  body.is-touch #action-feed .feed-line:nth-child(n+3),
  body.force-touch #action-feed .feed-line:nth-child(n+3) {
    display: none;
  }

  body.is-touch #dock,
  body.force-touch #dock {
    bottom: calc(4px + var(--safe-bottom));
    gap: 3px;
  }

  body.is-touch #discovery-panel,
  body.force-touch #discovery-panel {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 20px);
  }
}

/* Very short portrait phones */
@media (max-height: 600px) and (orientation: portrait) {
  body.is-touch #combat-stats,
  body.force-touch #combat-stats { display: none; }
}

/* ============================== */
/* Accessibility                  */
/* ============================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  .float-txt.go {
    transform: translate(-50%, 0);
  }

  #hit-marker,
  #hit-marker.show,
  #hit-marker.hit {
    transform: translate(-50%, -50%);
  }

  #combat-hud.combat-kick,
  #combat-hud.weapon-kick {
    animation: none !important;
    transform: none !important;
  }
}

@media (forced-colors: active) {
  .hotbar-slot.selected,
  button:focus-visible,
  [tabindex]:focus-visible {
    outline: 3px solid CanvasText;
  }

  #crosshair::before,
  #crosshair::after {
    background: CanvasText;
  }

  #hearts .heart.filled,
  #hearts .heart.empty,
  #hearts .health-count {
    color: CanvasText;
    opacity: 1;
  }

  #combat-hud,
  #npc-target,
  .combat-btn {
    border: 2px solid CanvasText;
    background: Canvas;
    color: CanvasText;
    forced-color-adjust: auto;
  }

  #hit-marker::before,
  #hit-marker::after,
  #hit-marker.headshot::before,
  #hit-marker.headshot::after,
  body.headshot #hit-marker::before,
  body.headshot #hit-marker::after,
  #game-root.headshot #hit-marker::before,
  #game-root.headshot #hit-marker::after,
  #reload-progress > i {
    background: Highlight;
    box-shadow: none;
  }
}
