/* RatRig — per-screen styles: guarida (outer frame + mining dashboard), minijuegos, tienda,
   inventario, estadísticas (the Portada lives in css/landing.css). Tokens and the pixel frame recipes live in main.css. The lair scene
   interior (.room, .rack, .mach, .npc, .cell-*, .spot-*) keeps the sprite palette and is owned by the
   lair work; css/rocket.css owns the rocket and cables. */

/* ================================================================== CUENTA
   The account box (js/ui/account.js). The Portada itself lives in css/landing.css. */

.start-form {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: stretch;
  margin-top: var(--sp-2);
  padding: var(--sp-5) 3px 0;
  border-top: 3px solid var(--ink);
  box-shadow: inset 0 3px 0 var(--s1-hi);
}
.start-form .label { margin-bottom: 4px; }
.start-form .btn-big { align-self: stretch; margin-top: var(--sp-3); }
.start-form .btn-ghost { align-self: flex-start; margin-top: var(--sp-3); }
.start-form .hint { font-size: var(--fs-6); color: var(--text-3); margin-top: var(--sp-2); }

/* ================================================================== GUARIDA (outer frame) */

.placing-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px 12px 10px 18px;
  background: var(--violet-deep);
  box-shadow: inset 3px 3px 0 #43307F, inset -3px -3px 0 #1A1040, var(--ring), 0 6px 0 var(--drop);
}
.placing-bar::before {
  content: '';
  flex: none;
  width: 8px; height: 8px;
  background: var(--gold);
  animation: placing-beacon 1s steps(1) infinite;
}
@keyframes placing-beacon { 50% { opacity: 0.2; } }
.placing-bar p { flex: 1; }
.placing-bar strong { font-weight: 600; }

.room-panel { padding: 10px; }
.room-panel .room-scroll { box-shadow: 0 0 0 3px var(--ink); }

/* ---- mining dashboard strip: css/dashboard.css (iteration 24) ---- */

/* room facts: one tidy stats card (label muted, value in the text colour) */
.lair-stats { padding: var(--sp-4) var(--sp-5); }
.lair-stats .panel-head { margin-bottom: var(--sp-3); }
.stat-list { margin: 0; display: grid; }
.stat-row { min-width: 0; }
.stat-row dt { color: var(--text-2); font-size: var(--fs-5); font-weight: 500; line-height: 1.3; }
.stat-row dd { margin: 0; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-row dd .nu-u { font-size: var(--fs-6); }
/* below the side-column width: the facts sit side by side as small sockets */
.room-strip.stat-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 8px; }
.room-strip .stat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: var(--well);
  box-shadow: var(--sunk-2);
}
.room-strip .stat-row dd { font: var(--px-s)/1 var(--f-display); }
.room-strip .stat-row dd .nu-u { font-family: var(--f-body); font-size: 12px; font-weight: 600; }

/* ---- lair scene interior (pixel palette; owned visually by the lair work — do not restyle) ---- */
.room-scroll { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.room {
  position: relative;
  margin: 0 auto;
  background: var(--c-ink);
  overflow: hidden;
  line-height: 0;
}
.room-bg, .rack, .mach, .npc { position: absolute; line-height: 0; }
.room-art, .room-hits, .room-npcs { position: absolute; inset: 0; }
.room-hits > * { position: absolute; }
.room-npcs { pointer-events: none; }

/* Machines sit still on their shelves (no idle hop/bob: rejected by the player); animated strips play
   in place, and a just-placed machine gets a one-time settle (css/ux.css .mach.thunk). */
.mach.glow {
  filter:
    drop-shadow(calc(var(--s, 1) * 1px) 0 0 var(--c-mint))
    drop-shadow(calc(var(--s, 1) * -1px) 0 0 var(--c-mint))
    drop-shadow(0 calc(var(--s, 1) * 1px) 0 var(--c-mint))
    drop-shadow(0 calc(var(--s, 1) * -1px) 0 var(--c-mint));
}
html[data-reduced-motion="true"] .mach { animation: none; }
.npc.flip .rr-sprite { transform: scaleX(-1); }

.cell-empty, .cell-machine, .spot-empty { padding: 0; margin: 0; cursor: pointer; border-radius: 0; }
.cell-empty {
  background: rgba(18, 14, 26, 0.25);
  border: 1px dashed rgba(244, 235, 221, 0.28);
}
.cell-empty:hover { background: rgba(140, 242, 200, 0.12); border-color: var(--c-mint); border-style: solid; }
.cell-empty.target {
  border: 2px solid var(--c-mint);
  background: rgba(140, 242, 200, 0.18);
  animation: blink 0.8s steps(2) infinite;
}
@keyframes blink { 50% { background: rgba(140, 242, 200, 0.42); border-color: var(--c-cream); } }
.cell-machine { background: transparent; border: none; }
.cell-machine:hover { box-shadow: inset 0 0 0 2px var(--c-cheese); }
.is-placing .cell-machine { cursor: not-allowed; }
.cell-empty:focus-visible, .cell-machine:focus-visible, .spot-empty:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 0; }
.spot-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(18, 14, 26, 0.55);
  border: 2px dashed var(--c-brick-light);
  color: var(--c-parchment);
  line-height: 1.15;
  font-size: calc(10px + var(--s, 1) * 4px);
  text-align: center;
}
.spot-empty:hover { border-color: var(--c-cheese); color: var(--c-cheese); }
.spot-plus { font-weight: 700; }
.spot-price { color: var(--c-cheese); font-weight: 700; }
.spot-why { color: var(--c-fur-light); font-size: 0.8em; padding: 0 4px; }
.spot-empty[aria-disabled="true"] { cursor: not-allowed; }

/* ---- end of lair scene interior ---- */

.lair-side { display: flex; flex-direction: column; gap: var(--sp-5); min-width: 0; }
.lair-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--sp-5); align-items: start; }

/* Red de minado: payouts and the network ranking */
.net-panel .kv { font-size: 15px; gap: 6px var(--sp-4); }
.net-panel .fund-rule { margin-bottom: var(--sp-3); }
.net-panel .panel-sub { padding-top: var(--sp-4); margin-top: var(--sp-4); border-top: 3px solid var(--ink); box-shadow: inset 0 3px 0 var(--s1-hi); }
.payouts { display: flex; flex-direction: column; gap: 4px; font-size: 15px; font-variant-numeric: tabular-nums; }
.payouts li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 var(--sp-2);
  padding: 6px 10px 5px;
  background: var(--well);
}
.payouts .payout-h { color: var(--text-2); }
.payouts .payout-v { font: var(--px-s)/1 var(--f-display); color: var(--gold); }
.payouts .payout-v.zero { font: 500 var(--fs-6)/1.4 var(--f-body); color: var(--text-3); }
.payouts .offline .payout-h { color: var(--text-2); }
.board { margin-top: var(--sp-4); }
.board summary {
  cursor: pointer;
  list-style: none;
  font: var(--px-s)/1 var(--f-display);
  padding: 4px 12px 0;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  background: var(--surface-2);
  box-shadow: var(--bevel-2s), var(--ring2);
  transition: background-color var(--t-fast) steps(2);
}
.board summary::-webkit-details-marker { display: none; }
.board summary::after {
  content: '';
  width: 8px; height: 6px;
  margin: -3px 2px 0 0;
  background:
    linear-gradient(var(--text-2), var(--text-2)) 0 0 / 8px 2px no-repeat,
    linear-gradient(var(--text-2), var(--text-2)) 2px 2px / 4px 2px no-repeat,
    linear-gradient(var(--text-2), var(--text-2)) 3px 4px / 2px 2px no-repeat;
  transition: transform var(--t) steps(2);
}
.board[open] summary::after { transform: rotate(180deg); }
.board summary:hover { background: var(--surface-3); }
.board-list { counter-reset: rank; font-size: 15px; display: flex; flex-direction: column; gap: 2px; margin-top: var(--sp-3); font-variant-numeric: tabular-nums; }
.board-list li { counter-increment: rank; display: grid; grid-template-columns: 28px 1fr auto; gap: var(--sp-2); padding: 4px 8px; }
.board-list li::before { content: counter(rank); font: var(--px-s)/1.1 var(--f-display); color: var(--text-3); }
.board-list li.me { color: var(--text); font-weight: 600; background: var(--violet-deep); box-shadow: inset 3px 0 0 var(--violet-text); }

/* Potencia temporal */
.boost-panel { display: flex; flex-direction: column; gap: var(--sp-3); }
.boost-panel .panel-title { margin-bottom: 0; }
.boost-panel .empty-note { font-size: 15px; }
.boost-panel .btn { align-self: flex-start; margin-top: var(--sp-2); }
@media (min-width: 1024px) {
  /* desktop: the card's action sits bottom-right, like every other card's primary action */
  .boost-panel .btn { align-self: flex-end; margin-top: auto; }
}
.boost-list { display: flex; flex-direction: column; gap: 6px; }
.boost {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  box-shadow: var(--bevel-2s);
}
.boost-name { display: flex; flex-direction: column; line-height: 1.25; font-weight: 600; min-width: 0; }
.boost-name small { font-size: var(--fs-6); color: var(--text-2); font-weight: 500; }
.boost-power { font: var(--px-s)/1 var(--f-display); color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.boost-time {
  font: var(--px-s)/1 var(--f-display);
  color: var(--text);
  min-width: 60px;
  padding: 4px 8px 2px;
  text-align: center;
  background: var(--well);
  box-shadow: var(--ring2);
  font-variant-numeric: tabular-nums;
}
.boost-total { color: var(--text-2); font-size: 15px; }
.boost-total strong { color: var(--text); }

/* drawer, room list & machine sheet (modal contents; also used by the "Salas" menu) */
.drawer { display: flex; flex-direction: column; gap: var(--sp-3); }
.drawer-where { color: var(--text-2); font-size: var(--fs-5); }
.drawer-list { display: flex; flex-direction: column; gap: 10px; padding: 3px; }
.drawer-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px 14px 10px 10px;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  border: 0;
  border-radius: 0;
  box-shadow: var(--bevel-2s), var(--ring2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-fast) steps(2), transform 70ms steps(2);
}
.drawer-item:hover:not(:disabled) { background: var(--surface-3); }
.drawer-item:active:not(:disabled) { transform: translateY(2px); }
.drawer-item:focus-visible { outline-offset: 4px; }
.drawer-item:disabled { opacity: 0.6; cursor: not-allowed; }
/* the room you are in (Salas menu) sits on a violet plate */
.drawer-item[aria-current="true"],
.drawer-item.is-here {
  background: var(--violet-deep);
  box-shadow: inset 3px 3px 0 #43307F, inset -2px -2px 0 #1A1040, 0 -2px 0 var(--violet-text), 0 2px 0 var(--violet-text), -2px 0 0 var(--violet-text), 2px 0 0 var(--violet-text);
}
/* rows that are not buttons (next room to buy, locked rooms) stay still */
div.drawer-item { cursor: default; }
div.drawer-item:hover:not(:disabled) { transform: none; background: var(--surface-2); }
.drawer-sprite {
  flex: none;
  width: 64px;
  min-height: 52px;
  display: grid;
  place-items: center;
  background: var(--well);
  box-shadow: var(--sunk-2);
}
.drawer-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; gap: 2px; }
.drawer-name { font-weight: 600; }
.drawer-meta { font-size: var(--fs-5); color: var(--text-2); }
.machine-sheet { display: flex; gap: var(--sp-5); align-items: flex-start; flex-wrap: wrap; }
.machine-sheet-art {
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: color-mix(in srgb, var(--tier, #8C7B75) 12%, var(--well));
  box-shadow: inset 0 0 0 3px var(--tier, var(--surface-3)), inset 0 0 0 5px rgba(7, 4, 15, 0.6), var(--ring2);
}
.machine-sheet-info { flex: 1 1 200px; display: flex; flex-direction: column; gap: var(--sp-2); }

@media (max-width: 1023.98px) {
  .lair-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
  .room-panel { padding: 8px; }
  .lair-stats { padding: var(--sp-4); }
  .room-strip .stat-row { padding: 8px 12px; }
  .placing-bar { flex-wrap: wrap; }
}

/* ---- desktop Guarida (frame only; the scene interior is untouched) ----
   1024–1399 px: dashboard strip, room, then the facts card, then "Red de minado" and "Potencia
   temporal" side by side, of equal height (the "Jugar minijuego" button lands bottom-right).
   ≥ 1400 px: the dashboard strip across the top, then the room on the left and a side column on the
   right with the facts card and both panels. The room column never drops under 1044 px (scene ×2 +
   frame), so the integer scale of the scene is the same as without the column. */
@media (min-width: 1024px) {
  .screen-lair { gap: var(--sp-5); }
  .lair-grid { align-items: stretch; }
  .lair-grid > .panel { padding: var(--sp-5); }
}
/* From 1240 px (iteration 22, with the side menu): the room sits right next to the menu and the facts
   column beside it, instead of the room centred with the facts below. */
@media (min-width: 1240px) and (max-width: 1599.98px) {
  .screen-lair .room { margin-left: 0; } /* the room right next to the menu where it nearly fills its column */
}
@media (min-width: 1240px) {
  .screen-lair {
    /* side = what is left once the room column has 1044 px (gutters, gap and a scrollbar included) */
    --lair-side: clamp(270px, calc(100vw - var(--rail-w, 0px) - 1134px), 540px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--lair-side);
    gap: 20px var(--sp-5);
    align-items: start;
  }
  .screen-lair > * { grid-column: 1 / -1; }
  .screen-lair > .room-panel,
  .screen-lair > .lair-main { grid-column: 1; }
  .screen-lair > .lair-grid,
  .screen-lair > .lair-side {
    grid-column: 2;
    position: sticky;
    top: calc(var(--header-h) + 20px);
  }
  .lair-side { gap: 20px; }
  .screen-lair .lair-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  /* the panel with the action ("Jugar minijuego") comes first, so it never ends up below the fold;
     the network history can run longer underneath */
  .screen-lair .lair-grid > .boost-panel { order: -1; }
  .screen-lair .lair-grid > .panel,
  .screen-lair .lair-stats { padding: 18px 20px; }
  .screen-lair .lair-grid .kv { font-size: 15px; gap: 6px 10px; }
  /* narrow column: each boost on two lines (name · power) with its timer on the right */
  .screen-lair .boost {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "icon name time" "icon power time";
    gap: 2px 10px;
    padding: 8px 10px 8px 8px;
  }
  .screen-lair .boost > .rr-sprite { grid-area: icon; }
  .screen-lair .boost-name { grid-area: name; font-size: 15px; }
  .screen-lair .boost-power { grid-area: power; }
  .screen-lair .boost-time { grid-area: time; }
  /* facts card in the side column: label left, value right, pixel rules between */
  .lair-side .room-strip.stat-list { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .lair-side .room-strip .stat-row {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: 7px 0 6px;
    background: none;
    box-shadow: none;
    border-top: 2px solid var(--s1-lo);
  }
  .lair-side .room-strip .stat-row:first-child { border-top: 0; padding-top: 0; }
  .lair-side .room-strip .stat-row:last-child { padding-bottom: 0; }
  .lair-side .room-strip .stat-row dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ================================================================== GAME TABS (segmented controls)
   .seg (tabs) and .diff-picker (radio group): dark sockets, the selected one a raised violet plate.
   js/ui/dom.js syncIndicators() still sets --ind-* and .has-ind; the sliding pill is not drawn. */

.seg::before,
.diff-picker::before { content: none; display: none; }
.ind-still::before { transition: none !important; }

/* ================================================================== MINIJUEGOS */

.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: var(--sp-6) var(--sp-5); }
.game-card { display: flex; flex-direction: column; gap: var(--sp-4); padding-top: 0; }
/* banner: the game's own background art (×2), its icon (×3) and how long a round lasts */
.game-banner {
  position: relative;
  height: 152px;
  margin: 0 calc(-1 * var(--sp-5));
  overflow: hidden;
  background: var(--c-ink);
  box-shadow: inset 0 -3px 0 var(--ink);
}
.game-banner-art { position: absolute; left: calc(var(--bx, 50%) - 320px); top: var(--by, -90px); line-height: 0; }
.game-banner-art::after { content: ''; position: absolute; inset: 0; background: rgba(13, 9, 25, 0.32); }
.game-banner .game-icon {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-48px, -50px);
  display: block;
  width: auto; height: auto;
  background: none;
  box-shadow: none;
  line-height: 0;
  filter: drop-shadow(0 4px 0 rgba(7, 4, 15, 0.85));
  transition: transform var(--t) steps(2);
}
.game-card:hover .game-banner .game-icon { transform: translate(-48px, -54px); }
.game-banner-time {
  position: absolute;
  right: 12px; bottom: 15px;
  padding: 4px 8px 2px;
  font: var(--px-s)/1 var(--f-display);
  color: var(--text);
  background: rgba(15, 11, 30, 0.88);
  box-shadow: var(--ring2);
}
.game-card-head { display: flex; gap: var(--sp-4); align-items: center; }
.game-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 80px; height: 80px;
  background: var(--well);
  box-shadow: var(--sunk-2), var(--ring2);
}
.game-title { font-family: var(--f-display); font-weight: 400; font-size: var(--px-m); color: var(--text); line-height: 1; }
.game-meta { font-size: var(--fs-5); color: var(--text-2); margin-top: 6px; }
.game-desc { line-height: 1.5; color: var(--text); }
/* control hints: one quiet line, for the input you are using (keyboard on desktop, touch on phones) */
.game-controls { display: flex; flex-direction: column; gap: 2px; margin-top: calc(-1 * var(--sp-2)); font-size: var(--fs-5); line-height: 1.45; color: var(--text-3); }
.game-controls strong { color: var(--text-2); font-weight: 600; }
.game-controls .ctl-touch { display: none; }
@media (pointer: coarse) {
  .game-controls .ctl-keys { display: none; }
  .game-controls .ctl-touch { display: block; }
}
.diff-picker {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 3px;
}
.diff { position: relative; z-index: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.diff input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.diff-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 4px 4px 2px;
  font: var(--px-s)/1 var(--f-display);
  color: var(--text-2);
  background: #17112C;
  box-shadow: var(--sunk-2), var(--ring2);
  transition: color var(--t-fast) steps(2), background-color var(--t-fast) steps(2), transform 70ms steps(2);
}
.diff:hover input:not(:checked):not(:disabled) + .diff-face { color: var(--text); background: #241B42; }
.diff:active input:not(:disabled) + .diff-face { transform: translateY(2px); }
.diff input:checked + .diff-face {
  color: #FFFFFF;
  background: var(--violet);
  box-shadow: inset 0 3px 0 var(--violet-hi), inset 0 -3px 0 var(--violet-lo), var(--ring2);
}
.diff input:focus-visible + .diff-face { outline: 3px solid var(--focus); outline-offset: 4px; }
.diff.locked { cursor: not-allowed; }
.diff.locked .diff-face { color: var(--text-3); flex-direction: row; flex-wrap: wrap; gap: 0 5px; }
.diff.locked .diff-face .rr-sprite { opacity: 0.7; }
.diff.locked input { cursor: not-allowed; }
.diff-face small { flex-basis: 100%; text-align: center; font: 500 12px/1.2 var(--f-body); color: var(--text-3); }
.diff input:checked + .diff-face small { color: #E8E0FF; }
/* Objetivo · Récords · Partidas: three small figures side by side */
.game-kv {
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  grid-auto-flow: column;
  gap: 4px var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  background: var(--well);
  box-shadow: var(--sunk-2);
}
.game-kv dt { font-size: var(--fs-6); font-weight: 500; color: var(--text-2); }
.game-kv dd { text-align: left; font-size: 15px; line-height: 1.35; }
.game-estimate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  font-size: var(--fs-5);
  color: var(--text-2);
}
.game-estimate .amount-num { color: var(--text); }
.game-card .btn-play { align-self: stretch; min-height: 56px; font-size: var(--px-m); }
/* the action row always sits on the card's floor, so the "Jugar" buttons of a row line up */
.game-card > .btn:last-child,
.game-card > .soon-box { margin-top: auto; margin-bottom: 4px; }
@media (min-width: 1024px) {
  /* three games, three columns: no empty fourth column on wide pages */
  .games-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.game-card.soon .game-banner { filter: grayscale(0.7) brightness(0.75); }
.soon-box { display: flex; flex-direction: column; gap: var(--sp-2); }

.results { display: flex; flex-direction: column; gap: var(--sp-3); }
.results-game { color: var(--text-2); font-size: 15px; }
.results-score { display: flex; align-items: baseline; gap: var(--sp-2); color: var(--text-2); }
.results-num {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-xl);
  line-height: 1;
  color: var(--text);
  text-shadow: 0 4px 0 var(--ink);
  font-variant-numeric: tabular-nums;
  animation: score-in 360ms steps(4) 120ms both;
}
@keyframes score-in { from { transform: translateY(8px); opacity: 0; } }
.results-record {
  align-self: flex-start;
  font: var(--px-s)/1 var(--f-display);
  padding: 6px 10px 4px;
  color: var(--gold-ink);
  background: var(--gold);
  box-shadow: inset 0 2px 0 var(--gold-hi), inset 0 -2px 0 var(--gold-lo), var(--ring2);
  animation: stamp 360ms steps(3) 300ms both;
}
@keyframes stamp { from { transform: translateY(-6px); opacity: 0; } }
.results-best { color: var(--text-2); font-size: 15px; }
.offline .big-qso { font: var(--px-m)/1 var(--f-display); color: var(--gold); }

/* ================================================================== TIENDA */

.seg {
  position: relative;
  display: inline-flex;
  gap: 8px;
  padding: 3px;
  align-self: flex-start;
  justify-self: start;
}
.seg-btn {
  position: relative;
  z-index: 1;
  min-height: 44px;
  padding: 3px 20px 0;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-s);
  line-height: 1;
  color: var(--text-2);
  background: #17112C;
  border: 0;
  border-radius: 0;
  box-shadow: var(--sunk-2), var(--ring2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--t-fast) steps(2), background-color var(--t-fast) steps(2), transform 70ms steps(2);
}
.seg-btn:hover:not([aria-selected="true"]) { color: var(--text); background: #241B42; }
.seg-btn:active { transform: translateY(2px); }
.seg-btn[aria-selected="true"] {
  color: #FFFFFF;
  background: var(--violet);
  box-shadow: inset 0 3px 0 var(--violet-hi), inset 0 -3px 0 var(--violet-lo), var(--ring2), 0 5px 0 var(--violet-side), -2px 3px 0 var(--ink), 2px 3px 0 var(--ink), 0 7px 0 var(--ink);
  transform: translateY(-3px);
}
.seg-btn:focus-visible { outline-offset: 4px; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 268px), 1fr)); gap: var(--sp-5); }
/* item card with a rarity frame: ink outline · tier colour · dark line · plate */
.shop-card {
  --frame: var(--tier, #8C7B75);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: 9px 9px var(--sp-4);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 3px var(--frame), inset 0 0 0 5px rgba(7, 4, 15, 0.7), inset 5px 5px 0 3px var(--s1-hi), var(--ring), 0 6px 0 var(--drop);
  transition: transform var(--t) steps(2);
}
.shop-card.locked { --frame: color-mix(in srgb, var(--tier, #8C7B75) 30%, #2A2049); }
.shop-card:not(.locked):hover { transform: translateY(-3px); }
.shop-art {
  /* the machine on a lit plinth, tinted with its tier */
  position: relative;
  display: grid;
  place-items: end center;
  height: 164px;
  padding-bottom: 24px;
  background:
    linear-gradient(transparent calc(100% - 22px), rgba(7, 4, 15, 0.45) 0),
    color-mix(in srgb, var(--tier, #8C7B75) 16%, var(--well));
  box-shadow: var(--sunk-2);
  overflow: hidden;
}
.shop-art > .rr-sprite { position: relative; transition: transform var(--t) steps(2); }
.shop-card:not(.locked):hover .shop-art > .rr-sprite { transform: translateY(-3px); }
.shop-card.locked .shop-art { background: var(--well); }
.shop-card.locked .shop-art > .rr-sprite { filter: brightness(0); opacity: 0.5; }
.shop-lock .rr-sprite { filter: drop-shadow(0 3px 0 rgba(10, 4, 20, 0.8)); }
.shop-lock { position: absolute; inset: 0; display: grid; place-items: center; }
.shop-info { display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; padding: 0 8px; }
.shop-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-family: var(--f-display); font-weight: 400; font-size: var(--px-s); line-height: 1.1; color: var(--text); }
.shop-card.locked .shop-name { color: var(--text-2); }
.shop-stats {
  display: flex;
  gap: 4px 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 15px;
}
.shop-stats .amount-num { font: var(--px-s)/1 var(--f-display); }
.shop-cells { color: var(--text-2); font-size: var(--fs-5); }
.shop-cells::before { content: '·'; margin-right: 12px; color: var(--text-3); }
.shop-eff { font-size: var(--fs-6); color: var(--text-3); font-variant-numeric: tabular-nums; margin-top: -4px; }
.shop-desc { font-size: 14px; line-height: 1.5; color: var(--text-2); }
.shop-owned {
  align-self: flex-start;
  padding: 3px 8px;
  font-size: var(--fs-6);
  font-weight: 600;
  color: var(--text);
  background: var(--violet-deep);
  box-shadow: inset 2px 0 0 var(--violet-text);
}
.shop-buy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3) var(--sp-3);
  margin: 0 8px 4px;
  padding-top: var(--sp-4);
  border-top: 2px solid var(--s1-lo);
}
.shop-buy .price .amount-num { font: var(--px-m)/1 var(--f-display); }
.shop-buy .price .rr-sprite { width: 32px !important; height: 32px !important; }
.shop-buy .btn { margin-left: auto; }
.shop-buy .why { flex-basis: 100%; text-align: right; font-size: var(--fs-6); color: var(--text-2); }

.rack-shop { display: flex; gap: var(--sp-5); align-items: flex-start; flex-wrap: wrap; }
.rack-shop-art { padding: var(--sp-4); background: var(--well); box-shadow: var(--sunk-2); line-height: 0; }
.rack-shop-info { flex: 1 1 280px; display: flex; flex-direction: column; gap: var(--sp-3); }
.rack-shop-info > p { max-width: 80ch; color: var(--text-2); }
.rack-shop-info > p.muted { font-size: var(--fs-5); }
.room-free { display: flex; flex-direction: column; gap: 4px; max-width: 720px; font-variant-numeric: tabular-nums; }
.room-free li {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px var(--sp-3);
  padding: 8px 12px;
  background: var(--well);
}
.room-free li > span:first-child { font-weight: 600; }
.room-free li > span:last-child { color: var(--text-2); }
.room-free li.locked { color: var(--text-3); }
.room-free li.locked > span:last-child { color: var(--text-3); }
@media (min-width: 1024px) {
  /* the rules on the left, the rooms and their free slots on the right */
  .rack-shop-info { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr); column-gap: var(--sp-7); row-gap: var(--sp-3); align-content: start; }
  .rack-shop-info > * { grid-column: 1; }
  .rack-shop-info > .room-free { grid-column: 2; grid-row: 1 / span 4; align-self: start; }
  /* six rack types: two full rows of three */
  .rack-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ================================================================== INVENTARIO */

.inv-summary { padding: var(--sp-4); }
.inv-list { display: flex; flex-direction: column; gap: var(--sp-5); }
.inv-row {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-5);
  padding: 10px var(--sp-4) 10px 10px;
}
.inv-art {
  display: grid;
  place-items: center;
  height: 100px;
  background: color-mix(in srgb, var(--tier, #8C7B75) 14%, var(--well));
  box-shadow: inset 0 0 0 3px var(--tier, #8C7B75), inset 0 0 0 5px rgba(7, 4, 15, 0.6), var(--ring2);
}
.inv-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.inv-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-family: var(--f-display); font-weight: 400; font-size: var(--px-s); line-height: 1.1; color: var(--text); }
.inv-meta { color: var(--text-2); font-size: var(--fs-5); }
.inv-counts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: var(--fs-5); color: var(--text-2); }
.inv-counts strong { font: var(--px-s)/1 var(--f-display); color: var(--text); font-variant-numeric: tabular-nums; }
.inv-actions { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-4); min-width: 172px; padding: 3px 3px 7px; }
.inv-actions .why { font-size: var(--fs-6); color: var(--text-3); text-align: center; }
.empty-panel { display: flex; flex-direction: column; gap: var(--sp-4); align-items: flex-start; }
@media (min-width: 1024px) {
  /* empty state as a banner: the message on the left, its action on the right */
  .empty-panel { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--sp-4) var(--sp-5); }
}
@media (min-width: 1400px) {
  /* wide pages: two machines per row instead of one very long row */
  .inv-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
  .inv-row { grid-template-columns: 144px minmax(0, 1fr) auto; gap: var(--sp-4); }
}

@media (max-width: 767.98px) {
  .inv-row { grid-template-columns: 96px minmax(0, 1fr); gap: var(--sp-3) var(--sp-4); padding: 10px 10px 12px; }
  .inv-art { height: 84px; }
  .inv-art .rr-sprite { transform: scale(0.75); }
  .inv-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .inv-actions .btn { flex: 1 1 auto; }
  .inv-actions .why { flex-basis: 100%; }
}

/* ================================================================== ESTADÍSTICAS */

.stat-tiles {
  display: grid;
  /* auto-fit: a short row of tiles (inventory summary) stretches instead of leaving empty columns */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 176px), 1fr));
  gap: 8px;
  margin: 0;
}
.stat-tile { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; padding: 10px 14px 12px; background: var(--well); box-shadow: var(--sunk-2); min-width: 0; }
.stat-tile dt { font-size: var(--fs-6); font-weight: 500; color: var(--text-2); line-height: 1.35; }
.stat-tile dd { margin: 0; font: var(--px-s)/1.1 var(--f-display); color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.stats-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 176px;
  padding: 12px;
  background:
    repeating-linear-gradient(transparent 0 37px, rgba(190, 170, 255, 0.07) 37px 39px),
    var(--well);
  box-shadow: var(--sunk-2), var(--ring2);
}
.bar {
  flex: 1;
  min-width: 4px;
  background: var(--violet-text);
  box-shadow: inset 0 3px 0 #E2D8FF, inset -3px 0 0 rgba(43, 29, 92, 0.45);
}
.bar.off { background: #7F7398; box-shadow: inset 0 3px 0 #A79CC0; }
.bar.zero { background: var(--plum-500); box-shadow: none; }
.bar.empty { height: 4px; background: var(--tint-2); box-shadow: none; }
.chart-legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--fs-5); color: var(--text-2); margin: var(--sp-3) 0 var(--sp-1); }
.lg::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 2px var(--ink); }
.lg-on::before { background: var(--violet-text); }
.lg-off::before { background: #7F7398; }
.chart-panel .muted { font-size: var(--fs-5); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 10px 8px; text-align: right; border-bottom: 2px solid var(--s1-lo); white-space: nowrap; }
.table tbody tr:last-child th, .table tbody tr:last-child td { border-bottom: 0; }
.table th:first-child { text-align: left; padding-left: 0; }
.table thead th { color: var(--text-2); font-weight: 500; font-size: var(--fs-6); }
.table tbody th { font-weight: 600; }
.table tbody td { font: var(--px-s)/1 var(--f-display); }

.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.ach {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3);
  background: var(--surface-2);
  box-shadow: var(--bevel-2s);
}
.ach-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 60px; height: 60px;
  line-height: 0;
  background: var(--well);
  box-shadow: var(--sunk-2), var(--ring2);
}
.ach.got { box-shadow: var(--bevel-2s), 0 -2px 0 var(--gold-lo), 0 2px 0 var(--gold-lo), -2px 0 0 var(--gold-lo), 2px 0 0 var(--gold-lo); }
.ach.got .ach-icon { background: color-mix(in srgb, var(--gold) 16%, var(--well)); box-shadow: inset 0 0 0 3px var(--gold), var(--ring2); }
.ach:not(.got) .ach-icon .rr-sprite { filter: grayscale(1) brightness(0.55); }
.ach:not(.got) { background: #221A3E; }
.ach-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ach-name { font: var(--px-s)/1.1 var(--f-display); color: var(--text); }
.ach:not(.got) .ach-name { color: var(--text-2); }
.ach-cond { font-size: var(--fs-5); line-height: 1.45; color: var(--text-2); }
.ach-reward { font-size: var(--fs-6); font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ach.got .ach-reward { color: var(--gold); }
.ach-date { font-size: var(--fs-6); color: var(--text-3); }

.settings-panel { display: flex; flex-direction: column; gap: var(--sp-4); }
.settings-panel .panel-title { margin-bottom: 0; }
.name-form { max-width: 460px; }
.save-tools { padding-top: var(--sp-4); border-top: 3px solid var(--ink); box-shadow: inset 0 3px 0 var(--s1-hi); }
.save-tools .panel-sub { margin-top: var(--sp-2); }
.save-tools .muted { margin-bottom: var(--sp-4); font-size: var(--fs-5); }
/* desktop: the destructive action keeps its distance from Exportar / Importar */
@media (min-width: 1024px) {
  .save-tools .btn-row .btn-danger { margin-left: auto; }
}
.fiction-note { color: var(--text-3); font-size: var(--fs-6); max-width: 72ch; }

@media (max-width: 899.98px) {
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 639.98px) {
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .stats-grid { align-items: stretch; } /* side-by-side panels end on the same line */
}

html[data-reduced-motion="true"] .shop-card:hover,
html[data-reduced-motion="true"] .shop-card:hover .shop-art > .rr-sprite,
html[data-reduced-motion="true"] .game-card:hover .game-banner .game-icon { transform: none; }
html[data-reduced-motion="true"] .game-card:hover .game-banner .game-icon { transform: translate(-48px, -50px); }
@media (prefers-reduced-motion: reduce) {
  .shop-card:hover, .shop-card:hover .shop-art > .rr-sprite { transform: none; }
  .game-card:hover .game-banner .game-icon { transform: translate(-48px, -50px); }
}

/* ================================================================== ALMACÉN: tabs (js/ui/inventory.js)
   Mineros · Estantes · Otros on the shared .seg control, each with a count plate. Estantes reuses the
   machine rows (.inv-row) with the rack drawn whole; Otros lists the temporary hash power still
   running (.boost rows, as in the Guarida) and pass rewards waiting to be claimed. */
.inv-tab { display: inline-flex; align-items: center; justify-content: center; gap: 10px; white-space: nowrap; }
.inv-tab-n {
  display: inline-block;
  min-width: 26px;
  padding: 3px 6px 1px;
  font: 18px/1 var(--f-display);
  text-align: center;
  color: var(--text);
  background: var(--well);
  box-shadow: var(--ring2);
  font-variant-numeric: tabular-nums;
}
.inv-tab-n.is-zero { color: var(--text-3); }
.inv-tab[aria-selected="true"] .inv-tab-n { color: #fff; background: var(--violet-lo); box-shadow: inset 0 2px 0 rgba(7, 4, 15, 0.35), var(--ring2); }
.inv-tabpanel { display: flex; flex-direction: column; gap: var(--sp-5); min-width: 0; }
.inv-tab-note { color: var(--text-2); font-size: var(--fs-5); line-height: 1.45; max-width: 80ch; }
.inv-empty-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
@media (min-width: 1024px) { .inv-empty-actions { flex: none; } }

/* Estantes: the spare rack drawn whole in the art well, framed in its material colour */
.inv-art.is-rack { height: 124px; }
.inv-rack .inv-name .rack-bonus-chip { margin-left: 2px; }

/* Otros */
.inv-boosts,
.inv-pass { display: flex; flex-direction: column; gap: var(--sp-4); }
.inv-sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.inv-sec-head .panel-title { margin-bottom: 0; }
.inv-sec-total { color: var(--text-2); font-size: var(--fs-5); }
.inv-sec-total strong { font: var(--px-s)/1 var(--f-display); color: var(--text); font-variant-numeric: tabular-nums; }
.inv-sec-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.inv-boost-list .boost-time { min-width: 112px; }
.inv-boost-list .boost.is-ended { opacity: 0.55; }
.inv-empty-note {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 12px 14px;
  color: var(--text-2);
  background: var(--well);
  box-shadow: var(--sunk-2);
}
.inv-empty-note > .rr-sprite { flex: none; }
.inv-empty-note p { max-width: 72ch; }
.inv-pass-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 6px; }
.inv-pass-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 10px; background: var(--surface-2); box-shadow: var(--bevel-2s); }
.inv-pass-icon { flex: none; display: grid; place-items: center; width: 32px; height: 32px; }
.inv-pass-name { display: flex; flex-direction: column; min-width: 0; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.inv-pass-name small { font-size: var(--fs-6); font-weight: 500; color: var(--text-2); }

@media (max-width: 767.98px) {
  .inv-art.is-rack { height: 96px; }
}
@media (max-width: 639.98px) {
  /* three equal tabs across the column */
  .inv-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; align-self: stretch; }
  .inv-tabs .seg-btn { min-width: 0; padding: 3px 4px 0; gap: 6px; }
  .inv-tab-n { min-width: 0; padding: 2px 4px 0; font-size: 16px; }
  .inv-empty-actions .btn,
  .inv-sec-actions .btn { flex: 1 1 auto; }
  /* each boost on two lines (name · power) with its timer on the right */
  .screen-inv .boost {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "icon name time" "icon power time";
    gap: 2px 10px;
    padding: 8px 10px 8px 8px;
  }
  .screen-inv .boost > .rr-sprite { grid-area: icon; }
  .screen-inv .boost-name { grid-area: name; font-size: 15px; }
  .screen-inv .boost-power { grid-area: power; }
  .screen-inv .boost-time { grid-area: time; min-width: 0; }
  .inv-empty-note { align-items: flex-start; }
}
