:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e2230;
  --border: #2a2f3d;
  --text: #d7dae2;
  --muted: #8b91a0;
  --gold: #e8b95a;
  --good: #7fc97f;
  --bad: #e07a7a;
  --accent: #5a9be8;

  /* Tokens de diseño (espaciado / radios / tipografía / sombras) */
  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --radius-1: 6px; --radius-2: 10px; --radius-3: 16px;
  --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px;
  --fs-base: 15px; --fs-lg: 18px; --fs-xl: 22px;
  --shadow-1: 0 1px 4px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.55);

  /* Capas del HUD (escena → hud → sheet → tab-bar → modales) */
  --z-scene: 0; --z-hud: 10; --z-sheet: 20; --z-nav: 30; --z-modal: 40;

  /* Medidas del HUD */
  --hud-top-h: 48px;
  --nav-h: 56px;
  --ground-h: clamp(48px, 14dvh, 120px);
  --sprite: 64px;        /* 16×16 a ×4 (múltiplo entero → pixelated nítido) */
  --sprite-boss: 96px;   /* ×6 */

  /* Superficies translúcidas del HUD */
  --overlay: rgba(6, 8, 12, 0.55);
  --panel-glass: rgba(23, 26, 33, 0.88);

  /* Safe areas (iOS con viewport-fit=cover) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, "Segoe UI", sans-serif;
}

/* Pixel art nítido a cualquier escala */
.pixel { image-rendering: pixelated; }
.icon { width: 24px; height: 24px; vertical-align: middle; }

/* ---------- Pantallas ---------- */
/* !important: gana a reglas de display por id (p. ej. #screen-title { display:flex }),
   que si no anularían el atributo [hidden] por mayor especificidad. */
.screen[hidden], .view[hidden], #sheet[hidden] { display: none !important; }
/* .panel.event fija display:flex (mayor especificidad que [hidden]): misma cura. */
.panel.event[hidden] { display: none !important; }
.screen-enter { animation: fadeIn 0.35s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Título / login ---------- */
#screen-title {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 120%, #232b1d 0%, transparent 55%),
    radial-gradient(ellipse at 50% -30%, #1c2438 0%, transparent 60%),
    var(--bg);
}
.title-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 40px;
  text-align: center;
}
.title-hero { width: 96px; height: 96px; }
.logo {
  margin: 0;
  font-size: 44px;
  letter-spacing: 10px;
  color: var(--gold);
  text-shadow: 0 3px 0 #6b4a2f, 0 6px 18px rgba(232, 185, 90, 0.25);
}
.tagline { margin: 0; color: var(--muted); }
#title-new, #title-continue {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 280px;
}
#name-input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  text-align: center;
}
#name-input:focus { outline: none; border-color: var(--gold); }

/* ---- Selector de perfiles ---- */
#profiles-block { width: 300px; }
.profiles-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 2px; margin: 4px 0; }
#profiles-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.profile { display: flex; gap: 6px; }
.profile-play {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  text-align: left;
}
.profile-play:hover:not(:disabled) { border-color: var(--gold); }
.profile-avatar { width: 28px; height: 28px; }
.profile-name { font-weight: 600; color: var(--text); }
.profile-del { flex: none; color: var(--bad); border-color: #5c2e2e; padding: 8px 11px; }
.profile-del:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
#new-profile { display: flex; flex-direction: column; gap: 10px; width: 300px; }
.title-hint { color: var(--muted); font-size: 11px; max-width: 320px; font-style: italic; }
.title-status { color: var(--gold); font-size: 13px; min-height: 1em; }

/* ---- Login por cuenta (título) y vinculación (Personaje) ---- */
#login-block { width: 300px; display: flex; flex-direction: column; gap: 8px; }
.linklike {
  background: none; border: none; color: var(--muted); font: inherit; font-size: 12px;
  cursor: pointer; padding: 4px; text-decoration: underline;
}
.linklike:hover { color: var(--gold); }
#login-form, #account-form { display: flex; flex-direction: column; gap: 8px; }
#account-form { margin-top: 8px; }
/* Estos tres fijan `display` POR ID (1-0-0), que gana al `[hidden]` de la hoja del
   navegador (0-1-0): sin `!important` el atributo hidden no oculta nada. Misma cura
   que `.screen[hidden]` y `#sheet[hidden]` (§12). */
#login-block[hidden], #login-form[hidden], #account-form[hidden] { display: none !important; }
#login-form input, #account-form input {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 10px 12px; font: inherit;
}
#login-form input:focus, #account-form input:focus { outline: none; border-color: var(--gold); }
.rank-next.good { color: var(--good); }
.rank-next.bad { color: var(--bad); }

/* ---- Vista Ajustes ---- */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 0;
}
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-note { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.toggle { min-width: 110px; }
.toggle.off { color: var(--muted); }
#volume-range { flex: 1; max-width: 180px; accent-color: var(--gold); }
.notif-type-row { cursor: pointer; }
.notif-type-row input[type="checkbox"] { accent-color: var(--gold); width: 18px; height: 18px; }
#notif-toggle.off { background: none; border: 1px solid var(--border); color: var(--muted); }
button.primary {
  background: linear-gradient(180deg, #f0c66e, #c8963d);
  border: 1px solid #8a6220;
  color: #2a1f0d;
  font-weight: 700;
  padding: 10px 16px;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); color: #2a1f0d; }
.title-version { color: var(--muted); font-size: 11px; letter-spacing: 2px; }

/* ---------- Cabecera: contenido (el layout HUD vive en hud.css) ---------- */
#gold-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 19px;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
#pc-display {
  /* Es un BOTÓN: abre la Tienda de Contribución (el sumidero del PC). */
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  white-space: nowrap; /* si no, "✦ 0 PC" parte en dos líneas en pantallas estrechas y
    la cabecera CRECE/ENCOGE según el ancho exacto — bug real, ver §12 y CLAUDE.md */
}
#pc-display:hover { text-decoration: underline; }
.perks-intro { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.world-status { font-size: 13px; white-space: nowrap; } /* misma razón que #pc-display */
#online-badge { color: var(--good); }
#offline-badge { color: var(--bad); }
#settings-btn { font-size: 15px; padding: 4px 9px; }
#debug-btn { font-size: 14px; padding: 2px 7px; line-height: 1; }
#header-more-btn { font-size: 15px; padding: 4px 9px; }
#header-more-menu button { white-space: nowrap; }

/* Modal de debug */
.debug-note { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.debug-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.debug-row > span { width: 150px; font-size: 13px; color: var(--muted); }
.debug-row button { font-size: 12px; padding: 5px 10px; }
#debug-close { margin-top: 8px; }

/* ---------- Escena: contenido (posición/tamaño en hud.css) ---------- */
#scene-location {
  position: absolute;
  z-index: 3;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.sprite-hero, .sprite-target { position: absolute; }
.sprite-hero { left: 26%; }
.sprite-target { right: 26%; }

/* Presencia: otros aventureros en tu localización */
#scene-peers {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 90%;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: none;
}
.peer { display: flex; flex-direction: column; align-items: center; opacity: 0.85; }
/* Ausente: produce por progreso offline pero no está conectado (§7.6) — más tenue. */
.peer.away { opacity: 0.45; }
.peer-sprite { width: 32px; height: 32px; animation: bob 2.6s ease-in-out infinite; } /* 16×16 a ×2 */
.peer-name {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.peer-more { font-size: 11px; color: rgba(255, 255, 255, 0.6); align-self: center; }

#scene-floaters { position: absolute; inset: 0; pointer-events: none; }
.floater {
  position: absolute;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  animation: floatUp 1.15s ease-out forwards;
}
.floater.gold { color: var(--gold); }
@keyframes floatUp {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-64px); opacity: 0; }
}

/* Barra de actividad: contenido (posición/forma flotante en hud.css) */
#activity-label { font-weight: 600; font-size: 14px; }
#activity-rate { color: var(--muted); font-size: 12px; }

/* Grupo del taller bloqueado (fundición antes de la Era 3, §7.8): visible pero apagado */
.craft-group.locked { opacity: 0.55; }
.craft-group.locked .craft-cell { filter: grayscale(0.6); }
.progressbar {
  flex: 1;
  height: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
#activity-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), #f4d58a);
  /* Sin esto, cada fotograma (60/s) fija el ancho de golpe: con ciclos rápidos
     (herramienta/arma de nivel alto) el valor salta de forma casi aleatoria entre
     fotogramas y se ve como un parpadeo (petición real 2026-07-21). La transición
     interpola esos saltos en un movimiento fluido. `.snap` la desactiva un instante
     (ver scene.js) para el destello a 100% al completarse un ciclo. */
  transition: width 0.15s linear;
}
#activity-progress.snap { transition: none; }

/* Entornos (cielo + suelo) */
.env-idle      { background: linear-gradient(180deg, #131722 0%, #1a2030 70%); --ground: #232936; }
.env-fight-1   { background: linear-gradient(180deg, #2b3550 0%, #4a5568 55%, #38492e 100%); --ground: #2f3d26; }
.env-fight-2   { background: linear-gradient(180deg, #131c1a 0%, #1e2f27 60%); --ground: #17241c; }
.env-fight-3   { background: linear-gradient(180deg, #2a2f3d 0%, #4a4a52 60%); --ground: #3d3a38; }
.env-fight-4   { background: linear-gradient(180deg, #1a2418 0%, #2c3a24 60%); --ground: #23301c; }
.env-fight-5   { background: linear-gradient(180deg, #1d2b40 0%, #3f5d80 60%); --ground: #d4e4f0; }
.env-fight-6   { background: linear-gradient(180deg, #24100c 0%, #5c2317 60%); --ground: #38150e; }
.env-mine      { background: linear-gradient(180deg, #14161c 0%, #262a35 65%); --ground: #30323c; }
.env-chop      { background: linear-gradient(180deg, #1c2b3a 0%, #24402c 65%); --ground: #1d3322; }
.env-boss      { background: linear-gradient(180deg, #1a0e1e 0%, #3a1530 55%, #2a0e12 100%); --ground: #24121e; }

/* Fondo por PNG (override de assets/backgrounds/, ver assets.js): cubre toda la escena.
   El suelo generado (#scene::after) se mantiene visible POR ENCIMA del PNG —franja de
   color --ground a la altura --ground-h—, así que el PNG solo pinta el cielo/fondo y
   los sprites siguen apoyados en ese suelo. */
#scene.has-bg-image {
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

/* Animaciones de sprites */
.anim-idle  { animation: bob 2.2s ease-in-out infinite; }
.anim-fight { animation: lunge 0.65s ease-in-out infinite; }
.anim-mine  { animation: swing 0.7s ease-in-out infinite; transform-origin: 50% 90%; }
.anim-chop  { animation: swing 0.85s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes bob   { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes lunge { 0%, 100% { transform: translateX(0); } 35% { transform: translateX(16px); } }
@keyframes swing { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(9deg); } }
.sprite-target.hurt { animation: hurt 0.18s ease-out; }
@keyframes hurt {
  0% { filter: brightness(2.4); transform: translateX(0); }
  50% { transform: translateX(5px); }
  100% { filter: brightness(1); transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .sprite-hero, .sprite-target, .floater, .peer-sprite { animation: none !important; }
}

/* ---------- Panel del objetivo global (El Puente) ---------- */
.panel.world { margin-bottom: 14px; border-color: #3a3f52; }
.panel.world.offline { opacity: 0.7; }
.world-header { display: flex; align-items: center; gap: 12px; }
.world-header h2 {
  margin: 0;
  color: var(--gold);
  letter-spacing: 1px;
  text-transform: none;
  font-size: 18px;
}
#donate-all-btn { margin-left: auto; }
.world-story { color: var(--muted); font-size: 13px; margin: 6px 0 12px; max-width: 900px; }
.world-offline { color: var(--bad); font-size: 13px; }
#world-lines {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.wline {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.wline.complete { border-color: var(--good); }
.wline-head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.wline-name { font-weight: 600; }
.wline-demand {
  font-size: 10px;
  color: #1a1207;
  background: var(--gold);
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 700;
}
.wline-share { margin-left: auto; color: var(--accent); font-size: 11px; }
.wline-track {
  height: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: 6px 0;
}
.wline-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4a7bc0, #6fa0e0);
  transition: width 0.4s ease-out;
}
.wline-bar.demand { background: linear-gradient(90deg, var(--gold), #f4d58a); }
.wline-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wline-prog { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wline-donate-group { display: flex; align-items: center; gap: 4px; }
.wline-amount {
  width: 76px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  text-align: right;
}
.wline-amount:focus { outline: none; border-color: var(--gold); }
.wline-amount:disabled { opacity: 0.5; }
.wline-max { font-size: 11px; padding: 4px 7px; color: var(--muted); }
.wline-donate { font-size: 12px; padding: 4px 10px; }
/* Bonus de demanda escalado (§7.3): ×3/×5 en líneas huérfanas laten para llamar la atención. */
.wline-demand.urgent { background: var(--bad); color: #fff; animation: demand-pulse 1.2s ease-in-out infinite; }
@keyframes demand-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- Ranking de contribución (§7.5) ---------- */
.world-ranking { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.ranking-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ranking-head h3 { margin: 0; font-size: 13px; color: var(--gold); }
.ranking-you { font-size: 11px; color: var(--accent); margin-left: auto; }
.ranking-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.ranking-row {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--bg);
}
.ranking-row.you { outline: 1px solid var(--gold); color: var(--gold); }
.ranking-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-pct { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.ranking-row.you .ranking-pct { color: var(--gold); }

/* ---------- Boss mundial ---------- */
.panel.event {
  margin-bottom: 14px;
  border-color: var(--gold);
  background: linear-gradient(180deg, #2a2210, var(--panel));
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
}
#event-name { font-weight: 700; color: var(--gold); }
#event-flavor { font-size: 12px; color: var(--muted); flex: 1; min-width: 0; }
#event-countdown { font-size: 13px; font-weight: 600; color: var(--gold); }
.panel.boss { margin-bottom: 14px; border-color: #6e3a5a; background: linear-gradient(180deg, #1e1220, var(--panel)); }
.boss-head { display: flex; align-items: center; gap: 14px; }
#boss-sprite { width: 56px; height: 56px; flex: none; animation: bob 2s ease-in-out infinite; }
.boss-info { flex: 1; min-width: 0; }
.boss-info h2 { margin: 0 0 4px; color: #e879b0; font-size: 16px; text-transform: none; letter-spacing: 0; }
.boss-track {
  height: 14px;
  background: var(--bg);
  border: 1px solid #6e3a5a;
  border-radius: 7px;
  overflow: hidden;
}
#boss-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c0304f, #e879b0);
  /* Sin transición: la anima JS cada frame (interpolación por DPS). */
}
.boss-stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 3px; }
#boss-attack-btn { flex: none; }

/* ---------- Equipo y kits ---------- */
.kit-status {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0 8px;
  border-bottom: 1px dotted var(--border);
  margin-bottom: 8px;
}
.kit-status.active { color: var(--gold); font-weight: 600; }
.rank-next { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
/* Antes cada chip repetía el nombre completo del tema ("Cazador T1 ✦fortuna"): con
   varias piezas era una pared de texto (petición real 2026-07-21). Ahora hay una fila
   de cabecera por tema (icono + nombre, UNA vez) y los chips solo llevan "T{n}" + el
   símbolo de la variante — el nombre completo sigue en el `title` de cada chip. */
.gear-slot { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.gear-slot:last-of-type { border-bottom: none; }
.gear-label { width: 66px; flex: none; font-size: 12px; color: var(--muted); padding-top: 6px; }
.gear-themes { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.gear-theme-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.gear-theme-icon { font-size: 13px; flex: none; }
.gear-theme-name { font-size: 11px; color: var(--muted); width: 52px; flex: none; }
.gear-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gear-none { font-size: 11px; color: var(--muted); font-style: italic; padding-top: 5px; }
.gear-chip { font-size: 11px; padding: 4px 9px; line-height: 1.3; }
.gear-chip.on { border-color: var(--gold); color: var(--gold); background: var(--panel-2); }
button.wide { width: 100%; margin: 8px 0; font-size: 12px; }
/* Crafteo/mejora de equipo: vive en la pestaña Taller (§6.5), junto a #refine-panel.
   Redisñado 2026-07-22 (petición real): antes eran botones de solo texto en columna,
   sin ningún icono ni indicador de progreso — se leía como un formulario. Ahora cada
   estación es una tarjeta (icono + título en la cabecera) y las recetas/piezas son
   tiles con icono propio en rejilla, más cercano a un inventario de juego. */
#gear-craft-panel { display: flex; flex-direction: column; gap: 10px; }
.craft-group { border-top: 1px solid var(--border); padding-top: 8px; }
.craft-theme {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 6px;
}
.station-head-icon, .station-head-icon-emoji {
  width: 22px;
  height: 22px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Rejilla de tiles: 1 columna en móvil, varias en pantallas anchas (auto-fit). */
.craft-cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-2);
  margin-bottom: 8px;
}

.craft-cell {
  /* Icono a la izquierda + contenido apilado a la derecha (nombre/info/coste): el
     coste sigue apilado en varias líneas dentro de `.craft-content` (petición real
     2026-07-21, client/ui/costview.js) — con 3+ ingredientes seguía necesitando su
     propia línea, solo cambia que ahora vive junto a un icono real. */
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  font-size: 11px;
}
.craft-content { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.craft-name { font-weight: 600; font-size: 12px; }
.craft-cost { color: var(--muted); width: 100%; }

/* Icono de receta (Materiales): sprite real del recurso que produce (icon_leather,
   icon_cloth, icon_ingot_t*, icon_<mena/madera/parte> — ya existían, cero arte nuevo). */
.craft-icon { width: 30px; height: 30px; flex: none; margin-top: 1px; }

/* Insignia de pieza (Equipo): sin sprite propio — emoji de slot sobre un fondo teñido
   por tema. Los 4 colores duplican a propósito los hex de ALTAR_TINTS
   (client/art/sprites.js, §7.16): misma identidad visual por tema en CSS puro, sin
   compartir la constante JS (no hay build step, P7). */
.craft-icon-badge {
  width: 30px;
  height: 30px;
  flex: none;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border-radius: var(--radius-1);
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.craft-icon-badge.tint-lumber { background: rgba(93, 145, 65, 0.22); border-color: #5d9141; }
.craft-icon-badge.tint-mining { background: rgba(95, 179, 217, 0.22); border-color: #5fb3d9; }
.craft-icon-badge.tint-hunter { background: rgba(224, 87, 74, 0.22); border-color: #e0574a; }
.craft-icon-badge.tint-titan  { background: rgba(143, 110, 224, 0.22); border-color: #8f6ee0; }
button:disabled .craft-icon,
button:disabled .craft-icon-badge { filter: grayscale(1); opacity: 0.6; }

/* Medidor de tier ("●●●○○○"): más legible de un vistazo que el texto "T3" plano. */
.tier-pips { font-size: 10px; letter-spacing: 1px; color: var(--gold); }

/* Insignia de variante (✦ fortuna / ❖ rendimiento), antes sufijo de texto plano. */
.variant-badge { font-size: 12px; margin-left: 4px; }
.variant-badge.fortune { color: var(--gold); }
.variant-badge.yield { color: var(--accent); }

/* Botón de acción de estación (mejorar / ampliar cola): fila compacta nombre+pips a la
   izquierda, coste a la derecha — distinto de los tiles de receta (que sí llevan icono
   propio); el icono de la estación ya está en la cabecera del grupo, no se repite aquí. */
.station-action {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  font-size: 11px;
  margin-bottom: 6px;
  background: var(--panel-2);
}
.station-action .craft-name { flex: 1; }
.station-action .craft-cost { width: auto; flex: none; text-align: right; }

/* Fila de trabajo en cola (§7.19/§7.20): icono + barra de progreso real (antes solo
   texto "🔨 Forjando… mm:ss") + botón de saltar. `job.startedAt`/`readyAt` ya existían
   en el motor — solo faltaba pintarlos. */
.job-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  margin-bottom: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-1);
}
.job-icon { width: 24px; height: 24px; flex: none; display: flex; align-items: center; justify-content: center; }
.job-icon-sprite { width: 24px; height: 24px; }
.job-icon-emoji { font-size: 15px; }
.job-main { flex: 1; min-width: 0; }
.job-bar {
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 3px;
}
.job-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #f4d58a);
  transition: width 0.3s linear;
}
.job-status { font-size: 11px; color: var(--muted); }
.job-skip { flex: none; font-size: 11px; padding: 4px 8px; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .job-fill { transition: none; } }

/* ---------- Mercado (Puesto de Intercambio, Fase D3 §7.12) ---------- */
.market-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 11px; color: var(--muted); }
#market-panel.locked .market-row { opacity: 0.55; filter: grayscale(0.6); }
.market-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px dotted var(--border);
  font-size: 11px;
}
.market-name-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.market-name { font-weight: 600; font-size: 12px; }
.market-price { color: var(--gold); text-align: right; }
.market-stock { color: var(--muted); }
.market-actions { display: flex; gap: 4px; justify-content: flex-end; }
.market-actions button { font-size: 10px; padding: 3px 7px; white-space: nowrap; }

/* ---------- Tienda de perks ---------- */
.h3-note { font-size: 10px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.perk { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dotted var(--border); }
.perk.owned { opacity: 0.6; }
.perk-main { flex: 1; min-width: 0; }
.perk-name { font-size: 13px; font-weight: 600; }
.perk-desc { font-size: 11px; color: var(--muted); }
.perk-buy { font-size: 11px; padding: 4px 8px; white-space: nowrap; color: var(--accent); }
.perk-buy:hover:not(:disabled) { border-color: var(--accent); }

/* ---------- Logros de Perfil (§7.14): un cuadradito por peldaño (medalla) y por eje
   (Obtenido de por vida / Donado de por vida), por material. Bloqueado = silueta gris
   (grayscale); desbloqueado = material a color con borde/fondo de la medalla. ---------- */
.ach-card { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-top: 1px dotted var(--border); }
.ach-card:first-of-type { border-top: none; }
.ach-head { display: flex; align-items: center; gap: 6px; }
.ach-name { font-weight: 600; font-size: 12px; }
.ach-axis { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ach-axis-label {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex: none;
  width: 92px;
}
.ach-progress { color: var(--text); }
.ach-tiles { display: flex; gap: 4px; }
.ach-tile {
  width: 26px;
  height: 26px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-1);
  border: 1px solid var(--border);
  background: var(--panel-2);
  transition: border-color 0.2s, background 0.2s;
}
.ach-tile .ach-icon { width: 16px; height: 16px; }
.ach-tile.locked .ach-icon { filter: grayscale(1) brightness(0.45); opacity: 0.55; }
.ach-tile.medal-copper {
  border-color: #b8733a;
  background: linear-gradient(160deg, rgba(184, 115, 58, 0.4), rgba(184, 115, 58, 0.1));
}
.ach-tile.medal-silver {
  border-color: #c9d3dc;
  background: linear-gradient(160deg, rgba(201, 211, 220, 0.4), rgba(201, 211, 220, 0.1));
}
.ach-tile.medal-gold {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(232, 185, 90, 0.4), rgba(232, 185, 90, 0.1));
}
.ach-tile.medal-diamond {
  border-color: #7fe8e0;
  background: linear-gradient(160deg, rgba(127, 232, 224, 0.45), rgba(127, 232, 224, 0.12));
  box-shadow: 0 0 6px rgba(127, 232, 224, 0.5);
}

/* ---------- Columna de feeds (chat + registro) ---------- */
.col-feeds { display: flex; flex-direction: column; gap: 14px; }
.feed { display: flex; flex-direction: column; min-height: 0; }
.feed h2 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}
.chat-log, #log { overflow-y: auto; font-size: 13px; }
.chat-log { max-height: 220px; margin-bottom: 8px; }
.chat-line { padding: 2px 2px; word-wrap: break-word; }
.chat-who { color: var(--accent); font-weight: 600; }
.chat-line.system { color: var(--gold); font-style: italic; }
.chat-tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.chat-tab { font-size: 11px; padding: 4px 10px; color: var(--muted); }
.chat-tab.active { color: var(--gold); border-color: var(--gold); background: var(--panel-2); }
#chat-local-where { font-size: 10px; opacity: 0.8; }
#chat-form { display: flex; gap: 6px; }
#chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
}
#chat-input:focus { outline: none; border-color: var(--gold); }

/* ---------- Navegación: badges (la tab-bar vive en hud.css) ---------- */
.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
  margin-left: 2px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}
.view-grid.feeds { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
@media (prefers-reduced-motion: reduce) { .nav-dot { animation: none; } }

/* ---------- Paneles ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}
.panel h3 { margin: 14px 0 6px; font-size: 13px; color: var(--gold); }

/* ---------- Filas de actividad ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
}
.row:hover { background: var(--panel-2); }
.row.active { background: var(--panel-2); outline: 1px solid var(--gold); }
.row.locked { opacity: 0.45; }
.row.locked .row-icon { filter: grayscale(1) brightness(0.6); }
.row-icon { width: 32px; height: 32px; flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
/* Aventureros en la zona (§7.6): dato de coordinación, discreto junto al nombre. */
.row-peers { font-weight: 400; font-size: 11px; color: var(--muted); }
.row-sub { color: var(--muted); font-size: 12px; }
.row-info { color: var(--muted); font-size: 12px; text-align: right; }

/* ---------- Botones ---------- */
button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
button:disabled { opacity: 0.45; cursor: default; }
button.danger { border-color: #5c2e2e; color: var(--bad); margin-top: 12px; }
button.danger:hover { border-color: var(--bad); }

/* ---------- Herramientas ---------- */
.tool {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.tool:last-of-type { border-bottom: none; }
.tool-head { display: flex; align-items: center; gap: 8px; grid-column: 1; }
.tool-name { font-weight: 600; }
.tool-level { color: var(--gold); margin-left: auto; }
.tool-effect { grid-column: 1; color: var(--muted); font-size: 12px; }
.tool .buy { grid-column: 2; grid-row: 1 / span 2; align-self: center; white-space: nowrap; }
/* Descuento de retaguardia (§7.4): botón resaltado en verde para el novato que hace catch-up. */
.tool .buy.rearguard { border-color: var(--good); color: var(--good); }
.tool-cost { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.tool-cost-tag { color: var(--good); }

/* Bloque de coste reutilizable (client/ui/costview.js): icono + "tienes/necesitas" por
   ingrediente, uno debajo del otro cuando hay más de uno — antes era texto seguido
   ("120🪙 · 40/60 Cuero · 12/20 Pino"), difícil de leer (petición real 2026-07-21). */
.cost-list { display: flex; flex-direction: column; gap: 2px; }
.cost-row { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.cost-icon { width: 14px; height: 14px; flex: none; }
/* Ingrediente concreto que falta en un coste: en rojo, con su fuente entre paréntesis */
.cost-row.cost-missing, .cost-missing { color: var(--bad); font-weight: 600; }

/* Botones de variante de forja: nombre + stat concreto debajo */
.forge-variant small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.forge-variant.active small { color: inherit; }

/* Info de bonus en celdas de crafteo (equipo) */
.craft-info { display: block; font-size: 11px; color: var(--muted); }

/* Inventario agrupado por familia, con tier visible */
.inv-group-title { margin: 8px 0 2px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.inv-tier { margin-left: 6px; font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }

/* Cofre estimado bajo el ranking de contribución */
.ranking-chest { margin: 4px 0 8px; font-size: 12px; color: var(--muted); }

/* Veta rica / mazmorra agitada (Fase C): la fila destaca mientras dura la ventana. */
.row.rich { border-left: 2px solid var(--gold); }
.row.rich .row-info { color: var(--gold); }

/* Forja de tiers (Fase B): elegir variante = elegir build. El efecto de cada
   variante va VISIBLE dentro del botón (en móvil no hay tooltips), y los botones
   se apilan solos en pantallas estrechas (grid auto-fit). */
.tool-forge {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
  padding-top: 4px;
}
.forge-title {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
}
.forge-variant {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  text-align: left;
  min-height: 44px; /* objetivo táctil cómodo */
}
.forge-variant .fv-name { font-size: 13px; font-weight: 600; }
.forge-variant .fv-desc { font-size: 11px; color: var(--muted); }
.forge-variant.active { border-color: var(--gold); }
.forge-variant.active .fv-name { color: var(--gold); }
.forge-cost { grid-column: 1 / -1; }

/* Vocación (§6.6): un botón por rama, mismo patrón que las variantes de forja */
#vocation-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.voc-choice { font-size: 12px; padding: 4px 10px; }
.voc-choice small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.voc-choice.active { border-color: var(--gold); color: var(--gold); }
.voc-choice.active small { color: inherit; }

/* ---- Altar (§7.16): tipo (reutiliza .voc-choice) → tier → sprite grande → coste ---- */
.altar-type-choices { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.altar-sprite-big { width: 128px; height: 128px; display: block; margin: 14px auto; }

/* ---------- Inventario ---------- */
.inv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  font-size: 13px;
}
.inv-row .inv-amount { margin-left: auto; color: var(--gold); font-variant-numeric: tabular-nums; }

/* ---------- Registro ---------- */
#log { max-height: 420px; overflow-y: auto; font-size: 13px; }
.log-line { padding: 3px 4px; border-bottom: 1px dotted var(--border); color: var(--muted); }
.log-line.good { color: var(--good); }
.log-line.bad { color: var(--bad); }
.log-line.highlight { color: var(--gold); }

/* ---------- Modales (offline, debug, novedades) ---------- */
#offline-modal, #debug-modal, #changelog-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal); /* por encima del sheet y de la tab-bar */
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}
#offline-modal[hidden], #debug-modal[hidden], #changelog-modal[hidden] { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 22px 28px;
  min-width: 300px;
}
.modal-box h2 { margin-top: 0; color: var(--gold); font-size: 17px; }
.modal-box ul { padding-left: 18px; }

/* ---------- Novedades (§12): historial de versiones, la actual destacada ---------- */
.changelog-box {
  max-width: 560px;
  width: min(560px, calc(100vw - 32px));
}
/* El historial crece con cada versión; el modal no. Scrollea, y que SE VEA que
   scrollea: barra siempre visible + degradado abajo mientras quede contenido (la clase
   `at-end` la pone changelog.js). Sin la pista, la última línea cortada era el único
   indicio de que había más. */
.cl-scroll { position: relative; margin-bottom: 16px; }
#changelog-list {
  max-height: min(60dvh, 460px);
  overflow-y: auto;
  padding-right: 10px; /* que la barra no se coma el texto */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  overscroll-behavior: contain; /* llegar al final no arrastra la página de detrás */
}
#changelog-list::-webkit-scrollbar { width: 8px; }
#changelog-list::-webkit-scrollbar-track { background: transparent; }
#changelog-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
#changelog-list::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.cl-scroll::after {
  content: "";
  position: absolute;
  left: 0;
  right: 10px; /* respeta la barra: el degradado no la tapa */
  bottom: 0;
  height: 44px;
  background: linear-gradient(transparent, var(--panel));
  pointer-events: none; /* es decoración: no debe robar clics ni la rueda */
  opacity: 1;
  transition: opacity 0.18s ease-out;
}
.cl-scroll.at-end::after, .cl-scroll.no-scroll::after { opacity: 0; }
.cl-entry { margin-bottom: 18px; }
.cl-entry:last-child { margin-bottom: 0; }
.cl-entry:not(.current) { opacity: 0.7; } /* versiones antiguas: contexto, no protagonistas */
.cl-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 13px;
}
.cl-version {
  font-family: ui-monospace, monospace;
  color: var(--gold);
  font-size: 12px;
}
.cl-title { font-weight: 600; }
.cl-date { color: var(--muted); font-size: 11px; margin-left: auto; }
.cl-changes { list-style: none; padding: 0; margin: 0; }
.cl-change {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.45;
  border-top: 1px solid var(--border);
}
.cl-tag {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
}
.cl-change.new .cl-tag { color: var(--gold); }
