:root {
  --bg: #121216;          /* = contour des silhouettes */
  --surface: #1d1d23;
  --surface-2: #2a2a32;
  --text: #f2f2f5;
  --muted: #9a9aa6;
  --accent: #ff453a;
  --accent-text: #fff;
  --ok: #30d158;
  --warn: #ffd60a;
  --radius: 14px;
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { display: none; min-height: 100%; }
.screen.active { display: block; }
#home, #editor, #summary {
  max-width: 760px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) var(--gutter) max(28px, env(safe-area-inset-bottom));
}

.top { margin-bottom: 18px; }
.top.row { display: flex; align-items: center; gap: 12px; }
h1 { margin: 0; font-size: 1.9rem; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 1.4rem; }
h3 { margin: 0; font-size: 1.1rem; }
.sub { margin: 4px 0 0; color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 8px 0 0; }
.safety { color: var(--muted); font-size: 0.85rem; margin-top: 28px; padding: 12px 14px; border: 1px solid var(--surface-2); border-radius: var(--radius); }
.warn { color: var(--warn); font-size: 0.9rem; margin: 8px 0 0; }

/* Boutons */
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  min-height: 48px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.secondary { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: transparent; color: var(--accent); }
.btn.wide { width: 100%; margin-top: 14px; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.link { background: none; border: 0; color: var(--accent); font-size: 0.8rem; cursor: pointer; padding: 0 4px; text-transform: none; letter-spacing: 0; }

/* Cartes programmes */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-desc { margin: 0; color: var(--muted); font-size: 0.9rem; flex: 1; }
.card-actions { display: flex; gap: 8px; margin-top: 4px; }
.card-actions .btn.primary { flex: 1; }
.badge { font-size: 0.7rem; color: var(--muted); border: 1px solid var(--surface-2); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }

/* Formulaire */
fieldset { border: 0; background: var(--surface); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0 0 14px; }
legend { float: left; width: 100%; font-weight: 700; margin-bottom: 10px; padding: 0; }
fieldset > legend + * { clear: both; }
fieldset > legend + .field { margin-top: 0; }
.grid2 .field, .grid3 .field { margin-top: 0; }
.grid2, .grid3 { margin-top: 10px; }
fieldset > legend + .grid3 { margin-top: 0; }
#form > .field { margin: 0 0 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0; }
.field > span { font-size: 0.9rem; color: var(--muted); }
.field input:not([type=range]) {
  background: var(--bg);
  border: 1px solid var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 32px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sublabel { clear: both; font-size: 0.85rem; color: var(--muted); margin: 14px 0 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.sublabel:first-child { margin-top: 0; }

.seg { clear: both; display: flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 10px 6px; min-height: 44px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 0.92rem; }
.seg button.on { background: var(--surface-2); color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 9px 14px; border-radius: 99px; border: 1px solid var(--surface-2); color: var(--muted); font-size: 0.92rem; min-height: 40px; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.actions .btn.primary { flex: 1 1 200px; }

/* Séance */
#session.active { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; user-select: none; -webkit-user-select: none; }
.hud {
  display: flex; justify-content: space-between; align-items: center;
  padding: max(8px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  font-size: clamp(1rem, 3.2vmin, 1.6rem); font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#hud-time { color: var(--text); }
.stage { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; cursor: pointer; }
.media { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.media img, .media video { height: 100%; max-height: 100%; max-width: 100%; object-fit: contain; display: block; }
.media.mirror img, .media.mirror video { transform: scaleX(-1); }
.attack-name { min-height: clamp(48px, 13vmin, 110px); text-align: center; display: flex; flex-direction: column; justify-content: center; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.attack-name strong { font-size: clamp(1.6rem, 8vmin, 4rem); line-height: 1; color: var(--accent); }
.attack-name span { font-size: clamp(0.9rem, 3.4vmin, 1.5rem); color: var(--muted); text-transform: capitalize; }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; pointer-events: none; white-space: pre-line; font-weight: 800; }
.overlay:empty { display: none; }
.overlay.big, .overlay.flash { background: rgba(18, 18, 22, 0.72); font-size: clamp(2.5rem, 14vmin, 8rem); }
.overlay.count { font-size: clamp(5rem, 40vmin, 20rem); color: var(--accent); }
.overlay.flash { color: var(--ok); }
.overlay.paused { font-size: clamp(2rem, 9vmin, 5rem); }
.overlay.paused::first-line { font-size: 1.4em; }
.overlay.rest { color: var(--muted); }

.session-controls { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; gap: 12px; z-index: 2; }
.btn.round { width: 64px; height: 64px; border-radius: 50%; padding: 0; font-size: 1.3rem; background: rgba(42, 42, 50, 0.85); }

/* Résumé */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat strong { display: block; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.85rem; }
.breakdown { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.breakdown h3 { margin-bottom: 10px; font-size: 1rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 9rem) 1fr 2.5rem; align-items: center; gap: 10px; margin: 6px 0; font-size: 0.92rem; }
.bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

@media (max-width: 420px) {
  .stat strong { font-size: 1.4rem; }
}
