/* ===== Escala general (igual que todo designtech.uy) =====
   Los tamaños están en rem: esto achica textos, tarjetas y márgenes en
   proporción (PC 70%, tablet 80%, celular 90%). */
html { font-size: 70%; }
@media (max-width: 1024px) { html { font-size: 80%; } }
@media (max-width: 600px)  { html { font-size: 90%; } }
/* Botones y campos: el navegador les pone 13.33px fijos; así escalan igual */
:where(button, input, select, textarea) { font-size: .8333rem; }
/* En celular los campos quedan en 16px: con menos, el iPhone hace zoom al tocarlos */
@media (max-width: 600px) { :is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea) { font-size: 16px !important; } }

/* ScoreTech — estilos mobile-first.
   Los colores de marca (--brand, --brand-on-dark, --accent) llegan desde app/config.php.
   El modo oscuro sigue la configuración del celular. */

:root {
  --brand: #0A4A94;
  --brand-on-dark: #6AA8F0;
  --accent: #FD6502;

  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --surface-2: #E9EEF5;
  --text: #0E1726;
  --muted: #5A6578;
  --border: #D8DFE9;
  --primary: var(--brand);
  --on-primary: #FFFFFF;
  --plus: color-mix(in srgb, var(--primary) 13%, var(--surface));
  --success: #15803D;
  --danger: #B91C1C;
  --gold: #B7791F;
  --shadow: 0 1px 2px rgba(14, 23, 38, .06), 0 .25rem 1rem rgba(14, 23, 38, .06);
  --radius: 1.125rem;
  --tap: 3rem;
  --gutter: .75rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220;
    --surface: #131C2E;
    --surface-2: #1E2A42;
    --text: #E8EDF5;
    --muted: #9AA7BD;
    --border: #26324A;
    --primary: var(--brand-on-dark);
    --on-primary: #071226;
    --success: #4ADE80;
    --danger: #F87171;
    --gold: #F6C453;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 .375rem 1.25rem rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font: 1rem/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
/* Logo de fondo como marca de agua, en el color de la marca y muy tenue. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--primary); opacity: .05;
  -webkit-mask: url("../img/logo-fondo.png") center / min(78vw, 32.5rem) no-repeat;
  mask: url("../img/logo-fondo.png") center / min(78vw, 32.5rem) no-repeat;
}
@media (prefers-color-scheme: dark) { body::before { opacity: .07; } }
@media print { body::before { display: none; } }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; line-height: 1.2; }
:focus-visible { outline: .1875rem solid var(--accent); outline-offset: 2px; border-radius: .5rem; }

.skip { position: absolute; left: -62.4375rem; top: .5rem; background: var(--surface); padding: .5rem .75rem; border-radius: .5rem; z-index: 100; }
.skip:focus { left: .5rem; }
.noscript { padding: 1.5rem; text-align: center; }
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: .75rem; color: var(--muted); text-align: center; padding: 1rem; }
.boot img { border-radius: 1.375rem; }
.offline { position: sticky; top: 0; z-index: 40; background: #7C2D12; color: #fff; font-size: .875rem; text-align: center; padding: .5rem var(--gutter); }

/* ---------- estructura ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: calc(.5rem + env(safe-area-inset-top)) var(--gutter) .5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { flex: 1; display: flex; align-items: center; gap: .625rem; min-width: 0; }
.brand img { width: 1.875rem; height: 1.875rem; border-radius: .5rem; }
.brand h1 { font-size: 1.125rem; font-weight: 800; letter-spacing: -.01em; }
main { flex: 1; width: 100%; max-width: 68.75rem; margin: 0 auto; padding: 1rem var(--gutter) 1.5rem; }
.has-bar main { padding: .625rem var(--gutter) .75rem; }
.footer { text-align: center; font-size: .8125rem; color: var(--muted); padding: .5rem var(--gutter) 1.5rem; }
.has-bar .footer { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
.footer a { color: inherit; font-weight: 600; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: 0 1rem;
  border-radius: .875rem; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text);
  font-weight: 700; user-select: none; touch-action: manipulation;
  transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn svg { width: 1.25rem; height: 1.25rem; flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { min-height: 2.5rem; padding: 0 .75rem; font-size: .9375rem; }
.btn-sm svg { width: 1.125rem; height: 1.125rem; }
.btn-lg { min-height: 3.5rem; font-size: 1.125rem; border-radius: 1rem; }
.btn-block { width: 100%; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: .875rem; background: transparent; color: var(--muted);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 1.375rem; height: 1.375rem; }

.input {
  width: 100%; min-height: var(--tap); padding: .625rem .875rem;
  border: 1px solid var(--border); border-radius: .75rem;
  background: var(--surface); font-size: 1rem;
}
.input:focus { border-color: var(--primary); outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 0; }

/* ---------- jugadores ---------- */
.setup { max-width: 32.5rem; margin: 0 auto; display: grid; gap: .75rem; }
.setup h2 { font-size: 1.375rem; margin: .25rem 0 .25rem; }
.names { display: grid; gap: .625rem; }
.name-row { display: flex; align-items: center; gap: .5rem; }
.name-row .idx {
  width: 2rem; flex: none; text-align: center;
  font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums;
}
.name-row .input { flex: 1; min-width: 0; font-size: 1.0625rem; }
.setup .btn-lg { margin-top: .5rem; }
.setup .gap { margin-top: .75rem; }

/* Selector de dos opciones: la elegida queda resaltada. */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; padding: .25rem; background: var(--surface-2); border-radius: 1rem; }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  min-height: var(--tap); padding: 0 .625rem; border: 0; border-radius: .75rem;
  background: transparent; color: var(--muted); font-weight: 700; touch-action: manipulation;
}
.seg button svg { width: 1.125rem; height: 1.125rem; flex: none; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow); }

/* ---------- tanteador ---------- */
/* 2 jugadores por fila en celular, 3 en tablet, 4 en computadora. */
.mode {
  display: flex; align-items: center; justify-content: center; gap: .375rem;
  width: 100%; min-height: 2.5rem; margin: 0 0 .625rem; padding: 0 .75rem;
  border: 1px solid var(--border); border-radius: .75rem; background: var(--surface);
  color: var(--muted); font-size: .875rem; font-weight: 600; touch-action: manipulation;
}
.mode strong { color: var(--text); }
.mode svg { width: 1.125rem; height: 1.125rem; flex: none; color: var(--accent); }
.mode:active { background: var(--surface-2); }

.players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
@media (min-width: 640px) { .players { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; } }
@media (min-width: 1000px) { .players { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.pcard {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: .875rem;
  box-shadow: var(--shadow); padding: .5rem .5rem .5rem .75rem;
}
.pcard::before { content: ""; position: absolute; inset: 0 auto 0 0; width: .25rem; background: var(--c); }
.pcard .head { display: flex; align-items: center; gap: .375rem; min-width: 0; }
.pname { flex: 1; min-width: 0; font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos {
  width: 1.625rem; height: 1.625rem; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c); color: #fff; font-weight: 800; font-size: .75rem; font-variant-numeric: tabular-nums;
}
.pcard.leader { border-color: color-mix(in srgb, var(--gold) 65%, var(--border)); }
.pcard.leader .pos { box-shadow: 0 0 0 2px var(--surface), 0 0 0 .25rem var(--gold); }

.score {
  display: block; text-align: center; margin: .25rem 0 .375rem;
  font-size: 2.125rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.score.bump { animation: bump .3s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }

.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem; }
.steps .btn { min-height: 2.5rem; padding: 0; border-radius: .625rem; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.steps .plus { background: var(--plus); }

.manual { display: flex; gap: .25rem; margin-top: .25rem; }
.manual .input { flex: 1 1 0; min-width: 0; min-height: 2.5rem; padding: .375rem .25rem; border-radius: .625rem; text-align: center; font-weight: 700; font-size: 1rem; }
.manual .btn { flex: none; width: 2.5rem; min-height: 2.5rem; padding: 0; border-radius: .625rem; }
.manual .btn svg { width: 1.25rem; height: 1.25rem; }
/* Celulares muy angostos: el campo ocupa su propia línea y − / + van debajo. */
@media (max-width: 359px) {
  .manual { display: grid; grid-template-columns: 1fr 1fr; }
  .manual .input { grid-column: 1 / -1; }
  .manual .btn { width: auto; }
}

.float {
  position: absolute; right: .625rem; top: 1.875rem; pointer-events: none;
  font-weight: 800; font-size: 1rem; color: var(--success);
  animation: float .85s ease-out forwards;
}
.float.neg { color: var(--danger); }
@keyframes float { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-1.625rem); } }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: .625rem; justify-content: center;
  padding: .5rem var(--gutter) calc(.5rem + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottombar .btn { flex: 1 1 0; min-width: 0; max-width: 16.25rem; min-height: 2.875rem; font-size: .9375rem; }

/* ---------- aviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(4.75rem + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 1rem); opacity: 0; pointer-events: none;
  background: #991B1B; color: #fff; padding: .75rem 1.125rem; border-radius: .875rem;
  font-size: .9375rem; max-width: calc(100% - 2rem); width: max-content; text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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