:root {
  --bg: #1b1626;
  --panel: #2b2236;
  --panel2: #362b45;
  --line: #120d18;
  --hi: #4a3d5e;
  --text: #f6ecd6;
  --muted: #b9a9c4;
  --accent: #ffcf6b;
  --accent2: #e89b3c;
  --good: #9ddc7c;
  --bad: #ff8f7a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --px: 3px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg);
  color: var(--text); font-family: 'Pixelify Sans', ui-monospace, monospace;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none; touch-action: none;
}
img { image-rendering: pixelated; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; image-rendering: pixelated; }

/* marco pixel reutilizable */
.px {
  background: var(--panel);
  box-shadow: 0 0 0 var(--px) var(--line), inset 0 calc(var(--px) * -1) 0 rgba(0,0,0,.28), inset 0 var(--px) 0 rgba(255,255,255,.07);
}

/* ── HUD ── */
#hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(var(--safe-t) + 10px) 44px 0 12px; pointer-events: none; z-index: 5; }
#gear {
  position: fixed; top: calc(var(--safe-t) + 10px); right: 8px; z-index: 6; width: 30px; height: 30px; opacity: .45;
  display: flex; align-items: center; justify-content: center; background: rgba(27,22,38,.55); box-shadow: 0 0 0 2px rgba(18,13,24,.6);
}
#gear:active { opacity: .9; }
#gear img { width: 16px; height: 16px; }
#season { color: var(--muted); font-size: 12px; }
#chips { display: flex; flex-wrap: wrap; gap: 6px; }
#chips:empty { display: none; }
.evchip {
  pointer-events: auto; display: flex; align-items: center; gap: 5px; padding: 4px 9px 4px 6px; font-size: 13px;
  background: rgba(27,22,38,.9); box-shadow: 0 0 0 2px var(--line); animation: hintIn .4s steps(3);
}
.evchip img { width: 16px; height: 16px; }
.evchip.wish { background: rgba(255,207,107,.95); color: #3a2510; }
.evchip.night { background: rgba(60,52,110,.92); }
#topbar { display: flex; flex-direction: column; gap: 6px; }
#res { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 5px; padding: 4px 9px 4px 6px; font-weight: 600; font-size: 15px;
  background: rgba(27, 22, 38, .86); box-shadow: 0 0 0 2px var(--line), inset 0 -2px 0 rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.06);
}
.chip img { width: 18px; height: 18px; }
.chip.bump { animation: bump .35s steps(3); }
@keyframes bump { 50% { transform: translateY(-3px); color: var(--accent); } }
#meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); text-shadow: 0 2px 0 rgba(0,0,0,.6); }
#meta .sky { display: flex; align-items: center; gap: 4px; padding: 2px 7px; background: rgba(27,22,38,.7); box-shadow: 0 0 0 2px var(--line); color: var(--text); }
#meta .sky img { width: 14px; height: 14px; }
#era-name { color: var(--accent); font-weight: 600; text-shadow: 0 2px 0 rgba(0,0,0,.7); }

#hint {
  pointer-events: auto; margin-top: 10px; display: block; max-width: 100%; text-align: left;
  padding: 8px 12px; font-size: 14px; line-height: 1.3; background: rgba(255, 207, 107, .95); color: #3a2510;
  box-shadow: 0 0 0 2px var(--line), inset 0 -3px 0 rgba(0,0,0,.18); animation: hintIn .5s steps(4);
}
#hint[hidden] { display: none; }
@keyframes hintIn { from { transform: translateY(-6px); opacity: 0; } }

#toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 10px; }
.toast {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 14px;
  background: rgba(27, 22, 38, .92); box-shadow: 0 0 0 2px var(--line); animation: toastIn .3s steps(3); transition: opacity .5s, transform .5s;
}
.toast img { width: 18px; height: 18px; }
.toast.out { opacity: 0; transform: translateY(-6px); }
.toast.important { box-shadow: 0 0 0 2px var(--accent), 0 3px 0 rgba(0,0,0,.35); }
.toast.sticky { pointer-events: auto; cursor: pointer; }
.toast.sticky::after { content: '✕'; margin-left: 6px; opacity: .6; font-size: 12px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* ── Dock ── */
#dock {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 14px); transform: translateX(-50%); z-index: 6;
  display: flex; gap: 8px; padding: 8px; background: rgba(27, 22, 38, .9);
  box-shadow: 0 0 0 3px var(--line), inset 0 -3px 0 rgba(0,0,0,.3), inset 0 3px 0 rgba(255,255,255,.05);
  transition: transform .25s steps(4), opacity .25s;
}
#dock.away { transform: translate(-50%, 140%); opacity: 0; pointer-events: none; }
#dock button {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 62px; padding: 7px 6px 6px;
  font-size: 12px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line), inset 0 -3px 0 rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.08);
}
#dock button:active { transform: translateY(2px); box-shadow: 0 0 0 2px var(--line), inset 0 -1px 0 rgba(0,0,0,.3); }
#dock button img { width: 26px; height: 26px; }
#dock button.main { background: #a8642c; color: #fff4dc; }

/* ── Botones ── */
/* un botón oculto se oculta de verdad (si no, el display de .btn lo vuelve a mostrar) */
.btn[hidden] { display: none !important; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; font-size: 15px; font-weight: 600;
  background: var(--panel2); box-shadow: 0 0 0 2px var(--line), inset 0 -3px 0 rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.08);
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn.primary { background: #c8792f; color: #fff6e2; }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: 0 0 0 2px var(--hi); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.big { width: 100%; padding: 13px 16px; font-size: 17px; margin-top: 10px; }
.btn:disabled { opacity: .45; filter: grayscale(.6); }

/* ── Barra de colocación ── */
#placebar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 14px); z-index: 7; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; background: rgba(27, 22, 38, .94); box-shadow: 0 0 0 3px var(--line);
}
#placebar[hidden] { display: none; }
.pinfo { display: flex; flex-direction: column; gap: 2px; }
.pinfo b { font-size: 17px; color: var(--accent); }
.pinfo span { font-size: 13px; color: var(--muted); }
.pinfo span.bad { color: var(--bad); }
.ptools { display: flex; gap: 6px; }
.ptools[hidden] { display: none; }
.ptools button { flex: 1; padding: 7px 4px; font: inherit; font-size: 13px; color: var(--muted); background: var(--panel2); box-shadow: 0 0 0 2px var(--line); border: 0; }
.ptools button.on { color: #fff6e2; background: #6a4a8a; box-shadow: 0 0 0 2px var(--accent); }
.ptools button[data-erase].on { background: #8a3a3a; box-shadow: 0 0 0 2px var(--bad); }
.dtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 10px; }
.dtabs button { padding: 6px 10px; font: inherit; font-size: 13px; color: var(--muted); background: transparent; box-shadow: 0 0 0 2px var(--line); border: 0; min-height: 32px; }
.dtabs button.on { color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tip.unlocks p { margin: 2px 0; }
.prio { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; }
.prio-help { margin: 2px 0 6px; font-size: 12px; line-height: 1.3; color: var(--muted); }
.prio small { color: var(--muted); font-size: 12px; margin-right: 4px; }
.prio button { flex: 1; padding: 7px 4px; font: inherit; font-size: 13px; color: var(--muted); background: var(--panel2); box-shadow: 0 0 0 2px var(--line); border: 0; min-height: 34px; }
.prio button.on { color: #fff6e2; background: #6a4a8a; box-shadow: 0 0 0 2px var(--accent); }
.pbtns { display: flex; gap: 10px; }
.pbtns .btn { flex: 1; }

/* ── Hoja inferior ── */
#sheet-wrap { position: fixed; inset: 0; z-index: 10; }
#sheet-wrap[hidden] { display: none; }
#sheet-wrap { pointer-events: none; }
#sheet-wrap #sheet { pointer-events: auto; }
#sheet-wrap .backdrop { position: absolute; inset: 0; background: rgba(10, 6, 18, .22); opacity: 0; transition: opacity .2s; pointer-events: none; }
#sheet-wrap.show .backdrop { opacity: 1; }
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 74vh; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: 10px 16px calc(var(--safe-b) + 20px); background: var(--panel);
  box-shadow: 0 -3px 0 var(--line), inset 0 3px 0 rgba(255,255,255,.07);
  transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.9,.3,1);
}
#sheet-wrap.show #sheet { transform: none; }
#sheet .grab { width: 44px; height: 4px; margin: 0 auto 8px; background: var(--hi); }
#sheet .close { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; font-size: 16px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); }
#sheet h2 { margin: 4px 0 4px; font-size: 24px; color: var(--accent); font-weight: 600; letter-spacing: .5px; }
#sheet h3 { margin: 16px 0 8px; font-size: 16px; font-weight: 600; }
.sub { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.desc { margin: 6px 0 10px; line-height: 1.4; font-size: 15px; color: #e6dacb; }
.tip { margin: 8px 0; font-size: 13px; color: var(--muted); line-height: 1.35; }

.tabs { display: flex; gap: 6px; margin: 10px 0 12px; overflow-x: auto; }
.tabs button { flex: none; padding: 7px 11px; font-size: 13px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); color: var(--muted); }
.tabs button.on { background: var(--accent); color: #3a2510; }
/* construir: cinco pestañas que caben en el móvil (si no, pasan a otra fila) */
/* (en rejilla: si no caben, la fila de abajo no se estira a todo lo ancho) */
.tabs.btabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); overflow: visible; }
.tabs.btabs button { padding-left: 6px; padding-right: 6px; white-space: nowrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px 9px; text-align: center;
  background: var(--panel2); box-shadow: 0 0 0 2px var(--line), inset 0 -3px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.06);
}
.card:active:not(:disabled) { transform: translateY(2px); }
.card .thumb { height: 64px; display: flex; align-items: flex-end; justify-content: center; }
.card .thumb img { max-height: 64px; max-width: 88px; }
.card .cname { font-size: 13px; font-weight: 600; line-height: 1.15; min-height: 2.3em; display: flex; align-items: center; }
.card.dim { opacity: .62; }
.card.locked { opacity: .45; filter: grayscale(.8) brightness(.8); }
.card .lock { font-size: 11px; color: var(--muted); }
.card .ctime { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.card .ctime img { width: 12px; height: 12px; }

.costs { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
.costs.big { justify-content: flex-start; gap: 8px 14px; margin: 8px 0; }
.costs.big .cost { font-size: 17px; }
.costs.big .cost img { width: 20px; height: 20px; }
.upgrade .costs { justify-content: flex-start; margin-bottom: 10px; }
.cost { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; }
.cost img { width: 14px; height: 14px; }
.cost.miss { color: var(--bad); }

.bhead, .era-head { display: flex; align-items: center; gap: 14px; padding-right: 40px; }
.bhead img { width: 72px; height: 72px; object-fit: contain; object-position: bottom; }
.era-head img { width: 56px; height: 56px; }
.era-head .sub { margin: 0; }

.rows { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; }
.rows > div, .rows > label { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: var(--panel2); font-size: 14px; }
.rows span { color: var(--muted); }
.rows b { display: flex; align-items: center; gap: 4px; font-weight: 600; }
.rows b img { width: 16px; height: 16px; }
.toggles input { width: 22px; height: 22px; accent-color: #c8792f; }

.cons { margin: 10px 0; padding: 10px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); }
.cons-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.bar { height: 10px; background: #1b1626; box-shadow: 0 0 0 2px var(--line); }
.bar > div { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--accent) 0 6px, var(--accent2) 6px 8px); }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.reqs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.reqs li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel2); font-size: 14px; color: var(--muted); }
.reqs li::before { content: ''; width: 12px; height: 12px; flex: none; box-shadow: 0 0 0 2px var(--hi); }
.reqs li.ok { color: var(--text); }
.reqs li.ok::before { background: var(--good); box-shadow: 0 0 0 2px #3d6b2c; }
.reqs img { width: 16px; height: 16px; }

.people { display: flex; flex-direction: column; gap: 6px; }
.person { display: flex; align-items: center; gap: 12px; padding: 6px 10px; text-align: left; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); }
.person img { width: 42px; height: 45px; object-fit: contain; }
.person div { display: flex; flex-direction: column; gap: 1px; }
.person b { font-size: 16px; }
.person span { font-size: 13px; color: #e6dacb; }
.person small { font-size: 11px; color: var(--muted); }
.credits { text-align: center; margin-top: 24px; }

/* ── Cambio de época ── */
#flash {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; background: radial-gradient(circle, rgba(255, 220, 150, .35), rgba(20, 12, 30, .75)); opacity: 0;
}
#flash[hidden] { display: none; }
#flash.go { animation: flash 4.2s ease both; }
#flash p { margin: 0; font-size: 18px; color: var(--muted); letter-spacing: 3px; text-transform: uppercase; }
#flash h1 { margin: 6px 0 0; font-size: 42px; color: var(--accent); text-shadow: 0 4px 0 #6a3a10, 0 0 24px rgba(255, 200, 100, .6); text-align: center; padding: 0 16px; }
@keyframes flash { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }

/* ── Pantalla de inicio ── */
#splash {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(#141024, #2a1f3c 60%, #3c2a40); transition: opacity .8s; cursor: pointer;
}
#splash.gone { opacity: 0; pointer-events: none; }
#splash h1 {
  margin: 0; font-size: 76px; font-weight: 700; letter-spacing: 10px; color: #ffe3a3; padding-left: 10px;
  text-shadow: 0 5px 0 #a8642c, 0 10px 0 #4a2a14, 0 0 40px rgba(255, 200, 110, .55); animation: float 4s ease-in-out infinite;
}
#splash .tag { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
#splash .go { margin-top: 48px; font-size: 16px; color: var(--text); opacity: 0; }
#splash.ready .go { animation: blink 1.6s steps(2) infinite; }
#splash .stars {
  position: absolute; inset: 0; pointer-events: none; opacity: .8;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 78% 12%, #ffe9b0 50%, transparent 51%),
    radial-gradient(2px 2px at 30% 70%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 88% 64%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 55% 30%, #cfe0ff 50%, transparent 51%), radial-gradient(2px 2px at 20% 88%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 66% 84%, #ffe9b0 50%, transparent 51%), radial-gradient(2px 2px at 44% 10%, #fff 50%, transparent 51%);
  animation: twinkle 3s steps(2) infinite;
}
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes blink { 0% { opacity: 1; } 50% { opacity: .2; } 100% { opacity: 1; } }
@keyframes twinkle { 50% { opacity: .45; } }

/* ── v0.2 ── */
.lvl { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.lvl i { width: 7px; height: 7px; background: var(--hi); box-shadow: 0 0 0 1px var(--line); }
.lvl i.on { background: var(--accent); }
.levelprev { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 10px; }
.levelprev img { height: 56px; object-fit: contain; }
.levelprev span { color: var(--muted); font-size: 20px; padding-bottom: 16px; }
.bar.big { height: 8px; margin: 4px 0 10px; }
.quote { font-style: italic; color: #f6ecd6; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.log li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; background: var(--panel2); font-size: 14px; line-height: 1.35; }
.log li img { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.log li div { display: flex; flex-direction: column; gap: 2px; }
.log small { color: var(--muted); font-size: 11px; }
.person .heart { display: inline-block; width: 8px; height: 7px; background: #e04a6a; clip-path: polygon(0 25%, 25% 0, 50% 25%, 75% 0, 100% 25%, 50% 100%); }
.person.pet { margin-bottom: 8px; }
.offers { display: flex; flex-direction: column; gap: 8px; }
.offer { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); }
.offer .costs { justify-content: flex-start; }
.offer .arrow { color: var(--muted); }
.offer .get { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.offer .get img.rare { height: 32px; }
.offer.done { opacity: .5; }
.sleepopts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.sleepopts .btn { padding: 14px; font-size: 17px; }
#sleepcover {
  position: fixed; inset: 0; z-index: 40; background: #06040c; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: #6a5a8a; opacity: 0; transition: opacity 8s ease;
}
#sleepcover[hidden] { display: none; }
#sleepcover.on { opacity: 1; }
#sleepcover p { margin: 0; font-size: 22px; }
#sleepcover small { font-size: 12px; opacity: .6; }

/* ── v0.3 ── */
/* números en fuente pixel más legible */
.num, .chip b, .cost, .lim, #clock, .rl span:last-child { font-family: 'Atkinson Hyperlegible', 'Pixelify Sans', sans-serif; font-weight: 700; letter-spacing: .2px; font-variant-numeric: tabular-nums; }
.chip b { font-size: 13px; }
.chip { cursor: pointer; color: var(--text); }
.chip:active { transform: translateY(1px); }
.cost { font-size: 11px; }
.costs.big .cost { font-size: 15px; }
#clock { font-size: 12px; }

#ratepop {
  position: fixed; z-index: 8; width: 220px; padding: 10px 12px; font-size: 13px;
  background: rgba(27, 22, 38, .96); box-shadow: 0 0 0 2px var(--line), 0 6px 0 rgba(0,0,0,.25); animation: hintIn .2s steps(2);
}
#ratepop[hidden] { display: none; }
#ratepop b { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--accent); margin-bottom: 6px; }
#ratepop b img { width: 18px; height: 18px; }
#ratepop .rl { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: #e6dacb; }
#ratepop .rl.big { font-size: 15px; color: var(--text); border-bottom: 2px solid var(--hi); margin-bottom: 4px; padding-bottom: 6px; }
#ratepop small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.3; }

#follow {
  pointer-events: auto; margin-top: 8px; display: flex; align-items: center; gap: 8px; padding: 6px 8px; max-width: 260px;
  background: rgba(27, 22, 38, .92); box-shadow: 0 0 0 2px var(--accent); cursor: pointer;
}
#follow[hidden] { display: none; }
#follow img { width: 30px; height: 34px; object-fit: contain; }
#follow div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
#follow b { font-size: 14px; }
#follow span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#follow button { width: 28px; height: 28px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); }

.evchip.raid { background: rgba(200, 60, 50, .95); animation: pulse 1s steps(2) infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px var(--line), 0 0 0 4px rgba(255,120,100,.5); } }

.card { position: relative; }
.card .lim { position: absolute; top: 4px; right: 6px; font-size: 10px; color: var(--muted); }

.mini-people { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.mini { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 3px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); font-size: 12px; }
.mini img { width: 22px; height: 24px; object-fit: contain; }
.upgrade.convert { padding: 10px; margin: 10px 0; background: rgba(255, 207, 107, .08); box-shadow: 0 0 0 2px rgba(255, 207, 107, .4); }
.upgrade.convert h3 { margin-top: 0; color: var(--accent); }

.bhead img.portrait { width: 60px; height: 66px; }
.traits { display: flex; flex-direction: column; gap: 4px; }
.trait { display: flex; flex-direction: column; padding: 8px 10px; background: var(--panel2); }
.trait b { font-size: 14px; color: var(--accent); }
.trait span { font-size: 13px; color: #e6dacb; }
.dream { display: flex; gap: 10px; align-items: center; padding: 10px; margin: 8px 0; background: var(--panel2); box-shadow: 0 0 0 2px var(--hi); }
.dream img { width: 22px; height: 22px; }
.dream div { display: flex; flex-direction: column; }
.dream small { color: var(--muted); font-size: 11px; }
.dream.done { box-shadow: 0 0 0 2px var(--good); }
.rels { display: flex; flex-direction: column; gap: 4px; }
.relrow { display: flex; align-items: center; gap: 10px; padding: 4px 10px; background: var(--panel2); text-align: left; }
.relrow img { width: 26px; height: 30px; object-fit: contain; }
.relrow span { flex: 1; font-size: 14px; }
.relrow small { font-size: 12px; color: var(--muted); }
i.crown { display: inline-block; width: 10px; height: 8px; background: var(--accent); clip-path: polygon(0 100%, 0 20%, 25% 55%, 50% 0, 75% 55%, 100% 20%, 100% 100%); }
.jobh { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 14px; cursor: pointer; }
.jobh .ic { width: 14px; height: 14px; }
.people h3:first-child { margin-top: 4px; }
#res .chip { pointer-events: auto; }

/* ── v0.4 ── */
.memorial { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.memorial img { width: 48px; height: 54px; object-fit: contain; filter: grayscale(.6) brightness(.9); }
.person.memo img { width: 30px; height: 30px; }
.bhead img.ruin { filter: grayscale(.7) brightness(.75); }

/* ── 0.5: diario, copias de seguridad, árbol de familias ── */
.toggles label span small { display: block; font-size: 11px; color: var(--muted); }
.diary h2 { margin-bottom: 6px; }
.dchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.dchip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); font-size: 13px; }
.dchip img { width: 14px; height: 14px; }
.dchip b { font-family: 'Atkinson Hyperlegible', sans-serif; font-weight: 700; font-size: 12px; color: var(--accent); }
.dlist { list-style: none; margin: 0; padding: 0 0 0 4px; display: flex; flex-direction: column; border-left: 2px solid var(--hi); }
.dlist li { display: grid; grid-template-columns: 52px 16px 1fr; gap: 8px; align-items: start; padding: 6px 4px 6px 8px; position: relative; font-size: 14px; line-height: 1.35; }
.dlist li::before { content: ''; position: absolute; left: -5px; top: 11px; width: 6px; height: 6px; background: var(--accent2); box-shadow: 0 0 0 2px var(--panel); }
.dlist time { font-family: 'Atkinson Hyperlegible', sans-serif; font-weight: 700; font-size: 10px; color: var(--muted); padding-top: 3px; white-space: nowrap; }
.dlist img { width: 16px; height: 16px; margin-top: 1px; }
.linkbtn { color: var(--accent); text-decoration: underline; padding: 0; }
textarea.code { width: 100%; min-height: 96px; margin: 8px 0; padding: 8px; background: var(--line); color: var(--text); border: 0; box-shadow: 0 0 0 2px var(--hi); font: 11px/1.3 ui-monospace, monospace; word-break: break-all; user-select: text; -webkit-user-select: text; touch-action: auto; resize: vertical; }
.filebtn { position: relative; display: inline-flex; align-items: center; gap: 6px; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.heir { margin: 6px 0; }
.heir p { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 14px; color: #e6dacb; }
.heir img { width: 16px; height: 16px; }
.relrow.dead { opacity: .65; }

.family { margin: 8px 0 12px; padding: 8px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); overflow-x: auto; }
.fnode { display: flex; flex-direction: column; align-items: flex-start; }
.funion { display: flex; align-items: center; gap: 4px; margin-left: 18px; }
.funion:empty { display: none; }
.fheart { width: 8px; height: 7px; background: #e04a6a; clip-path: polygon(0 25%, 25% 0, 50% 25%, 75% 0, 100% 25%, 50% 100%); flex: none; }
.ftree { list-style: none; margin: 2px 0 0 12px; padding: 0 0 0 10px; border-left: 2px solid var(--hi); }
.ftree li { position: relative; padding: 3px 0; }
.ftree li::before { content: ''; position: absolute; left: -10px; top: 20px; width: 8px; height: 2px; background: var(--hi); }
.fperson { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 2px; text-align: left; background: var(--panel); box-shadow: 0 0 0 2px var(--line); }
.fperson img { width: 26px; height: 30px; object-fit: contain; }
.fperson span { display: flex; flex-direction: column; }
.fperson b { font-size: 13px; font-weight: 500; }
.fperson small { font-size: 10px; color: var(--muted); }
.fperson.dead { opacity: .6; cursor: default; }
.fperson.dead img { filter: grayscale(.8); }
.chiefs li img { width: 16px; height: 16px; }

/* ── 0.6: Luminito, modo contemplación y nombres ── */
#calmbtn {
  position: fixed; top: calc(var(--safe-t) + 46px); right: 8px; z-index: 6; width: 30px; height: 30px; opacity: .55;
  display: flex; align-items: center; justify-content: center; background: rgba(27,22,38,.55); box-shadow: 0 0 0 2px rgba(18,13,24,.6);
}
#calmbtn:active { opacity: .95; }
#calmbtn img { width: 16px; height: 16px; }
body.calm #hud, body.calm #dock, body.calm #gear, body.calm #calmbtn, body.calm #ratepop { opacity: 0; pointer-events: none; transition: opacity .8s; }
#hud, #dock, #gear, #calmbtn { transition: opacity .5s; }
#calmcap {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 34px); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 20px; text-align: center;
}
#calmcap[hidden] { display: none; }
#calmcap span { font-size: 17px; color: #fff3d8; text-shadow: 0 2px 0 rgba(0,0,0,.75), 0 0 12px rgba(0,0,0,.6); opacity: 0; }
#calmcap span.in { animation: capIn 1.2s ease forwards; }
@keyframes capIn { from { opacity: 0; transform: translateY(4px); } to { opacity: .92; transform: none; } }
#calmcap small { font-size: 12px; color: var(--muted); text-shadow: 0 2px 0 rgba(0,0,0,.7); }
#calmcap small[hidden] { display: none; }

#guide {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--safe-b) + 98px); z-index: 7; display: flex; align-items: flex-end; gap: 6px;
  animation: guideIn .35s steps(3); cursor: pointer;
}
#guide[hidden] { display: none; }
@keyframes guideIn { from { transform: translateY(10px); opacity: 0; } }
#guide-face { width: 72px; height: 84px; image-rendering: pixelated; flex: none; filter: drop-shadow(0 0 10px rgba(255, 160, 60, .55)); }
#guide .gbox {
  flex: 1; min-width: 0; position: relative; padding: 9px 12px 12px; margin-bottom: 8px; background: #fff3dc; color: #3a2510;
  box-shadow: 0 0 0 2px var(--line), inset 0 -3px 0 rgba(0,0,0,.12), 4px 4px 0 rgba(18,13,24,.45);
}
#guide .gbox::before { content: ''; position: absolute; left: -8px; bottom: 14px; width: 8px; height: 8px; background: #fff3dc; clip-path: polygon(100% 0, 0 50%, 100% 100%); }
#guide .gbox b { display: block; font-size: 12px; color: #c4473a; letter-spacing: .04em; }
#guide .gbox p { margin: 2px 0 0; font-size: 15px; line-height: 1.35; min-height: 2.7em; }
#guide .gnext { position: absolute; right: 8px; bottom: 4px; width: 8px; height: 5px; background: #c4473a; clip-path: polygon(0 0, 100% 0, 50% 100%); opacity: 0; }
#guide.done .gnext { opacity: 1; animation: nextBob .6s steps(2) infinite; }
@keyframes nextBob { 50% { transform: translateY(2px); } }
#guide-skip { position: absolute; right: 2px; top: -24px; font-size: 12px; color: var(--muted); text-shadow: 0 2px 0 rgba(0,0,0,.7); padding: 2px 4px; }
#guide-skip[hidden] { display: none; }
#guide-mini {
  position: fixed; left: 10px; bottom: calc(var(--safe-b) + 98px); z-index: 6; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 20px);
  padding: 2px 10px 2px 2px; background: rgba(27, 22, 38, .9); box-shadow: 0 0 0 2px var(--line); text-align: left; animation: guideIn .35s steps(3);
}
#guide-mini[hidden] { display: none; }
#guide-mini canvas { width: 36px; height: 42px; image-rendering: pixelated; flex: none; }
#guide-mini span { font-size: 13px; line-height: 1.25; color: var(--text); }
.gpulse { animation: gpulse 1s steps(2) infinite !important; }
@keyframes gpulse { 50% { box-shadow: 0 0 0 3px #ffcf6b, 0 0 14px 2px rgba(255, 207, 107, .7); } }

.namein {
  width: 100%; margin: 6px 0; padding: 10px 12px; font: 600 18px 'Pixelify Sans', ui-monospace, monospace; color: var(--text);
  background: var(--line); border: 0; box-shadow: 0 0 0 2px var(--hi); user-select: text; -webkit-user-select: text; touch-action: auto;
}
.namein:focus { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.namesug { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.era-head img { image-rendering: pixelated; }
.era-head img { object-fit: contain; }

/* ── 0.7: topes de almacén y mejoras ── */
.chip.full b { color: #ffb35c; }
.chip.full { box-shadow: 0 0 0 2px #8a4a1c, inset 0 -2px 0 rgba(0,0,0,.3); }
#ratepop small.bad { display: block; color: #ffb35c; margin-top: 4px; }
.lvl { flex-wrap: wrap; }
.lvl i.lock { opacity: .25; }
.rows.gains { margin: 6px 0 8px; }
.rows.gains b { gap: 5px; }
.rows.gains .arrow { font-style: normal; color: var(--muted); }
.rows.gains .up { color: var(--good); }

/* ── 0.9: volumen, contemplación con flechas y editar poblado ── */
.toggles label.slider { gap: 10px; }
.toggles label.slider span { flex: none; }
.toggles input[type="range"] { flex: 1; min-width: 0; width: auto; height: 22px; accent-color: #c8792f; touch-action: pan-x; }
.toggles label.slider b { width: 30px; text-align: right; color: var(--text); font-family: 'Atkinson Hyperlegible', sans-serif; font-weight: 700; font-size: 12px; }
.calmnav { display: flex; align-items: center; gap: 10px; max-width: 100%; }
.calmnav span { min-width: 0; }
.calmnav button {
  pointer-events: auto; flex: none; width: 34px; height: 34px; background: rgba(27,22,38,.72); box-shadow: 0 0 0 2px rgba(18,13,24,.7);
  position: relative; opacity: .8;
}
.calmnav button:active { opacity: 1; transform: translateY(1px); }
.calmnav button::before { content: ''; position: absolute; inset: 0; margin: auto; width: 10px; height: 12px; background: #fff3d8; }
#calm-prev::before { clip-path: polygon(100% 0, 0 50%, 100% 100%); }
#calm-next::before { clip-path: polygon(0 0, 100% 50%, 0 100%); }
#editbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 14px); z-index: 7; padding: 12px; display: flex; flex-direction: column; gap: 10px;
  background: rgba(27, 22, 38, .94); box-shadow: 0 0 0 3px var(--line), inset 0 -3px 0 rgba(0,0,0,.3);
}
#editbar[hidden] { display: none; }
#editbar .pinfo { display: flex; flex-direction: column; gap: 3px; }
#editbar .pinfo b { color: var(--accent); }
#editbar .pinfo span { font-size: 14px; color: #e6dacb; }
#editbar .pinfo span.bad { color: var(--bad); }
body.editing #gear, body.editing #calmbtn, body.editing #guide, body.editing #guide-mini { display: none !important; }
#dock button[hidden] { display: none; }

/* ── 0.10: polvo de estrella ── */
.chip.dust { background: rgba(58, 40, 92, .9); box-shadow: 0 0 0 2px #2a1a44, inset 0 -2px 0 rgba(0,0,0,.3), inset 0 2px 0 rgba(255,220,140,.12); }
.chip.dust b { color: #ffd98a; }

/* ── 0.11: panel de edificio compacto (cabe sin desplazarse) ── */
.bp .bhead { gap: 10px; align-items: flex-start; }
.bp .bhead img { width: 52px; height: 52px; flex: none; }
.bp .bhead h2 { font-size: 20px; margin: 0 0 1px; }
.bp .bhead .sub { margin: 0; font-size: 12px; }
.bp .bdesc { margin: 3px 0 0; font-size: 12px; line-height: 1.3; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 4px; margin: 8px 0 6px; }
.bstats > div { display: flex; flex-direction: column; gap: 1px; padding: 5px 8px; background: var(--panel2); min-width: 0; }
.bstats small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bstats b { display: flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.bstats b img { width: 14px; height: 14px; }
.bp .mini-people { margin: 4px 0; gap: 4px; }
.bp .mini { padding: 2px 6px 2px 2px; font-size: 11px; }
.bp .mini img { width: 18px; height: 20px; }
.bp .tip { margin: 4px 0; font-size: 12px; }
.bp .cons { margin: 6px 0; padding: 8px; }
.bp .cons .tip { margin: 4px 0 0; }
.bup { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; padding: 8px; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); }
.bup.convert { background: rgba(255, 207, 107, .08); box-shadow: 0 0 0 2px rgba(255, 207, 107, .4); }
.bup img.next { width: 40px; height: 44px; object-fit: contain; object-position: bottom; flex: none; }
.bup-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bup-main > b { font-size: 14px; color: var(--accent); }
.bup-main small { font-size: 11px; color: var(--muted); line-height: 1.25; }
.gains { display: flex; flex-wrap: wrap; gap: 3px 10px; }
.gain { display: inline-flex; align-items: baseline; gap: 4px; font-size: 12px; }
.gain small { font-size: 10px; color: var(--muted); }
.gain b { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.gain b img { width: 12px; height: 12px; align-self: center; }
.gain .arrow { font-style: normal; color: var(--muted); }
.gain .up { color: var(--good); }
.bup-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bup-foot .costs { justify-content: flex-start; margin: 0; flex: 1; min-width: 0; }
.bup-foot .btn { flex: none; }
.bp .row-btns { margin-top: 8px; gap: 6px; }

/* ── 0.11: dock más pequeño; Ajustes y Contemplación abajo a la derecha ── */
#dock { padding: 6px; gap: 6px; }
#dock button { min-width: 52px; padding: 5px 5px 4px; font-size: 11px; gap: 2px; }
#dock button img { width: 24px; height: 24px; }
#gear, #calmbtn {
  top: auto; right: max(10px, env(safe-area-inset-right, 0px)); width: 40px; height: 40px; opacity: 1;
  background: rgba(27, 22, 38, .92); box-shadow: 0 0 0 2px var(--line), inset 0 -2px 0 rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.07);
}
#gear { bottom: calc(var(--safe-b) + 14px); }
#calmbtn { bottom: calc(var(--safe-b) + 60px); }
#gear img, #calmbtn img { width: 24px; height: 24px; }
#gear:active, #calmbtn:active { transform: translateY(1px); background: var(--panel2); }
body.dockaway #gear, body.dockaway #calmbtn { display: none; }
#hud { padding-right: 12px; }
#guide { bottom: calc(var(--safe-b) + 84px); right: 58px; }
#guide-mini { bottom: calc(var(--safe-b) + 84px); max-width: calc(100% - 78px); }
/* el dock se centra en el hueco que dejan los botones de la derecha (no se pisan ni en móviles estrechos) */
#dock { left: calc(50% - 25px); }

/* ── 0.12: botones de la esquina más pequeños y barra de recursos en una sola línea ── */
#gear, #calmbtn { width: 32px; height: 32px; }
#gear img, #calmbtn img { width: 16px; height: 16px; }
#calmbtn { bottom: calc(var(--safe-b) + 52px); }
#dock { left: calc(50% - 21px); }
#guide { right: 50px; bottom: calc(var(--safe-b) + 84px); }

/* ── 0.12b: recursos en un panel con rejilla fija (1 línea hasta 6, si no 2 líneas) ── */
#res {
  display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: 2px; padding: 2px;
  background: var(--line); box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 3px 0 rgba(0,0,0,.35);
}
#res .chip {
  min-width: 0; justify-content: flex-start; gap: 4px; padding: 4px 5px; font-size: 13px;
  background: rgba(27, 22, 38, .9); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.05);
}
#res .chip img { width: 15px; height: 15px; flex: none; }
#res .chip b { min-width: 0; overflow: hidden; text-overflow: clip; white-space: nowrap; }
#res .chip.pop { background: rgba(40, 32, 56, .92); }
#res .chip.dust { background: rgba(58, 40, 92, .92); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,220,140,.12); }
#res .chip.full { box-shadow: inset 0 0 0 2px #8a4a1c; }

/* ── 0.12c: polvo de estrella abajo a la izquierda, junto al menú ── */
#dock { left: 50%; }
#dustbtn {
  position: fixed; left: max(10px, env(safe-area-inset-left, 0px)); bottom: calc(var(--safe-b) + 14px); z-index: 6;
  width: 38px; height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: rgba(58, 40, 92, .94); box-shadow: 0 0 0 2px var(--line), inset 0 -2px 0 rgba(0,0,0,.3), inset 0 2px 0 rgba(255,220,140,.14);
}
#dustbtn img { width: 16px; height: 16px; }
#dustbtn b { font-family: 'Atkinson Hyperlegible', sans-serif; font-weight: 700; font-size: 10px; color: #ffd98a; line-height: 1; }
#dustbtn.bump { animation: bump .35s steps(3); }
#dustbtn:active { transform: translateY(1px); }
body.calm #dustbtn, body.editing #dustbtn, body.dockaway #dustbtn { display: none; }
#guide-mini { left: 56px; max-width: calc(100% - 112px); }

/* ── 0.12d: Ajustes + Contemplación juntos miden lo mismo que el menú (60 px); estrella más pequeña ── */
#gear, #calmbtn { width: 32px; height: 28px; }
#gear { bottom: calc(var(--safe-b) + 14px); }
#calmbtn { bottom: calc(var(--safe-b) + 46px); }
#gear img, #calmbtn img { width: 16px; height: 16px; }
#dustbtn { width: 30px; height: 36px; gap: 2px; }
#dustbtn img { width: 12px; height: 12px; }
#dustbtn b { font-size: 9px; }

/* ── 0.13: menú Construir más compacto y con lo que produce cada cosa ── */
.grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.card { padding: 6px 4px 6px; gap: 3px; }
.card .thumb { height: 46px; }
.card .thumb img { max-height: 46px; max-width: 70px; }
.card .cname { font-size: 12px; min-height: 2.2em; }
.card .costs { gap: 2px 6px; }
.card .gives { position: absolute; top: 4px; left: 5px; display: inline-flex; align-items: center; gap: 2px; }
.card .gives img { width: 14px; height: 14px; }
.card .gives b { font-size: 11px; color: var(--accent); }
.card .lim { font-size: 11px; }
.tabs button { padding-left: 9px; padding-right: 9px; }
.reqs2 { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; }
.req { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; padding: 6px 10px 7px; background: var(--panel2); text-align: left; }
.req .rlabel { display: flex; align-items: center; gap: 6px; font-size: 14px; min-width: 0; }
.req .rlabel img { width: 16px; height: 16px; }
.req .rnum { font-size: 12px; color: var(--muted); }
.req .rbar { grid-column: 1 / -1; height: 4px; background: #1b1626; display: block; }
.req .rbar i { display: block; height: 100%; background: var(--accent2); }
.req.ok { box-shadow: inset 3px 0 0 var(--good); }
.req.ok .rnum { color: var(--good); }
.req.ok .rbar i { background: var(--good); }
.req:active { transform: translateY(1px); }
.pf .bhead { gap: 10px; align-items: flex-start; }
.pf .bhead img.portrait { width: 48px; height: 54px; flex: none; }
.pf .bhead h2 { font-size: 21px; margin: 0; }
.pf .bhead .sub { margin: 0; font-size: 12px; }
.pf .pact { margin: 3px 0 0; font-size: 13px; font-style: italic; color: #e6dacb; }
.pf .row-btns { margin-top: 8px; }
.pf .tabs { margin: 10px 0 8px; }
.pf .traits { display: flex; flex-direction: column; gap: 3px; }
.pf .desc.small { font-size: 13px; margin: 8px 0; }
.pf .dream { margin: 6px 0; }
.sgroup { margin: 6px 0; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); }
.sgroup summary { list-style: none; cursor: pointer; padding: 10px 12px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.sgroup summary::-webkit-details-marker { display: none; }
.sgroup summary::after { content: ''; width: 8px; height: 8px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 50% 100%); transition: transform .15s; }
.sgroup[open] summary::after { transform: rotate(180deg); }
.sgroup .sbody { padding: 0 10px 10px; }
.sgroup .rows { margin: 4px 0; }
.sgroup .rows > div, .sgroup .rows > label { background: var(--panel); }
.desc.small { font-size: 13px; }

/* ── 0.13: legibilidad arriba (degradado suave) ── */
#hud::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: calc(var(--safe-t) + 112px); z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(14, 10, 22, .62) 0%, rgba(14, 10, 22, .38) 55%, rgba(14, 10, 22, 0) 100%);
}
#meta { color: #d8cce4; }
#season { color: #d8cce4; font-size: 12px; text-shadow: 0 1px 0 rgba(0,0,0,.8), 0 0 6px rgba(0,0,0,.6); }
#era-name { text-shadow: 0 1px 0 rgba(0,0,0,.9), 0 0 6px rgba(0,0,0,.6); }

/* ── 0.13: mínimo 11 px en textos pequeños ── */
.dlist time, .fperson small, .bstats small, .gain small, .card .lim { font-size: 11px; }
#dustbtn { width: 34px; height: 38px; }
#dustbtn b { font-size: 11px; }

/* ── 0.13: Tribu → Personas compacta ── */
.people .person { gap: 10px; padding: 5px 8px; }
.people .person img { width: 30px; height: 34px; }
.people .person b { font-size: 14px; }
.people .person span { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people .person small { font-size: 11px; }
.people .person > div { min-width: 0; }
.people { gap: 3px; }
.ptitle { margin: 10px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
/* en el editor, Luminito habla por encima de la barra */
body.editing #guide:not([hidden]) { display: flex !important; bottom: calc(var(--safe-b) + 150px); right: 10px; }
.fnd { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; padding: 8px; background: var(--panel2); }
.fnd > img { width: 40px; height: 46px; object-fit: contain; flex: none; }
.fnd > div { flex: 1; min-width: 0; }
.fnd small { font-size: 11px; color: var(--muted); }
.fnd .namein { margin: 3px 0; font-size: 16px; padding: 7px 10px; }
.soongrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.soon { display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; padding: 4px 6px; background: var(--panel2); opacity: .7; }
.soon img { grid-row: 1 / 3; width: 26px; height: 26px; object-fit: contain; filter: grayscale(.7); }
.soon span { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.soon small { font-size: 11px; color: var(--muted); }

/* ══════════ Escritorio (PC): paneles a la derecha, barra contenida, ratón y teclado ══════════ */
@media (min-width: 900px) {
  /* barra de arriba compacta, no estirada a todo el ancho */
  #topbar { max-width: 560px; }
  #hud { padding-left: 18px; padding-top: calc(var(--safe-t) + 14px); }
  #hud::before { height: 130px; }
  #res .chip { padding: 5px 8px; font-size: 14px; }
  #res .chip img { width: 16px; height: 16px; }
  #meta { font-size: 14px; }
  #toasts { margin-left: auto; margin-right: auto; max-width: 520px; }

  /* los paneles salen a la derecha, sin tapar el mapa */
  #sheet-wrap .backdrop { display: none; }
  #sheet {
    left: auto; right: 16px; top: 16px; bottom: 16px; width: 420px; max-height: none;
    padding: 16px 18px 20px; transform: translateX(calc(100% + 32px));
    box-shadow: 0 0 0 3px var(--line), 0 18px 40px rgba(0,0,0,.45), inset 0 3px 0 rgba(255,255,255,.06);
  }
  #sheet .grab { display: none; }
  #sheet .close { top: 14px; right: 14px; }
  #sheet-wrap.show #sheet { transform: none; }

  /* con un panel abierto, el menú y los botones se apartan a la izquierda del panel */
  #dock, #gear, #calmbtn, #dustbtn { transition: left .25s ease, right .25s ease, transform .25s steps(4), opacity .25s; }
  body.sheet-open #dock { left: calc((100% - 452px) / 2); }
  body.sheet-open #gear, body.sheet-open #calmbtn { right: 462px; }
  /* Ajustes + Contemplación juntos miden lo mismo que el menú en PC (66 px) */
  #gear, #calmbtn { width: 36px; height: 31px; }
  #calmbtn { bottom: calc(var(--safe-b) + 49px); }
  #dustbtn { width: 38px; height: 44px; }

  /* menú inferior un poco más grande y con pistas de teclado */
  #dock { padding: 7px; gap: 7px; }
  #dock button { min-width: 64px; padding: 6px 8px 5px; font-size: 12px; }
  #dock button img { width: 24px; height: 24px; }
  #dock button .key { font-family: 'Atkinson Hyperlegible', sans-serif; font-weight: 700; font-size: 9px; color: var(--muted); }

  #guide { left: 18px; right: auto; max-width: 560px; bottom: calc(var(--safe-b) + 92px); }
  #guide-mini { left: 62px; max-width: 520px; bottom: calc(var(--safe-b) + 92px); }
  #placebar, #editbar { left: 50%; right: auto; width: 560px; transform: translateX(-50%); }
  #ratepop { width: 240px; }
  #calmcap span { font-size: 19px; }
  .calmnav button { width: 38px; height: 38px; }
}
/* ratón: todo lo que se puede pulsar lo parece */
@media (hover: hover) and (pointer: fine) {
  .card:not(:disabled):hover, .btn:not(:disabled):hover, #dock button:hover, .person:hover, .fperson:not(.dead):hover,
  .relrow:hover, .req:hover, .mini:hover, .tabs button:hover, .chip:hover, #gear:hover, #calmbtn:hover, #dustbtn:hover {
    filter: brightness(1.15); cursor: pointer;
  }
  .sgroup summary:hover { background: rgba(255,255,255,.04); }
  #game.pointer { cursor: pointer; }
  #game.grabbing { cursor: grabbing; }
}

/* ── 0.22: legibilidad y zonas táctiles ── */
.card .lim, .fperson small, .bstats small, .gain small, #dustbtn b, .dlist time { font-size: 11px; }
#sheet .close { width: 40px; height: 40px; }
/* botones pequeños de esquina: el área que se puede tocar es mayor que el dibujo */
#gear::after, #calmbtn::after, #dustbtn::after { content: ''; position: absolute; inset: -7px; }
.btn.small { min-height: 36px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Tribu: familias por generaciones ── */
details.family { margin: 8px 0; padding: 0; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); overflow: hidden; }
details.family > summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 8px 26px; position: relative; }
details.family > summary::-webkit-details-marker { display: none; }
details.family > summary::before { content: '▸'; position: absolute; left: 10px; top: 9px; color: var(--accent); }
details.family[open] > summary::before { content: '▾'; }
details.family > summary b { font-size: 15px; color: var(--accent); }
details.family > summary small { font-size: 12px; color: var(--muted); }
details.family > :not(summary) { margin: 0 10px 10px; }
details.family.past details.family { background: var(--panel); }
.fgen { border-top: 2px solid var(--line); padding-top: 6px; margin-top: 6px; }
.fgen-t { margin: 0 0 4px; font-size: 12px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; }
.fgroup { margin: 4px 0 8px; }
.fgroup > small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fpair { display: inline-flex; align-items: center; gap: 4px; }
.fheart { width: 9px; height: 8px; background: #e0607a; clip-path: polygon(50% 100%, 0 35%, 15% 0, 50% 25%, 85% 0, 100% 35%); flex: none; }

/* ── Tribu: trabajos de un vistazo ── */
.jsec { margin: 8px 0 4px; }
.jsec .ptitle { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; }
.jsec .ptitle img { width: 16px; height: 16px; }
.jrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 4px 8px; margin: 3px 0; background: var(--panel2); box-shadow: 0 0 0 2px var(--line); }
.jrow.short { box-shadow: 0 0 0 2px var(--line), inset 3px 0 0 var(--accent); }
.jname { display: flex; flex-direction: column; text-align: left; min-width: 0; background: none; padding: 0; }
.jname b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jname small { font-size: 12px; color: var(--muted); }
.javs { display: flex; flex-wrap: wrap; gap: 2px; justify-content: flex-end; max-width: 150px; }
.javs.wide { max-width: none; justify-content: flex-start; }
.jav { width: 26px; height: 30px; padding: 0; background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.jav img { width: 26px; height: 30px; object-fit: contain; image-rendering: pixelated; }
.jfree { width: 26px; height: 30px; box-shadow: inset 0 0 0 1px var(--line); background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.04) 4px 8px); }
.jout { min-width: 42px; text-align: right; font-size: 13px; color: var(--accent); }

#ratepop .rl-t { margin: 6px 0 2px; font-size: 12px; color: var(--muted); }
#ratepop .rl small { font-size: 11px; color: var(--muted); margin-left: 4px; }
