/* P&P Stats · mobile-first. © 2026 Jordi Sain */
:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --text: #17231b;
  --muted: #5f6f64;
  --line: #d9e1d6;
  --brand: #1f5f3f;
  --brand-ink: #ffffff;
  --accent: #c8e86b;
  --on: #1f5f3f;
  --on-ink: #ffffff;
  --team-a: #2463a6;
  --team-b: #b5502a;
  --ok: #1d7a43;
  --bad: #a33b2b;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4d00;
  --radius: 14px;
  --tap: 46px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1612; --surface: #17211b; --surface-2: #1f2c24; --text: #e7efe9; --muted: #9db0a3;
    --line: #2c3b31; --brand: #2f7d55; --on: #8fd16a; --on-ink: #0f1612; --accent: #8fd16a;
    --team-a: #6aa8ec; --team-b: #f08d63; --ok: #6fd391; --bad: #f08a7a; --warn-bg: #3a3014; --warn-ink: #f3d68a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
@media (prefers-color-scheme: dark) { a { color: var(--on); } }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.container { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; }

/* ---- barra superior */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--brand); color: var(--brand-ink);
}
.brand { color: inherit; font-weight: 700; text-decoration: none; }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.topbar .icon-btn { color: var(--brand-ink); }
.sync { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-ink); text-decoration: none; font-size: .85rem; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #9fb3a6; }
.sync[data-state="ok"] .sync-dot { background: var(--accent); }
.sync[data-state="syncing"] .sync-dot { background: #ffd34d; animation: pulse 1s infinite; }
.sync[data-state="offline"] .sync-dot, .sync[data-state="nologin"] .sync-dot, .sync[data-state="noconfig"] .sync-dot { background: #c9d1cb; }
.sync[data-state="error"] .sync-dot { background: #ff7b6b; }
@keyframes pulse { 50% { opacity: .35; } }
body.scoring .topbar { display: none; } /* en el campo, toda la pantalla para anotar */
body.scoring .credits { display: none; }
.credits { text-align: center; color: var(--muted); font-size: .75rem; padding: 8px 0 20px; }

/* ---- botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; }
.btn:disabled { opacity: .4; }
.btn.danger, .icon-btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap);
  border: 0; background: transparent; color: var(--text); font-size: 1.2rem; text-decoration: none; border-radius: 12px; cursor: pointer;
}
.icon-btn.small { min-width: 40px; min-height: 40px; font-size: 1rem; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- tarjetas y formularios */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.form .field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }
input, select {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; /* 16px: evita el zoom de iOS */
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; gap: 8px; }
.player-input { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.me-radio { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; color: var(--muted); font-size: .9rem; }
.me-radio input { width: 20px; min-height: 20px; }
.team-block { border-left: 3px solid var(--line); padding-left: 10px; margin-bottom: 10px; }
.team-block .tag { margin-bottom: 6px; }
.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 12px; border-radius: 10px; font-size: .9rem; }
.warn a { color: inherit; font-weight: 600; }

/* ---- chips (selectores grandes para el pulgar) */
.chips { display: flex; gap: 6px; }
.chips.wrap { flex-wrap: wrap; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; scroll-snap-type: x proximity; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: var(--tap); min-width: var(--tap); padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  scroll-snap-align: start; touch-action: manipulation;
}
.chip.num { flex: 1 1 0; min-width: 0; padding: 0; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--on); border-color: var(--on); color: var(--on-ink); }
.chip:disabled { opacity: .3; }

.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.team-A { background: color-mix(in srgb, var(--team-a) 18%, transparent); color: var(--team-a); }
.tag.team-B { background: color-mix(in srgb, var(--team-b) 18%, transparent); color: var(--team-b); }
.tag.gir { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.tag.nogir { background: var(--surface-2); color: var(--muted); }

/* ---- inicio */
.hero { margin: 8px 0 16px; }
.section-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.rounds { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.round { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 6px 10px 14px; }
.round-main { flex: 1; min-width: 0; text-decoration: none; color: var(--text); }
.round-course { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.round-score { display: grid; justify-items: end; font-variant-numeric: tabular-nums; }
.round-score strong { font-size: 1.25rem; }
.empty { padding: 8px 0; }

/* ---- anotación */
.hole-head { display: flex; align-items: center; gap: 8px; padding-top: env(safe-area-inset-top); }
.hole-title { flex: 1; min-width: 0; }
.hole-number { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.hole-title .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hole-meta { text-align: right; font-variant-numeric: tabular-nums; }
.hole-meta strong { font-size: 1.25rem; }
.hole-strip { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 10px -16px 12px; padding: 0 16px; }
.hole-strip::-webkit-scrollbar { display: none; }
.dot {
  flex: 0 0 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); text-decoration: none; border: 1px solid transparent;
}
.dot.done { background: color-mix(in srgb, var(--on) 25%, transparent); color: var(--text); }
.dot.current { border-color: var(--on); background: var(--on); color: var(--on-ink); }
.field.wind { margin-bottom: 12px; }
.field.wind .chips { flex-wrap: wrap; }
.field.wind .chip { flex: 1 1 calc(50% - 6px); font-size: .9rem; }
.players { display: grid; gap: 10px; }
.player { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.player .field { margin-top: 10px; }
.player-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.player-name { font-weight: 700; font-size: 1.05rem; margin-right: auto; }
.toggle {
  width: 100%; margin-top: 10px; min-height: var(--tap); border-radius: 12px; border: 1px dashed var(--line);
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.toggle.on { border-style: solid; border-color: var(--on); background: color-mix(in srgb, var(--on) 15%, transparent); color: var(--text); }
.team-summary { margin-top: 10px; display: grid; gap: 6px; }
.team-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.team-row strong { font-size: 1.2rem; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px; margin: 12px 0; }
.total { display: grid; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; font-variant-numeric: tabular-nums; }
.total.me { outline: 2px solid var(--on); }
.total span:first-child { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.total strong { font-size: 1.2rem; }
.hole-nav {
  position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 2fr; gap: 8px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 25%);
}
.hole-nav .btn { min-height: 56px; }

/* ---- alta de recorrido */
.holes-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.holes-table th, .holes-table td { padding: 3px 4px; text-align: left; }
.holes-table th { font-size: .8rem; color: var(--muted); }
.holes-table td:first-child { width: 3.5em; font-weight: 600; }
.holes-table input { min-height: 40px; }

/* ---- aviso */
#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; font-size: .95rem;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- GPS en nueva partida */
.geo-btn { width: 100%; margin-bottom: 14px; }
.geo-line { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .95rem; }
.geo-line.warn { background: var(--warn-bg); }
.warn-inline { color: var(--warn-ink); background: var(--warn-bg); padding: 0 4px; border-radius: 4px; font-size: .9rem; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; font-size: .9rem; }
.check input { width: 20px; min-height: 20px; margin-top: 1px; flex: none; }
.link { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

/* ---- barra inferior */
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
body.scoring { padding-bottom: env(safe-area-inset-bottom); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; min-height: 56px;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600;
}
.tabbar a span { font-size: 1.3rem; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabbar a.on { color: var(--brand); }
.tabbar a.on span { filter: none; opacity: 1; }
@media (prefers-color-scheme: dark) { .tabbar a.on { color: var(--on); } }
body.scoring .tabbar { display: none; } /* anotando, toda la pantalla para el hoyo */
#toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---- campos */
.page-title { font-size: 1.4rem; margin: 6px 0 10px; }
.course-sub { margin: -6px 0 12px; }
.back { display: inline-block; margin: 4px 0 2px; text-decoration: none; font-weight: 600; }
.search input { margin-bottom: 8px; }
.chips.prov { margin-bottom: 10px; }
.course-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.course-row {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.course-main { flex: 1; min-width: 0; }
.course-name { font-weight: 700; }
.course-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.course-side { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.course-side span { font-size: 1.4rem; }
.card h3 { font-size: 1rem; margin: 0 0 8px; }
.card h3:not(:first-child) { margin-top: 14px; }
.card > p { margin: 0 0 8px; }
#play { margin-bottom: 12px; }
.kv { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.kv li { display: flex; justify-content: space-between; gap: 12px; }
.kv a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes { white-space: pre-wrap; }
textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; resize: vertical;
}
.form .field .muted.small { display: block; margin-top: 4px; }
.tee-block { margin-bottom: 14px; }
.tee-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.scorecard-wrap { overflow-x: auto; margin-bottom: 6px; }
.scorecard { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .82rem; }
.scorecard th, .scorecard td { padding: 4px 2px; text-align: center; border-bottom: 1px solid var(--line); }
.scorecard th { text-align: left; color: var(--muted); font-weight: 600; width: 2.6em; }
.scorecard tr:first-child td { font-weight: 700; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.stat { display: grid; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-variant-numeric: tabular-nums; }
.stat strong { font-size: 1.5rem; }
.mini-rounds { list-style: none; margin: 8px 0 0; padding: 0; }
.mini-rounds a { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.scorecard { table-layout: fixed; }
.btn.waze { background: #33ccff; border-color: #33ccff; color: #0b1f2a; }
