/* Padelistas — estilo RNR: plano y limpio tipo Keynote.
   Fondo blanco, tinta casi negra, acento verde y líneas finas. */

:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --soft: #F6F7F6;
  --chip: #F1F3F2;
  --ink: #0B0F0C;
  --muted: #5B6660;
  --line: #E2E6E3;
  --line-strong: #CDD3CF;
  --accent: #1E8F55;
  --accent-dark: #17754A;
  --accent-bright: #5FD38D;
  --accent-soft: #EAF4EE;
  --danger: #B3261E;
  --radius: 6px;
  --radius-sm: 4px;
  --sans: "Inter", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.02em; }
h1 { font-size: clamp(30px, 7vw, 40px); line-height: 1.05; }
h2 { font-size: 20px; letter-spacing: -0.01em; }

.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.rule { width: 40px; height: 3px; background: var(--accent); margin: 14px 0 0; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.form-error { margin: 0; color: var(--danger); font-size: 14px; }
.form-error:empty { display: none; }

/* ---------- Marca ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand img { border-radius: var(--radius-sm); }

/* ---------- Botones ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 600 14px/1 var(--sans);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
a.btn { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--outline { border-color: var(--line-strong); background: transparent; }
.btn--outline:hover { border-color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--soft); }
.btn--danger { background: transparent; color: var(--danger); }
.btn--danger:hover { background: #FBEDEC; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; height: 46px; font-size: 15px; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft); color: var(--ink); }

/* ---------- Formularios ---------- */
.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > span, .field > legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  padding: 0;
  margin-bottom: 6px;
}
.field > span { margin-bottom: 0; }
input[type="text"], input[type="tel"], input[type="password"], input[type="date"], input[type="time"], input[type="search"] {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 15px var(--sans);
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--accent); outline: 1px solid var(--accent); }
.search { height: 38px; font-size: 14px; margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { margin-bottom: 40px; }
.login-card h1 { font-size: clamp(36px, 10vw, 44px); }
.login-card .rule { margin: 18px 0 18px; }
.lede { font-size: 16px; color: var(--muted); margin: 0 0 28px; }
.login-form { border-top: 1px solid var(--line); padding-top: 24px; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: 600 14px var(--sans);
  padding: 8px 10px;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.me { display: flex; align-items: center; gap: 6px; }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--ink);
  font: 700 12px var(--sans);
  letter-spacing: .02em;
}
.avatar.is-me { background: var(--accent); color: #fff; }
.avatar-btn { border: 0; cursor: pointer; padding: 0; }
.avatar-btn:hover { background: var(--accent-dark); }

/* ---------- Página ---------- */
.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 16px 96px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 28px;
}
.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 13px var(--sans);
  padding: 8px 16px;
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button.is-active { background: var(--ink); color: #fff; }
.segmented--block { display: flex; margin-bottom: 4px; }
.segmented--block button { flex: 1; padding: 10px 16px; }

.section { margin-bottom: 40px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.section-head .num { color: var(--accent); font-weight: 800; font-size: 20px; letter-spacing: -0.01em; }
.count { margin-left: auto; font: 600 13px var(--sans); color: var(--muted); }

.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }

/* ---------- Tarjeta de partido ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-top {
  display: flex;
  gap: 14px;
  padding: 16px 16px 12px;
  align-items: flex-start;
}
.datebox {
  flex: none;
  width: 54px;
  text-align: center;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.datebox .m {
  display: block;
  background: var(--ink);
  color: #fff;
  font: 700 10px/1 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 5px 0 4px;
}
.datebox .d {
  display: block;
  font: 800 24px/1.1 var(--sans);
  letter-spacing: -0.02em;
  padding: 5px 0 6px;
}
.card-meta { flex: 1; min-width: 0; }
.card-title { font-size: 17px; line-height: 1.25; margin: 0 0 6px; letter-spacing: -0.01em; }
.card-title .rel { color: var(--accent); }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 14px; }
.meta-row span { display: inline-flex; align-items: center; gap: 5px; }
.meta-row strong { color: var(--ink); font-weight: 600; }
.meta-row svg { color: var(--accent); }

.pill {
  flex: none;
  font: 700 11px var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  white-space: nowrap;
}
.pill--ok { color: var(--accent); }
.pill--warn { color: var(--ink); }
.pill--muted { color: var(--muted); }

.slots {
  list-style: none;
  margin: 0;
  padding: 4px 16px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.slot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  border: 1px solid var(--line);
  min-width: 0;
}
.slot .avatar { width: 28px; height: 28px; font-size: 11px; }
.slot-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .you { color: var(--accent); font-weight: 600; font-size: 12px; }
.slot .remove { width: 24px; height: 24px; font-size: 16px; }
.slot--empty {
  border-style: dashed;
  border-color: var(--line-strong);
  background: transparent;
  color: var(--muted);
  justify-content: center;
  font: 600 13px var(--sans);
  cursor: pointer;
  width: 100%;
}
.slot--empty:hover { color: var(--accent); border-color: var(--accent); }
.slot--empty:disabled { cursor: default; }
.slot--empty:disabled:hover { color: var(--muted); border-color: var(--line-strong); }

.card-actions {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.card-actions .spacer { flex: 1; }
.card.is-past { opacity: .8; }

/* ---------- Vacío ---------- */
.empty {
  padding: 32px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.empty h3 { font-size: 20px; color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 0 0 16px; }

/* ---------- Tabla de jugadores ---------- */
.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.player-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.player-list li:last-child { border-bottom: 0; }
.player-list li.head {
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
}
.player-list .info { flex: 1; min-width: 0; }
.player-list .name { font-weight: 600; }
.player-list .phone { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.player-list .stats { font-size: 12px; color: var(--muted); }
.player-list .stats b { color: var(--accent); font-weight: 700; }

/* ---------- Selector de pista ---------- */
.court-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.court-opt {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  font: 600 14px var(--sans);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.court-opt:hover { border-color: var(--ink); }
.court-opt.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- Selector de jugadores ---------- */
.player-picker {
  display: grid;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.pick {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: 14px var(--sans);
  text-align: left;
  cursor: pointer;
}
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--soft); }
.pick .avatar { width: 30px; height: 30px; font-size: 11px; }
.pick .pick-name { flex: 1; font-weight: 600; }
.pick .check {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 13px;
}
.pick.is-selected { background: var(--accent-soft); }
.pick.is-selected .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick .add-label { color: var(--accent); font-weight: 600; font-size: 13px; }
.pick:disabled { opacity: .4; cursor: default; }
.pick:disabled:hover { background: transparent; }
.pick-empty { padding: 16px; margin: 0; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Diálogos ---------- */
.sheet {
  width: min(520px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(11, 15, 12, .12);
}
.sheet::backdrop { background: rgba(11, 15, 12, .45); }
.sheet-body { display: grid; gap: 18px; padding: 24px 20px 20px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 22px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
#add-subtitle { margin: -6px 0 0; font-size: 14px; }

@media (max-width: 560px) {
  .sheet {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92dvh;
  }
  .sheet-body { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .court-picker { grid-template-columns: 1fr 1fr; }
  .topbar-inner { gap: 8px; }
  .topbar .brand span { display: none; }
  .tabs { margin-left: 0; }
  .player-list li { flex-wrap: wrap; }
  .player-list .info { flex-basis: calc(100% - 44px); }
  .player-list li .btn { flex: 1; }
  .player-list li .btn:first-of-type { margin-left: 44px; }
  #new-match-btn {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 5;
    height: 50px;
    padding: 0 20px;
    box-shadow: 0 2px 8px rgba(11, 15, 12, .18);
  }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-left: 3px solid var(--accent-bright);
  border-radius: var(--radius-sm);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: calc(100% - 32px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-left-color: #F28B82; }

/* ---------- Telarañas ---------- */
.cobweb-layer { position: fixed; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
.cobweb {
  position: absolute;
  width: var(--s);
  height: var(--s);
  color: var(--muted);
  opacity: .75;
  pointer-events: none;
  animation: web-in .8s ease-out;
}
.cobweb--tl { top: 0; left: 0; }
.cobweb--tr { top: 0; right: 0; transform: scaleX(-1); }
.cobweb--bl { bottom: 0; left: 0; transform: scaleY(-1); }
.cobweb--br { bottom: 0; right: 0; transform: scale(-1, -1); }
.cobweb--hang {
  top: 54px;
  height: auto;
  margin-left: calc(var(--s) / -2);
  transform-origin: 50% 0;
  animation: web-in .8s ease-out, web-swing 6s ease-in-out infinite alternate;
}
.cobweb--hang svg { display: block; height: auto; }

body.stick-mode .cobweb { pointer-events: auto; cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M29 3 9 23' stroke='%238B5A2B' stroke-width='3.5' stroke-linecap='round'/%3E%3Cpath d='M9 23 3 29M9 23l-3 7M9 23l-7 3M9 23l-1 8M9 23l-8 1' stroke='%23C9A227' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") 4 28, pointer; }
body.stick-mode .cobweb:hover { color: var(--accent); opacity: 1; }
body.stick-mode { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M29 3 9 23' stroke='%238B5A2B' stroke-width='3.5' stroke-linecap='round'/%3E%3Cpath d='M9 23 3 29M9 23l-3 7M9 23l-7 3M9 23l-1 8M9 23l-8 1' stroke='%23C9A227' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") 4 28, auto; }
.cobweb.is-sweeping { pointer-events: none; animation: web-sweep .55s ease-in forwards; }

@keyframes web-in { from { opacity: 0; } }
@keyframes web-swing { from { rotate: -3deg; } to { rotate: 3deg; } }
@keyframes web-sweep {
  30% { rotate: -12deg; }
  to { rotate: 25deg; translate: 60px -40px; scale: .3; opacity: 0; }
}

.stick-btn.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.cobweb-chip {
  position: fixed;
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 21;
  margin: 0;
  max-width: calc(100% - 200px);
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 560px) {
  .stick-btn span { display: none; }
  .stick-btn { padding: 0 8px; }
  .cobweb-chip { bottom: calc(22px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .cobweb, .cobweb--hang { animation: none; }
}

/* ---------- Invitaciones ---------- */
.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}
.card.is-invite { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.invite {
  margin: 0 16px 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}
.invite p { margin: 0; flex: 1 1 220px; font-size: 14px; }
.invite-actions { display: flex; gap: 6px; }
.slot--pending { background: transparent; border-style: dashed; }
.slot--pending .avatar { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); }
.slot--pending .slot-name { color: var(--muted); }
.pending-label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.pending-label svg { width: 11px; height: 11px; }
