:root {
  --ink: #14120f;
  --panel: #1f1c17;
  --panel-2: #2a261f;
  --line: #3b352c;
  --text: #f6f0e5;
  --muted: #a9a091;
  --flame: #ffc53d;
  --ember: #ff7a1a;
  --good: #66d893;
  --bad: #ff6f61;
  --radius: 14px;
  --gutter: 16px;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--flame); outline-offset: 2px; }

.eyebrow { margin: 0; color: var(--flame); font: 600 12px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 8px 0 12px; font-size: clamp(44px, 15vw, 72px); line-height: .95; font-weight: 800; letter-spacing: -.03em; overflow-wrap: anywhere; }

.primary {
  width: 100%; min-height: 56px; border: 0; border-radius: var(--radius);
  background: var(--flame); color: var(--ink); font-size: 18px; font-weight: 800;
}
.primary:active { background: var(--ember); }
.primary:disabled { opacity: .55; }
.secondary {
  flex: 1; min-height: 50px; border: 1px solid var(--line); border-radius: var(--radius);
  background: transparent; font-weight: 700;
}
.row { display: flex; gap: 10px; }
.error { min-height: 20px; margin: 0; color: var(--bad); font-size: 14px; }
.hint { min-height: 20px; margin: 0; color: var(--muted); font-size: 14px; text-align: center; }

/* Accueil */
.landing, .final {
  max-width: 480px; min-height: 100dvh; margin: 0 auto;
  padding: max(32px, env(safe-area-inset-top)) var(--gutter) max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: center;
}
.pitch { margin: 0 0 40px; color: var(--muted); font-size: 20px; line-height: 1.35; }
.join { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.field input {
  min-height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); font-size: 18px;
}

/* Atelier */
.studio {
  height: 100dvh; max-width: 560px; margin: 0 auto; display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(140px, 1fr) auto auto;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.progress { display: flex; align-items: center; gap: 10px; padding: 12px var(--gutter); }
.segments { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.segments i { height: 5px; border-radius: 3px; background: var(--line); transition: background .3s; }
.segments i.on { background: var(--flame); }
.counter { color: var(--muted); font: 600 13px var(--mono); }

.preview { position: relative; margin: 0 var(--gutter); min-height: 0; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
.preview iframe, .player iframe { width: 100%; height: 100%; border: 0; display: block; background: #14120f; }
.preview.updated { animation: flash .8s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--flame); } to { box-shadow: 0 0 0 0 transparent; } }
.badge { position: absolute; top: 8px; right: 8px; padding: 3px 7px; border-radius: 7px; background: rgb(20 18 15 / .8); color: var(--flame); font: 600 12px var(--mono); pointer-events: none; }

.ticker {
  display: flex; align-items: center; gap: 9px; width: calc(100% - 2 * var(--gutter));
  min-height: 46px; margin: 0 var(--gutter); padding: 0 2px; border: 0; background: none; text-align: left;
}
.ticker span { flex: 1; min-width: 0; color: var(--muted); font: 13px/1.3 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticker b { color: var(--text); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.building { background: var(--flame); animation: pulse 1s infinite; }
.dot.bug, .dot.warn { background: var(--bad); }
.dot.ok, .dot.fixed, .dot.done { background: var(--good); }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }

.card { padding: 16px var(--gutter) 14px; border-radius: 20px 20px 0 0; background: var(--panel); border-top: 1px solid var(--line); min-height: 286px; }
.card h2 { margin: 0 0 14px; font-size: 21px; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
.card.enter > * { animation: rise .25s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.options button {
  min-height: 56px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-2); font-size: 15px; font-weight: 650; line-height: 1.15; overflow-wrap: anywhere;
}
.options button:active { border-color: var(--flame); color: var(--flame); }
.free { display: flex; gap: 8px; }
.free input { flex: 1; min-width: 0; min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--ink); font-size: 16px; }
.free input::placeholder { color: var(--muted); }
.free button { flex: none; width: 52px; border: 0; border-radius: 12px; background: var(--flame); color: var(--ink); font-size: 20px; font-weight: 800; }
.free button:disabled, .options button:disabled { opacity: .45; }
.card .error { margin-top: 6px; }

.waiting h2 { color: var(--muted); }
.skeleton { height: 56px; border-radius: 12px; background: var(--panel-2); animation: pulse 1.2s infinite; }

/* Fin */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 22px 0 28px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); }
.stats div { padding: 14px; background: var(--panel); }
.stats dt { color: var(--muted); font-size: 12px; }
.stats dd { margin: 4px 0 0; font: 700 25px var(--mono); }
.final .row { margin: 10px 0; }

.player { position: fixed; inset: 0; background: #000; z-index: 5; }
.close { width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgb(20 18 15 / .75); font-size: 25px; line-height: 1; }
.player .close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; }

.journal { width: 100%; max-width: 560px; height: 78dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 20px 20px 0 0; background: var(--panel); color: var(--text); }
.journal::backdrop { background: rgb(0 0 0 / .6); }
.journal header { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 12px var(--gutter); background: var(--panel); border-bottom: 1px solid var(--line); }
.journal h2 { margin: 0; font-size: 18px; }
.journal ol { list-style: none; margin: 0; padding: 8px var(--gutter) 24px; }
.journal li { display: flex; gap: 10px; padding: 8px 0; font: 13px/1.4 var(--mono); color: var(--muted); }
.journal li .dot { margin-top: 5px; }
.journal li.bug, .journal li.fixed, .journal li.summary, .journal li.done { color: var(--text); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Animateur */
.qr { padding: 12px; border-radius: var(--radius); background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }
.games { margin: 0; padding-left: 22px; line-height: 2; }
.games a { color: var(--flame); }
