/* =========================================================
   GolfTrack — DA « Precision Fairway GPS »
   ========================================================= */

:root {
  --canvas: #F5F6F2;
  --card: #FFFFFF;
  --line: #DCE2DC;
  --chip: #E9EFEB;
  --slate: #111713;
  --slate-2: #1D4D3F;
  --ink: #111713;
  --muted: #677169;
  --muted-2: #A8B8AC;
  --primary: #111713;
  --primary-dark: #000000;
  --green: #111713;
  --ok: #123F32; /* vert : uniquement pour « très bon contact » et « GPS OK » */
  --green-ink: #111713;
  --green-soft: #E9EFEB;
  --red: #B91C1C;
  --red-ink: #B91C1C;
  --red-soft: #FEE2E2;
  --amber: #A8B8AC;
  --amber-soft: #E9EFEB;
  --wedge-soft: #E9EFEB;
  --wedge-ink: #111713;
  --shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
  --display: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --body: 'Lexend', ui-sans-serif, system-ui, sans-serif;
  --tabbar-h: 56px;
  --actions-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--body);
  font-size: 13px;
  line-height: 19px;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button:active { transform: scale(0.975); }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

h1, h2 { font-family: var(--display); margin: 0; }

/* ---------- En-tête ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  background: rgba(250, 250, 250, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 4px; }
.brand-name { font-family: var(--display); font-size: 16px; font-weight: 600; line-height: 21px; letter-spacing: -0.01em; }
.brand-sub { font-family: var(--display); font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; }
.appbar-right { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
}

.gps-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 29px; padding: 0 9px;
  border-radius: 999px;
  background: var(--chip);
  font-family: var(--display); font-weight: 600; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.gps-pill.ok .pulse, .hud-chip.ok .pulse { animation: breathe 1.8s ease-in-out infinite; }
.gps-pill.meh .pulse { background: var(--amber); }
.gps-pill.bad .pulse, .gps-pill.wait .pulse { background: var(--red); }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(127, 127, 127, 0.55); } 50% { box-shadow: 0 0 0 5px rgba(127, 127, 127, 0); } }

/* ---------- Écrans ---------- */
main { padding: 9px 12px calc(var(--tabbar-h) + 19px + env(safe-area-inset-bottom, 0px)); }
body.playing main { padding-bottom: calc(var(--tabbar-h) + var(--actions-h) + 19px + env(safe-area-inset-bottom, 0px)); }
.screen { display: flex; flex-direction: column; gap: 12px; }

.eyebrow {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--display); font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  color: var(--muted);
}
.eyebrow svg { width: 16px; height: 16px; }
.eyebrow.green { color: var(--primary); }
.eyebrow.light { color: var(--muted-2); }
.muted { color: var(--muted); margin: 0; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-top: 4px; }
.section-head h2 { font-size: 18px; line-height: 26px; font-weight: 500; letter-spacing: -0.01em; }
.soft-pill { background: var(--chip); color: var(--muted); font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: 999px; }

.card { background: var(--card); border: 1.5px solid var(--line); border-radius: 4px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 9px; }

/* ---------- Cartouche télémétrie (HUD) ---------- */
.hud {
  position: relative;
  overflow: hidden;
  background:
    repeating-radial-gradient(circle at 92% 8%, transparent 0 46px, rgba(127, 127, 127, 0.10) 47px 48px, transparent 49px 92px),
    linear-gradient(160deg, #1D4D3F 0%, #111713 70%);
  border: 1px solid var(--slate-2);
  border-radius: 4px;
  padding: 12px;
  color: #fff;
  display: flex; flex-direction: column; gap: 11px;
}
.hud.compact { gap: 6px; padding: 11px 12px; }
.hud-chip {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.14);
  color: #FFFFFF;
  font-family: var(--display); font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  white-space: nowrap;
}
.hud-chip.warn { background: rgba(245, 158, 11, 0.16); color: #FFFFFF; }
.hud-chip.warn .pulse { background: var(--amber); }
.hud-chip.bad { background: rgba(239, 68, 68, 0.16); color: #FCA5A5; }
.hud-chip.bad .pulse { background: var(--red); }
.hud-title { font-size: 22px; line-height: 33px; letter-spacing: -0.02em; }
.hud-text { margin: -5px 0 0; color: #DCE2DC; }

.hud-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hole { display: flex; align-items: center; gap: 9px; min-width: 0; }
.hole-badge {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 4px;
  background: var(--primary);
  font-family: var(--display); font-size: 19px; font-weight: 600;
}
.hole-badge.dark { background: var(--slate-2); color: #FFFFFF; }
.hole-badge.round { width: 31px; height: 31px; border-radius: 50%; background: var(--green); }
.hole-badge.round svg { width: 18px; height: 18px; }
.hole-title { font-family: var(--display); font-size: 18px; font-weight: 600; line-height: 24px; white-space: nowrap; }
.hole-sub { font-family: var(--display); font-size: 13px; font-weight: 500; color: var(--muted-2); letter-spacing: 0.02em; }

.pods { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 6px; }
.pod {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 8px 5px;
  text-align: center;
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0;
}
.pod .k { font-family: var(--display); font-size: 10px; font-weight: 600; letter-spacing: 0.08em; color: #DCE2DC; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod .v { font-family: var(--display); font-size: 19px; font-weight: 600; line-height: 28px; font-variant-numeric: tabular-nums; }
.pod .v small { font-size: 13px; color: #FFFFFF; margin-left: 1px; }
.pod.main { background: rgba(127, 127, 127, 0.32); border-color: rgba(127, 127, 127, 0.45); padding: 8px 4px; }
.pod.main .k { color: #FFFFFF; }
.pod.main .v { font-size: 28px; line-height: 43px; letter-spacing: -0.03em; }
.pod.main .v small { font-size: 15px; }
.pod.main .v.wait { font-size: 17px; line-height: 43px; color: #DCE2DC; letter-spacing: 0; }

.hero-metric { display: flex; align-items: baseline; gap: 9px; }
.hero-metric .big { font-family: var(--display); font-size: 32px; line-height: 50px; font-weight: 600; letter-spacing: -0.03em; color: #FFFFFF; }
.hero-metric .big small { font-size: 15px; }

.shot-strip { list-style: none; margin: 0; padding: 0; display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.shot-strip::-webkit-scrollbar { display: none; }
.shot-strip li { flex: none; }
.shot-strip li button, .shot-strip li.empty {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 29px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px; color: #DCE2DC;
}
.shot-strip li b { font-family: var(--display); color: #FFFFFF; }
.shot-strip li.empty { background: transparent; border: 1px dashed rgba(255, 255, 255, 0.2); color: var(--muted-2); }
.shot-strip .manual-mark { font-style: normal; color: #FFFFFF; font-size: 11px; }
.shot-strip .add-mark { font-style: normal; color: var(--muted-2); font-size: 11px; border: 1px dashed rgba(255, 255, 255, 0.3); border-radius: 999px; padding: 0 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.q1 { background: var(--red); } .dot.q2 { background: var(--amber); } .dot.q3 { background: var(--green); }

/* ---------- Grille des clubs ---------- */
.club-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.club {
  position: relative;
  min-height: 78px;
  padding: 9px 5px 8px;
  border-radius: 4px;
  background: var(--card);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  text-align: center;
}
.club .badge {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 4px;
  background: var(--chip);
  color: var(--ink);
  font-family: var(--display); font-size: 15px; font-weight: 600;
}
.club .badge svg { width: 20px; height: 20px; }
.club.wood .badge { background: var(--green-soft); color: var(--green-ink); }
.club.wedge .badge { background: var(--wedge-soft); color: var(--wedge-ink); }
.club .name { font-family: var(--display); font-size: 15px; font-weight: 600; line-height: 19px; letter-spacing: 0.01em; white-space: nowrap; }
.club .avg { font-family: var(--display); font-size: 12px; font-weight: 500; color: var(--muted); line-height: 12px; font-variant-numeric: tabular-nums; min-height: 13px; }
.club.last { background: var(--slate); border: 2px solid var(--green); color: #fff; box-shadow: 0 0 0 2px rgba(127, 127, 127, 0.25); }
.club.last .name { color: #FFFFFF; }
.club.last .avg { color: #A8B8AC; }
.club.last .badge { background: var(--slate-2); color: #FFFFFF; }

/* ---------- Boutons ---------- */
.btn-primary, .btn-secondary {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--display); font-size: 15px; font-weight: 600;
  width: 100%;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px rgba(127, 127, 127, 0.6); }
.btn-secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.35; }
.count-pill { background: rgba(255, 255, 255, 0.22); padding: 2px 8px; border-radius: 999px; font-size: 13px; }

.play-actions {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  z-index: 9;
  display: grid; grid-template-columns: 1fr 1.7fr; gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(to top, var(--canvas) 70%, rgba(250, 250, 250, 0));
}
.play-actions .btn-secondary { background: var(--card); font-size: 14px; }
.play-actions .btn-primary { font-size: 14px; }

/* ---------- Barre de navigation ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--display); font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--muted);
}
.tabbar button.on { color: var(--primary); }
.tabbar svg { width: 20px; height: 20px; }

/* ---------- Conseil ---------- */
.tip { display: flex; gap: 9px; align-items: flex-start; background: var(--chip); border-radius: 4px; padding: 12px; }
.tip-icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 4px; background: #DCE2DC; color: var(--primary-dark); }
.tip p { margin: 4px 0 0; color: #3D3D3D; }
.steps { margin: 5px 0 0; padding-left: 14px; color: #3D3D3D; display: flex; flex-direction: column; gap: 4px; }

/* ---------- Écran d'évaluation ---------- */
.eval {
  position: fixed; inset: 0; z-index: 30;
  overflow-y: auto;
  background: var(--canvas);
  padding: calc(6px + env(safe-area-inset-top, 0px)) 12px calc(19px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 11px;
  animation: slide 0.18s ease-out;
}
@keyframes slide { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.eval-top { display: flex; align-items: center; gap: 8px; }
.eval-top .icon-btn { background: var(--chip); color: var(--ink); }
.eval-top-label { font-family: var(--display); font-weight: 500; color: var(--muted); }
.eval-coords { display: flex; justify-content: space-between; gap: 6px; font-family: var(--display); font-size: 13px; font-weight: 500; color: #DCE2DC; font-variant-numeric: tabular-nums; }
.eval-coords b { color: #FFFFFF; }
.eval-question { font-size: 21px; line-height: 31px; font-weight: 500; letter-spacing: -0.02em; margin-top: -5px; }

.quality-list { display: flex; flex-direction: column; gap: 9px; }
.quality {
  min-height: 69px;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: 4px;
  text-align: left;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow);
}
.q-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 4px; }
.q-icon svg { width: 24px; height: 24px; stroke-width: 2.6; }
.q-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.q-text b { font-family: var(--display); font-size: 17px; line-height: 22px; font-weight: 600; }
.q-text small { font-size: 13px; line-height: 15px; }
.quality.q1 { background: var(--red-soft); color: var(--red-ink); }
.quality.q1 .q-icon { background: var(--red-ink); color: #fff; }
.quality.q2 { background: #E9EFEB; color: var(--ink); }
.quality.q2 .q-icon { background: var(--wedge-soft); color: var(--ink); }
.quality.q2 small { color: var(--muted); }
.quality.q3 { background: var(--primary); color: #fff; }
.quality.q3 .q-icon { background: #FFFFFF; color: var(--slate); }
.quality-list.busy .quality { opacity: 0.45; pointer-events: none; }
.quality-list.busy .quality.picked { opacity: 1; outline: 3px solid var(--slate); outline-offset: 2px; }

/* ---------- Mon sac ---------- */
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; background: #E9EFEB; border-radius: 4px; margin-top: -6px; }
.segmented button { min-height: 40px; border-radius: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
.segmented button.on { background: var(--card); color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }

#bag-stats { display: flex; flex-direction: column; gap: 8px; }
.club-stat { background: var(--card); border: 1.5px solid var(--line); border-radius: 4px; padding: 11px 12px; box-shadow: var(--shadow); }
.club-stat.best { border-color: rgba(127, 127, 127, 0.55); background: linear-gradient(90deg, #fff 55%, #F5F6F2); }
.club-stat .row1 { display: flex; align-items: center; gap: 6px; }
.club-stat .cname { font-family: var(--display); font-size: 16px; font-weight: 600; }
.tag { font-size: 10px; font-weight: 500; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.tag.best { background: var(--primary-dark); color: #fff; }
.tag.out { background: transparent; border: 1px dashed var(--muted-2); color: var(--muted); }
.club-stat.out { background: var(--canvas); border-style: dashed; box-shadow: none; }
.club-stat.out .cname { color: var(--muted); }
.club-stat .row1 { align-items: center; }
.club-stat .cleft { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.club-stat .right { margin-left: auto; display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.club-stat .max { font-family: var(--display); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; color: var(--muted); }
.club-stat .val { font-family: var(--display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.club-stat .val small { font-size: 13px; color: var(--muted); }
.bar { height: 9px; border-radius: 999px; background: var(--chip); margin: 8px 0 6px; overflow: hidden; }
.bar div { height: 100%; border-radius: 999px; background: var(--primary-dark); }
.club-stat .row3 { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
.club-stat .row3 b { color: var(--primary-dark); font-weight: 500; }
.club-stat.nodata .val { color: var(--muted-2); font-size: 15px; }

.bag-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.bag-item { min-height: 40px; border-radius: 4px; border: 1.5px solid var(--line); background: var(--chip); color: var(--muted); font-family: var(--display); font-weight: 600; font-size: 13px; }
.bag-item.on { background: var(--slate); border-color: var(--green); color: #FFFFFF; }

/* ---------- Historique ---------- */
.section-head.first { margin-top: 0; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history li { display: flex; align-items: center; gap: 9px; background: var(--card); border: 1.5px solid var(--line); border-radius: 4px; padding: 11px 12px; box-shadow: var(--shadow); }
.history .h-date { font-family: var(--display); font-size: 15px; font-weight: 600; }
.history .h-meta { font-size: 12px; color: var(--muted); }
.history .h-main { flex: 1; min-width: 0; }
.history .h-score { text-align: right; font-family: var(--display); font-size: 17px; font-weight: 600; color: var(--primary-dark); line-height: 21px; }
.history .h-score small { display: block; font-size: 10px; color: var(--muted); font-weight: 500; letter-spacing: 0.04em; }
.history .del { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); background: var(--chip); }
.history .del svg { width: 16px; height: 16px; }
.live-tag { display: inline-block; vertical-align: middle; margin-left: 5px; font-family: var(--body); font-size: 10px; font-weight: 500; text-transform: none; padding: 2px 6px; border-radius: 999px; background: var(--green-soft); color: var(--green-ink); }
.empty-state { text-align: center; color: var(--muted); padding: 25px 12px; background: var(--card); border: 1.5px dashed var(--line); border-radius: 4px; }

/* ---------- Feuille de confirmation ---------- */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.5); display: flex; align-items: flex-end; }
.sheet {
  width: 100%;
  background: var(--canvas);
  border-radius: 4px 4px 0 0;
  padding: 17px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 9px;
  animation: slide 0.18s ease-out;
}
.sheet h2 { font-size: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; z-index: 50; pointer-events: none;
  bottom: calc(var(--tabbar-h) + var(--actions-h) + 12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: var(--slate); color: #fff;
  padding: 9px 14px; border-radius: 999px;
  font-family: var(--display); font-weight: 600; font-size: 13px;
  white-space: nowrap; max-width: calc(100% - 32px);
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.5);
}
.toast .dot { width: 9px; height: 9px; }

@media (min-width: 600px) {
  main, .eval { max-width: 560px; margin: 0 auto; }
  .club-grid { grid-template-columns: repeat(4, 1fr); }
}
