:root {
  /* Charte CODECODEC */
  --cream: #f4efe6;
  --cream-deep: #ebe6db;
  --card: #efebe2;
  --ink: #2c2c2c;
  --muted: #6b6b6b;
  --paper: #ffffff;
  --sage: #7ba87a;
  --sage-deep: #5f8f5e;
  --sage-soft: #8fb88e;
  --red: #e53935;
  --orange: #ed8b33;
  --blue: #3b6de0;
  --blue-deep: #2a56c4;
  --gold: #ed8b33;
  --danger: #e53935;
  --ok: #7ba87a;
  --asphalt: #f4efe6;
  --panel: #efebe2;
  --line: rgba(44, 44, 44, 0.12);
  --shadow: 0 10px 28px rgba(60, 50, 30, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  height: 100dvh;
  background: var(--cream);
  color: var(--ink);
  font-family: Nunito, "Segoe UI", sans-serif;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 14px 12px;
}

.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--cream);
}

.boot-loader[hidden] {
  display: none;
}

.boot-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  max-width: 320px;
}

.boot-loader-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.boot-loader-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
}

.boot-loader-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  min-height: 1.3em;
}

.boot-loader-hint {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
  max-width: 260px;
}

.boot-loader.is-error .boot-loader-hint {
  display: none;
}

.boot-loader-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(44, 44, 44, 0.12);
  border-top-color: var(--sage-deep);
  animation: boot-spin 0.75s linear infinite;
}

.boot-loader.is-error .boot-loader-spinner {
  animation: none;
  border-color: rgba(229, 57, 53, 0.25);
  border-top-color: var(--red);
}

@keyframes boot-spin {
  to {
    transform: rotate(360deg);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--sage);
  color: white;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-kicker {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage-deep);
}

.brand h1 {
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--ink);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.defi-play-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(255, 139, 43, 0.16), rgba(239, 57, 59, 0.1));
  border: 1.5px solid rgba(230, 79, 8, 0.35);
  color: var(--ink);
}

.defi-play-banner[hidden] {
  display: none !important;
}

.defi-play-banner__badge {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ff8b2b;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.defi-play-banner__name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  color: #c2410c;
}

.defi-play-banner__quit {
  flex: 0 0 auto;
  padding: 8px 14px !important;
  font-size: 13px !important;
  color: #b42318 !important;
  border-color: rgba(180, 35, 24, 0.28) !important;
}

#app.is-defi-play .topbar {
  padding-bottom: 6px;
}

.ghost,
.primary {
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
}

.ghost {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(60, 50, 30, 0.06);
}

.ghost.on {
  background: var(--sage);
  color: white;
  border-color: transparent;
}

.ghost.rec {
  background: var(--red);
  color: white;
  border-color: transparent;
}

.ghost.rec.on,
.ghost.rec.recording {
  animation: rec-pulse 1.1s ease-in-out infinite;
}

.ghost.rec-assist {
  background: rgba(59, 109, 224, 0.12);
  color: var(--blue-deep);
  border-color: rgba(59, 109, 224, 0.35);
}

.ghost.rec.ready {
  background: var(--sage);
  animation: none;
}

@keyframes rec-pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.12);
  }
}

.demo-status {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--sage-deep);
  text-align: center;
}

.primary {
  background: var(--orange);
  color: white;
}

.primary.alt {
  background: var(--sage);
  color: white;
}

.primary.blue {
  background: var(--blue);
  color: white;
}

.primary.blue:active {
  background: var(--blue-deep);
}

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr minmax(260px, 320px);
  gap: 12px;
}

  .canvas-wrap {
  position: relative;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #b8cbd8;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

#view {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  transition: filter 0.45s ease;
}

.canvas-wrap.demo-avoid #view {
  /* N&B géré en post-process WebGL (pneus d’alerte restent en couleur). */
  filter: none;
}

.demo-look-badge {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.demo-cross-link {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  padding: 16px 28px;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #1a1400;
  text-decoration: none;
  text-align: center;
  background: #ffe000;
  border: 3px solid #fff6a0;
  box-shadow:
    0 0 0 3px rgba(255, 224, 0, 0.45),
    0 10px 28px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: demo-cross-in 0.35s ease-out both;
}

.demo-cross-link:hover,
.demo-cross-link:focus-visible {
  background: #fff24a;
  filter: brightness(1.05);
  outline: none;
}

.demo-cross-link[hidden] {
  display: none !important;
}

@keyframes demo-cross-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 10px)) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.demo-timecode {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 8px 16px;
  border-radius: 10px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(10, 16, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
  white-space: nowrap;
}

.demo-timecode[hidden] {
  display: none !important;
}

.demo-audio-sync {
  position: absolute;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  z-index: 28;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(94vw, 440px);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(10, 14, 22, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  color: #f4f7ff;
  text-align: center;
}

.demo-audio-sync[hidden] {
  display: none !important;
}

.demo-audio-sync-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.demo-audio-sync-clock {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.demo-audio-sync-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.demo-audio-sync-actions .ghost,
.demo-audio-sync-actions .primary {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 13px;
}

.demo-audio-sync-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  opacity: 0.85;
  max-width: 38rem;
}

.demo-scrub {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  width: min(520px, calc(100% - 24px));
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(10, 16, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.demo-scrub[hidden] {
  display: none !important;
}

.demo-scrub-btn {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

/* Largeur fixe : « Pause » / « Reprendre » ne reflowent pas la barre (évite les faux seek). */
#btn-demo-pause {
  min-width: 6.5rem;
}

.demo-seek {
  flex: 1 1 160px;
  min-width: 120px;
  accent-color: var(--blue);
  cursor: pointer;
}

.demo-scrub-clock {
  flex: 0 0 auto;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.demo-play-cta {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 30;
  min-width: min(280px, 78vw);
  padding: 18px 32px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: #fff;
  background: linear-gradient(180deg, #4d7ef0 0%, var(--blue) 55%, var(--blue-deep) 100%);
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 18px;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.35) inset,
    0 -3px 0 rgba(20, 40, 100, 0.28) inset,
    0 10px 0 rgba(26, 52, 120, 0.35),
    0 18px 36px rgba(20, 40, 90, 0.35);
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  transform: translate(-50%, -50%);
  animation: demo-play-in 0.45s ease-out both, demo-play-pulse 1.6s ease-in-out 0.5s infinite;
}

.demo-play-cta:hover,
.demo-play-cta:focus-visible {
  background: linear-gradient(180deg, #5a89f5 0%, #4578ea 55%, #2f5fd0 100%);
  outline: none;
}

.demo-play-cta:active {
  transform: translate(-50%, calc(-50% + 6px));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 2px 0 rgba(26, 52, 120, 0.35),
    0 8px 18px rgba(20, 40, 90, 0.28);
  animation: none;
}

.demo-play-cta[hidden] {
  display: none !important;
}

.win-actions {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: min(320px, 86vw);
  padding: 16px 16px 14px;
  background: rgba(18, 28, 40, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 16px;
  box-shadow: 0 14px 36px rgba(12, 20, 36, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  animation: win-actions-in 0.4s ease-out both;
}

.win-actions[hidden] {
  display: none !important;
}

.win-actions-lead {
  margin: 0;
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
}

.win-actions-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.win-actions-btns .primary,
.win-actions-btns .primary.blue {
  width: 100%;
  min-height: 46px;
  font-size: 16px;
  font-weight: 800;
  border-radius: 12px;
}

@keyframes win-actions-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 12px)) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes demo-play-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 14px)) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes demo-play-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.04);
  }
}

.cam-author {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  top: auto;
  z-index: 6;
  width: auto;
  max-width: none;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  pointer-events: auto;
}

.cam-author[hidden] {
  display: none !important;
}

.cam-author-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.cam-author-bar strong {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--blue-deep);
}

.cam-seq-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cam-seq-tab {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}

.cam-seq-tab.on {
  background: var(--blue);
  border-color: transparent;
  color: #fff;
}

.cam-timeline-label {
  flex: 1;
  min-width: 120px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
}

.cam-author-bar .ghost {
  padding: 6px 10px;
  font-size: 12px;
}

.cam-author-bar .ghost.on {
  background: rgba(229, 57, 53, 0.12);
  color: var(--red);
  border-color: rgba(229, 57, 53, 0.35);
}

.cam-rec-btn.on {
  background: #c62828 !important;
  color: #fff !important;
  border-color: #c62828 !important;
  animation: cam-rec-pulse 1.1s ease-in-out infinite;
}

@keyframes cam-rec-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(198, 40, 40, 0);
  }
}

.cam-author-bar .ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cam-timeline-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cam-timeline-track {
  position: relative;
  flex: 1;
  height: 32px;
  border-radius: 999px;
  background: rgba(44, 44, 44, 0.1);
  cursor: pointer;
  touch-action: none;
  overflow: visible;
}

.cam-timeline-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: rgba(123, 168, 122, 0.35);
  pointer-events: none;
}

.cam-timeline-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.cam-timeline-mark {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 14px;
  margin-left: -7px;
  border-radius: 6px;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
  padding: 0;
  z-index: 2;
}

.cam-timeline-mark.is-audio {
  cursor: pointer;
  background: var(--sage-deep);
}

.cam-timeline-mark.is-selected {
  background: var(--orange);
  transform: scale(1.2);
  z-index: 3;
}

.cam-timeline-mark.is-dragging {
  background: var(--orange);
  transform: scale(1.35);
  z-index: 4;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.cam-timeline-points {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-height: 72px;
  overflow: auto;
}

.cam-timeline-points:empty {
  display: none;
}

.cam-timeline-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: rgba(44, 44, 44, 0.08);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.cam-timeline-chip.is-selected {
  background: rgba(237, 139, 51, 0.2);
  border-color: var(--orange);
}

.cam-timeline-chip-del {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(229, 57, 53, 0.12);
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  cursor: pointer;
}

.cam-timeline-chip-del:hover {
  background: var(--red);
  color: #fff;
}

.cam-timeline-playhead {
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--ink);
  pointer-events: none;
  left: 0%;
  z-index: 1;
}

.cam-timeline-add {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sage);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.cam-timeline-add:hover {
  background: var(--sage-deep);
}

.phone-frame {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.phone-frame[hidden] {
  display: none !important;
}

.phone-frame-cutout {
  position: relative;
  height: min(94%, calc(100% - 16px));
  aspect-ratio: 390 / 844;
  max-width: min(46%, 420px);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.25),
    0 0 0 9999px rgba(18, 21, 26, 0.52);
}

.phone-frame-cutout::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 10px;
  border-radius: 999px;
  background: rgba(18, 21, 26, 0.55);
}

.phone-frame-label {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(18, 21, 26, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

#btn-phone-frame.on {
  background: var(--sage);
  color: #fff;
  border-color: transparent;
}

.canvas-wrap.demo-avoid .demo-look-badge {
  background: rgba(40, 40, 40, 0.82);
  color: #f0f0f0;
}

.canvas-wrap:not(.demo-avoid) .demo-look-badge:not([hidden]) {
  background: rgba(123, 168, 122, 0.92);
  color: #fff;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

#view.orbiting {
  cursor: grabbing;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 420px);
  text-align: center;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.coach {
  min-height: 0;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.coach-heading {
  display: block;
  width: 100%;
  margin: 0;
  border: 0;
  background: var(--sage);
  color: white;
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 12px;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
}

.coach-heading:hover,
.coach-heading:focus-visible {
  filter: brightness(1.06);
  outline: none;
}

#app.is-defi-play .coach-heading {
  background: #ff8b2b;
}

/* Bouton classement : visible seulement sur mobile / tablette */
.btn-leaderboard {
  display: none;
}

.coach-body {
  flex: 1;
  min-height: 120px;
  margin: 0;
  padding: 10px 14px 8px;
  overflow: auto;
}

.leaderboard {
  font-size: 13px;
}

.leaderboard-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 8px 2px;
}

.leaderboard-diff {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange);
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.leaderboard-search {
  margin: 0 0 10px;
}

.leaderboard-search-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.leaderboard-search-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 120, 232, 0.18);
}

.leaderboard-search-input::placeholder {
  color: var(--muted);
  font-weight: 600;
}

.leaderboard-search-result {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.leaderboard-search-hit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(31, 120, 232, 0.1);
  color: var(--navy, #1e3a5f);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.leaderboard-search-more {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.leaderboard td.rank--search {
  width: 3.2em;
  white-space: nowrap;
  color: var(--blue, #1f78e8);
  font-variant-numeric: tabular-nums;
}

.leaderboard table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.leaderboard th,
.leaderboard td {
  text-align: left;
  padding: 5px 4px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.leaderboard th:nth-child(1),
.leaderboard td.rank {
  width: 3.2em;
}

.leaderboard th:nth-child(2),
.leaderboard td.name {
  width: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard th:nth-child(3),
.leaderboard td.time {
  width: 6.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.leaderboard th {
  color: var(--muted);
  font-size: 11px;
}

.leaderboard td.rank {
  width: 1.6em;
  color: var(--sage-deep);
  font-weight: 800;
}

.leaderboard td.rank--medal {
  width: 2.4em;
  padding-left: 2px;
  padding-right: 2px;
  text-align: center;
  vertical-align: middle;
}

.leaderboard .rank-medal {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.18);
  vertical-align: middle;
}

.leaderboard .rank--gold .rank-medal {
  background: linear-gradient(145deg, #ffe677 0%, #f0c42e 40%, #d4a017 100%);
  border: 1.5px solid #c4920a;
}

.leaderboard .rank--silver .rank-medal {
  background: linear-gradient(145deg, #f5f7fa 0%, #c9d0d8 45%, #9aa3ad 100%);
  border: 1.5px solid #8a939d;
}

.leaderboard .rank--bronze .rank-medal {
  background: linear-gradient(145deg, #f0b07a 0%, #cd7f32 45%, #a05a1c 100%);
  border: 1.5px solid #8a4b16;
}

.defi-admin-list {
  max-height: min(42vh, 320px);
  overflow: auto;
  margin: 8px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.defi-admin-empty {
  color: var(--muted);
  margin: 8px 0;
}

.defi-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.defi-admin-row__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.defi-admin-row__meta strong {
  color: var(--ink);
  font-size: 15px;
}

.defi-admin-row__meta span {
  color: var(--muted);
  font-size: 12px;
}

.defi-admin-delete {
  flex: 0 0 auto;
  color: #b42318 !important;
  border-color: rgba(180, 35, 24, 0.25) !important;
}

.defi-lobby-delete {
  margin: 0 0 12px;
  color: #b42318;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.leaderboard tr.highlight td {
  background: #eef6ee;
  color: #2f6b3a;
}

.leaderboard-sheet {
  position: fixed;
  inset: 0;
  z-index: 38;
  display: grid;
  place-items: end center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  background: rgba(28, 36, 44, 0.45);
}

.leaderboard-sheet[hidden] {
  display: none !important;
}

.leaderboard-sheet-card {
  width: min(440px, 100%);
  max-height: min(72vh, 560px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 14px 16px;
}

.leaderboard-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.leaderboard-sheet-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--sage-deep);
}

.score-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 36, 44, 0.45);
}

.score-dialog[hidden] {
  display: none !important;
}

.score-dialog-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px 16px;
}

.score-dialog-card h3 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
}

.score-dialog-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.score-label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 6px;
}

.score-dialog-card .score-label + input + .score-label,
.score-dialog-card .score-label + select + .score-label,
.score-dialog-card input + .score-label,
.score-dialog-card select + .score-label {
  margin-top: 12px;
}

#score-name,
#defi-create-creator,
#defi-create-name,
#defi-join-name {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  background: var(--cream);
  color: var(--ink);
}

.score-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.defi-dialog-card {
  width: min(400px, 100%);
}

.defi-select {
  width: 100%;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
}

.defi-status {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.defi-status.is-error {
  color: #b42318;
}

.defi-status.is-ok {
  color: #067647;
}

.defi-create-fields[hidden],
#defi-create-actions[hidden],
#defi-create-lead[hidden] {
  display: none !important;
}

#defi-create-dialog.is-published .defi-create-fields,
#defi-create-dialog.is-published #defi-create-actions,
#defi-create-dialog.is-published #defi-create-lead {
  display: none !important;
}

.defi-share {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(47, 111, 237, 0.08);
  border: 1px solid rgba(47, 111, 237, 0.2);
}

.defi-share[hidden] {
  display: none !important;
}

.defi-share-name {
  margin: 0;
  font-weight: 800;
  font-size: 16px;
  color: var(--orange-dark, #c45a00);
}

.defi-share-hint {
  margin: 0;
  color: var(--muted, #65717a);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
}

.defi-share-link {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  background: #fff;
}

.defi-win-actions {
  flex-wrap: wrap;
  justify-content: stretch;
}

.defi-win-actions .ghost,
.defi-win-actions .primary {
  flex: 1 1 auto;
}

.defi-actions .ghost,
.defi-actions .primary {
  flex: 1 1 auto;
}

.coach-kicker {
  color: var(--orange);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 14px;
}

.coach h2 {
  font-family: inherit;
  font-size: 24px;
  font-weight: 800;
  margin: 4px 0 8px;
  color: var(--ink);
}

#coach-text {
  color: var(--muted);
  line-height: 1.45;
  font-size: 15px;
}

.wheel-panel {
  display: grid;
  justify-items: center;
  margin: 12px 16px;
}

#wheel {
  width: 120px;
  height: 120px;
}

#wheel-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.steps {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 8px 16px 14px;
}

.steps li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  color: var(--muted);
}

.steps li.on {
  color: var(--ink);
  font-weight: 800;
}

.steps li.done {
  color: var(--sage-deep);
}

.steps .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: grid;
  place-items: center;
  font-size: 10px;
  margin-top: 1px;
}

.stats[hidden] {
  display: none !important;
}

.coach[hidden] {
  display: none !important;
}

.stats div {
  background: var(--cream);
  border-radius: 14px;
  padding: 8px;
  border: 1px solid var(--line);
}

.stats dt {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.stats dd {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

.touch {
  display: none;
  gap: 10px;
  padding-top: 10px;
  align-items: flex-end;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.touch-steer {
  flex: 0 0 auto;
  position: relative;
  width: 156px;
  height: 156px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
}

/* Invisible hit area — élargie, mais limitée à droite pour ne pas manger les pédales. */
.touch-steer-hit {
  position: absolute;
  top: -64px;
  left: -64px;
  bottom: -64px;
  right: -28px;
  z-index: 2;
  border-radius: 50%;
  touch-action: none;
}

.touch-steer-face {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(92, 98, 106, 0.72);
  border: 2px solid rgba(60, 66, 74, 0.55);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

.touch-steer img {
  display: block;
  width: 92%;
  height: 92%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  transform-origin: center center;
  will-change: transform;
}

.touch-cluster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
  touch-action: none;
}

.touch-drive {
  min-width: 0;
  align-items: end;
  gap: 12px;
}

.touch button {
  min-height: 56px;
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  border: 1px solid var(--line);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch button:active,
.touch button.held {
  background: var(--sage);
  color: white;
}

.pedal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 0 !important;
  height: 118px;
  padding: 8px 6px 2px;
  border: 0 !important;
  border-radius: 14px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pedal-plate {
  display: block;
  width: min(100%, 72px);
  height: 78px;
  border-radius: 10px 10px 14px 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 28%),
    repeating-linear-gradient(
      180deg,
      #2a3038 0 5px,
      #1c2128 5px 10px
    );
  border: 1px solid rgba(243, 234, 216, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -10px 16px rgba(0, 0, 0, 0.35),
    0 8px 0 #0a0d14,
    0 12px 18px rgba(0, 0, 0, 0.35);
  transform: perspective(180px) rotateX(12deg);
  transform-origin: 50% 100%;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
}

.pedal-accel .pedal-plate {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 28%),
    repeating-linear-gradient(
      180deg,
      #3a4558 0 5px,
      #262e3c 5px 10px
    );
  border-color: rgba(61, 124, 255, 0.35);
}

.pedal-reverse .pedal-plate {
  border-color: rgba(232, 195, 106, 0.28);
  width: min(100%, 58px);
  height: 64px;
}

.pedal-caption {
  line-height: 1;
  pointer-events: none;
}

.pedal:active .pedal-plate,
.pedal.held .pedal-plate {
  transform: perspective(180px) rotateX(12deg) translateY(7px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -6px 12px rgba(0, 0, 0, 0.4),
    0 2px 0 #0a0d14,
    0 4px 10px rgba(0, 0, 0, 0.3);
  filter: brightness(1.08);
}

.pedal.held {
  background: transparent !important;
  color: var(--paper);
}

.pedal-accel.held {
  color: var(--sage-deep);
}

.pedal-reverse.held {
  color: var(--orange);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 239, 230, 0.72);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 5;
  overflow: visible;
}

.overlay[hidden] {
  display: none;
}

.menu-stage {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100dvh - 24px);
  padding-top: 0;
  margin-top: 0;
  --fernande-h: 200px;
  /* fraction image = bas du tablier (salopette) */
  --fernande-overalls: 0.84;
  --fernande-banner-top: calc(var(--fernande-h) * var(--fernande-overalls) - 4px);
  --fernande-nudge: 4px;
}

/* Fernande — bas du tablier aligné sur le haut du bandeau rouge */
.menu-fernande {
  position: absolute;
  z-index: 8;
  left: auto;
  right: 56px;
  top: calc(var(--fernande-banner-top) - var(--fernande-h) * var(--fernande-overalls) + var(--fernande-nudge));
  height: var(--fernande-h);
  width: auto;
  max-width: none;
  object-fit: contain;
  object-position: right bottom;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 3px 8px rgba(60, 40, 20, 0.22));
}

.menu-card {
  position: relative;
  z-index: 1;
  width: 100%;
  overflow: visible;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 0;
  box-shadow: var(--shadow);
  margin-top: var(--fernande-banner-top);
}

.menu-banner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: white;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 12px 72px 12px 18px;
  min-height: 52px;
  border-radius: 26px 26px 0 0;
}

.menu-body {
  position: relative;
  z-index: 3;
  background: var(--card);
  border-radius: 0 0 26px 26px;
  padding: 22px 26px 22px;
  max-height: calc(100dvh - 210px);
  overflow: auto;
}

.menu-banner-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1.1;
  padding: 0 8px;
}

.menu-banner-title-main {
  font-size: 15px;
  letter-spacing: 0.1em;
}

.menu-banner-title-by {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0.9;
}

.menu-banner-admin {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
}

.menu-banner-admin:hover,
.menu-banner-admin:focus-visible {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.12);
}

.menu-banner-admin.on {
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
}

.menu-kicker {
  color: var(--orange);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.menu-card h2 {
  font-family: inherit;
  font-size: clamp(26px, 5vw, 36px);
  font-weight: 800;
  margin: 6px 0 10px;
  color: var(--ink);
}

.menu-lead {
  color: var(--muted);
  line-height: 1.5;
}

.menu-lead[hidden] {
  display: none !important;
}

.difficulty {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
}

.diff-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 100%;
  height: 100%;
  padding: 10px 8px 10px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: var(--cream);
  box-shadow: 0 2px 8px rgba(60, 50, 30, 0.06);
}

.diff-card.on {
  background: #fff;
}

.diff-card.is-facile.on {
  border-color: #16a34a;
  background: #e8f5ec;
}

.diff-card.is-normal.on {
  border-color: #2563eb;
  background: #eaf1ff;
}

.diff-card.is-examen.on {
  border-color: #ef4444;
  background: #fdeeee;
}

.diff {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1 1 auto;
  background: transparent;
  color: var(--ink);
  border-radius: 10px;
  padding: 4px 2px 2px;
  border: 0;
  font-weight: 800;
  line-height: 1.25;
  box-shadow: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.diff-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 0;
  display: grid;
  place-items: center;
  margin-top: 0;
  background: transparent;
}

.diff-card.is-facile .diff-icon {
  color: #16a34a;
}

.diff-card.is-normal .diff-icon {
  color: #2563eb;
}

.diff-card.is-examen .diff-icon {
  color: #ef4444;
}

.diff-icon svg {
  display: block;
  width: 28px;
  height: 28px;
}

.diff-text {
  min-width: 0;
  flex: 1 1 auto;
}

.diff-title {
  display: block;
  font-size: 15px;
  font-weight: 800;
}

.diff-desc {
  display: block;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
  min-height: 2.7em;
}

.diff-card.is-facile .diff-title {
  color: #16a34a;
}

.diff-card.is-normal .diff-title {
  color: #2563eb;
}

.diff-card.is-examen .diff-title {
  color: #ef4444;
}

.diff-demo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-top: auto;
  padding: 4px 2px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  opacity: 0.72;
}

.diff-demo-btn:hover,
.diff-demo-btn:focus-visible {
  opacity: 1;
}

.diff-demo-btn:disabled {
  opacity: 0.4;
  cursor: wait;
}

.diff-card.is-facile .diff-demo-btn {
  color: #15803d;
}

.diff-card.is-normal .diff-demo-btn {
  color: #1d4ed8;
}

.diff-card.is-examen .diff-demo-btn {
  color: #dc2626;
}

.diff-demo-icon {
  display: none;
}

.menu-level-block {
  margin: 14px 0 16px;
  display: grid;
  gap: 10px;
}

.menu-tuto-btn {
  justify-self: start;
  padding: 8px 12px;
  font-size: 13px;
}

.menu-friends {
  margin: 8px 0 10px;
  padding: 16px 14px 12px;
  border-radius: 16px;
  background: rgba(249, 115, 22, 0.14);
  border: 1.5px solid rgba(249, 115, 22, 0.4);
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.12);
}

.menu-friends-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.menu-friends-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #f97316;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 10px rgba(249, 115, 22, 0.4);
}

.menu-friends-icon svg {
  display: block;
  width: 24px;
  height: 24px;
}

.menu-friends-copy {
  min-width: 0;
}

.menu-friends-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #ea580c;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.menu-friends-lead {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

.menu-friends-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.menu-friends-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #2563eb;
}

.menu-friends-btn-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.menu-friends-btn-icon svg {
  display: block;
}

.menu-friends-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  color: #374151;
}

.tuto-bar {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 5;
  width: min(520px, calc(100% - 20px));
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}

.tuto-bar[hidden] {
  display: none !important;
}

.tuto-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tuto-bar-title {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sage-deep);
}

.tuto-pause-btn,
.tuto-save-btn {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  border-radius: 10px;
}

.tuto-fit-btn {
  padding: 6px 9px;
  font-size: 12px;
}

.tuto-fit-info {
  margin-left: auto;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--sage-deep);
}

.tuto-clock {
  margin-left: auto;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.tuto-wave-wrap {
  position: relative;
  width: 100%;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: #1a2230;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  touch-action: none;
}

.tuto-wave {
  display: block;
  width: 100%;
  height: 100%;
}

.tuto-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #5ad0ff;
  box-shadow: 0 0 6px rgba(90, 208, 255, 0.8);
  pointer-events: none;
  transform: translateX(-1px);
}

.tuto-rec-end {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--orange);
  pointer-events: none;
  transform: translateX(-1px);
}

.tuto-seek {
  width: 100%;
  accent-color: var(--blue);
  cursor: pointer;
}

.tuto-hint,
.tuto-status {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.tuto-hint {
  color: var(--muted);
}

.tuto-status {
  color: var(--sage-deep);
}

.tuto-success-btn {
  flex: 0 0 auto;
  background: var(--sage-deep, #2f6b4f);
  color: #fff;
  border-color: transparent;
}

.tuto-bar.is-recording .tuto-status {
  color: var(--orange);
}

.tuto-bar.is-recording .tuto-wave-wrap {
  box-shadow: inset 0 0 0 2px rgba(237, 139, 51, 0.55);
}

.menu-demo-film {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft, #5a6570);
  cursor: pointer;
  user-select: none;
}

.menu-demo-film[hidden] {
  display: none !important;
}

.menu-demo-film input {
  width: 14px;
  height: 14px;
  accent-color: var(--blue, #2f6fed);
}

.menu-actions {
  display: grid;
  gap: 8px;
}

.menu-actions .primary,
.menu-actions .ghost {
  width: 100%;
  padding: 13px 16px;
  font-size: 15px;
}

.menu-actions .primary:disabled,
.menu-actions .ghost:disabled,
.menu-demo-btn:disabled {
  opacity: 0.45;
  cursor: wait;
}

.hints {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

kbd {
  display: inline-block;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0 5px;
  font-family: inherit;
  font-size: 11px;
  color: var(--ink);
  background: var(--paper);
}

.hints-touch {
  display: none;
}

.menu-codecodec {
  display: flex;
  justify-content: center;
  margin-top: 14px;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.menu-codecodec:hover,
.menu-codecodec:focus-visible {
  opacity: 0.85;
}

.menu-codecodec--promo {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--ink);
  opacity: 1;
  text-align: center;
  background: linear-gradient(135deg, #fff4e4 0%, #ffe8cc 100%);
  border: 1.5px solid rgba(255, 140, 40, 0.35);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(255, 106, 0, 0.1);
}

.menu-codecodec--promo:hover,
.menu-codecodec--promo:focus-visible {
  opacity: 1;
  color: var(--ink);
  border-color: rgba(255, 106, 0, 0.55);
  box-shadow: 0 6px 16px rgba(255, 106, 0, 0.16);
}

.menu-codecodec-copy {
  display: block;
  flex: 0 1 auto;
  max-width: 34ch;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
  color: #3a4450;
  text-align: center;
}

.menu-codecodec-copy strong {
  display: block;
  margin-bottom: 2px;
  font-size: 15px;
  font-weight: 800;
  color: #c2410c;
}

.menu-codecodec-logo {
  display: block;
  height: 32px;
  width: auto;
  object-fit: contain;
  flex: 0 0 auto;
}

.codecodec-promo {
  display: block;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1.5px solid rgba(255, 140, 40, 0.35);
  border-radius: 14px;
  background: linear-gradient(135deg, #fff4e4 0%, #ffe8cc 100%);
  text-align: center;
  text-decoration: none;
  color: #3a4450;
  font-size: 13.5px;
  line-height: 1.4;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(255, 106, 0, 0.08);
}

.codecodec-promo:hover,
.codecodec-promo:focus-visible {
  text-decoration: none;
  border-color: rgba(255, 106, 0, 0.55);
  color: #c2410c;
}

.codecodec-promo strong {
  font-weight: 800;
  color: #c2410c;
}

@media (max-width: 720px) {
  .top-actions .ghost {
    padding: 8px 10px;
    font-size: 12px;
  }

  .cam-author {
    left: 6px;
    right: 6px;
    bottom: 6px;
    padding: 8px 10px;
  }

  .cam-timeline-label {
    font-size: 10px;
  }
}

/* Mobile + tablette (tactile ou écran ≤ 1180 px — iPad paysage inclus) */
@media (max-width: 1180px), ((hover: none) and (pointer: coarse)) {
  #app {
    height: 100dvh;
    padding: 0;
    position: relative;
  }

  .topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "logo actions"
      "title title";
    align-items: center;
    column-gap: 8px;
    row-gap: 4px;
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 8px;
    background: linear-gradient(to bottom, rgba(244, 239, 230, 0.94), rgba(244, 239, 230, 0.2), transparent);
  }

  .brand {
    display: contents;
  }

  .brand-kicker {
    display: none;
  }

  .brand-logo {
    grid-area: logo;
    height: 28px;
  }

  .brand-mark {
    grid-area: logo;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    font-size: 12px;
  }

  .brand > div {
    grid-area: title;
    min-width: 0;
  }

  .brand h1 {
    font-size: 13px;
    line-height: 1.2;
    font-weight: 800;
  }

  .top-actions {
    grid-area: actions;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    min-width: 0;
  }

  .top-actions .ghost {
    padding: 6px 8px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  #btn-traj {
    font-size: 0;
  }

  #btn-traj::after {
    content: "Guidage";
    font-size: 11px;
  }

  #btn-rec-mark {
    font-size: 0;
  }

  #btn-rec-mark::after {
    content: "Enreg.";
    font-size: 11px;
  }

  #btn-rec-mark[data-rec-phase="recording"]::after {
    content: "Stop";
  }

  #btn-rec-mark[data-rec-phase="ready"]::after {
    content: "Sauver";
  }

  #btn-rec-pose {
    font-size: 0;
  }

  #btn-rec-pose::after {
    content: "Pose 1";
    font-size: 11px;
  }

  #btn-rec-offset {
    font-size: 0;
  }

  #btn-rec-offset::after {
    content: "−1,5 m";
    font-size: 11px;
  }

  #btn-leaderboard {
    font-size: 0;
  }

  #btn-leaderboard::after {
    content: "Top 10";
    font-size: 11px;
  }

  #app.is-defi-play #btn-leaderboard::after {
    content: "Défi";
  }

  .defi-play-banner {
    position: absolute;
    top: calc(52px + env(safe-area-inset-top, 0px));
    left: 8px;
    right: 8px;
    z-index: 5;
    margin: 0;
    padding: 6px 10px;
    gap: 6px 8px;
  }

  .defi-play-banner__badge {
    font-size: 10px;
    padding: 3px 8px;
  }

  .defi-play-banner__name {
    font-size: 13px;
  }

  .defi-play-banner__quit {
    padding: 6px 10px !important;
    font-size: 12px !important;
  }

  #btn-restart {
    font-size: 0;
  }

  #btn-restart::after {
    content: "↻";
    font-size: 13px;
  }

  .coach {
    position: absolute;
    left: 8px;
    right: auto;
    width: 112px;
    top: calc(72px + env(safe-area-inset-top, 0px));
    bottom: auto;
    max-height: none;
    height: auto;
    z-index: 3;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(239, 235, 226, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .coach::before {
    display: none;
  }

  .coach-heading {
    display: none;
  }

  .btn-leaderboard {
    display: inline-flex;
  }

  .coach-body {
    display: none;
  }

  .stage {
    display: block;
    flex: 1;
    min-height: 0;
    height: 100%;
  }

  .canvas-wrap {
    position: absolute;
    inset: 0;
    border-radius: 0;
    height: 100%;
    box-shadow: none;
  }

  .coach > * {
    margin-left: 0;
    margin-right: 0;
  }

  .leaderboard {
    font-size: 13px;
  }

  .leaderboard-empty {
    font-size: 13px;
    margin: 4px 0;
  }

  .wheel-panel,
  .steps {
    display: none;
  }

  .stats {
    margin: 0;
    padding: 0;
    border-top: none;
    grid-template-columns: 1fr;
    gap: 4px;
    width: 100%;
    align-self: stretch;
  }

  .stats > div:nth-child(4) {
    display: none;
  }

  .stats div {
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--cream);
  }

  .stats dt {
    font-size: 10px;
  }

  .stats dd {
    font-size: 16px;
  }

  .touch {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom, 0px);
    z-index: 4;
    padding: 8px 10px;
    gap: 10px;
    align-items: flex-end;
    background: linear-gradient(to top, rgba(244, 239, 230, 0.88), transparent);
  }

  .touch-steer {
    width: 148px;
    height: 148px;
  }

  .touch-steer-hit {
    top: -60px;
    left: -60px;
    bottom: -60px;
    right: -24px;
  }

  .touch-drive {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex: 1;
  }

  .pedal {
    height: 148px;
  }

  .pedal-plate {
    width: min(100%, 68px);
    height: 72px;
  }

  .pedal-reverse .pedal-plate {
    width: min(100%, 54px);
    height: 60px;
  }

  .touch button:not(.pedal) {
    min-height: 54px;
    font-size: 14px;
  }

  .toast {
    bottom: calc(130px + env(safe-area-inset-bottom, 0px));
  }

  .hints-keyboard {
    display: none;
  }

  .hints-touch {
    display: block;
  }

  .phone-frame {
    display: none !important;
  }

  .overlay {
    padding: 12px;
    align-items: end;
  }

  .menu-stage {
    width: 100%;
    padding-top: 0;
    max-height: none;
    --fernande-h: 150px;
    --fernande-banner-top: calc(var(--fernande-h) * var(--fernande-overalls) - 4px);
    --fernande-nudge: 3px;
  }

  .menu-fernande {
    right: 48px;
  }

  .menu-card {
    width: 100%;
    margin-top: var(--fernande-banner-top);
    border-radius: 22px 22px 16px 16px;
    padding: 0;
    overflow: visible;
  }

  .menu-body {
    max-height: calc(100dvh - 180px);
    overflow: auto;
  }

  .menu-banner {
    padding: 10px 96px 10px 16px;
    min-height: 48px;
  }

  .menu-banner-title-main {
    font-size: 13px;
    letter-spacing: 0.08em;
  }

  .menu-banner-title-by {
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  .menu-body {
    padding: 18px 18px 16px;
  }

  .menu-card h2 {
    font-size: clamp(22px, 7vw, 32px);
  }
}
@media (max-width: 560px) {
  .brand h1 {
    font-size: 12px;
  }

  .menu-stage {
    --fernande-h: 132px;
    --fernande-banner-top: calc(var(--fernande-h) * var(--fernande-overalls) - 2px);
    --fernande-nudge: 3px;
  }

  .menu-fernande {
    right: 44px;
  }

  .menu-card {
    margin-top: var(--fernande-banner-top);
  }

  .menu-body {
    padding: 14px 14px 12px;
  }

  .menu-kicker {
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .menu-card h2 {
    font-size: clamp(18px, 5.5vw, 24px);
    margin: 4px 0 0;
    line-height: 1.2;
  }

  .menu-level-block {
    margin: 10px 0 12px;
    gap: 8px;
  }

  /* 3 niveaux côte à côte, cartes compactes */
  .difficulty {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .diff-card {
    padding: 8px 4px 8px;
    border-radius: 14px;
    gap: 6px;
  }

  .diff {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    padding: 2px 0 0;
  }

  .diff-icon {
    width: 28px;
    height: 28px;
  }

  .diff-icon svg {
    width: 24px;
    height: 24px;
  }

  .diff-title {
    font-size: 12px;
    line-height: 1.15;
  }

  .diff-desc {
    font-size: 9px;
    font-weight: 600;
    margin-top: 2px;
    min-height: 0;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .diff-demo-btn {
    padding: 3px 2px 1px;
    font-size: 10px;
    gap: 0;
  }

  .menu-actions {
    margin: 0 0 8px;
  }

  .menu-play-btn {
    padding: 12px 14px;
    font-size: 15px;
  }

  .menu-friends {
    margin: 4px 0 8px;
    padding: 14px 12px 10px;
    border-radius: 14px;
  }

  .menu-friends-head {
    gap: 10px;
    margin-bottom: 10px;
  }

  .menu-friends-icon {
    width: 40px;
    height: 40px;
  }

  .menu-friends-icon svg {
    width: 20px;
    height: 20px;
  }

  .menu-friends-title {
    font-size: 16px;
  }

  .menu-friends-lead {
    font-size: 12px;
  }

  .menu-friends-actions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .menu-friends-btn {
    padding: 9px 6px;
    font-size: 11px;
    gap: 4px;
    justify-content: center;
    text-align: center;
    line-height: 1.25;
  }

  .menu-friends-clear {
    margin-top: 6px;
    padding: 8px;
    font-size: 11px;
  }

  .hints {
    font-size: 10px;
    line-height: 1.35;
    margin: 6px 0 0;
  }

  .menu-codecodec {
    margin-top: 10px;
  }

  .menu-codecodec-logo {
    height: 22px;
  }

  .top-actions .ghost {
    padding: 6px 7px;
  }
}

@media (max-width: 1180px) and (orientation: landscape), ((hover: none) and (pointer: coarse) and (orientation: landscape)) {
  .coach {
    left: auto;
    right: 8px;
    top: calc(68px + env(safe-area-inset-top, 0px));
    bottom: auto;
    width: 112px;
    max-width: none;
    height: auto;
    min-height: 0;
    padding: 6px;
    border-radius: 12px;
  }

  .stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 0;
  }

  .stats div {
    padding: 4px 6px;
  }

  .stats dd {
    font-size: 14px;
  }

  .touch {
    left: 0;
    right: 0;
    width: auto;
    bottom: -12px;
    padding: 0 max(14px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px))
      max(14px, env(safe-area-inset-left, 0px));
    background: transparent;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
  }

  .touch-steer,
  .touch-drive {
    pointer-events: auto;
  }

  .touch-steer {
    width: 188px;
    height: 188px;
    margin-left: max(12px, env(safe-area-inset-left, 0px));
  }

  .touch-steer-hit {
    top: -72px;
    left: -72px;
    bottom: -72px;
    right: -32px;
  }

  .touch-drive {
    flex: 0 0 auto;
    width: min(240px, 38vw);
    gap: 12px;
    margin-right: max(8px, env(safe-area-inset-right, 0px));
  }

  .pedal {
    height: 128px;
  }

  .pedal-plate {
    width: min(100%, 76px);
    height: 80px;
  }

  .pedal-reverse .pedal-plate {
    width: min(100%, 62px);
    height: 68px;
  }

  .toast {
    bottom: calc(188px + env(safe-area-inset-bottom, 0px));
  }
}

/* Texte SEO : indexable, hors écran (aucune incidence visuelle). */
.seo-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Tablette portrait — cibles plus grandes */
@media (min-width: 721px) and (max-width: 1180px) and (orientation: portrait),
  ((hover: none) and (pointer: coarse) and (min-width: 721px) and (orientation: portrait)) {
  .touch-steer {
    width: 168px;
    height: 168px;
  }

  .touch-steer-hit {
    top: -64px;
    left: -64px;
    bottom: -64px;
    right: -28px;
  }

  .pedal {
    height: 118px;
  }

  .pedal-plate {
    width: min(100%, 72px);
    height: 76px;
  }

  .top-actions .ghost {
    padding: 10px 14px;
    font-size: 13px;
  }
}
