:root {
  --bg: #0a0f1f;
  --bg2: #111a35;
  --card: #151f3d;
  --card2: #1b2750;
  --line: rgba(255, 255, 255, .09);
  --txt: #f3f6ff;
  --mut: #8f9bbd;
  --lime: #c6ff3d;
  --ink: #0a0f1f;
  --red: #ff5c7a;
  --blue: #2f6bff;
  --court: #1a4fd6;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --r: 26px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--txt); overscroll-behavior: none; }
body {
  font: 500 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

#app {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  background:
    radial-gradient(120% 60% at 50% -10%, #1d2f6b 0%, transparent 60%),
    radial-gradient(80% 50% at 100% 100%, #14305e55 0%, transparent 60%),
    var(--bg);
}

/* ---------- en-tête ---------- */
.top {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--safe-t) + 12px) 16px 6px;
}
.team-pill {
  display: flex; align-items: center; gap: 8px; max-width: 62%;
  padding: 7px 12px 7px 8px; border-radius: 999px; background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line); font-weight: 700;
}
.team-pill .dot4 { width: 22px; height: 22px; flex: none; }
.team-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balls { display: flex; align-items: center; gap: 4px; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); font-weight: 800; font-size: 14px; }
.ball { width: 16px; height: 16px; border-radius: 50%; background: var(--lime); box-shadow: inset -2px -2px 0 rgba(0,0,0,.18); position: relative; flex: none; }
.ball.used { background: transparent; border: 2px solid rgba(255,255,255,.28); box-shadow: none; }

/* ---------- vues ---------- */
#view { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 0 14px calc(92px + var(--safe-b)); }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll::-webkit-scrollbar, .welcome::-webkit-scrollbar, .sheet::-webkit-scrollbar { display: none; }
.welcome, .sheet { scrollbar-width: none; }

.h-title { font-size: 26px; font-weight: 900; letter-spacing: -.02em; }
.h-sub { color: var(--mut); font-size: 14px; margin-top: 2px; }

/* ---------- dock ---------- */
.dock {
  position: fixed; left: 14px; right: 14px; bottom: calc(10px + var(--safe-b)); z-index: 20;
  display: flex; padding: 6px; border-radius: 28px; gap: 4px;
  background: rgba(21, 31, 61, .82); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.dock button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px;
  border-radius: 22px; color: var(--mut); font-size: 11px; font-weight: 800; letter-spacing: .02em; position: relative;
  transition: background .2s, color .2s;
}
.dock button svg { width: 24px; height: 24px; }
.dock button.on { background: var(--lime); color: var(--ink); }
.dock .badge {
  position: absolute; top: 4px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 900; display: grid; place-items: center;
}

/* ---------- rail « mes matchs » ---------- */
.rail { flex: none; display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.chip-match {
  flex: none; display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line); text-align: left;
}
.chip-match.full { background: linear-gradient(135deg, #234a1d, #2b5f1a); border-color: #5fbf3c66; }
.chip-match.gone { border-color: var(--red); }
.chip-match b { display: block; font-size: 13px; font-weight: 900; }
.chip-match small { color: var(--mut); font-size: 12px; font-weight: 700; }
.pips { display: flex; gap: 3px; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.2); }
.pip.on { background: var(--lime); }

/* ---------- deck ---------- */
.deck-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.deck { position: relative; flex: 1; min-height: 0; perspective: 900px; }
.card {
  position: absolute; inset: 0 0 4px 0; display: flex; flex-direction: column; padding: 16px 16px 14px;
  border-radius: var(--r); border: 1px solid var(--line);
  background: linear-gradient(170deg, var(--card2) 0%, var(--card) 55%, #101937 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  touch-action: none; will-change: transform; transform-origin: 50% 90%;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s;
}
.card.drag { transition: none; }
.card[data-depth="1"] { transform: translateY(14px) scale(.95); opacity: .85; pointer-events: none; }
.card[data-depth="2"] { transform: translateY(28px) scale(.90); opacity: .55; pointer-events: none; }
.card[data-depth="3"] { transform: translateY(40px) scale(.85); opacity: 0; pointer-events: none; }
.card.fly { transition: transform .32s ease-in, opacity .32s; }

.c-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); font-weight: 900; font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
}
.day.soon { background: var(--lime); color: var(--ink); }
.price { font-weight: 900; font-size: 15px; color: var(--lime); }
.price small { color: var(--mut); font-weight: 700; }
.c-time { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 2px; }
.c-time .t { font-size: clamp(54px, 17vw, 76px); font-weight: 900; letter-spacing: -.04em; line-height: .95; font-variant-numeric: tabular-nums; }
.c-time .e { color: var(--mut); font-weight: 800; font-size: 15px; }

/* terrain */
.court-box { flex: 1; min-height: 0; display: grid; place-items: center; margin: 4px 0; }
.court { position: relative; height: 100%; max-height: 100%; aspect-ratio: 5 / 6.4; max-width: 100%; }
.court svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.spot { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 3px; width: 25%; }
.spot[data-i="0"] { left: 27%; top: 24%; } .spot[data-i="1"] { left: 73%; top: 24%; }
.spot[data-i="2"] { left: 27%; top: 76%; } .spot[data-i="3"] { left: 73%; top: 76%; }
.av {
  width: clamp(40px, 15vw, 58px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  font-size: clamp(20px, 7.5vw, 29px); border: 3px solid rgba(255, 255, 255, .92); box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
  position: relative; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
.av.ghost { opacity: .5; border: 3px dashed rgba(255, 255, 255, .7); box-shadow: none; }
.av.me { box-shadow: 0 0 0 3px var(--lime), 0 6px 16px rgba(0,0,0,.35); }
.av.empty { background: rgba(255, 255, 255, .06) !important; border: 3px dashed rgba(255, 255, 255, .35); box-shadow: none; font-size: 22px; color: rgba(255,255,255,.6); animation: pulse 1.8s infinite; }
.av .jk { position: absolute; right: -6px; top: -6px; font-size: 14px; }
.spot .nm { font-size: 11px; font-weight: 800; background: rgba(8, 12, 28, .62); padding: 1px 7px; border-radius: 9px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); } }
@keyframes pulse { 50% { opacity: .45; } }

.c-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.c-foot .club { font-weight: 900; font-size: 17px; line-height: 1.15; }
.c-foot .meta { color: var(--mut); font-size: 13px; font-weight: 700; margin-top: 2px; }
.need { padding: 8px 12px; border-radius: 14px; background: rgba(198, 255, 61, .14); color: var(--lime); font-weight: 900; font-size: 13px; white-space: nowrap; }
.need.hot { background: var(--lime); color: var(--ink); }

.stamp {
  position: absolute; top: 74px; padding: 6px 14px; border: 4px solid; border-radius: 14px; font-weight: 900; font-size: 26px;
  letter-spacing: .04em; opacity: 0; pointer-events: none; z-index: 5;
}
.stamp.yes { left: 16px; color: var(--lime); border-color: var(--lime); transform: rotate(-12deg); }
.stamp.no { right: 16px; color: var(--red); border-color: var(--red); transform: rotate(12deg); }

.actions { flex: none; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 16px 0 4px; }
.btn-round { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: var(--card2); border: 1px solid var(--line); transition: transform .12s; }
.btn-round:active { transform: scale(.9); }
.btn-round svg { width: 28px; height: 28px; }
.btn-round.no { color: var(--red); }
.btn-round.yes { width: 82px; height: 82px; background: var(--lime); color: var(--ink); box-shadow: 0 10px 30px rgba(198, 255, 61, .35); }
.btn-round.yes svg { width: 38px; height: 38px; }
.btn-round.small { width: 44px; height: 44px; color: var(--mut); }
.btn-round.small svg { width: 20px; height: 20px; }
.btn-round[disabled] { opacity: .3; pointer-events: none; }

.empty-state { flex: 1; display: grid; place-content: center; text-align: center; gap: 12px; padding: 20px; }
.empty-state .big { font-size: 64px; animation: bounce 2s infinite; }
.empty-state h3 { font-size: 22px; font-weight: 900; }
.empty-state p { color: var(--mut); max-width: 300px; margin: 0 auto; }
@keyframes bounce { 50% { transform: translateY(-10px); } }
.shimmer { height: 8px; width: 160px; margin: 0 auto; border-radius: 4px; background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(198,255,61,.6), rgba(255,255,255,.08)); background-size: 200% 100%; animation: sh 1.2s linear infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- boutons génériques ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 16px 18px; border-radius: 20px;
  background: var(--lime); color: var(--ink); font-weight: 900; font-size: 17px; transition: transform .12s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: rgba(255, 255, 255, .08); color: var(--txt); border: 1px solid var(--line); }
.btn.danger { background: rgba(255, 92, 122, .14); color: var(--red); }
.btn.wa { background: #25d366; color: #052e16; }
.btn.sm { padding: 11px 14px; font-size: 14px; border-radius: 14px; width: auto; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* ---------- semaine (peinture) ---------- */
.paint-head { flex: none; padding-bottom: 8px; }
.quota-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 8px; }
.quota-row label { font-weight: 800; font-size: 13px; color: var(--mut); }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: rgba(255,255,255,.07); }
.seg button { min-width: 38px; height: 34px; border-radius: 12px; font-weight: 900; color: var(--mut); display: grid; place-items: center; }
.seg button.on { background: var(--lime); color: var(--ink); }
.presets { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
.presets button { flex: none; padding: 8px 13px; border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid var(--line); font-weight: 800; font-size: 13px; }
.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 30px repeat(7, 1fr); grid-template-rows: 26px repeat(16, 1fr); gap: 3px; touch-action: none; }
.grid .dh { display: grid; place-items: center; font-weight: 900; font-size: 12px; color: var(--mut); border-radius: 8px; }
.grid .dh.today { color: var(--ink); background: var(--lime); }
.grid .hh { display: grid; place-items: center; font-size: 10px; font-weight: 800; color: var(--mut); font-variant-numeric: tabular-nums; }
.cell {
  border-radius: 7px; background: rgba(255, 255, 255, .05); display: grid; place-items: center; font-size: 10px; font-weight: 900;
  color: rgba(255, 255, 255, .5); position: relative; transition: background .08s, transform .08s;
}
.cell[data-h="1"] { background: rgba(47, 107, 255, .22); }
.cell[data-h="2"] { background: rgba(47, 107, 255, .38); }
.cell[data-h="3"] { background: rgba(47, 107, 255, .55); }
.cell[data-h="4"], .cell[data-h="5"], .cell[data-h="6"], .cell[data-h="7"], .cell[data-h="8"] { background: rgba(47, 107, 255, .75); }
.cell.on { background: var(--lime); color: var(--ink); transform: scale(.96); }
.cell.on.hot { box-shadow: 0 0 0 2px #fff, 0 0 16px 2px rgba(198, 255, 61, .8); z-index: 1; }
.legend { flex: none; display: flex; gap: 14px; justify-content: center; padding: 8px 0 0; color: var(--mut); font-size: 12px; font-weight: 700; flex-wrap: wrap; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; }
.saved { font-size: 12px; font-weight: 800; color: var(--lime); opacity: 0; transition: opacity .3s; }
.saved.show { opacity: 1; }

/* ---------- équipe ---------- */
.section { margin-top: 18px; }
.section h3 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); font-weight: 900; margin-bottom: 8px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.row .av { width: 44px; font-size: 22px; border-width: 2px; animation: none; flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row b { display: block; font-weight: 800; }
.row small { color: var(--mut); font-weight: 700; font-size: 12px; }
.row .warn { color: #ffb347; }
.toggle { width: 50px; height: 30px; border-radius: 15px; background: rgba(255,255,255,.15); position: relative; transition: background .2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--lime); }
.toggle.on::after { transform: translateX(20px); background: var(--ink); }
.emojis { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emojis button { aspect-ratio: 1; border-radius: 14px; background: rgba(255,255,255,.06); font-size: 22px; border: 2px solid transparent; }
.emojis button.on { border-color: var(--lime); background: rgba(198, 255, 61, .15); }
.field { width: 100%; padding: 15px 16px; border-radius: 18px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); font-size: 17px; font-weight: 700; outline: none; }
.field:focus { border-color: var(--lime); }
.field-label { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--mut); font-weight: 900; margin: 14px 0 6px; }

/* ---------- accueil / onboarding ---------- */
.welcome { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(var(--safe-t) + 24px) 20px calc(20px + var(--safe-b)); overflow-y: auto; }
.welcome > * { flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 30px; font-weight: 900; letter-spacing: -.03em; }
.logo svg { width: 38px; height: 38px; }
.hero { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 14px 0; }
.hero h1 { font-size: clamp(32px, 9.5vw, 44px); line-height: 1.04; font-weight: 900; letter-spacing: -.035em; }
.hero h1 em { font-style: normal; color: var(--lime); }
.hero p { color: var(--mut); font-size: 16px; max-width: 340px; }
.mini-court { position: relative; width: 150px; height: 192px; margin: 2px 0; align-self: center; }
.mini-court .av { width: 44px; font-size: 22px; }
.mini-court .nm { display: none; }
.stack-btns { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; }
.steps { display: grid; gap: 10px; margin-top: 4px; }
.step { display: flex; align-items: center; gap: 12px; color: var(--txt); font-weight: 700; font-size: 15px; }
.step i { font-style: normal; flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; background: rgba(198,255,61,.14); color: var(--lime); font-weight: 900; }
.back { align-self: flex-start; margin-bottom: 10px; color: var(--mut); font-weight: 800; padding: 8px 0; }

/* ---------- sheet / overlay / toast ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(4, 7, 18, .6); opacity: 0; transition: opacity .25s; }
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto;
  padding: 10px 18px calc(22px + var(--safe-b)); border-radius: 30px 30px 0 0;
  background: linear-gradient(180deg, #1c2a56, #121b3a); border-top: 1px solid var(--line);
  transform: translateY(105%); transition: transform .32s cubic-bezier(.2, .9, .2, 1);
}
.sheet.show { transform: none; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 0 auto 14px; }
.sheet .court-box { height: 250px; flex: none; }
.sheet h2 { font-size: 24px; font-weight: 900; letter-spacing: -.02em; }
.sheet .sub { color: var(--mut); font-weight: 700; margin: 3px 0 4px; }
.sheet .stack-btns { padding-top: 10px; }
.note { padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .07); font-weight: 700; font-size: 14px; margin-top: 10px; }
.note.ok { background: rgba(198, 255, 61, .14); color: var(--lime); }
.note.bad { background: rgba(255, 92, 122, .14); color: var(--red); }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); z-index: 60; transform: translate(-50%, 20px); opacity: 0;
  background: #fff; color: var(--ink); padding: 12px 18px; border-radius: 16px; font-weight: 800; max-width: 88vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: all .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); color: #fff; }

.celebrate { position: fixed; inset: 0; z-index: 70; display: grid; place-content: center; text-align: center; gap: 10px; background: rgba(8, 12, 28, .86); animation: fade .25s; }
.celebrate h2 { font-size: 40px; font-weight: 900; letter-spacing: -.03em; color: var(--lime); }
.celebrate p { color: var(--txt); font-weight: 700; font-size: 18px; }
.celebrate .big { font-size: 80px; animation: bounce 1s infinite; }
.confetti { position: fixed; top: -20px; width: 10px; height: 16px; z-index: 71; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes fade { from { opacity: 0; } }

.install { margin-top: 10px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--lime); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 560px) {
  #app { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .dock { left: 50%; right: auto; width: 452px; transform: translateX(-50%); }
  .sheet { left: 50%; right: auto; width: 480px; transform: translate(-50%, 105%); }
  .sheet.show { transform: translate(-50%, 0); }
}
@media (max-height: 640px) {
  .c-time .t { font-size: 48px; }
  .btn-round.yes { width: 70px; height: 70px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
