/* ==========================================================================
   VÍA LIBRE — estilos de producción
   Dirección de arte: A · "Juguete de hojalata" (ver arte/dir-a.md y arte/dir-a.html)
   Claymorphism SOLO en lo interactivo (clic, compra asequible, evento) sobre
   paneles planos, en paleta ciruela-carbón nocturna.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Neutros */
  --bg:         #1F192B;
  --bg:         oklch(0.23 0.035 300);
  --panel:      #2E273A;
  --panel:      oklch(0.29 0.035 300);
  --panel-2:    #3B3448;
  --panel-2:    oklch(0.34 0.035 300);
  --border:     #453F50;
  --border:     oklch(0.38 0.03 300);
  --text:       #F8F5EF;
  --text:       oklch(0.97 0.008 80);
  --text-2:     #B9B5C3;
  --text-2:     oklch(0.78 0.02 300);
  --text-muted: #A6A2AF;
  --text-muted: oklch(0.72 0.02 300);

  /* Acentos (máx. 3 + neutros) */
  --yellow:      #FFC921;
  --yellow:      oklch(0.86 0.17 88);
  --yellow-deep: #A45F00;
  --yellow-deep: oklch(0.55 0.14 70);
  --magenta:      #D740A2;
  --magenta:      oklch(0.62 0.21 345);
  --magenta-deep: #83005D;
  --magenta-deep: oklch(0.40 0.18 345);
  /* Variante de --magenta ~18% más oscura, mismo tono (345). Solo para relleno sólido
     con texto claro encima (ej. btn-cut): --magenta con --text da 3.75:1, insuficiente
     para AA (4.5:1). Definida solo en hex: al no tener contraparte oklch fiable,
     mezclar ambas formas aquí daría un fallback que no coincide con el valor real. */
  --magenta-btn:  #B03485;
  --mint:      #51DAA7;
  --mint:      oklch(0.80 0.14 165);
  --mint-deep: #008760;
  --mint-deep: oklch(0.55 0.12 165);

  --danger:      #FF6B5B;
  --danger:      oklch(0.66 0.19 25);
  --danger-deep: #8C2A1E;
  --danger-deep: oklch(0.40 0.16 25);

  --ink: var(--bg);

  --r-sm: 8px;
  --r-md: 14px;
  --r-pill: 999px;

  /* z-index semántico */
  --z-sticky: 10;
  --z-event: 20;
  --z-dialog: 30;
  --z-toast: 40;

  --dur-press: 120ms;
  --ease-press: ease-out;
  --dur-pulse: 2.5s;

  --font-display: 'Fredoka', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;

  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* El atributo `hidden` debe ganar siempre, aunque el propio componente declare su
   `display` (flex, grid...): los estilos de autor pisan al user-agent por origen,
   no por especificidad, así que sin este !important un panel con `hidden` pero
   `display:flex` propio se queda visible. Alternar con `el.hidden`, nunca con
   `style.display` a mano. */
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: oklch(0.23 0.035 300);
  background:
    radial-gradient(1100px 620px at 14% -8%, rgba(255,201,33,.07), transparent 60%),
    radial-gradient(900px 500px at 100% 10%, rgba(215,64,162,.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.4;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }
button:not(:disabled) { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
textarea { font-family: var(--font-body); }

.num { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.icon {
  width: 1.3em; height: 1.3em;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

.sr-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

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

/* interactivo: sin selección de texto ni resaltado táctil */
button, .click-object, .event-bubble, .tab-btn, .topnav a { user-select: none; -webkit-user-select: none; }
[contenteditable], textarea, input { user-select: text; -webkit-user-select: text; }

/* ---------------------------------- Topbar ---------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: 20px;
  height: var(--topbar-h); padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--yellow); }
.brand .icon { width: 26px; height: 26px; }
/* h1 de marca: h1,h2,h3 ya pone margin:0/font-weight:600/letter-spacing -0.02em
   globalmente, así que solo hace falta fijar el tamaño y el color para que quede
   igual que el <span> anterior. */
.brand h1 { font-family: var(--font-display); font-size: 1.15rem; color: var(--text); }

.topnav { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.topnav a {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px; min-height: 44px;
  border-radius: var(--r-pill);
  color: var(--text-2); font-weight: 700; font-size: .85rem;
  transition: background var(--dur-press) var(--ease-press), color var(--dur-press) var(--ease-press);
}
.topnav a:hover { color: var(--text); background: var(--panel); }
.topnav a[aria-current="page"] { color: var(--ink); background: var(--yellow); }
.topnav .icon { width: 17px; height: 17px; }

.topbar-spacer { flex: 1; }

/* ---------------------------------- Board ---------------------------------- */
.board {
  max-width: 1320px; margin: 0 auto;
  padding: 44px 24px 64px;
  display: grid;
  grid-template-columns: 3fr 4fr 3fr;
  gap: 28px;
  align-items: stretch;
}
.col { display: flex; flex-direction: column; gap: 30px; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 26px 26px;
}
.panel > h2 { font-size: 1.05rem; }
.panel-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; color: var(--text);
  flex-wrap: wrap;
}
.panel-head .icon { width: 19px; height: 19px; color: var(--text-2); }
.panel-head h2 { flex: 1; min-width: 0; }

/* ---------------------------------- Columna izquierda ---------------------------------- */
.stats-header { display: flex; flex-direction: column; gap: 18px; }
.bank { padding: 6px 2px 0; }
.bank-label {
  display: block; font-size: .76rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
}
.bank-value {
  font-family: var(--font-display); font-weight: 700;
  font-size: 3.5rem; line-height: 1; letter-spacing: -0.03em;
  color: var(--yellow);
}
.bank-value .unit { font-family: var(--font-body); font-weight: 700; font-size: 1.1rem; color: var(--text-2); margin-left: 6px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-weight: 700; font-size: .85rem; color: var(--text);
}
.stat-chip .icon { width: 16px; height: 16px; }
.stat-chip.rate .icon { color: var(--yellow); }
.stat-chip.prestige .icon { color: var(--magenta); }
.stat-chip.effect { border-color: var(--mint); color: var(--mint); }
.stat-chip.effect .icon { color: var(--mint); }

.click-wrap {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 20px 0 8px;
  text-align: center;
}
.click-stage { position: relative; width: 304px; height: 304px; }
.click-stage::before {
  content: "";
  position: absolute; inset: -22px;
  border-radius: 50%;
  background: radial-gradient(circle, oklch(0.86 0.17 88 / .30), transparent 70%);
  animation: glow var(--dur-pulse) ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: .55; transform: scale(.94); } to { opacity: 1; transform: scale(1.04); } }

.click-object {
  position: relative; width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid var(--yellow-deep);
  background: var(--yellow);
  background: oklch(0.86 0.17 88);
  box-shadow:
    0 16px 30px -10px rgba(10,6,2,.55),
    inset 0 4px 6px rgba(255,255,255,.4),
    inset 0 -12px 20px -6px rgba(120,60,0,.5);
  display: grid; place-items: center;
  padding: 0; border-style: solid;
  transition: transform var(--dur-press) var(--ease-press), box-shadow var(--dur-press) var(--ease-press);
  min-width: 44px; min-height: 44px;
  touch-action: none;
}
.click-object:hover { filter: brightness(1.03); }
.click-object:active, .click-object.is-pressed {
  transform: translateY(3px);
  box-shadow:
    0 8px 16px -8px rgba(10,6,2,.55),
    inset 0 2px 3px rgba(255,255,255,.3),
    inset 0 -6px 12px -4px rgba(120,60,0,.45);
}
.click-object svg { width: 72%; height: 72%; }

.float-pool { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.float-plus {
  position: absolute;
  padding: 5px 12px;
  background: var(--magenta); color: var(--text);
  font-family: var(--font-display); font-weight: 700; font-size: 1.3rem;
  border-radius: var(--r-pill);
  box-shadow: 0 6px 14px -4px rgba(10,6,2,.5);
  animation: floatUp 2.3s ease-out;
  opacity: 0;
  will-change: transform, opacity;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(0) scale(.85); }
  18% { opacity: 1; transform: translateY(-6px) scale(1); }
  100% { opacity: 0; transform: translateY(-58px) scale(1); }
}

.click-label { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; letter-spacing: -0.02em; }
.click-hint { color: var(--text-muted); font-size: .82rem; font-weight: 600; }

/* ---------------------------------- Columna centro: vía ---------------------------------- */
.rail-panel { position: relative; overflow: visible; }
.rail-stage { position: relative; --rail-dur: 19s; }
.rail-svg { width: 100%; height: auto; display: block; overflow: visible; }
.rail-track { stroke: var(--mint); stroke: oklch(0.80 0.14 165); stroke-width: 4; stroke-linecap: round; }
.rail-node-ring { fill: var(--panel); stroke: var(--mint); stroke: oklch(0.80 0.14 165); stroke-width: 4; }
.rail-node-dot { fill: var(--mint); fill: oklch(0.80 0.14 165); }
.train-token { color: var(--text-2); }
.train-token rect { fill: var(--text-2); stroke: var(--bg); stroke-width: 1; }
.train-token path { fill: var(--text-2); stroke: var(--bg); stroke-width: 1; }
.train-token circle { fill: var(--bg); }
.t1 { animation: crawl1 var(--rail-dur) linear infinite; }
.t2 { animation: crawl2 calc(var(--rail-dur) * 1.32) linear infinite; animation-delay: -6s; }
.t3 { animation: crawl1 calc(var(--rail-dur) * 0.78) linear infinite; animation-delay: -9s; opacity: .7; }
@keyframes crawl1 { from { transform: translate(26px,45px); } to { transform: translate(560px,45px); } }
@keyframes crawl2 { from { transform: translate(560px,45px); } to { transform: translate(26px,45px); } }

.rail-labels { display: flex; justify-content: space-between; margin-top: 8px; gap: 6px; }
.rail-labels span {
  flex: 1 1 33%; min-width: 0; font-size: .72rem; font-weight: 700; color: var(--text-2);
  text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail-labels span:first-child { text-align: left; }
.rail-labels span:last-child { text-align: right; }

.event-bubble {
  position: absolute; top: -18px; right: 4%;
  z-index: var(--z-event);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 10px;
  max-width: min(92vw, 360px);
  overflow-wrap: anywhere;
  background: var(--panel);
  border: 3px solid var(--magenta);
  border-radius: var(--r-pill);
  box-shadow:
    0 12px 22px -8px rgba(10,6,2,.55),
    inset 0 3px 4px rgba(255,255,255,.10),
    inset 0 -8px 14px -4px rgba(131,0,93,.5);
  cursor: pointer;
  color: inherit;
  min-height: 44px;
}
/* El pulso ya no anima box-shadow (fuerza repintado cada frame): la sombra "to"
   vive fija en un ::after y solo se anima su opacity (compositable). En reposo
   se ve igual que antes; a ojo el cruce entre estados es indistinguible. */
.event-bubble::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: var(--r-pill);
  box-shadow:
    0 16px 30px -8px rgba(10,6,2,.6),
    0 0 0 6px oklch(0.62 0.21 345 / .16),
    inset 0 3px 4px rgba(255,255,255,.14),
    inset 0 -8px 14px -4px rgba(131,0,93,.6);
  opacity: 0;
  animation: eventPulse 1.7s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes eventPulse {
  from { opacity: 0; }
  to { opacity: 1; }
}
.event-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--magenta); background: oklch(0.62 0.21 345);
  display: grid; place-items: center; color: var(--ink); flex-shrink: 0;
}
.event-icon .icon { width: 20px; height: 20px; }
.event-text { text-align: left; }
.event-text strong { display: block; font-size: .85rem; font-weight: 800; color: var(--text); }
.event-text small { display: block; font-size: .76rem; font-weight: 700; color: var(--text-2); margin-top: 1px; }

/* Estadísticas rápidas */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; }
.stat-tile { display: flex; flex-direction: column; gap: 8px; }
.stat-tile .icon { width: 18px; height: 18px; color: var(--text-2); }
.stat-tile b { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; color: var(--text); }
.stat-tile span { font-size: .72rem; color: var(--text-muted); font-weight: 600; }

/* Listas compartidas (mejoras / tienda / plan): planas, sin tarjetas anidadas.
   Cada fila son dos líneas: arriba icono + NOMBRE COMPLETO a todo el ancho
   (nunca comparte línea con precio ni botón, así que nunca se corta, sea cual
   sea el nombre o el ancho de columna); abajo el guiño/unidades + precio +
   botón, que sí pueden abreviarse porque son secundarios. */
.row-list { display: flex; flex-direction: column; }
.row-list > li {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--border);
}
.row-list > li:last-child { border-bottom: none; padding-bottom: 4px; }

.row-head { display: flex; align-items: flex-start; gap: 12px; }

.row-icon {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: var(--panel-2);
  display: grid; place-items: center; color: var(--text-2);
  flex-shrink: 0;
}
.row-icon .icon { width: 19px; height: 19px; }
.row-list > li:not(.is-next) .row-icon { box-shadow: inset 0 0 0 2px var(--mint); }

.row-name {
  flex: 1; min-width: 0; padding-top: 2px;
  font-weight: 800; font-size: .92rem; color: var(--text); line-height: 1.3;
  white-space: normal; word-break: normal; overflow-wrap: anywhere;
}

.row-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-left: 50px;
}
.row-sub {
  flex: 1 1 80px; min-width: 60px;
  font-size: .78rem; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
li.is-next .row-sub { color: var(--text-muted); }

.row-buy { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.row-price { font-weight: 800; font-size: .86rem; color: var(--yellow); }
.row-prod { font-size: .72rem; color: var(--text-2); }

.btn-buy {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; min-height: 44px;
  border-radius: var(--r-pill); border: 2px solid var(--yellow-deep);
  background: var(--yellow); background: oklch(0.86 0.17 88);
  color: var(--ink); font-weight: 800; font-size: .8rem;
  box-shadow:
    0 7px 12px -5px rgba(10,6,2,.5),
    inset 0 2px 2px rgba(255,255,255,.4),
    inset 0 -6px 9px -3px rgba(120,60,0,.5);
  transition: transform var(--dur-press) var(--ease-press), box-shadow var(--dur-press) var(--ease-press), background var(--dur-press) var(--ease-press);
}
.btn-buy:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 3px 6px -3px rgba(10,6,2,.5), inset 0 1px 1px rgba(255,255,255,.3), inset 0 -3px 5px -2px rgba(120,60,0,.45);
}
.btn-buy.btn-circle { padding: 0; width: 44px; height: 44px; border-radius: 50%; justify-content: center; flex-shrink: 0; }
.btn-buy.btn-small { padding: 8px 14px; min-height: 44px; font-size: .78rem; }

/* No asequible: contorno fantasma + color de texto explícito, nunca opacidad */
.btn-buy:disabled, .btn-buy.is-unaffordable {
  background: var(--panel-2); color: var(--text-muted);
  border-color: var(--border); box-shadow: none; cursor: not-allowed;
}

.btn-locked {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; min-height: 44px;
  border-radius: var(--r-pill); border: 2px solid var(--border);
  background: transparent; color: var(--text-muted);
  font-weight: 800; font-size: .8rem;
}
.btn-locked:not(:disabled):hover { color: var(--text); border-color: var(--text-2); }
.btn-locked:disabled { cursor: not-allowed; }
.btn-locked .icon { width: 14px; height: 14px; }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; min-height: 44px;
  border-radius: var(--r-pill); border: 2px solid var(--danger-deep);
  background: transparent; color: var(--danger);
  font-weight: 800; font-size: .8rem;
}
.btn-danger:hover { background: oklch(0.66 0.19 25 / .12); }
.btn-danger .icon { width: 14px; height: 14px; }

li.is-next .row-price { color: var(--text-muted); }
li.is-next .row-icon { color: var(--text-muted); }
.tag-next {
  font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 2px 6px;
}

.empty-note { color: var(--text-muted); font-size: .85rem; padding: 8px 2px; }

.plan-owned {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; min-height: 44px;
  border-radius: var(--r-pill); border: 2px solid var(--mint-deep);
  color: var(--mint); font-weight: 800; font-size: .8rem;
}
.plan-owned .icon { width: 14px; height: 14px; }

/* Selector de modo de compra */
.buy-mode { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel-2); border-radius: var(--r-pill); margin-bottom: 16px; }
.buy-mode-btn {
  border: none; background: transparent; color: var(--text-2);
  font-weight: 800; font-size: .78rem; padding: 7px 14px; min-height: 44px;
  border-radius: var(--r-pill);
}
.buy-mode-btn.is-active { background: var(--yellow); color: var(--ink); }
.buy-mode-btn:disabled { color: var(--text-muted); cursor: not-allowed; }

/* Corte de vía */
.prestige-gate { color: var(--text-muted); font-size: .88rem; font-weight: 600; padding: 4px 2px; }
.meter-label { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.meter-label b { color: var(--text); font-family: var(--font-display); font-weight: 600; }
.meter-track { height: 12px; border-radius: var(--r-pill); background: var(--panel-2); overflow: hidden; }
/* #DA4FA9: --magenta aclarado ~8%, mismo tono, solo para este relleno — contra
   --panel-2 (pista) --magenta daba 2.91:1, por debajo del 3:1 mínimo no-textual (WCAG 1.4.11). */
.meter-fill { height: 100%; width: 0%; border-radius: var(--r-pill); background: #DA4FA9; transition: width 300ms ease-out; }
.prestige-actions { display: flex; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.btn-cut {
  padding: 12px 20px; min-height: 44px;
  border-radius: var(--r-pill); border: 2px solid var(--magenta-deep);
  /* --magenta con --text encima daba 3.75:1 (falla AA 4.5:1 en texto de cuerpo).
     --magenta-btn es el mismo tono ~18% más oscuro: 5.25:1. */
  background: var(--magenta-btn); color: var(--text);
  font-weight: 800; font-size: .88rem;
  box-shadow: 0 7px 14px -6px rgba(10,6,2,.5), inset 0 2px 2px rgba(255,255,255,.25), inset 0 -6px 10px -3px rgba(60,0,40,.5);
  transition: transform var(--dur-press) var(--ease-press), box-shadow var(--dur-press) var(--ease-press);
}
.btn-cut:active:not(:disabled) { transform: translateY(2px); }
.btn-cut:disabled {
  background: transparent; color: var(--text-muted); border-color: var(--border);
  box-shadow: none; cursor: not-allowed;
}
.prestige-note { color: var(--text-2); font-size: .82rem; flex: 1; min-width: 180px; }
.prestige-note strong { color: var(--text); }

.plan-section { margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--border); }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-weight: 800; font-size: .92rem; }
.plan-head .num { color: var(--text-2); font-weight: 700; font-size: .82rem; }

/* ---------------------------------- Columna derecha: tienda ---------------------------------- */
.shop-panel .row-list > li { padding: 13px 2px; }
.shop-footnote { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); color: var(--text-muted); font-size: .76rem; }

/* Logros */
.ach-counter { font-size: .8rem; font-weight: 800; color: var(--text-2); margin-left: auto; }
/* auto-fill + minmax: el número de columnas se recalcula solo según el ancho
   real disponible, así que nunca desborda ni se corta, sea cual sea la
   anchura de la columna o del viewport. */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.ach-tile {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
  min-height: 96px;
}
.ach-tile .ach-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
}
.ach-tile .ach-icon .icon { width: 16px; height: 16px; }
.ach-tile strong { font-size: .78rem; font-weight: 800; }
.ach-tile span { font-size: .7rem; color: var(--text-2); line-height: 1.3; }
.ach-tile.is-earned .ach-icon { background: var(--yellow); color: var(--ink); }
.ach-tile.is-earned strong { color: var(--text); }
.ach-tile.is-pending { border-style: dashed; }
.ach-tile.is-pending .ach-icon { background: transparent; border: 2px solid var(--border); color: var(--text-muted); }
.ach-tile.is-pending strong { color: var(--text-muted); }
.ach-tile.is-pending span { color: var(--text-muted); }

/* Ajustes */
.settings-block { margin-bottom: 20px; }
.settings-block:last-child { margin-bottom: 0; }
.settings-label { display: block; font-size: .78rem; font-weight: 800; color: var(--text-2); margin-bottom: 6px; }
.settings-subhead { font-size: .92rem; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.save-area {
  width: 100%; resize: vertical;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px; font-size: .78rem; line-height: 1.4;
  font-family: 'Courier New', monospace;
}
.save-area::placeholder { color: var(--text-muted); }
.settings-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.settings-hint { font-size: .78rem; color: var(--text-2); min-height: 1em; }
.settings-hint.is-error { color: var(--danger); }
.settings-toggle { justify-content: space-between; }
.switch-label { font-weight: 700; font-size: .88rem; }
#chkSci { width: 24px; height: 24px; accent-color: var(--yellow); }
.stat-list { display: flex; flex-direction: column; gap: 8px; }
.stat-list li { display: flex; justify-content: space-between; font-size: .84rem; padding: 6px 0; border-bottom: 1px solid var(--border); }
.stat-list li:last-child { border-bottom: none; }
.stat-list span { color: var(--text-2); }
.stat-list b { color: var(--text); font-weight: 700; }
.storage-warning {
  display: flex; align-items: center; gap: 8px;
  color: var(--danger); font-size: .82rem; font-weight: 700;
  padding: 10px 12px; border: 1px solid var(--danger-deep); border-radius: var(--r-sm);
  margin-bottom: 18px;
}
.storage-warning .icon { width: 18px; height: 18px; flex-shrink: 0; }
.settings-version { color: var(--text-muted); font-size: .76rem; margin-top: 20px; }

/* ---------------------------------- Toast ---------------------------------- */
.toast-wrap { position: fixed; left: 20px; bottom: 20px; z-index: var(--z-toast); }
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px 12px 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 14px 28px -12px rgba(0,0,0,.6);
  animation: toastIn .5s ease-out both;
  max-width: min(340px, calc(100vw - 40px));
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--yellow); background: oklch(0.86 0.17 88);
  color: var(--ink); display: grid; place-items: center; flex-shrink: 0;
}
.toast-icon .icon { width: 19px; height: 19px; }
.toast-text { min-width: 0; }
.toast-text strong { display: block; font-size: .85rem; font-weight: 800; }
.toast-text span { display: block; font-size: .78rem; color: var(--text-2); margin-top: 1px; }

/* ---------------------------------- Diálogos ---------------------------------- */
.app-dialog {
  z-index: var(--z-dialog);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 26px; max-width: min(420px, calc(100vw - 40px));
  box-shadow: 0 24px 48px -16px rgba(0,0,0,.6);
}
.app-dialog::backdrop { background: rgba(10,6,15,.6); }
.app-dialog h3 { font-size: 1.1rem; margin-bottom: 12px; }
.app-dialog p { color: var(--text-2); font-size: .9rem; line-height: 1.5; margin-bottom: 10px; }
.app-dialog p strong { color: var(--text); }
.app-dialog menu { display: flex; justify-content: flex-end; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }

/* ---------------------------------- Tabbar móvil ---------------------------------- */
.tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky);
  background: var(--panel); border-top: 1px solid var(--border);
  padding: 6px 4px;
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; min-height: 44px; border-radius: var(--r-sm);
  border: none; background: transparent;
  color: var(--text-muted); font-size: .62rem; font-weight: 700; text-align: center;
}
.tab-btn .icon { width: 19px; height: 19px; }
.tab-btn[aria-current="page"] { color: var(--yellow); }

/* Visibilidad de paneles por pestaña: solo tiene efecto por debajo de 768px */
.is-tab-hidden { }

/* ---------------------------------- Pie ---------------------------------- */
.pie {
  max-width: 1280px; margin: 0 auto; padding: 0 24px 32px;
  color: var(--text-muted); font-size: .78rem; font-weight: 600;
  display: flex; justify-content: flex-end;
}

/* ================================== Responsive ================================== */

/* Escritorio ≥1024px: tres columnas con altura de ventana y scroll interno en tienda/mejoras */
@media (min-width: 1024px) {
  .board {
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;
  }
  .col { height: 100%; overflow-y: auto; scrollbar-gutter: stable; }
  .shop-panel .row-list {
    overflow-y: auto; max-height: 48vh;
  }
  .upgrades-panel .row-list {
    overflow-y: auto; max-height: 26vh;
  }
}

/* Tablet 768-1023px: dos columnas */
@media (min-width: 768px) and (max-width: 1023px) {
  .board { grid-template-columns: 1fr 1fr; }
  .col-shop { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: repeat(4,1fr); }
}

/* Móvil <768px: una columna, cabecera fija, pestañas inferiores */
@media (max-width: 767px) {
  .is-tab-hidden { display: none !important; }

  .topnav { display: none; }
  .tabbar { display: flex; }

  .board { grid-template-columns: 1fr; padding: 0 16px 84px; gap: 20px; }
  .col { gap: 20px; }

  .stats-header {
    position: sticky; top: var(--topbar-h); z-index: var(--z-sticky);
    background: var(--bg); padding: 16px 0 12px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
    border-bottom: 1px solid var(--border);
  }

  .panel { padding: 18px; }
  .bank-value { font-size: 2.4rem; }
  .click-stage { width: 210px; height: 210px; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .row-buy { align-items: flex-end; }
  .toast-wrap { left: 12px; right: 12px; bottom: 76px; }
  .toast { max-width: none; }
  .event-bubble { right: 2%; top: -14px; padding: 8px 12px 8px 8px; }
  .event-text small, .event-text strong { font-size: .72rem; }
  .settings-row { flex-direction: column; align-items: stretch; }
  .app-dialog menu { flex-wrap: wrap; }
}
