:root {
  --red: #ec1c2e;
  --red-dark: #c4121f;
  --dark: #0e0e12;
  --dark-2: #1a1a20;
  --ink: #14141a;
  --muted: #6b7280;
  --line: #e6e7eb;
  --bg: #f4f5f7;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif;
  background: #000;
  color: var(--ink);
  overscroll-behavior: none;
}

/* Cadre "téléphone" centré sur grand écran, plein écran sur mobile */
.phone {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Écrans ---------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: fade 0.25s ease;
}
.screen.dark {
  background: var(--dark);
  color: #fff;
}
.screen.has-nav {
  padding-bottom: 84px;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Header ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  margin-bottom: 12px;
}
.top .title {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 17px;
}
.iconbtn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 22px;
  cursor: pointer;
  border-radius: 10px;
  display: grid;
  place-items: center;
}
.screen:not(.dark) .iconbtn {
  color: var(--ink);
}

/* ---------- Logo marque ---------- */
.brand-badge {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 40px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}
.brand-badge.sm {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  font-size: 22px;
}
.brand-word {
  font-weight: 800;
  font-size: 26px;
  text-align: center;
  margin: 14px 0 4px;
}
.brand-word b {
  color: var(--red);
}

/* ---------- Timer question ---------- */
.qtimer {
  display: inline-block;
  font-weight: 800;
  font-size: 15px;
  color: var(--red);
  border: 2px solid var(--red);
  border-radius: 999px;
  padding: 6px 16px;
  margin: 0 auto 12px;
}
.qtimer.low {
  color: #fff;
  background: var(--red);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

/* ---------- Matching ---------- */
.match-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.match-row .name {
  flex: 1;
  font-weight: 700;
  font-size: 15px;
}
.match-row select {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  font: inherit;
  background: #fff;
}

/* ---------- Résultat ---------- */
.result-ic {
  font-size: 60px;
  text-align: center;
}
.result-title {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  margin: 6px 0;
}
.result-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.result-line:last-child {
  border-bottom: none;
}
.result-line .v {
  margin-left: auto;
  font-weight: 800;
}

/* ---------- Typo ---------- */
h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 18px 0 8px;
  text-align: center;
}
h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 4px 0 6px;
}
.lead {
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 8px;
}
.screen.dark .lead {
  color: #aab;
}
.spacer {
  flex: 1;
}
.center {
  text-align: center;
}

/* ---------- Boutons ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  transition: transform 0.06s ease, opacity 0.2s;
}
.btn:active {
  transform: scale(0.98);
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}
.btn.ghost {
  background: transparent;
  color: inherit;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
}
.screen:not(.dark) .btn.ghost {
  border-color: var(--line);
  color: var(--ink);
}
.btn.light {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn.sm {
  padding: 12px;
  font-size: 14px;
}
.btn + .btn {
  margin-top: 10px;
}

/* ---------- Cartes / tuiles ---------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.screen.dark .card {
  background: var(--dark-2);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 12px;
}
.screen.dark .tile {
  background: var(--dark-2);
  border-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.tile .ic {
  width: 26px;
  text-align: center;
  font-size: 20px;
  color: var(--red);
}

/* ---------- Anneau de progression ---------- */
.ring {
  --p: 0;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 8px auto 4px;
  display: grid;
  place-items: center;
  background: radial-gradient(closest-side, #fff 78%, transparent 79%),
    conic-gradient(var(--red) calc(var(--p) * 1%), var(--line) 0);
}
.ring .n {
  font-size: 28px;
  font-weight: 800;
}
.ring .l {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Liste d'étapes ---------- */
.step {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  font-weight: 600;
}
.step.current {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(236, 28, 46, 0.12);
}
.step.locked {
  color: var(--muted);
}
.step .badge {
  margin-left: auto;
  font-size: 18px;
}
.step.done .badge {
  color: #16a34a;
}
.step.current .badge {
  color: var(--red);
}

/* ---------- Question ---------- */
.opt {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.opt .k {
  display: inline-block;
  width: 26px;
  font-weight: 800;
  color: var(--red);
}
.opt.correct {
  border-color: #16a34a;
  background: #ecfdf3;
}
.opt.wrong {
  border-color: var(--red);
  background: #fef2f2;
}
.opt[disabled] {
  pointer-events: none;
  opacity: 0.95;
}
.opt.opt-img {
  display: flex;
  align-items: center;
  gap: 10px;
}
.opt-photo {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
}
.opt .opt-label {
  flex: 1;
}
.match-photo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
}

/* ---------- Indice ---------- */
.clue-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  line-height: 1.55;
  font-size: 16px;
  box-shadow: var(--shadow);
}
.screen.dark .clue-box {
  background: #fff;
  color: var(--ink);
}
.hint-photo {
  width: 100%;
  border-radius: 14px;
  margin-top: 12px;
  display: block;
}
.note {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}
.pill {
  display: inline-block;
  background: rgba(236, 28, 46, 0.1);
  color: var(--red);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 700;
}
.warn {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin: 2px 0 0;
}

/* ---------- Map ---------- */
#map,
.map {
  width: 100%;
  height: 300px;
  border-radius: 16px;
  overflow: hidden;
  z-index: 0;
}
.map-sm {
  height: 200px;
}

/* ---------- Récap ---------- */
.recap-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.recap-row:last-child {
  border-bottom: none;
}
.recap-row .ic {
  color: var(--red);
  width: 24px;
  text-align: center;
}
.recap-row .v {
  margin-left: auto;
  font-weight: 800;
}
.big-time {
  font-size: 40px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 1px;
}

/* ---------- Scanner ---------- */
.scan-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#reader {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
}
.scan-hint {
  text-align: center;
  color: #aab;
}

/* ---------- Bottom nav ---------- */
.nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
}
.nav.dark {
  background: var(--dark);
  border-top-color: rgba(255, 255, 255, 0.08);
}
.nav button {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}
.nav button .ic {
  font-size: 19px;
}
.nav button.active {
  color: var(--red);
  font-weight: 700;
}

/* ---------- Divers ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: #14141a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 86%;
  text-align: center;
  z-index: 9999;
  box-shadow: var(--shadow);
  animation: fade 0.2s ease;
}
.chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 6px 0 16px;
}
.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.chip.sel {
  border-color: var(--red);
  background: rgba(236, 28, 46, 0.06);
  color: var(--red);
}
.chip.taken {
  opacity: 0.45;
}
input.code {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  text-align: center;
  letter-spacing: 6px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  margin-bottom: 14px;
}
.rule {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  line-height: 1.5;
}
.rule .n {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}
.trophy {
  font-size: 64px;
  text-align: center;
}
.confetti {
  font-size: 30px;
  text-align: center;
  letter-spacing: 6px;
}
.loader {
  margin: 40px auto;
  width: 46px;
  height: 46px;
  border: 4px solid rgba(236, 28, 46, 0.2);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.err {
  color: var(--red);
  font-size: 14px;
  text-align: center;
  min-height: 18px;
  margin-bottom: 8px;
}
