:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5f6b7a;
  --primary: #0b5394;
  --primary-text: #ffffff;
  --border: #d8dee6;
  --ok: #1e7d3a;
  --err: #b3261e;
  --code-bg: #f6f8fa;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --card: #1b2129;
    --text: #e6ebf1;
    --muted: #9aa6b4;
    --primary: #4a8fd6;
    --border: #2d3540;
    --ok: #5cc27a;
    --err: #f08a80;
    --code-bg: #141920;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh;
}
header { background: var(--primary); color: var(--primary-text); padding: 14px 16px; }
header h1 { margin: 0; font-size: 1.15rem; }
main { max-width: 560px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
h2 { margin: 0 0 8px; font-size: 1.1rem; }

.viewport {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  background: #000; border-radius: 10px; overflow: hidden;
}
video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame {
  position: absolute; inset: 15%;
  border: 3px solid rgba(255,255,255,.85); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
  pointer-events: none; display: none;
}
.scanning .frame { display: block; }
.placeholder {
  position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: #cfd6df;
}
.scanning .placeholder { display: none; }

.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions button { flex: 1; }
button {
  font: inherit; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
button:disabled { opacity: .6; }


footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 8px 0 20px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; pointer-events: none; }

header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge { font-weight: 600; letter-spacing: .04em; }
.scan-info { margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
.install { border-color: var(--primary); }
.install p { margin: 0; }
.install .ios-share { display: inline-block; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; }

/* Écran Joker */
#screenJoker { display: grid; gap: 14px; }
#screenJoker[hidden] { display: none; }
.field { display: grid; gap: 4px; }
.label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.code { font-size: 1.5rem; font-weight: 700; }
select {
  font: inherit; width: 100%; min-width: 0; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.with-button { display: flex; gap: 8px; }
button.icon { flex: none; width: 48px; padding: 0; font-size: 1.3rem; }
.numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.roulette { font-size: 1.4rem; font-weight: 700; text-align: center; text-align-last: center; }
.hint { margin: -6px 0 0; min-height: 1.2em; font-size: .85rem; color: var(--err); }
.pds { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 10%, transparent); font-weight: 600; }
.pds .mono { margin-top: 4px; font-size: 1.05rem; }
button.big { width: 100%; padding: 14px; font-size: 1.1rem; }
.actions { margin-top: 0; }

/* Fenêtres modales */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(0,0,0,.55);
}
.overlay[hidden] { display: none; }
.dialog { width: 100%; max-width: 420px; background: var(--card); border-radius: 14px; padding: 20px; }
.dialog p { margin: 0 0 16px; font-size: 1.05rem; }
.dialog.center { text-align: center; }
.actions.column { flex-direction: column; }
.result-title { font-weight: 700; }
.result-title.ok { color: var(--ok); }
.result-title.err { color: var(--err); }
.hourglass { font-size: 3rem; display: inline-block; animation: spin 2s linear infinite; margin-bottom: 8px; }
@keyframes spin { 50% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .hourglass { animation: none; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 10px;
  background: var(--err); color: #fff; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.info { background: var(--text); color: var(--bg); }
.toast[hidden] { display: none; }
