/* ── Fléchettes — feuille de style commune (accueil, salon, mobile) ──────── */

:root {
  --bg: #0e1216;
  --bg-soft: #141a21;
  --panel: #1a222b;
  --panel-2: #212b36;
  --line: #2b3743;
  --text: #f2efe6;
  --muted: #93a3b3;
  --green: #3fb96b;
  --green-dark: #2a8a4e;
  --red: #e04b3c;
  --gold: #f2b544;
  --blue: #4aa3e0;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;

  /* Zones sûres iOS : encoche, barre d'état et indicateur d'accueil.
     Passer par des variables permet aussi de les simuler en développement. */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #1b2a24 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.02em; }
p { margin: 0; }
button { font: inherit; color: inherit; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(20px + var(--sat)) calc(16px + var(--sar)) calc(48px + var(--sab)) calc(16px + var(--sal));
}

/* ── En-tête ─────────────────────────────────────────────────────────────── */

.masthead { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.masthead .logo { width: 38px; height: 38px; flex: none; }
.masthead h1 { font-size: 1.35rem; }
.masthead .sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }

/* ── Blocs ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card > h2 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 12px;
}

.hint { color: var(--muted); font-size: .82rem; margin-top: 8px; line-height: 1.45; }

/* ── Contrôles segmentés ─────────────────────────────────────────────────── */

.seg { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

.seg button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
}

.seg button:active { transform: scale(.98); }
.seg button strong { display: block; font-size: 1rem; }
.seg button span { display: block; color: var(--muted); font-size: .75rem; margin-top: 3px; line-height: 1.3; }
.seg button[aria-pressed="true"] { border-color: var(--green); background: #1c2f25; }
.seg button[aria-pressed="true"] strong { color: var(--green); }

/* ── Joueurs ─────────────────────────────────────────────────────────────── */

.row { display: flex; gap: 8px; }

input[type="text"] {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 14px;
  font-size: 1rem;
  min-width: 0;
}

input[type="text"]:focus { outline: 2px solid var(--green-dark); outline-offset: 1px; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background .12s, transform .08s;
}

.btn:active { transform: scale(.97); }
a.btn { text-decoration: none; color: var(--text); }
a { color: var(--green); }
.btn.primary { background: var(--green-dark); border-color: var(--green); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.block { width: 100%; display: block; text-align: center; }

.players { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }

.players li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.players .idx {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.players .name { flex: 1; font-weight: 600; }
.players .rm { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.players .rm:hover { color: var(--red); }

.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: .9rem; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }

/* ── Salon (code + QR) ───────────────────────────────────────────────────── */

.lobby-code {
  font-size: 3.4rem;
  font-weight: 800;
  letter-spacing: .22em;
  text-align: center;
  color: var(--gold);
  margin: 4px 0 2px;
  text-indent: .22em;
}

.qr {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  width: 190px;
  margin: 14px auto 6px;
  display: block;
}

.qr svg { display: block; width: 100%; height: auto; }

.links { display: grid; gap: 8px; margin-top: 14px; }

.link-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: .85rem;
  color: var(--muted);
  word-break: break-all;
}

.error { color: var(--red); font-size: .9rem; margin-top: 10px; min-height: 1.2em; }

/* ── Écran de jeu (mobile) ───────────────────────────────────────────────── */

.play {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(10px + var(--sat)) calc(12px + var(--sar)) calc(18px + var(--sab)) calc(12px + var(--sal));
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100vh;
}

/* En web app iOS, la page passe sous la barre d'état : on garde la première
   ligne cliquable et lisible sous l'heure et l'indicateur de batterie. */
.topbar { min-height: 34px; }

.topbar { display: flex; align-items: center; gap: 10px; font-size: .78rem; color: var(--muted); }
.topbar .code { font-weight: 800; letter-spacing: .14em; color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .btn { padding: 6px 10px; font-size: .76rem; white-space: nowrap; }
.topbar #rules { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }

.scoreboard {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.scoreboard.waiting { opacity: .75; }
.scoreboard .who { font-size: 1.05rem; font-weight: 700; }
.scoreboard .who .badge { color: var(--gold); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.scoreboard .score { font-size: 4.6rem; font-weight: 800; line-height: 1; margin: 4px 0 2px; letter-spacing: -.04em; }
.scoreboard .meta { color: var(--muted); font-size: .8rem; }

.darts { display: flex; justify-content: center; gap: 8px; margin: 12px 0 4px; }

.dart {
  min-width: 62px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  padding: 8px 6px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(0, 0, 0, .18);
}

.dart.filled { border-style: solid; border-color: var(--green-dark); color: var(--text); background: #1a2b21; }
.dart.void { border-color: var(--line); color: var(--muted); text-decoration: line-through; }
.dart.bust { border-color: var(--red); color: var(--red); background: #2a1715; }

.reco { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.reco .label { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.reco .route { font-size: 1.5rem; font-weight: 800; color: var(--gold); margin-top: 2px; }
.reco .note { font-size: .75rem; color: var(--muted); margin-top: 2px; }

/* ── Pavé de saisie ──────────────────────────────────────────────────────── */

.keypad { display: grid; gap: 8px; }

.quick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }

.quick button {
  background: #23303b;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 2px;
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
}

.mults { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.mults button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 4px;
  font-weight: 800;
  letter-spacing: .08em;
  cursor: pointer;
}

.mults button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #20170a; }

.numbers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }

.numbers button, .specials button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px 0;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .06s, background .1s;
}

.numbers button:active, .specials button:active, .quick button:active { transform: scale(.95); background: var(--green-dark); }

.specials { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.specials .miss { color: var(--red); }
.specials .bull { color: var(--gold); }

.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; }
.tools .btn { padding: 11px 6px; font-size: .84rem; }

.keypad.locked { opacity: .35; pointer-events: none; filter: grayscale(.5); }

.waitline { text-align: center; color: var(--gold); font-weight: 700; padding: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--sab));
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: .85rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 50;
  max-width: 92vw;
  text-align: center;
}

.toast.show { opacity: 1; }
.toast.bad { border-color: var(--red); color: #ffd7d3; }

/* ── Liste des scores (mobile) ───────────────────────────────────────────── */

.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.standings li {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: .92rem;
}

.standings li.active { border-left-color: var(--gold); background: #1f2630; }
.standings li.done { border-left-color: var(--green); color: var(--muted); }
.standings li.out { opacity: .45; }
.standings .n { flex: 1; font-weight: 600; }
.standings .s { font-weight: 800; font-size: 1.05rem; }
.standings .rk { font-size: .72rem; color: var(--green); font-weight: 700; }

@media (max-width: 380px) {
  .scoreboard .score { font-size: 3.8rem; }
  .numbers button, .specials button { padding: 13px 0; font-size: 1.05rem; }
}
