:root {
  --night: #140c24;
  --ink: #241334;
  --cream: #f6ecd8;
  --cream-dim: #d8cbb4;
  --gold: #f0bf48;
  --gold-deep: #c98d26;
  --glass: rgba(20, 12, 36, 0.74);
  --line: rgba(255, 240, 200, 0.2);
  --focus: #9ad7ff;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--cream);
  font: 500 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  /* mobile : un appui long ne doit pas lancer la sélection de texte ni le menu contextuel (sinon le joystick reste bloqué) */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }

#game {
  position: fixed;
  inset: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font: 700 0.8em/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  text-align: center;
  color: var(--cream);
}

button { font: inherit; color: inherit; }
button:focus-visible, .btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: calc(10px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  right: calc(10px + var(--safe-r));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 200ms ease;
}
body.started .hud { opacity: 1; }
.hud > * { pointer-events: auto; }
body:not(.started) .hud > * { pointer-events: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.clock-icon { display: inline-flex; color: var(--gold); }
.clock-icon .moon { display: none; color: #c9d8ff; }
.clock-icon[data-night="1"] .sun { display: none; }
.clock-icon[data-night="1"] .moon { display: block; }

.hud-actions { display: flex; gap: 8px; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.icon-btn:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: rgba(60, 36, 96, 0.85); }
}
#btn-sound .snd-off { display: none; }
#btn-sound[data-muted="1"] .snd-on { display: none; }
#btn-sound[data-muted="1"] .snd-off { display: block; }

/* ---------- Zone & aide contextuelle ---------- */
.zone {
  position: fixed;
  top: calc(64px + var(--safe-t));
  left: 50%;
  translate: -50% -4px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid rgba(240, 191, 72, 0.45);
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out), translate 200ms var(--ease-out);
  z-index: 4;
}
.zone.show { opacity: 1; translate: -50% 0; }

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  translate: -50% 4px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease-out), translate 160ms var(--ease-out);
  z-index: 4;
}
.hint.show { opacity: 1; translate: -50% 0; }
body:has(.radio.show) .hint { bottom: calc(82px + var(--safe-b)); }
body.is-touch .hint { display: none; }

/* ---------- Boutique goodies ---------- */
.shop-dialog { width: min(94vw, 460px); }
.shop-body { padding: 0 12px 14px; overflow-y: auto; max-height: calc(92vh - 64px); }
.shop-preview { display: flex; align-items: center; gap: 14px; padding: 4px 4px 12px; }
#shop-avatar {
  flex: none;
  width: 90px;
  height: 108px;
  image-rendering: pixelated;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 70%, rgba(240, 191, 72, 0.28), rgba(95, 58, 154, 0.25) 70%);
  border: 1px solid var(--line);
}
.shop-note { margin: 0; font-size: 0.9rem; color: var(--cream-dim); line-height: 1.4; }
.shop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 10px 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease, border-color 160ms ease;
}
.shop-item:active { transform: scale(0.98); }
.shop-item:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .shop-item:hover { background: rgba(255, 255, 255, 0.1); }
}
.shop-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.shop-name { font-weight: 800; }
.shop-desc { font-size: 0.85rem; color: var(--cream-dim); }
.shop-state {
  flex: none;
  min-width: 76px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(240, 191, 72, 0.55);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
}
.shop-item[aria-pressed="true"] { border-color: rgba(240, 191, 72, 0.7); background: rgba(240, 191, 72, 0.12); }
.shop-item[aria-pressed="true"] .shop-state { background: var(--gold); color: var(--ink); }
.shop-item[aria-pressed="true"] .shop-state::before { content: "✓ "; }

/* ---------- Éditeur de personnage ---------- */
.look-dialog { width: min(96vw, 520px); max-height: 94vh; }
.look-dialog[open] { display: flex; flex-direction: column; }
.look-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}
#look-avatar {
  width: 230px;
  height: 120px;
  image-rendering: pixelated;
  border-radius: 14px;
  background: radial-gradient(ellipse at 50% 90%, rgba(240, 191, 72, 0.25), rgba(95, 58, 154, 0.18) 70%);
}
.look-note { margin: 0; font-size: 0.8rem; color: var(--cream-dim); text-align: center; }
.look-body { overflow-y: auto; padding: 6px 14px 12px; display: grid; gap: 4px; overscroll-behavior: contain; }
.look-group { margin: 0; padding: 8px 0; border: 0; min-width: 0; }
.look-group[hidden] { display: none; }
.look-group legend { padding: 0 0 6px; font-weight: 800; font-size: 0.9rem; }
.look-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.look-opt { position: relative; display: inline-flex; cursor: pointer; }
.look-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.look-swatch {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(255, 240, 200, 0.25);
  box-shadow: inset 0 0 0 2px rgba(20, 12, 28, 0.5);
  transition: transform 140ms var(--ease-out), border-color 140ms ease;
}
.look-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 700;
  font-size: 0.9rem;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease;
}
.look-opt:active .look-swatch, .look-opt:active .look-chip { transform: scale(0.95); }
.look-opt input:checked + .look-swatch { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 2px rgba(240, 191, 72, 0.35); }
.look-swatch { position: relative; }
.look-preset {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 16px 6px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease;
}
.look-preset.add { border-style: dashed; color: var(--cream-dim); padding-left: 14px; }
.add-plus { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); font-size: 1.2rem; line-height: 1; }
.skin-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.skin-bar:empty { display: none; }
.skin-text { flex: 1 1 100%; margin: 0; font-size: 0.85rem; color: var(--cream-dim); }
.mini-btn {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.mini-btn:active { transform: scale(0.96); }
.mini-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.mini-btn.primary { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.mini-btn.danger { border-color: rgba(255, 138, 128, 0.55); color: #ffb0a8; }
@media (hover: hover) and (pointer: fine) {
  .mini-btn:hover { background: rgba(255, 255, 255, 0.12); }
  .mini-btn.primary:hover { background: #ffd060; }
}
.skin-form { display: grid; gap: 6px; width: 100%; }
.skin-label { font-size: 0.85rem; font-weight: 700; }
.skin-input {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 240, 200, 0.45);
  background: rgba(10, 6, 20, 0.6);
  color: var(--cream);
  font: inherit;
}
.skin-input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.skin-input[aria-invalid="true"] { border-color: #ff8a80; }
.skin-error { margin: 0; font-size: 0.85rem; color: #ffb0a8; }
.skin-actions { display: flex; gap: 8px; }
.look-preset canvas { width: 28px; height: 44px; image-rendering: pixelated; }
.look-preset:active { transform: scale(0.96); }
.look-preset:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.look-preset[aria-pressed="true"] { border-color: var(--gold); background: rgba(240, 191, 72, 0.16); color: var(--gold); }
.look-preset[aria-pressed="true"] span::after { content: " ✓"; }
@media (hover: hover) and (pointer: fine) {
  .look-preset:hover { background: rgba(255, 255, 255, 0.1); }
}
.look-opt input:checked + .look-swatch::after {
  content: "✓";
  position: absolute;
  right: -6px;
  top: -6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 900;
  box-shadow: 0 0 0 2px #1c1030;
}
.look-opts { padding: 6px 6px 0 0; }
.look-opt input:checked + .look-chip { border-color: var(--gold); background: rgba(240, 191, 72, 0.16); color: var(--gold); }
.look-opt input:checked + .look-chip::before { content: "✓"; margin-right: 6px; }
.look-opt input:focus-visible + .look-swatch, .look-opt input:focus-visible + .look-chip { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .look-opt:hover .look-chip { background: rgba(255, 255, 255, 0.1); }
  .look-opt:hover .look-swatch { border-color: rgba(255, 240, 200, 0.55); }
}
.look-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 14px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line);
}
.look-foot .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.settings-link {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 56px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.settings-link:active { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) {
  .settings-link:hover { background: rgba(255, 255, 255, 0.1); }
}

/* ---------- Fondu (descente / remontée de la Cage) ---------- */
.fade { position: fixed; inset: 0; z-index: 4; background: #000; opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
.fade.on { opacity: 1; }

/* ---------- Bienvenue (première entrée) ---------- */
.welcome {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  z-index: 7;
  display: grid;
  gap: 14px;
  width: min(440px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  max-height: calc(100vh - 120px - var(--safe-t) - var(--safe-b));
  overflow-y: auto;
  padding: 20px 18px 18px;
  border-radius: 20px;
  border: 1px solid rgba(240, 191, 72, 0.45);
  background: rgba(28, 16, 48, 0.95);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  translate: -50% 0;
  opacity: 1;
  transition: opacity 220ms var(--ease-out), translate 260ms var(--ease-out);
  @starting-style { opacity: 0; translate: -50% 16px; }
}
.welcome[hidden] { display: none; }
.welcome.out { opacity: 0; translate: -50% 10px; transition-duration: 180ms; }
.welcome h2 { margin: 0; font-size: 1.25rem; color: var(--gold); text-wrap: balance; }
.welcome-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.welcome-list li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.4; }
.welcome-list strong { color: var(--cream); }
.welcome-ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 900;
}
.welcome-ic.gold { background: var(--gold); color: var(--ink); }
.welcome .btn { width: 100%; }

/* ---------- Succès ---------- */
.ach-toast {
  position: fixed;
  top: calc(66px + var(--safe-t));
  left: 50%;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, calc(100vw - 20px - var(--safe-l) - var(--safe-r)));
  padding: 10px 16px 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(240, 191, 72, 0.6);
  background: rgba(28, 16, 48, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  text-align: left;
  cursor: pointer;
  translate: -50% 0;
  opacity: 1;
  transition: opacity 220ms var(--ease-out), translate 260ms var(--ease-out);
  @starting-style { opacity: 0; translate: -50% -14px; }
}
.ach-toast[hidden] { display: none; }
.ach-toast.out { opacity: 0; translate: -50% -10px; transition-duration: 180ms; }
.ach-toast:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ach-toast-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gold);
  color: var(--ink);
}
.ach-toast-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ach-toast-eyebrow { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.ach-toast-title { font-weight: 800; }
.ach-toast-desc { font-size: 0.85rem; color: var(--cream-dim); }
.ach-dialog { width: min(94vw, 460px); }
.ach-body { padding: 0 12px 14px; overflow-y: auto; max-height: calc(92vh - 64px); }
.ach-summary { margin: 0 4px 12px; color: var(--cream-dim); }
.ach-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ach-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}
.ach-item.done { border-color: rgba(240, 191, 72, 0.6); background: rgba(240, 191, 72, 0.1); }
.ach-item-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream-dim);
  font-weight: 900;
  font-size: 1.1rem;
}
.ach-item.done .ach-item-icon { background: var(--gold); color: var(--ink); }
.ach-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ach-item-title { font-weight: 800; }
.ach-item-desc { font-size: 0.85rem; color: var(--cream-dim); }
.ach-reset { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.ach-reset:empty { display: none; }
.ach-reset p { flex: 1 1 100%; margin: 0; font-size: 0.85rem; color: var(--cream-dim); }
.ach-item-date { font-size: 0.75rem; color: var(--gold); font-weight: 700; }

/* ---------- Réglages ---------- */
.settings-dialog { width: min(94vw, 420px); }
.settings-body { padding: 4px 12px 14px; }
.switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}
.switch-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.switch-title { font-weight: 800; }
.switch-desc { font-size: 0.85rem; color: var(--cream-dim); line-height: 1.35; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 240, 200, 0.45);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: translate 180ms var(--ease-out);
}
.switch:checked { background: var(--gold); border-color: var(--gold); }
.switch:checked::after { translate: 20px 0; background: var(--ink); }
.switch:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- One World Radio (Grande Scène) ---------- */
.radio {
  position: fixed;
  left: calc(10px + var(--safe-l));
  bottom: calc(22px + var(--safe-b));
  max-width: min(360px, calc(100vw - 20px - var(--safe-l) - var(--safe-r)));
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 6px 6px 12px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  translate: 0 6px;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out), translate 200ms var(--ease-out);
  z-index: 4;
}
.radio.show { opacity: 1; translate: 0 0; pointer-events: auto; }
body.is-touch .radio { max-width: calc(100vw - 132px - var(--safe-l) - var(--safe-r)); }
.radio-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #8a8398; }
.radio[data-state="loading"] .radio-dot { animation: radio-wait 900ms ease-in-out infinite alternate; }
.radio[data-state="playing"] .radio-dot { background: #ff4d5e; box-shadow: 0 0 0 3px rgba(255, 77, 94, 0.28); }
.radio[data-state="error"] .radio-dot { background: var(--gold); }
@keyframes radio-wait { from { opacity: 0.35; } to { opacity: 1; } }
.radio-text { display: flex; flex-direction: column; min-width: 0; padding-right: 6px; line-height: 1.25; }
.radio-name { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.radio-track { font-size: 0.9rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.radio-retry {
  flex: none;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(240, 191, 72, 0.55);
  background: rgba(240, 191, 72, 0.14);
  color: var(--gold);
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.radio-retry { display: inline-flex; align-items: center; gap: 6px; }
.radio-retry[hidden] { display: none; }
@media (max-width: 480px) {
  .radio-retry { width: 44px; padding: 0; justify-content: center; }
  .radio-retry-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.radio-retry:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .radio-retry:hover { background: rgba(240, 191, 72, 0.24); }
}

/* ---------- Bulles ---------- */
.bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.bubble {
  position: absolute;
  left: 0;
  top: 0;
  max-width: min(220px, 60vw);
  padding: 7px 11px;
  border-radius: 10px;
  background: #fff8ea;
  color: var(--ink);
  border: 2px solid var(--ink);
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.3;
  box-shadow: 0 3px 0 rgba(20, 12, 36, 0.35);
  transform-origin: 50% 100%;
  transition: opacity 160ms var(--ease-out), scale 160ms var(--ease-out);
  margin-top: -8px;
}
@starting-style { .bubble { opacity: 0; scale: 0.94; } }
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 10px;
  height: 10px;
  background: #fff8ea;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}
.bubble.out { opacity: 0; scale: 0.96; }

/* ---------- Contrôles tactiles ---------- */
.touch-layer { position: fixed; inset: 0; z-index: 2; touch-action: none; }
.stick {
  position: fixed;
  left: 0;
  top: 0;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border-radius: 50%;
  background: rgba(20, 12, 36, 0.35);
  border: 2px solid rgba(246, 236, 216, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.stick.on { opacity: 1; }
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(246, 236, 216, 0.85);
  box-shadow: 0 2px 0 rgba(20, 12, 36, 0.5);
  transform: translate(-50%, -50%);
}

.action-btn {
  position: fixed;
  right: calc(18px + var(--safe-r));
  bottom: calc(22px + var(--safe-b));
  z-index: 5;
  display: none;
  min-width: 84px;
  height: 84px;
  padding: 0 12px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 4px 0 var(--gold-deep);
  touch-action: manipulation;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
}
.action-btn:active { transform: translateY(3px) scale(0.97); box-shadow: 0 1px 0 var(--gold-deep); }
body.is-touch.started .action-btn { display: block; }

/* ---------- Écran d'accueil ---------- */
.start {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(180deg, rgba(20, 12, 36, 0.55), rgba(20, 12, 36, 0.86) 60%);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  overflow-y: auto;
  transition: opacity 200ms var(--ease-out);
}
.start.leaving { opacity: 0; pointer-events: none; }
.start-card {
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 16px;
  padding: 24px 20px;
  border-radius: 20px;
  background: rgba(28, 16, 48, 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.title {
  margin: 0;
  display: grid;
  gap: 2px;
  font-size: clamp(1.9rem, 8vw, 2.5rem);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--gold);
  text-shadow: 0 3px 0 #5a3510;
}
.title-hl {
  color: #ff8fc8;
  text-shadow: 0 3px 0 #7a2450;
}
.subtitle {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: none;
}
.tagline { margin: 0; color: var(--cream-dim); }
.avatar { display: flex; align-items: center; justify-content: center; gap: 16px; }
#avatar {
  width: 70px;
  height: 110px;
  image-rendering: pixelated;
  padding: 0;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 85%, rgba(240, 191, 72, 0.25), transparent 60%);
}
.btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  border: 0;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 var(--gold-deep); font-size: 1.05rem; }
.btn.primary:active { transform: translateY(2px) scale(0.98); box-shadow: 0 2px 0 var(--gold-deep); }
.btn.secondary { background: rgba(255, 255, 255, 0.08); color: var(--cream); border: 1px solid var(--line); }
@media (hover: hover) and (pointer: fine) {
  .btn.secondary:hover { background: rgba(255, 255, 255, 0.14); }
}
.avatar-actions { display: grid; gap: 8px; }
.avatar-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.controls { margin: 0; font-size: 0.875rem; color: var(--cream-dim); line-height: 1.7; }

/* ---------- Plan ---------- */
.map-dialog {
  width: min(94vw, 720px);
  max-height: 92vh;
  padding: 0;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #1c1030;
  color: var(--cream);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.map-dialog::backdrop { background: rgba(10, 6, 20, 0.62); }
.map-dialog[open] { animation: map-in 200ms var(--ease-out); }
@keyframes map-in { from { opacity: 0; transform: scale(0.97); } }
.map-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 18px; }
.map-head h2 { margin: 0; font-size: 1.1rem; color: var(--gold); }
.map-body { position: relative; margin: 0 12px 12px; border-radius: 12px; overflow: hidden; }
#map-canvas { display: block; width: 100%; height: auto; }
.map-labels { position: absolute; inset: 0; pointer-events: none; }
.map-label {
  position: absolute;
  translate: -50% -50%;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(20, 12, 36, 0.82);
  color: var(--cream);
  font-size: clamp(0.65rem, 2.2vw, 0.8rem);
  font-weight: 700;
  white-space: nowrap;
}
.map-me {
  position: absolute;
  width: 14px;
  height: 14px;
  translate: -50% -50%;
  border-radius: 50%;
  background: #ff5e7e;
  border: 2px solid #fff8ea;
  box-shadow: 0 0 0 4px rgba(255, 94, 126, 0.35);
}
.map-me span {
  position: absolute;
  left: 50%;
  bottom: 16px;
  translate: -50% 0;
  padding: 1px 6px;
  border-radius: 6px;
  background: #ff5e7e;
  color: #fff8ea;
  font-size: 0.75rem;
  font-weight: 800;
}

@media (min-width: 640px) {
  .start-card { padding: 32px 32px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .zone, .hint { translate: -50% 0; transition: opacity 160ms ease; }
  .radio, .radio.show { translate: 0 0; transition: opacity 160ms ease; }
  .switch::after { transition: none; }
  .look-swatch, .look-chip { transition: none; }
  .ach-toast { transition: opacity 160ms ease; @starting-style { opacity: 0; translate: -50% 0; } }
  .ach-toast.out { translate: -50% 0; }
  .welcome { transition: opacity 160ms ease; @starting-style { opacity: 0; translate: -50% 0; } }
  .welcome.out { translate: -50% 0; }
  .radio[data-state="loading"] .radio-dot { animation: none; opacity: 0.7; }
  .zone.show, .hint.show { translate: -50% 0; }
  .bubble { transition: opacity 160ms ease; }
  @starting-style { .bubble { scale: 1; } }
  .map-dialog[open] { animation: none; }
  .btn:active, .icon-btn:active, .action-btn:active { transform: none; }
}
