/* =====================================================================
   Pique de pareja
   Marcador de estadio: cada uno tiene su color (rojo y azul), el dorado
   solo marca rangos, premios y lo que pide atención. Todo lo demás es tinta
   sobre hormigón, con filetes en vez de tarjetas.
   ===================================================================== */

@font-face {
  font-family: 'Big Shoulders Display';
  font-weight: 700; font-style: normal; font-display: swap;
  src: url('../fonts/big-shoulders-display-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Big Shoulders Display';
  font-weight: 900; font-style: normal; font-display: swap;
  src: url('../fonts/big-shoulders-display-latin-900-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Sans';
  font-weight: 400; font-style: normal; font-display: swap;
  src: url('../fonts/instrument-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Sans';
  font-weight: 600; font-style: normal; font-display: swap;
  src: url('../fonts/instrument-sans-latin-600-normal.woff2') format('woff2');
}

:root {
  --page: #E7E9EE;
  --field: #F5F6F9;
  --ink: #15172B;
  --muted: #565B72;
  --line: #C7CBD7;
  --line-strong: #8B90A6;

  --me: #D42F23;
  --me-text: #B72418;
  --other: #2346D8;
  --other-text: #2346D8;
  --gold: #F5B700;
  --danger: #B3261E;
  --ok: #17703F;
  --focus: #2346D8;

  --r1: #B4763B;
  --r2: #9EA5B3;
  --r3: #F5B700;
  --r4: #46B4BA;
  --r5: #4A8FF0;
  --r6: #A24CE8;

  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0F1120;
    --field: #181B30;
    --ink: #F1F2F8;
    --muted: #A2A8C2;
    --line: #2B2F4B;
    --line-strong: #565C7E;

    --me-text: #FF8073;
    --other-text: #93A7FF;
    --danger: #E5544A;
    --ok: #58C98B;
    --focus: #93A7FF;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 17px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top);
}
#app { min-height: 100dvh; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- Estructura ---------- */
.shell { max-width: 560px; margin: 0 auto; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.screen { padding: 18px 16px 8px; }
.band { padding: 22px 0; border-top: 1px solid var(--line); }
.band.first { border-top: 0; padding-top: 6px; }
.band.accent {
  margin: 0 -16px; padding: 20px 16px;
  border-top: 0; border-left: 6px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 20%, transparent);
}
.band.status { border-top: 0; border-left: 5px solid var(--gold); padding: 4px 0 4px 14px; margin: 24px 0; }
.band.status h2 { margin-bottom: 4px; }
.band.status p { margin: 4px 0 12px; }
.band.status .btn { margin-top: 4px; }

/* ---------- Tipografía ---------- */
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
h1.brand {
  font: 900 clamp(60px, 19vw, 100px)/0.86 var(--display);
  letter-spacing: -0.005em; margin: 18px 0 12px;
}
h2 { font: 700 28px/1.05 var(--display); margin-bottom: 10px; letter-spacing: 0.005em; }
h3 { font: 600 17px/1.3 var(--body); }
h4 { font: 600 15px/1.3 var(--body); margin-bottom: 6px; }
p { margin: 0.5em 0; }
.lede { font-size: 19px; line-height: 1.4; margin: 0 0 18px; max-width: 30em; }
.kicker { color: var(--muted); font-size: 15px; margin: 2px 0 12px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14.5px; margin: 6px 0 12px; }
.hint.center { text-align: center; }
.hint.pad { padding: 0 0 12px; }
.center { text-align: center; }
.empty { color: var(--muted); margin: 8px 0 16px; }
.footer { text-align: center; font-size: 13px; margin: 8px 0 24px; }
.ok-line { color: var(--ok); font-weight: 600; }
.notice {
  background: color-mix(in srgb, var(--gold) 24%, transparent);
  padding: 12px 14px; border-radius: 8px; margin: 12px 0;
}

/* ---------- Botones ---------- */
.btn {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 13px 22px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: var(--ink); color: var(--page);
  font: 600 17px/1.1 var(--body); text-decoration: none; text-align: center;
  cursor: pointer; transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 42px; padding: 9px 16px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn.busy { opacity: 0.6; }
.link {
  appearance: none; background: none; border: 0; padding: 12px 0;
  color: var(--ink); font: 600 16px var(--body); text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer;
}
.link.small { font-size: 14.5px; padding: 8px 0; font-weight: 400; color: var(--muted); }
.icon-btn {
  appearance: none; display: grid; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: none; color: var(--ink); cursor: pointer;
}
.icon-btn.round { border: 2px solid var(--ink); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.icon { display: inline-flex; line-height: 0; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.actions.row { flex-direction: row; flex-wrap: wrap; margin-top: 10px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Formularios ---------- */
label { display: block; font-weight: 600; font-size: 15px; margin: 16px 0 6px; }
input, textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink);
  background: var(--field); border: 1.5px solid var(--line-strong);
  border-radius: 10px; padding: 12px 14px;
}
textarea { resize: vertical; min-height: 84px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:focus-visible, textarea:focus-visible { outline-offset: 1px; border-color: var(--ink); }
input:disabled { opacity: 0.5; }
.form .btn { margin-top: 16px; }
.form .btn.wide { margin-top: 20px; }
.inline-form { display: flex; gap: 8px; align-items: center; width: 100%; flex-wrap: wrap; }
.inline-form input { flex: 1 1 180px; }
.inline-form.stack { flex-direction: column; align-items: stretch; }
.code-input { text-transform: uppercase; letter-spacing: 0.12em; font: 700 24px var(--display); text-align: center; }
.code {
  font: 900 clamp(56px, 17vw, 84px)/1 var(--display); letter-spacing: 0.04em;
  text-align: center; margin: 22px 0 8px;
}

/* ---------- Pantalla de entrada ---------- */
.auth { padding-top: 0; }
.auth .band { padding: 24px 0; }
.brand-strip { display: grid; grid-template-columns: 1fr 1fr; height: 12px; margin: 0 -16px; }
.brand-strip span:first-child { background: var(--me); }
.brand-strip span:last-child { background: var(--other); }
.auth .link { display: block; margin: 12px auto 24px; }

/* ---------- Barra inferior ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--page); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 60px; padding: 10px 2px 8px;
  color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 600;
}
.tab.active { color: var(--ink); box-shadow: inset 0 3px 0 var(--ink); }
.tab-icon { position: relative; display: inline-flex; }
.tab-dot {
  position: absolute; top: -3px; right: -6px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--gold); border: 2px solid var(--page);
}

/* ---------- Marcador (inicio) ---------- */
.versus { display: grid; grid-template-columns: 1fr 1fr; margin: 0 -16px; }
.side { display: flex; flex-direction: column; min-height: 218px; padding: 16px 16px 16px; color: #fff; min-width: 0; }
.side.me { background: var(--me); }
.side.other { background: var(--other); }
.side-name { font: 700 27px/1 var(--display); overflow-wrap: anywhere; }
.side-total {
  margin-top: auto; padding-top: 14px;
  font: 900 clamp(80px, 26vw, 128px)/0.8 var(--display);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.side-rank { margin-top: 12px; font-weight: 600; font-size: 17px; }
.side-next { font-size: 14px; opacity: 0.92; }

.tug { display: grid; gap: 3px; height: 12px; margin: 3px 0 0; }
.tug span { display: block; }
.tug-me { background: var(--me); transform-origin: left center; animation: tug-in 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.tug-other { background: var(--other); transform-origin: right center; animation: tug-in 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes tug-in { from { transform: scaleX(0); } }

.verdict { font: 700 27px/1.1 var(--display); margin: 16px 0 4px; }
.breakdown { font-size: 14px; margin: 4px 0 0; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.goal { display: flex; align-items: center; gap: 4px; padding: 10px 0; }
.goal-text { flex: 1; overflow-wrap: anywhere; padding: 4px 0; }
.goal.editing { display: block; }
.goal-list { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip {
  appearance: none; background: transparent; color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  padding: 8px 14px; font: 400 15px var(--body); cursor: pointer;
}

.extra { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; }
.extra-pts { font: 900 42px/0.95 var(--display); min-width: 58px; font-variant-numeric: tabular-nums; }
.extra-pts.me { color: var(--me-text); }
.extra-pts.other { color: var(--other-text); }
.extra-who { margin: 0; font-weight: 600; }
.extra-note { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.extras + .btn, .empty + .btn { margin-top: 8px; }

.ladder { list-style: none; margin: 12px 0 0; padding: 0; }
.ladder-row {
  display: grid; grid-template-columns: 14px auto 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.ladder-row:last-child { border-bottom: 0; }
.ladder-name { font: 700 24px/1 var(--display); }
.ladder-min { font-size: 14px; }
.ladder-who { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.who { font-size: 12.5px; font-weight: 600; color: #fff; padding: 3px 8px; border-radius: 4px; }
.who.me { background: var(--me); }
.who.other { background: var(--other); }

.rank-dot { display: inline-block; width: 13px; height: 13px; border-radius: 50%; background: var(--line-strong); flex: none; }
.rank-dot.r1 { background: var(--r1); } .rank-dot.r2 { background: var(--r2); }
.rank-dot.r3 { background: var(--r3); } .rank-dot.r4 { background: var(--r4); }
.rank-dot.r5 { background: var(--r5); } .rank-dot.r6 { background: var(--r6); }
.rank-mark { display: inline-flex; align-items: center; gap: 10px; font: 700 28px/1 var(--display); }
.rank-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.rank-state { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.rank-state.open { color: var(--ok); }

/* ---------- Deseos ---------- */
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  border: 2px solid var(--ink); border-radius: 999px; padding: 3px; margin: 2px 0 6px;
}
.seg-btn {
  appearance: none; background: none; border: 0; border-radius: 999px;
  min-height: 42px; padding: 8px 6px; color: var(--ink);
  font: 600 15px/1.15 var(--body); cursor: pointer;
}
.seg-btn[aria-selected='true'] { background: var(--ink); color: var(--page); }
.wish { display: flex; gap: 10px 12px; align-items: flex-start; flex-wrap: wrap; padding: 14px 0; }
.wish-main { flex: 1 1 200px; min-width: 0; }
.wish-text { margin: 0; font-weight: 600; overflow-wrap: anywhere; white-space: pre-line; }
.wish-meta { margin: 4px 0 0; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.wish-meta.error { color: var(--danger); }
.wish-link { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; overflow-wrap: anywhere; }
.wish-meta.strong { color: var(--ink); font-weight: 600; }
.wish-actions { display: flex; gap: 2px; align-items: center; flex: 0 0 auto; flex-wrap: wrap; margin-left: auto; }
.wish.editing { display: block; }
.muted-list .wish-text { font-weight: 400; color: var(--muted); }

/* ---------- Cuestionario y resultados ---------- */
.questions { list-style: none; margin: 8px 0 0; padding: 0; }
.question { padding: 20px 0 22px; border-top: 1px solid var(--line); }
.question:first-child { border-top: 0; }
.q-count { margin: 0; font-size: 14px; }
.q-title { font: 700 30px/1.05 var(--display); margin: 4px 0 6px; overflow-wrap: anywhere; }
.q-ask { margin: 0 0 4px; color: var(--muted); }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.scale-btn {
  appearance: none; min-height: 54px; border-radius: 8px; cursor: pointer;
  border: 2px solid var(--line-strong); background: var(--field); color: var(--ink);
  font: 700 28px/1 var(--display); font-variant-numeric: tabular-nums;
}
.scale-btn[aria-checked='true'] { background: var(--ink); border-color: var(--ink); color: var(--page); }
.comment { margin-top: 8px; }
.comment textarea { min-height: 64px; }
.submit-bar {
  position: sticky; bottom: calc(66px + env(safe-area-inset-bottom));
  background: var(--page); border-top: 1px solid var(--line); padding: 12px 0 4px; margin-top: 8px;
}
.progress { margin: 0 0 10px; font-weight: 600; }

.result { padding: 18px 0; border-top: 1px solid var(--line); }
.result:first-child { border-top: 0; }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.result-head h3 { font: 700 24px/1 var(--display); }
.result-headline { margin: 0; font-weight: 600; }
.result-score { display: grid; grid-template-columns: 1fr 1fr; margin: 12px -16px 4px; }
.rs { display: flex; flex-direction: column; padding: 12px 16px 14px; color: #fff; min-width: 0; }
.rs.me { background: var(--me); }
.rs.other { background: var(--other); }
.rs-name { font: 700 20px/1 var(--display); overflow-wrap: anywhere; }
.rs-num { font: 900 60px/0.95 var(--display); font-variant-numeric: tabular-nums; margin-top: 6px; }
.rs-bonus { font-size: 13.5px; opacity: 0.92; }
.result.pending .hint { margin-top: 4px; }
.more { margin-top: 8px; }
.more summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.answers { margin: 8px 0 14px; }
.answer { display: flex; gap: 14px; padding: 9px 0; }
.answer-score { font: 700 32px/1 var(--display); min-width: 36px; font-variant-numeric: tabular-nums; }
.answer-goal { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.answer-comment { margin: 2px 0 0; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }

/* ---------- Puntos extra (hoja) ---------- */
.stepper { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 10px 0 2px; }
.stepper-num { font: 900 92px/1 var(--display); min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Hoja inferior ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 28, 0.52); }
.sheet-panel {
  position: relative; width: 100%; max-width: 560px; max-height: 90dvh; overflow: auto;
  background: var(--page); border-radius: 18px 18px 0 0;
  padding: 6px 18px calc(22px + env(safe-area-inset-bottom));
  animation: sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet.closing .sheet-panel { transform: translateY(100%); transition: transform 0.16s ease-in; }
.sheet.closing .sheet-backdrop { opacity: 0; transition: opacity 0.16s ease-in; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; }
.sheet-head h2 { margin: 0; }
.sheet-text { white-space: pre-line; overflow-wrap: anywhere; margin: 8px 0 0; }

/* ---------- Avisos y carga ---------- */
#toasts {
  position: fixed; z-index: 100; left: 12px; right: 12px;
  top: calc(env(safe-area-inset-top) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  max-width: 520px; padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--page); font-weight: 600; font-size: 15.5px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { opacity: 0; transition: opacity 0.35s ease; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }

.loading { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 60dvh; color: var(--muted); font-weight: 600; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line-strong); border-top-color: var(--ink);
  animation: spin 0.8s linear infinite;
}
.spinner.small { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

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