/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg: #14110f;
  --bg-deep: #0c0a09;
  --panel: #221d19;
  --panel-raised: #2b2520;
  --line: #3a322b;
  --text: #efe7dc;
  --muted: #a39685;
  --glow-top: #2d2420;
  --accent: #9aa0a6; /* lo fija main.js según el mineral actual */
  --accent-glow: color-mix(in srgb, var(--accent) 45%, transparent);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* La paleta la fija ui.js según el bioma. Registradas como colores para que cambien animadas (los
   navegadores sin @property la cambian de golpe). */
@property --bg { syntax: '<color>'; inherits: true; initial-value: #14110f; }
@property --bg-deep { syntax: '<color>'; inherits: true; initial-value: #0c0a09; }
@property --glow-top { syntax: '<color>'; inherits: true; initial-value: #2d2420; }
@property --panel { syntax: '<color>'; inherits: true; initial-value: #221d19; }
@property --panel-raised { syntax: '<color>'; inherits: true; initial-value: #2b2520; }
@property --line { syntax: '<color>'; inherits: true; initial-value: #3a322b; }

:root {
  transition: --bg 1.6s ease, --bg-deep 1.6s ease, --glow-top 1.6s ease,
    --panel 1.6s ease, --panel-raised 1.6s ease, --line 1.6s ease;
}

/* ── Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body { padding-bottom: var(--ad-h, 0px); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, var(--glow-top) 0%, transparent 70%),
    radial-gradient(circle at 15% 85%, rgba(255, 255, 255, 0.035) 0 2px, transparent 3px) 0 0 / 90px 90px,
    radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.03) 0 1.5px, transparent 2.5px) 0 0 / 130px 130px,
    linear-gradient(var(--bg), var(--bg-deep));
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
}

h2 { margin: 0; }

/* ── Layout ────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "hud   shop"
    "stage shop";
  height: 100vh;
  height: 100dvh;
  height: calc(100dvh - var(--ad-h, 0px)); /* el banner de anuncios, si lo hay, va debajo */
}

.hud   { grid-area: hud; }
.stage { grid-area: stage; }
.shop  { grid-area: shop; }

/* ── HUD ───────────────────────────────────────────────── */
.hud {
  position: relative; /* ancla el botón de opciones */
  padding: 20px 24px 8px;
  text-align: center;
}

.hud-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hud-currency {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}

.hud-value {
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-shadow: 0 0 24px var(--accent-glow);
}

.hud-unit {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.biome-name {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-mineral {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  font-size: 0.9rem;
  font-weight: 600;
}

.hud-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 12px;
}

.mineral-mult {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.hud-progress {
  width: min(380px, 100%);
  margin: 12px auto 0;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 0 0 1px var(--line);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 60%, #000), var(--accent));
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 0.25s ease-out;
}

.progress-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Zona de clic ──────────────────────────────────────── */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  min-height: 0;
}

/* Aviso al desbloquear un mineral */
.toast {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 24px -6px var(--accent-glow);
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast[hidden] { display: none; }
.toast.show { animation: toast-in var(--toast-ms, 3200ms) ease-out forwards; }

.toast-title { font-weight: 800; font-size: 1.05rem; }
.toast-sub { color: var(--muted); font-size: 0.8rem; }

@keyframes toast-in {
  0%   { opacity: 0; transform: translate(-50%, -14px); }
  8%   { opacity: 1; transform: translate(-50%, 0); }
  85%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

.rock-wrap {
  position: relative;
  width: min(62vw, 46vh, 340px);
  aspect-ratio: 1;
}

.rock {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  touch-action: none; /* evita zoom/scroll al picar con varios dedos */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease-out;
}

/* Halo del color del mineral; --glow (0,35 a 1) crece con la rareza */
.rock::before {
  content: '';
  position: absolute;
  inset: -10%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 56%, var(--accent-glow) 0%, transparent 66%);
  opacity: var(--glow, 0.4);
  pointer-events: none;
  animation: glow-pulse 6s ease-in-out infinite;
  transition: opacity 0.2s;
}

.rock:hover::before { opacity: calc(var(--glow, 0.4) + 0.12); }
.rock:active { transform: scale(0.95); }

.rock:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 6px;
}

@keyframes glow-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

.rock-gem {
  position: relative;
  display: block;
  width: 92%;
  height: 92%;
  pointer-events: none;
}

.rock-gem svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter:
    drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 calc(4px + 10px * var(--glow, 0.4)) var(--accent-glow));
}

.gem-spin {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: gem-spin 40s linear infinite;
}

@keyframes gem-spin { to { transform: rotate(360deg); } }

.gem-glint {
  transform-box: fill-box;
  transform-origin: center;
  animation: glint 3.2s ease-in-out infinite;
}

@keyframes glint {
  0%, 70%, 100% { opacity: 0; transform: scale(0.4); }
  80%           { opacity: 1; transform: scale(1.1) rotate(20deg); }
}

.rock.unlocked { animation: rock-unlock 900ms ease-out; }

@keyframes rock-unlock {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.rock-gem.hit { animation: rock-hit 160ms ease-out; }

@keyframes rock-hit {
  0%   { transform: scale(1) rotate(0); }
  35%  { transform: scale(0.92) rotate(var(--tilt, 0deg)); }
  100% { transform: scale(1) rotate(0); }
}

/* Capa de efectos sobre la roca: números flotantes y chispas */
.floaters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.floater {
  position: absolute;
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 0 10px var(--accent), 0 2px 4px rgba(0, 0, 0, 0.8);
  will-change: transform, opacity;
  animation: float-up var(--floater-ms, 900ms) ease-out forwards;
}

@keyframes float-up {
  from { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
  15%  { transform: translate(-50%, -80%) scale(1.15); }
  to   { transform: translate(-50%, -260%) scale(1); opacity: 0; }
}

.spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 55%, #fff);
  box-shadow: 0 0 6px var(--accent);
  will-change: transform, opacity;
  animation: spark var(--spark-ms, 450ms) ease-out forwards;
}

/* Esquirla de roca (rarezas bajas) y estrellita (altas) */
.spark.chip {
  width: 9px;
  height: 6px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 35%, #6e675f);
  box-shadow: none;
  clip-path: polygon(0 20%, 60% 0, 100% 55%, 40% 100%);
}

.spark.star {
  width: 11px;
  height: 11px;
  border-radius: 0;
  background: color-mix(in srgb, var(--accent) 35%, #fff);
  box-shadow: none;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}

/* Salen despedidas y caen un poco (gravedad) */
@keyframes spark {
  from { transform: translate(-50%, -50%) rotate(0) scale(1); opacity: 1; }
  to   { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 24px)) rotate(var(--rot, 0deg)) scale(0.25); opacity: 0; }
}

.ripple {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  animation: ripple 420ms ease-out forwards;
}

@keyframes ripple {
  from { transform: translate(-50%, -50%) scale(0.3); opacity: 0.55; }
  to   { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(circle at 50% 50%, var(--accent-glow), transparent 62%);
  pointer-events: none;
  animation: flash 600ms ease-out forwards;
}

@keyframes flash { from { opacity: 0.45; } to { opacity: 0; } }

/* Polvo flotante de fondo (se pausa con la pestaña oculta: ver .paused) */
.dust {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.mote {
  position: absolute;
  bottom: -10px;
  width: var(--s, 3px);
  height: var(--s, 3px);
  border-radius: 50%;
  background: var(--c, color-mix(in srgb, var(--accent) 45%, #fff));
  opacity: 0;
  animation: mote-rise 24s linear infinite;
}

@keyframes mote-rise {
  0%   { transform: translate(0, 0); opacity: 0; }
  10%  { opacity: 0.22; }
  90%  { opacity: 0.15; }
  100% { transform: translate(var(--sway, 0px), -105vh); opacity: 0; }
}

@keyframes mote-fall {
  0%   { transform: translate(0, 0); opacity: 0; }
  10%  { opacity: 0.4; }
  90%  { opacity: 0.3; }
  100% { transform: translate(var(--sway, 0px), 108vh); opacity: 0; }
}

@keyframes mote-twinkle {
  0%, 100% { transform: scale(0.3); opacity: 0; }
  50%      { transform: scale(1); opacity: 0.9; }
}

/* Partículas por bioma (.dust[data-fx]; el tipo sale de config.biomes[].fx.kind) */
.dust[data-fx="drip"] .mote { top: -12px; bottom: auto; height: calc(var(--s) * 4); border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%; animation-name: mote-fall; }
.dust[data-fx="snow"] .mote { top: -12px; bottom: auto; filter: blur(0.4px); animation-name: mote-fall; }
.dust[data-fx="ember"] .mote { box-shadow: 0 0 6px 1px var(--c); animation-name: mote-rise; }
.dust[data-fx="glint"] .mote,
.dust[data-fx="sparkle"] .mote,
.dust[data-fx="stars"] .mote { bottom: auto; animation-name: mote-twinkle; animation-timing-function: ease-in-out; }
.dust[data-fx="glint"] .mote { box-shadow: 0 0 6px 1px var(--c); }
.dust[data-fx="sparkle"] .mote { border-radius: 2px; rotate: 45deg; box-shadow: 0 0 8px 1px var(--c); }
.dust[data-fx="stars"] .mote { box-shadow: 0 0 3px var(--c); }

.paused *, .paused *::before, .paused *::after { animation-play-state: paused !important; }


.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Tienda ────────────────────────────────────────────── */
.shop {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(34, 29, 25, 0.92), rgba(24, 20, 17, 0.96));
}

.shop-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.empty[hidden] { display: none; }

.shop-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.shop-head .shop-title { margin-bottom: 0; }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 0.78rem; }
.btn-small[hidden] { display: none; }
.btn-small[aria-disabled="true"] { opacity: 0.55; cursor: default; }
.btn-small.can-buy { border-color: color-mix(in srgb, var(--accent) 70%, var(--line)); background: color-mix(in srgb, var(--accent) 18%, var(--panel-raised)); }
.btn.bought { animation: bought 260ms ease-out; }

.seg {
  display: flex;
  gap: 4px;
}

.seg-btn {
  min-width: 2.6rem;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn[hidden] { display: none; }
.seg-btn:hover { color: var(--text); }

.seg-btn[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--text);
}

.seg-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-raised);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  opacity: 0.6; /* apagada: aún no se puede pagar */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s, transform 0.06s;
}

.item[hidden] { display: none; }

.item[aria-disabled="true"] { cursor: not-allowed; }

.item.teaser { opacity: 0.4; border-style: dashed; }

.item.can-buy {
  opacity: 1;
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--panel-raised));
  box-shadow: 0 0 16px -6px var(--accent-glow);
}

.item.can-buy:hover { background: color-mix(in srgb, var(--accent) 22%, var(--panel-raised)); }
.item.can-buy:active { transform: scale(0.98); }

.item.owned { opacity: 0.5; }

.item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.item.bought { animation: bought 260ms ease-out; }

@keyframes bought {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  100% { box-shadow: 0 0 0 14px transparent; }
}

.item-icon {
  flex: none;
  width: 2.7rem; /* el emoji llega a ~1,4 em de ancho en algunas fuentes */
  font-size: 1.8rem;
  line-height: 1;
  text-align: center;
}

.item-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.item-name { font-weight: 700; }

.item-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.item-cost {
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--accent) 60%, var(--text));
}

.item-count.bump { animation: bump 260ms ease-out; }

@keyframes bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); color: var(--text); }
  100% { transform: scale(1); }
}

.item-count {
  transform-origin: right center;
  flex: none;
  min-width: 2ch;
  color: var(--muted);
  font-size: 1.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ── Móvil / tablet vertical: todo apilado ─────────────── */
/* Un móvil en horizontal (poco alto) mantiene las dos columnas para ver la roca entera. */
@media (max-width: 820px) and (min-height: 500px), (max-width: 600px) {
  .app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100dvh - var(--ad-h, 0px));
  }

  .hud {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(6px);
  }

  .hud-value { font-size: clamp(1.9rem, 9vw, 2.6rem); }
  .hud-stats { gap: 28px; margin-top: 6px; }

  .stage { padding: 24px 16px 20px; }
  .rock-wrap { width: min(68vw, 300px); }

  .shop {
    overflow-y: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  }
}

/* ── Aviso de ganancias offline ────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 6, 5, 0.72);
  backdrop-filter: blur(3px);
  animation: modal-fade 200ms ease-out;
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(380px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 22px 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--line));
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px -12px var(--accent-glow);
  text-align: center;
  animation: modal-pop 240ms ease-out;
}

.modal-title { margin-bottom: 14px; font-size: 1.25rem; }
.modal-lead { margin: 0; color: var(--muted); font-size: 0.95rem; }

.modal-amount {
  margin: 2px 0;
  font-size: clamp(1.8rem, 9vw, 2.4rem);
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px var(--accent-glow);
  overflow-wrap: anywhere;
}

#offline-unit { font-size: 1rem; font-weight: 600; color: var(--muted); }

.modal-detail { margin: 14px 0 0; color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.modal-mineral { margin: 10px 0 0; font-weight: 700; }
.modal-mineral[hidden] { display: none; }

.modal-button {
  margin-top: 18px;
  width: 100%;
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 22%, var(--panel-raised));
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.modal-button:hover { background: color-mix(in srgb, var(--accent) 32%, var(--panel-raised)); }
.modal-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { transform: translateY(10px) scale(0.97); } to { transform: none; } }

/* ── Opciones ──────────────────────────────────────────── */
.icon-button {
  position: absolute;
  top: 10px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.icon-button:hover { background: var(--panel-raised); }
.icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.options-card { text-align: left; }
.options-card .modal-title { text-align: center; margin-bottom: 8px; }

.opt { padding: 12px 0; border-top: 1px solid var(--line); }
.opt-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.opt-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.opt-hint {
  display: block;
  margin: 8px 0 0;
  min-height: 1.1em;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}
.opt-hint.ok { color: #8bd17c; }
.opt-hint.error { color: #ff8a80; }

.btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { background: var(--panel-raised); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[hidden] { display: none; }

.btn-warn { border-color: color-mix(in srgb, #e0a030 60%, var(--line)); }
.btn-danger { border-color: color-mix(in srgb, #e05050 60%, var(--line)); color: #ff9a92; }
.btn.armed { background: #7a2a26; border-color: #e05050; color: #fff; }

.transfer { margin-top: 10px; }
.transfer[hidden] { display: none; }

.transfer-code {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: 0.72rem/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  resize: vertical;
}
.transfer-code:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.options-card .modal-button { margin-top: 6px; }

.opt-slider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.opt-slider input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 28px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Logros y estadísticas ─────────────────────────────── */
.icon-left { right: auto; left: 12px; }
.icon-sound { top: 56px; }

.ach-card { text-align: left; }
.ach-card .modal-title { margin-bottom: 10px; text-align: center; }
.ach-card .opt-hint { text-align: center; }
.ach-tabs { flex-wrap: wrap; justify-content: center; margin-bottom: 4px; }

.ach-summary {
  margin: 10px 0 0;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.medals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.medal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  opacity: 0.55;
  filter: grayscale(1);
}

.medal.done {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-raised));
  opacity: 1;
  filter: none;
}

.medal-icon { flex: none; width: 2.2rem; font-size: 1.6rem; line-height: 1; text-align: center; }
.medal-body { display: flex; flex-direction: column; min-width: 0; }
.medal-name { font-size: 0.85rem; font-weight: 700; }
.medal-desc { color: var(--muted); font-size: 0.72rem; line-height: 1.25; }

.stats { display: flex; flex-direction: column; margin: 12px 0 0; }
.stats[hidden] { display: none; }

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}

.stat-name { margin: 0; color: var(--muted); font-size: 0.85rem; }
.stat-figure { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.milestone-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }

.milestone-list[hidden] { display: none; }

.milestone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  opacity: 0.6;
}
.milestone-row.done { opacity: 1; border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: color-mix(in srgb, var(--accent) 12%, var(--panel-raised)); }
.milestone-row .medal-body { flex: 1; }
.milestone-state { flex: none; color: var(--muted); font-size: 0.75rem; text-align: right; }

.report[hidden] { display: none; }
.report .opt-title { margin: 14px 0 0; }
.report .stats { margin-top: 4px; }
.stat-row[hidden] { display: none; }
.stat-row.total .stat-name, .stat-row.total .stat-figure { color: var(--text); font-weight: 800; }

.next-milestone { color: var(--text); opacity: 0.85; }

.item.gold { border-color: #c9a227; }
.item.gold .item-name { color: #f2c230; }

.floater.crit { font-size: 1.5em; color: #ffd54a; text-shadow: 0 0 12px rgba(255, 190, 40, 0.9); }

.ach-toast {
  top: auto;
  bottom: 40px;
  border-color: #c9a227;
  background: color-mix(in srgb, #c9a227 16%, var(--panel));
  font-weight: 700;
}
.ach-toast.show { animation: toast-in var(--ach-toast-ms, 2800ms) ease-out forwards; }

/* ── Eventos: mineral dorado y frenesí ───────────────────── */
.golden-layer { position: absolute; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; }

.golden {
  position: absolute;
  top: var(--y, 30%);
  left: 42%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid #ffe27a;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c2, #f2c230 55%, #a8770a);
  box-shadow: 0 0 24px 6px rgba(255, 200, 60, 0.75);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  animation: golden-cross var(--cross, 10s) linear forwards, golden-bob 1.1s ease-in-out infinite alternate;
}
.golden.rtl { animation-direction: reverse, alternate; }
.golden:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.golden.popped { animation: golden-pop 300ms ease-out forwards; pointer-events: none; }

@keyframes golden-cross { from { left: -80px; } to { left: calc(100% + 16px); } }
@keyframes golden-bob { from { margin-top: -14px; } to { margin-top: 14px; } }
@keyframes golden-pop { to { transform: scale(2.2); opacity: 0; } }

.boost {
  padding: 3px 12px;
  border: 1px solid #ff8c3d;
  border-radius: 999px;
  background: color-mix(in srgb, #ff8c3d 20%, var(--panel));
  font-size: 0.85rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.boost[hidden] { display: none; }
.app.frenzy .rock::before { opacity: calc(var(--glow, 0.4) + 0.35); }

/* ── Misiones ──────────────────────────────────────────── */
.intro {
  width: min(86%, 360px);
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  text-align: left;
}
.intro[hidden] { display: none; }
.intro-head { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.intro-text { margin: 4px 0 8px; font-weight: 700; }
.intro-bar, .goal-bar { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(0, 0, 0, 0.4); }
.intro-fill, .goal-fill { width: 0; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #fff); transition: width 0.2s; }
.intro-count { display: block; margin-top: 4px; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.missions-card { text-align: left; }
.missions-card .modal-title { margin-bottom: 4px; text-align: center; }
.missions-streak { margin: 0 0 6px; text-align: center; font-weight: 800; color: #ffb347; }
.gift { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 0; }
.gift-text { font-size: 0.9rem; font-weight: 600; }
.gift .btn { flex: none; width: auto; min-width: 130px; margin-top: 0; }
.goal-list { display: flex; flex-direction: column; gap: 10px; }
.goal { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.goal[hidden] { display: none; }
.goal.done { border-color: color-mix(in srgb, #8bd17c 60%, var(--line)); }
.goal-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.goal-text { font-weight: 700; }
.goal-reward { flex: none; color: var(--muted); font-size: 0.75rem; }
.goal-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; min-height: 30px; }
.goal-count { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.goal-claim { min-height: 30px; }
.goal-claim[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.goal-claim.can-buy { border-color: #8bd17c; background: color-mix(in srgb, #8bd17c 18%, var(--panel-raised)); }

/* ── Resumen al renacer ────────────────────────────────── */
.summary-card { width: min(460px, 100%); text-align: left; }
.summary-card .modal-title { margin-bottom: 6px; text-align: center; }
.summary-highlight { margin: 0 0 10px; padding: 8px 12px; border: 1px solid #6fd3ff; border-radius: 12px; background: color-mix(in srgb, #6fd3ff 14%, var(--panel)); font-weight: 700; text-align: center; line-height: 1.35; }
.summary-grid { display: flex; flex-direction: column; }
.summary-row { display: grid; grid-template-columns: 1fr auto 4.8rem; align-items: baseline; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.summary-row[hidden] { display: none; }
.summary-label { color: var(--muted); font-size: 0.85rem; }
.summary-value { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.summary-change { font-size: 0.75rem; font-weight: 800; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.summary-change.good { color: #8bd17c; }
.summary-change.bad { color: #ff8a80; }
.summary-cores { margin: 12px 0 0; font-size: 1.1rem; font-weight: 800; color: #6fd3ff; text-align: center; }
.summary-actions { justify-content: center; }
.summary-actions .btn { min-height: 40px; }
.summary-actions .btn[hidden] { display: none; }
.summary-card .modal-button { margin-top: 12px; }

/* ── Retos especiales ──────────────────────────────────── */
.challenges-open { width: 100%; margin-top: 8px; }
.challenges-card { width: min(520px, 100%); text-align: left; }
.challenges-card .modal-title { margin-bottom: 4px; text-align: center; }
.challenges-card .opt-hint { text-align: center; }
.challenge-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.challenge { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.challenge.done { border-color: color-mix(in srgb, #8bd17c 55%, var(--line)); }
.challenge.active { border-color: #6fd3ff; box-shadow: 0 0 14px -6px #6fd3ff; }
.challenge-head { display: flex; align-items: center; gap: 8px; }
.challenge-icon { font-size: 1.4rem; line-height: 1; }
.challenge-name { font-weight: 800; }
.challenge-line { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.challenge-goal { color: var(--text); font-weight: 700; }
.challenge-reward { color: #ffd76a; }
.challenge-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.challenge-status { color: var(--muted); font-size: 0.78rem; }
.challenge-foot .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.challenge-foot .btn.armed { background: #7a2a26; border-color: #e05050; color: #fff; }

.challenge-banner {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #6fd3ff;
  border-radius: 12px;
  background: color-mix(in srgb, #6fd3ff 16%, var(--panel));
  font-size: 0.82rem;
  font-weight: 700;
}
.challenge-banner[hidden] { display: none; }
.challenge-text { min-width: 0; }
.challenge-banner .btn.armed { background: #7a2a26; border-color: #e05050; color: #fff; }
.stage.in-challenge .toast { top: 56px; }

/* ── Tarjeta compartible ───────────────────────────────── */
.ach-share[hidden] { display: none; }
.ach-share { justify-content: center; margin-top: 14px; }
.share-card { width: min(460px, 100%); }
.share-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1080 / 1350; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.share-actions { justify-content: center; }
.share-card .opt-hint { text-align: center; }

/* ── Mineralpedia ──────────────────────────────────────── */
.dex-card { width: min(520px, 100%); text-align: left; }
.dex-card .modal-title { margin-bottom: 4px; text-align: center; }
.dex-tabs { justify-content: center; margin: 4px 0 8px; }
.dex-list[hidden] { display: none; }
.dex-progress { margin: 0; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.dex-bar { height: 8px; margin: 6px 0 4px; overflow: hidden; border-radius: 999px; background: rgba(0, 0, 0, 0.4); }
.dex-fill { width: 0; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #fff); transition: width 0.3s; }
.dex-card .opt-hint { text-align: center; }
.dex-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.dex-biome { display: flex; justify-content: space-between; gap: 8px; margin: 12px 2px 0; color: var(--muted); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.dex-biome.complete { color: #8bd17c; }
.dex-entry { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.dex-entry { --entry-accent: var(--accent); }
.dex-entry.found { border-color: color-mix(in srgb, var(--entry-accent) 55%, var(--line)); background: color-mix(in srgb, var(--entry-accent) 10%, var(--panel-raised)); }
.dex-gem { flex: none; width: 56px; height: 56px; }
.dex-gem svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5)); }
.dex-gem.emoji { display: grid; place-items: center; font-size: 2.1rem; line-height: 1; }
.dex-entry:not(.found) .dex-gem.emoji { filter: brightness(0) opacity(0.35); }
.dex-entry:not(.found) .dex-gem svg { filter: brightness(0) opacity(0.35); }
.dex-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dex-name { font-weight: 800; }
.dex-meta { color: var(--muted); font-size: 0.72rem; }
.dex-fact { font-size: 0.8rem; line-height: 1.35; }
.dex-entry:not(.found) { opacity: 0.7; }

/* ── Renacer (prestigio) ───────────────────────────────── */
.icon-missions { top: 56px; }
.icon-missions[hidden] { display: none; }
.icon-dex { top: 102px; }
.icon-prestige { top: 148px; }
.icon-prestige[hidden] { display: none; }

.icon-prestige.ready {
  border-color: #6fd3ff;
  box-shadow: 0 0 14px 2px rgba(111, 211, 255, 0.55);
  animation: prestige-ready 1.4s ease-in-out infinite;
}

@keyframes prestige-ready {
  50% { box-shadow: 0 0 22px 6px rgba(111, 211, 255, 0.8); transform: scale(1.08); }
}

.badge {
  position: absolute;
  right: -6px;
  bottom: -6px;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #1c8fbf;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
}
.badge[hidden] { display: none; }

.prestige-card { width: min(520px, 100%); text-align: left; }
.prestige-card .modal-title { margin-bottom: 10px; text-align: center; }
.prestige-card .opt:first-of-type { border-top: 0; }

.prestige-summary { display: flex; justify-content: center; gap: 36px; margin-bottom: 6px; }
.prestige-stat { display: flex; flex-direction: column; align-items: center; }
.prestige-figure { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.prestige-label { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }

.prestige-result {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid #6fd3ff;
  border-radius: 12px;
  background: color-mix(in srgb, #6fd3ff 14%, var(--panel));
  font-weight: 700;
  text-align: center;
}
.prestige-result[hidden] { display: none; }

.prestige-goal { margin: 0; font-weight: 700; }
.prestige-gain { margin: 6px 0 0; font-size: 1.15rem; font-weight: 800; color: #6fd3ff; }
.prestige-gain[hidden] { display: none; }

.btn-prestige { width: 100%; min-height: 44px; margin-top: 12px; border-color: color-mix(in srgb, #6fd3ff 40%, var(--line)); }
.btn-prestige[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-prestige.can-buy { border-color: #6fd3ff; background: color-mix(in srgb, #6fd3ff 20%, var(--panel-raised)); box-shadow: 0 0 16px -6px #6fd3ff; }
.btn-prestige.armed { background: #7a2a26; border-color: #e05050; }

.skill-list { display: flex; flex-direction: column; gap: 8px; }
.skill .item-body { flex: 1; }

.milestones { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.milestone.done { color: var(--text); font-weight: 600; }

/* ── Anuncios (js/ads-ui.js) ───────────────────────────── */
.ad-dock {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 60; /* sobre el juego, bajo las ventanas */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-deep) 94%, transparent);
}
.ad-dock[hidden], .ad-banner[hidden] { display: none; }

.ad-banner { max-width: 100%; overflow: hidden; text-align: center; } /* el ancho y el alto los pone ads-ui.js según el banner */
.ad-frame { display: block; margin: 0 auto; border: 0; }
.ad-banner-test { display: grid; place-items: center; height: 100%; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 0.8rem; }

.ad-gate a, .opt-hint a { color: var(--accent); }
.ad-gate { z-index: 250; padding: 8px; }
.ad-gate .modal-card { padding-left: 6px; padding-right: 6px; }
.ad-gate-banner { width: 320px; max-width: 100%; height: 50px; margin: 14px auto 0; overflow: hidden; }
.ad-gate-banner[hidden] { display: none; }

.ad-boost { align-self: center; margin-top: 2px; }
.ad-reward { width: 100%; min-height: 40px; margin: 0 0 8px; border-color: color-mix(in srgb, #ff8c3d 55%, var(--line)); }
.ad-reward[hidden] { display: none; }
.gift { flex-wrap: wrap; }
.gift .ad-reward { flex: 1 0 100%; margin: 0; }
.ad-reward[aria-disabled="true"], .ad-boost[aria-disabled="true"] { opacity: 0.55; cursor: default; }

.ad-test { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px; background: rgba(8, 6, 5, 0.92); }
.ad-test-card { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(320px, 100%); padding: 24px 22px; border: 1px dashed var(--line); border-radius: 18px; background: var(--panel); text-align: center; }
.ad-test-count { margin: 0; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ── Pantallas bajas con dos columnas (móvil horizontal): compactar ── */
@media (max-height: 500px) and (min-width: 601px) {
  .hud { padding: 8px 16px 0; }
  .hud-value { font-size: 2rem; }
  .hud-stats { margin-top: 4px; }
  .stage { gap: 6px; padding: 8px; }
  .rock-wrap { width: min(40vh, 340px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
