:root {
  --bg: #f0fdf4;
  --ink: #0f172a;
  --muted: #475569;
  --card: #ffffff;
  --line: #d1fae5;
  --brand: #15803d;
  --brand-dark: #14532d;
  --ours: #2563eb;
  --theirs: #dc2626;
  --you: #facc15;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #c2410c;
  --bad-bg: #ffedd5;
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.screen {
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
}

/* ── Boutons ─────────────────────────────────────────────────────────── */
.btn {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  touch-action: manipulation;
}
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 0 var(--brand-dark); }
.btn.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--brand-dark); }
.btn:disabled { background: #cbd5e1; color: #64748b; box-shadow: none; cursor: default; }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--you); outline-offset: 2px; }

/* ── Accueil ─────────────────────────────────────────────────────────── */
#home { display: flex; align-items: center; }
.home-card {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 10px 30px rgb(20 83 45 / 0.12);
}
.home-logo { display: block; margin: 0 auto; }
h1 { margin: 4px 0 6px; text-align: center; font-size: 1.9rem; color: var(--brand-dark); }
.lead { margin: 0 0 16px; text-align: center; color: var(--muted); }
.how { margin: 0 0 12px; padding-left: 1.3em; }
.how li { margin-bottom: 6px; }
.tip { margin: 0 0 20px; padding: 10px 12px; border-radius: 12px; background: #fef9c3; text-align: center; font-weight: 600; }
label { display: block; font-weight: 700; margin-bottom: 6px; }
input {
  width: 100%;
  min-height: 54px;
  padding: 0 14px;
  border: 2px solid #86efac;
  border-radius: 12px;
  font: inherit;
  font-size: 1.2rem; /* ≥ 16px : iOS ne zoome pas sur le champ */
}
.error { min-height: 1.3em; margin: 6px 0 10px; color: var(--bad); font-weight: 600; }

/* ── Manche ──────────────────────────────────────────────────────────── */
/* Le terrain garde au moins la moitié de l'écran : sur un petit téléphone,
   c'est l'explication qui passe sous le pli, pas le terrain qui rétrécit. */
#play { display: flex; flex-direction: column; gap: 8px; }
.topbar { display: flex; justify-content: space-between; align-items: center; }
.round { font-weight: 800; color: var(--brand-dark); }
.score-pill .star { color: #eab308; }
.score-pill { background: var(--card); border-radius: 999px; padding: 4px 12px; font-weight: 800; }
.context { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 3px 10px; font-size: 0.9rem; font-weight: 700; }
.chip.phase.attaque { background: #dbeafe; color: #1e3a8a; }
.chip.phase.defense { background: #fee2e2; color: #7f1d1d; }
.title { margin: 0; font-weight: 600; font-size: 1.05rem; }

.field-wrap { height: max(52dvh, calc(100dvh - 330px)); display: flex; justify-content: center; }
#field {
  height: 100%;
  max-width: 100%;
  aspect-ratio: 28 / 40;
  touch-action: none; /* le doigt choisit une place, il ne fait pas défiler */
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}
#field.locked { cursor: default; }

.legend { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1.5px solid #0f172a; }
.dot.you { background: var(--you); }
.dot.ours { background: var(--ours); border-color: #fff; outline: 1px solid var(--ours); }
.dot.theirs { background: var(--theirs); border-color: #fff; outline: 1px solid var(--theirs); }
.dot.ball { background: #fff; }

.panel { background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: 0 -2px 12px rgb(20 83 45 / 0.08); }
.hint { margin: 0 0 10px; text-align: center; color: var(--muted); }
.verdict { margin: 0 0 4px; font-size: 1.25rem; font-weight: 800; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.explain { margin: 0 0 12px; }
#feedback.good { border-left: 6px solid var(--good); padding-left: 10px; }
#feedback.bad { border-left: 6px solid var(--bad); padding-left: 10px; }

/* ── Fin ─────────────────────────────────────────────────────────────── */
#end { display: flex; align-items: center; }
.end-card { width: 100%; background: var(--card); border-radius: var(--radius); padding: 24px 20px; text-align: center; box-shadow: 0 10px 30px rgb(20 83 45 / 0.12); }
.end-hello { margin: 0; font-size: 1.3rem; font-weight: 700; }
.end-score { margin: 8px 0 0; font-size: 4rem; font-weight: 900; color: var(--brand); line-height: 1; }
.end-max { font-size: 1.6rem; color: var(--muted); }
.end-message { margin: 10px 0 16px; font-weight: 600; }
.recap { text-align: left; margin: 0 0 20px; padding: 0; list-style: none; }
.recap li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--line); }
.recap .mark { font-weight: 900; width: 1.3em; flex: none; }
.recap .mark.good { color: var(--good); }
.recap .mark.bad { color: var(--bad); }
.recap .what { color: var(--muted); font-size: 0.9rem; }
