/* ==========================================================================
   Intercambio — sistema visual inspirado en las guías de interfaz de Apple:
   tipografía del sistema, listas agrupadas, materiales translúcidos,
   un solo color de acento y movimiento sobrio.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --label: #1d1d1f;
  --label-2: #6e6e73;
  --label-3: #a1a1a6;
  --separator: rgba(60, 60, 67, 0.16);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.08);
  --fill-pressed: rgba(118, 118, 128, 0.18);

  --accent: #c41230;
  --accent-pressed: #a30f28;
  --accent-tint: rgba(196, 18, 48, 0.09);
  --on-accent: #ffffff;
  --green: #1f8a3b;
  --green-tint: rgba(31, 138, 59, 0.11);
  --orange: #b25000;
  --orange-tint: rgba(255, 149, 0, 0.14);
  --gold: #a87b00;

  --material: rgba(245, 245, 247, 0.78);
  --material-thick: rgba(255, 255, 255, 0.86);
  --backdrop: rgba(0, 0, 0, 0.32);
  --sheet-bg: #f2f2f7;
  --sheet-surface: #ffffff;

  --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.02), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', 'Segoe UI Variable', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro', 'Segoe UI Variable Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-rounded: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, sans-serif;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-raised: #2c2c2e;
    --label: #f5f5f7;
    --label-2: #a1a1a6;
    --label-3: #6e6e73;
    --separator: rgba(84, 84, 88, 0.55);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.16);
    --fill-pressed: rgba(118, 118, 128, 0.32);

    --accent: #ff4f63;
    --accent-pressed: #ff6b7c;
    --accent-tint: rgba(255, 79, 99, 0.16);
    --on-accent: #ffffff;
    --green: #30d158;
    --green-tint: rgba(48, 209, 88, 0.16);
    --orange: #ffb340;
    --orange-tint: rgba(255, 159, 10, 0.18);
    --gold: #e6c15a;

    --material: rgba(18, 18, 20, 0.72);
    --material-thick: rgba(36, 36, 38, 0.9);
    --backdrop: rgba(0, 0, 0, 0.55);
    --sheet-bg: #1c1c1e;
    --sheet-surface: #2c2c2e;

    --shadow-card: none;
    --shadow-float: 0 16px 48px rgba(0, 0, 0, 0.6);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern';
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 1em; height: 1em; flex: none; display: block; }

/* ---------- Barra de navegación ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-top);
  background: transparent;
  transition: background-color 0.25s, box-shadow 0.25s;
}
.navbar.scrolled {
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--separator);
}
.navbar-inner {
  max-width: 720px;
  margin: 0 auto;
  height: 52px;
  padding: 0 8px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.navbar-title {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
}
.navbar.scrolled .navbar-title,
.navbar.always-title .navbar-title { opacity: 1; transform: none; }
.navbar-leading { justify-self: start; display: flex; }
.navbar-trailing { justify-self: end; display: flex; gap: 4px; }

/* ---------- Página ---------- */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 4px 20px calc(48px + var(--safe-bottom));
}
.large-title { padding: 8px 0 22px; }
.large-title h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 7vw, 40px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.028em;
}
.large-title p { margin-top: 6px; color: var(--label-2); font-size: 17px; }
.view { animation: view-in 0.35s var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Secciones y listas agrupadas ---------- */
.section { margin-top: 28px; }
.section:first-child { margin-top: 0; }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 7px;
  font-size: 13px;
  line-height: 1.38;
  letter-spacing: -0.008em;
  color: var(--label-2);
}
.section-header h2 { font-size: 13px; font-weight: 400; }
.section-header.big { padding: 0 2px 10px; }
.section-header.big h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--label); letter-spacing: -0.02em; }
.section-footer {
  padding: 7px 16px 0;
  font-size: 13px;
  line-height: 1.38;
  letter-spacing: -0.008em;
  color: var(--label-2);
}

.group {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  background: transparent;
  border: 0;
  text-align: left;
  color: var(--label);
  text-decoration: none;
}
.cell + .cell::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: var(--sep-inset, 16px);
  height: 0.5px;
  background: var(--separator);
}
.cell.has-avatar { --sep-inset: 64px; }
.cell.has-icon { --sep-inset: 58px; }
button.cell, a.cell { transition: background-color 0.15s; }
button.cell:hover { background: var(--fill-2); }
button.cell:active { background: var(--fill-pressed); }
button.cell:disabled { cursor: default; background: transparent; }
.cell-body { flex: 1; min-width: 0; }
.cell-title, .cell-sub { display: block; }
.cell-title { font-size: 17px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { font-size: 14px; line-height: 1.35; color: var(--label-2); margin-top: 1px; letter-spacing: -0.01em; }
.cell-trailing { display: flex; align-items: center; gap: 8px; color: var(--label-2); font-size: 15px; flex: none; }
.chevron { color: var(--label-3); font-size: 13px; }
.cell.accent { color: var(--accent); }
.cell.destructive { color: var(--accent); justify-content: center; }

.icon-tile {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 17px;
  flex: none;
  background: var(--label-3);
}
.icon-tile.red { background: #e5243b; }
.icon-tile.green { background: #34a853; }
.icon-tile.gray { background: #8e8e93; }
.icon-tile.indigo { background: #5856d6; }
.icon-tile.orange { background: #f08c00; }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font-family: var(--font-rounded);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  color: #fff;
  background: linear-gradient(180deg, var(--a1, #a1a1a6), var(--a2, #8e8e93));
  user-select: none;
}
.avatar.lg { width: 72px; height: 72px; font-size: 28px; }

/* Estado de paso (checklist) */
.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--label-2);
  box-shadow: inset 0 0 0 1.5px var(--label-3);
}
.step-dot.done { background: var(--green); color: #fff; box-shadow: none; }
.step-dot.current { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  background: var(--fill);
  color: var(--label-2);
}
.badge.green { background: var(--green-tint); color: var(--green); }
.badge.orange { background: var(--orange-tint); color: var(--orange); }
.badge.accent { background: var(--accent-tint); color: var(--accent); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.022em;
  white-space: nowrap;
  transition: background-color 0.15s, transform 0.15s var(--ease), opacity 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover { background: var(--accent-pressed); }
.btn:active { transform: scale(0.975); }
.btn:disabled { background: var(--fill); color: var(--label-3); pointer-events: none; box-shadow: none; }
.btn[data-busy]:disabled { background: var(--accent); color: var(--on-accent); opacity: 0.75; }
.btn.tinted[data-busy]:disabled, .btn.gray[data-busy]:disabled { background: var(--fill); color: var(--label-2); }
.btn.block { width: 100%; }
.btn.tinted { background: var(--accent-tint); color: var(--accent); }
.btn.tinted:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.btn.gray { background: var(--fill); color: var(--label); }
.btn.gray:hover { background: var(--fill-pressed); }
.btn.small { height: 34px; padding: 0 14px; font-size: 15px; border-radius: 980px; }
.btn.medium { height: 44px; font-size: 16px; border-radius: 12px; }
.btn .spinner { width: 18px; height: 18px; }

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 17px;
  border-radius: 10px;
  white-space: nowrap;
}
.text-btn:hover { opacity: 0.75; }
.text-btn:disabled { color: var(--label-3); opacity: 1; cursor: default; }
.text-btn.strong { font-weight: 600; }
.text-btn .i { font-size: 22px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--fill);
  color: var(--label-2);
  font-size: 15px;
}
.icon-btn:hover { background: var(--fill-pressed); }

/* ---------- Campos ---------- */
.field {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--fill);
  color: var(--label);
  font-size: 17px;
  outline: none;
  transition: box-shadow 0.15s, background-color 0.15s;
}
.field::placeholder { color: var(--label-3); }
.field:focus { background: var(--surface); box-shadow: 0 0 0 1px var(--separator), 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea.field { height: auto; min-height: 240px; padding: 12px 14px; line-height: 1.5; resize: vertical; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 15px; letter-spacing: 0; }
.cell .field-inline {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  font-size: 17px;
  padding: 0;
  height: 28px;
  text-align: right;
  color: var(--label);
}
.money-input { display: flex; align-items: center; gap: 2px; color: var(--label-2); font-size: 17px; flex: none; }
.money-input .field-inline { width: calc(var(--chars, 1) * 1ch + 6px); min-width: 2ch; max-width: 130px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.money-input .field-inline:disabled { color: var(--label-2); -webkit-text-fill-color: var(--label-2); opacity: 1; }
.cell .field-inline::placeholder { color: var(--label-3); }

.search {
  position: relative;
  display: block;
  margin-bottom: 24px;
}
label.cell { cursor: text; }
.search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--label-2); font-size: 16px; pointer-events: none; }
.search .field { height: 38px; padding-left: 34px; font-size: 17px; }
.search .clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; background: none; color: var(--label-3); display: grid; place-items: center; font-size: 17px; }

/* Selector estilo menú de iOS */
.picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 58%;
  min-width: 0;
  flex: none;
}
.picker select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--label-2);
  font-size: 17px;
  padding: 6px 22px 6px 6px;
  text-align: right;
  text-align-last: right;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
}
.picker select:focus-visible { background: var(--fill); }
.picker.filled select { color: var(--accent); }
.picker::after {
  content: '';
  position: absolute;
  right: 4px;
  top: 50%;
  width: 10px;
  height: 14px;
  transform: translateY(-50%);
  pointer-events: none;
  background-color: var(--label-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 14'%3E%3Cpath d='M1.5 5 5 1.5 8.5 5M1.5 9 5 12.5 8.5 9' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 14'%3E%3Cpath d='M1.5 5 5 1.5 8.5 5M1.5 9 5 12.5 8.5 9' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.picker.filled::after { background-color: var(--accent); }

/* Toggle tipo iOS */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 31px;
  background: var(--fill-pressed);
  transition: background-color 0.25s;
}
.switch span::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.25s var(--ease);
}
.switch input:checked + span { background: #34c759; }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: 0.45; }
.switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* Stepper */
.stepper { display: inline-flex; align-items: center; background: var(--fill); border-radius: 9px; height: 32px; }
.stepper button { width: 44px; height: 32px; border: 0; background: none; font-size: 20px; color: var(--label); display: grid; place-items: center; }
.stepper button:disabled { color: var(--label-3); cursor: default; }
.stepper button + button { box-shadow: -0.5px 0 0 var(--separator); }
.stepper-value { min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; color: var(--label-2); font-size: 17px; margin-right: 12px; }

/* Control segmentado */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
  margin-bottom: 24px;
}
.segmented button {
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--label);
  transition: background-color 0.2s, box-shadow 0.2s;
}
.segmented button[aria-selected='true'] {
  background: var(--surface-raised);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

/* ---------- Tarjetas destacadas ---------- */
.hero-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 28px 24px 24px;
  text-align: center;
}
.hero-card .glyph {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 32px;
  color: #fff;
  background: linear-gradient(160deg, #ec3a51, #b00e2a);
  box-shadow: 0 8px 20px -6px rgba(196, 18, 48, 0.55);
}
.hero-card .glyph.gray { background: linear-gradient(160deg, #a1a1a6, #7c7c80); box-shadow: none; }
.hero-card h2 { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.hero-card p { color: var(--label-2); margin: 8px auto 20px; max-width: 420px; font-size: 16px; }
.hero-card .btn { min-width: 220px; }
.hero-card .footnote { margin-top: 12px; font-size: 13px; color: var(--label-2); }

.progress-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-card); padding: 16px; }
.progress-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.progress-num { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.progress-num small { font-size: 17px; color: var(--label-2); font-weight: 500; letter-spacing: -0.01em; }
.bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.6s var(--ease); }
.meta-row { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--label-2); }
.meta-row b { color: var(--label); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Papelito (tarjeta giratoria) ---------- */
.slip-wrap { perspective: 1400px; max-width: 360px; margin: 0 auto; }
.slip {
  position: relative;
  width: 100%;
  aspect-ratio: 1.6;
  border: 0;
  padding: 0;
  background: none;
  transform-style: preserve-3d;
  transition: transform 0.75s var(--ease);
  border-radius: 20px;
}
.slip.flipped { transform: rotateY(180deg); }
.slip-face {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}
.slip-back {
  color: #fff;
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(150deg, #e3344b 0%, #b30f2b 55%, #7e0a1f 100%);
  box-shadow: 0 20px 40px -16px rgba(150, 10, 35, 0.6), inset 0 0 0 0.5px rgba(255, 255, 255, 0.25);
}
.slip-back::before,
.slip-back::after { content: ''; position: absolute; background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.05); }
.slip-back::before { left: 0; right: 0; top: 50%; height: 14px; transform: translateY(-50%); background: linear-gradient(180deg, #f3d77a, #c99a2e); }
.slip-back::after { top: 0; bottom: 0; left: 28%; width: 14px; background: linear-gradient(90deg, #f3d77a, #c99a2e); }
.slip-back .tap {
  position: relative;
  z-index: 1;
  margin-top: auto;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  padding: 6px 12px;
  border-radius: 980px;
  background: rgba(0, 0, 0, 0.25);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.slip-front {
  transform: rotateY(180deg);
  background: var(--surface);
  box-shadow: var(--shadow-float), inset 0 0 0 0.5px var(--separator);
  text-align: center;
}
.slip-front .eyebrow { font-size: 13px; color: var(--label-2); font-weight: 500; }
.slip-front .who {
  font-family: var(--font-display);
  font-size: clamp(30px, 9vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 6px 0 4px;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.slip-front .fam { font-size: 15px; color: var(--label-2); }
.slip-hint { text-align: center; font-size: 13px; color: var(--label-2); margin-top: 14px; }

/* ---------- Ranking ---------- */
.rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--fill);
  color: var(--label-2);
}
.rank.r1 { background: linear-gradient(160deg, #f7d66b, #d0a215); color: #5b4300; }
.rank.r2 { background: linear-gradient(160deg, #e4e6ea, #b5b9c1); color: #3c4049; }
.rank.r3 { background: linear-gradient(160deg, #e9b48a, #b77845); color: #4b2a10; }
.score { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--label); }
.score small { color: var(--label-2); font-weight: 400; }

/* ---------- Estado vacío ---------- */
.empty { text-align: center; padding: 56px 24px; }
.empty .i { font-size: 44px; color: var(--label-3); margin: 0 auto 14px; }
.empty h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.empty p { color: var(--label-2); margin-top: 6px; font-size: 16px; }

/* ---------- Hoja / diálogo ---------- */
dialog.sheet {
  border: 0;
  padding: 0;
  margin: 0;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  background: transparent;
  color: var(--label);
  overflow: hidden;
}
dialog.sheet::backdrop { background: transparent; }
.sheet-scrim {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.sheet-panel {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(100%, 520px);
  max-height: calc(100dvh - 12px - var(--safe-top));
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--sheet-bg);
  border-radius: 14px 14px 0 0;
  padding: 8px 20px calc(24px + var(--safe-bottom));
  box-shadow: var(--shadow-float);
  transform: translate3d(-50%, 100%, 0);
  transition: transform 0.5s var(--ease);
  will-change: transform;
  -webkit-overflow-scrolling: touch;
}
/* Hoja alta (cuando hay teclado): anclada arriba como en iOS. El contenido queda
   en la parte superior y el teclado ocupa el espacio vacío de abajo, así nada se mueve. */
dialog.sheet.large .sheet-panel {
  top: calc(var(--safe-top) + 12px);
  max-height: none;
}
dialog.sheet.large .pin-head { padding-top: 20px; }
/* Campo "señuelo" para abrir el teclado sin desplazar la página (ver ui.sheet). */
.focus-proxy {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
}
dialog.sheet.open .sheet-scrim { opacity: 1; }
dialog.sheet.open .sheet-panel { transform: translate3d(-50%, 0, 0); }
.sheet-panel .group, .sheet-panel .pin-boxes .box { background: var(--sheet-surface); }
.sheet-panel:focus { outline: none; }
.sheet-panel { -webkit-user-select: none; user-select: none; cursor: default; }
.sheet-panel input, .sheet-panel textarea { -webkit-user-select: text; user-select: text; }
.sheet-grabber { cursor: grab; }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); opacity: 0.5; margin: 0 auto 6px; }
.sheet-bar {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 2px -6px 6px;
}
.sheet-bar .title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.close-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  justify-self: end;
  background: var(--fill);
  color: var(--label-2);
  font-size: 15px;
  transition: background-color 0.15s, transform 0.15s var(--ease);
}
.close-btn svg { stroke-width: 2.6; }
.close-btn:hover { background: var(--fill-pressed); color: var(--label); }
.close-btn:active { transform: scale(0.92); }
@media (min-width: 640px) {
  .sheet-panel {
    top: 50%;
    bottom: auto;
    border-radius: 18px;
    padding-bottom: 24px;
    transform: translate(-50%, -46%) scale(0.96);
    opacity: 0;
    transition: transform 0.35s var(--ease), opacity 0.25s;
  }
  dialog.sheet.open .sheet-panel { transform: translate(-50%, -50%); opacity: 1; }
  /* En pantallas grandes la hoja alta se muestra arriba (no al centro) para que un
     teclado en pantalla (iPad) no la tape. */
  dialog.sheet.large .sheet-panel { top: max(48px, 10vh); bottom: auto; transform: translate(-50%, 16px) scale(0.96); }
  dialog.sheet.large.open .sheet-panel { transform: translate(-50%, 0); }
  dialog.sheet.large .pin-head { padding-top: 4px; }
  .sheet-grabber { display: none; }
  .sheet-panel { padding-top: 14px; }
}

/* Alerta (confirmaciones) */
dialog.alert {
  border: 0;
  padding: 0;
  width: min(300px, calc(100% - 48px));
  border-radius: 16px;
  background: var(--material-thick);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  color: var(--label);
  box-shadow: var(--shadow-float);
  text-align: center;
  overflow: hidden;
  opacity: 0;
  transform: scale(1.08);
  transition: opacity 0.2s, transform 0.25s var(--ease);
}
dialog.alert.open { opacity: 1; transform: none; }
dialog.alert.has-input { margin-top: max(72px, 18vh); }
dialog.alert::backdrop { background: var(--backdrop); }
.alert-body { padding: 20px 16px 16px; }
.alert-body h3 { font-size: 17px; font-weight: 600; line-height: 1.3; }
.alert-body p { font-size: 13px; line-height: 1.4; margin-top: 4px; letter-spacing: -0.008em; }
.alert-body .field { margin-top: 12px; height: 36px; font-size: 15px; background: var(--surface); }
.alert-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; box-shadow: 0 -0.5px 0 var(--separator); }
.alert-actions button { height: 44px; border: 0; background: none; color: var(--accent); font-size: 17px; }
.alert-actions button + button { box-shadow: -0.5px 0 0 var(--separator); }
.alert-actions button:hover { background: var(--fill-2); }
.alert-actions button.primary { font-weight: 600; }
.alert-actions button.destructive { color: #e5243b; }
.alert-actions button:disabled { color: var(--label-3); cursor: default; background: none; }

/* ---------- PIN ---------- */
.pin-head { text-align: center; padding: 8px 0 4px; }
.pin-head .avatar { margin: 0 auto 12px; }
.pin-head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.pin-head p { color: var(--label-2); font-size: 15px; margin-top: 4px; }
.pin-boxes { position: relative; display: flex; justify-content: center; gap: 12px; margin: 24px auto 8px; width: max-content; }
.pin-boxes .box {
  width: 52px;
  height: 60px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--separator);
  display: grid;
  place-items: center;
  transition: box-shadow 0.15s;
}
.pin-boxes .box::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--label); transform: scale(0); transition: transform 0.18s var(--ease); }
.pin-boxes .box.filled::after { transform: scale(1); }
.pin-boxes .box.active { box-shadow: inset 0 0 0 2px var(--accent); }
.pin-boxes input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  font-size: 16px;
  caret-color: transparent;
  color: transparent;
  background: transparent;
}
.pin-boxes.error { animation: shake 0.42s; }
.pin-boxes.error .box { box-shadow: inset 0 0 0 2px #e5243b; }
.pin-msg { min-height: 20px; text-align: center; font-size: 13px; color: var(--label-2); }
.pin-msg.error { color: #e5243b; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* ---------- Aviso flotante (HUD) ---------- */
.toast-host { position: fixed; top: calc(12px + var(--safe-top)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 18px;
  border-radius: 980px;
  background: var(--material-thick);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-float), inset 0 0 0 0.5px var(--separator);
  font-size: 15px;
  font-weight: 500;
  animation: toast-in 0.45s var(--ease);
}
.toast .i { font-size: 18px; }
.toast.ok .i { color: var(--green); }
.toast.err .i { color: #e5243b; }
.toast.out { animation: toast-out 0.3s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px) scale(0.96); } }

/* ---------- Varios ---------- */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; opacity: 0.7; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; min-height: 50dvh; color: var(--label-3); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.toolbar .count { margin-left: auto; font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.stack-12 > * + * { margin-top: 12px; }
.mt-28 { margin-top: 28px; }
.muted { color: var(--label-2); }
.nowrap { white-space: nowrap; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.88em; padding: 1px 5px; border-radius: 5px; background: var(--fill); letter-spacing: 0; }
.pairs-arrow { color: var(--label-3); font-size: 13px; }
.you { color: var(--accent); font-weight: 600; font-size: 13px; }

@media (max-width: 420px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .pin-boxes .box { width: 48px; height: 56px; }
  .picker { max-width: 52%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
