:root {
  --ink: #2a1f2d;
  --cream: #fff7ee;
  --matcha: #7fae4b;
  --rose: #e8698a;
  --gold: #e2a93b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #f6cfb8;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink); overscroll-behavior: none; touch-action: none;
  user-select: none; -webkit-user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#hud {
  position: fixed; inset: 0; pointer-events: none;
  padding: calc(env(safe-area-inset-top) + 12px) 12px 12px;
  display: flex; justify-content: space-between; align-items: flex-start;
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 6px; }
.hud-right { align-items: flex-end; margin-right: 48px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 247, 238, .88); border-radius: 999px;
  padding: 5px 12px 5px 8px; font-size: 17px; min-width: 74px;
  box-shadow: 0 2px 10px rgba(60, 30, 40, .15);
}
.pill b { font-variant-numeric: tabular-nums; }
.pill.score { padding: 5px 14px; justify-content: flex-end; font-size: 20px; }
.pill.pop { animation: pop .25s ease-out; }
@keyframes pop { 50% { transform: scale(1.18); } }
.lives { font-size: 18px; letter-spacing: 2px; filter: drop-shadow(0 1px 3px rgba(60,30,40,.3)); }

#boostbar {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%); width: min(260px, 60vw); height: 20px;
  background: rgba(255, 247, 238, .8); border-radius: 999px; overflow: hidden;
  box-shadow: 0 2px 10px rgba(60, 30, 40, .15);
}
#boostbar i { position: absolute; inset: 0; width: 0; background: linear-gradient(90deg, #a9d06f, var(--matcha)); border-radius: 999px; transition: width .2s; }
#boostbar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 20px; letter-spacing: 3px; font-weight: 700; color: #35501c; }
#boostbar.on i { background: linear-gradient(90deg, #ffe07a, #ff9fb8); }

#mute {
  position: fixed; top: calc(env(safe-area-inset-top) + 10px); right: 10px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; border: 0; font-size: 18px;
  background: rgba(255, 247, 238, .88); box-shadow: 0 2px 10px rgba(60, 30, 40, .15);
}
#toast {
  position: fixed; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none;
  font-size: clamp(22px, 5vw, 34px); font-weight: 800; color: #fff;
  text-shadow: 0 2px 0 rgba(60, 30, 40, .35), 0 4px 18px rgba(60, 30, 40, .4);
  opacity: 0; transform: translateY(10px) scale(.9); transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: none; }
#flash { position: fixed; inset: 0; pointer-events: none; background: #ff5a76; opacity: 0; transition: opacity .35s; }
#flash.on { opacity: .35; transition: none; }

.overlay {
  position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 22px);
  background: linear-gradient(180deg, rgba(42, 31, 45, 0) 30%, rgba(42, 31, 45, .45));
}
#over { align-items: center; background: rgba(42, 31, 45, .45); backdrop-filter: blur(3px); }
.card {
  width: min(430px, 100%); background: rgba(255, 247, 238, .94); border-radius: 26px;
  padding: 20px 22px 18px; text-align: center; box-shadow: 0 18px 50px rgba(42, 31, 45, .35);
}
.kicker { margin: 0 0 4px; font-size: 12px; letter-spacing: 4px; text-transform: uppercase; color: var(--rose); font-weight: 700; }
h1, h2 { font-family: "Didot", "Bodoni 72", "Playfair Display", Georgia, serif; margin: 0; line-height: 1; font-weight: 700; }
h1 { font-size: clamp(40px, 11vw, 58px); }
h1 em { font-size: .62em; color: var(--matcha); font-weight: 400; }
h2 { font-size: clamp(26px, 7vw, 34px); }
.lead { margin: 12px 0 14px; font-size: 15px; line-height: 1.4; }
.btn {
  appearance: none; border: 0; border-radius: 999px; padding: 14px 46px; font: inherit;
  font-size: 19px; font-weight: 800; letter-spacing: 1px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #f08aa3, var(--rose)); box-shadow: 0 6px 0 #b9456a, 0 12px 24px rgba(232, 105, 138, .4);
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b9456a; }
.keys { margin: 14px 0 0; font-size: 12px; opacity: .7; }
.keys.touch { display: none; }
@media (pointer: coarse) { .keys.desk { display: none; } .keys.touch { display: block; } }
.best { margin: 8px 0 0; font-size: 13px; font-weight: 700; color: #8a6a3a; min-height: 1em; }
.big { font-size: 56px; font-weight: 800; margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.stats { display: flex; justify-content: center; gap: 10px; margin-bottom: 6px; }
.stats div { flex: 1; background: #fff; border-radius: 16px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; }
.stats span { font-size: 20px; } .stats b { font-size: 20px; } .stats small { font-size: 11px; opacity: .6; }
#over .btn { margin-top: 12px; }
@media (max-height: 520px) {
  .lead, .keys { display: none !important; }
  h1 { font-size: 34px; } .card { padding: 12px 18px; } .btn { margin-top: 10px; padding: 10px 40px; }
  .big { font-size: 36px; margin: 2px 0; }
}
@media (orientation: landscape) and (min-width: 700px) {
  #menu { align-items: center; justify-content: flex-end; padding-right: 7vw; background: none; }
}

/* Une petite édition parisienne : portraits et choix accessibles. */
.overlay { z-index: 3; overflow-y: auto; touch-action: pan-y; }
#menu { align-items: center; justify-content: center; padding: max(20px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom)); background: rgba(40, 37, 36, .3); backdrop-filter: blur(5px); }
.card { border: 1px solid rgba(255,255,255,.8); background: #fff8ef; }
.menu-card { width: min(960px, 100%); display: grid; grid-template-columns: .9fr 1.1fr; gap: 38px; padding: 38px; text-align: left; border-radius: 22px; }
.menu-copy { align-self: center; }
.kicker { color: #876b44; font-size: 10px; letter-spacing: 2.7px; }
h1 { font-weight: 400; font-size: clamp(48px, 5.8vw, 76px); line-height: .98; margin: 22px 0; letter-spacing: -2px; }
h1 em { color: #566942; font-size: .76em; }
.lead { color: #655b51; font-size: 15px; line-height: 1.65; max-width: 320px; }
.route { color: #9b825f; font-size: 12px; letter-spacing: 3px; margin: 24px 0 0; }
.choice-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.7px; margin: 0 0 12px; color: #6f6252; }
.character-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.character-option { position: relative; min-width: 0; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #e9dfce; color: #fff; cursor: pointer; font: inherit; text-align: left; aspect-ratio: 2 / 3; transition: border-color .18s, box-shadow .18s; }
.character-option img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }
.character-option::after { content: ''; position: absolute; inset: 40% 0 0; background: linear-gradient(transparent, rgba(32,30,25,.8)); pointer-events: none; }
.character-option[aria-checked="true"] { border-color: #718052; box-shadow: 0 0 0 3px rgba(113,128,82,.18); }
.character-option:hover { border-color: #a09278; }
.character-caption { position: absolute; z-index: 1; left: 12px; right: 8px; bottom: 13px; }
.character-caption b { display: block; font: 27px Georgia, serif; }
.character-caption small { display: block; margin-top: 3px; font-size: 9px; color: #f1e4d1; }
.choice-check { display: none; position: absolute; z-index: 1; top: 9px; right: 9px; width: 23px; height: 23px; background: #566942; border: 1px solid #e2e6d5; border-radius: 50%; text-align: center; line-height: 21px; font-size: 13px; }
[aria-checked="true"] .choice-check { display: block; }
button:focus-visible { outline: 3px solid #354e37; outline-offset: 5px; }
.btn { width: 100%; margin-top: 20px; background: #526442; border-radius: 8px; padding: 14px 18px; font-size: 15px; letter-spacing: .3px; box-shadow: 0 3px 0 #36482a; }
.btn:active { box-shadow: 0 1px 0 #36482a; transform: translateY(2px); }
.btn:disabled { opacity: .65; cursor: wait; }
#asset-status { font-size: 11px; margin: 9px 0 0; color: #826143; }
#asset-status:empty { display: none; }
.text-btn { display: block; margin: 6px auto; padding: 5px; background: none; border: none; text-decoration: underline; color: #526442; cursor: pointer; }
.keys { font-size: 10px; line-height: 1.5; text-align: center; margin-top: 13px; }
.select-keys { margin-top: 3px; }
.best { font-size: 11px; text-align: center; }
#over .card { width: min(440px, 100%); padding: 24px; }
#over h2 { margin-top: 10px; font-size: 28px; }
#over .big { font-size: 48px; }
#over .choice-label { margin-top: 17px; }
#over .character-option { height: 146px; aspect-ratio: auto; }
#over .character-option img { object-position: center top; }
#over .character-caption { bottom: 9px; }
#over .character-caption b { font-size: 23px; }
#district { position: absolute; top: calc(env(safe-area-inset-top) + 16px); left: 50%; transform: translateX(-50%); text-align: center; color: #473e36; text-shadow: 0 1px 8px #fff7ed; }
#district span { display: block; text-transform: uppercase; font-size: 9px; letter-spacing: 1.4px; }
#district b { display: block; font: 23px Georgia, serif; margin-top: 4px; }
#district-caption { position: absolute; left: 50%; top: 17%; transform: translate(-50%, 8px); width: max-content; max-width: 90%; text-align: center; padding: 12px 24px; background: rgba(255,248,239,.94); border-radius: 3px; color: #526442; font: 24px Georgia, serif; opacity: 0; transition: opacity .7s, transform .7s; }
#district-caption.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 650px) {
  #menu { padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)); }
  .menu-card { display: block; padding: 23px 20px 19px; text-align: center; border-radius: 18px; }
  h1 { font-size: 48px; margin: 12px 0; }
  h1 br { display: none; }
  h1 em { display: block; font-size: .72em; margin-top: 1px; }
  .lead { font-size: 12px; line-height: 1.5; margin: 10px auto 14px; }
  .route { display: none; }
  .choice-label { font-size: 9px; margin-bottom: 10px; }
  .character-picker { gap: 10px; }
  .character-option { aspect-ratio: 2 / 3; }
  .character-caption { left: 9px; bottom: 11px; }
  .character-caption b { font-size: 24px; }
  .character-caption small { font-size: 8px; }
  .btn { margin-top: 16px; }
  .select-keys { display: none; }
  #district { top: calc(env(safe-area-inset-top) + 18px); }
  #district b { font-size: 17px; max-width: 135px; }
  #district span { font-size: 7px; }
  #district-caption { font-size: 21px; top: 19%; }
}
@media (max-height: 600px) and (min-width: 651px) {
  .menu-card { max-width: 800px; padding: 22px; gap: 28px; }
  .character-option { height: 220px; aspect-ratio: auto; }
  h1 { font-size: 54px; }
  #over .card { padding: 14px 22px; }
  #over .character-option { height: 92px; }
  #over .big { font-size: 32px; }
  #over .choice-label { margin: 10px 0 7px; }
}
@media (max-height: 710px) and (max-width: 650px) {
  #menu { align-items: flex-start; padding: 12px; }
  .menu-card { padding: 16px; }
  h1 { font-size: 38px; margin: 8px 0; }
  .character-option { max-height: 200px; }
  .keys { margin-top: 9px; }
  #over .character-option { height: 112px; }
}
@media (prefers-reduced-motion: reduce) { .character-option, #district-caption { transition: none; } }
/* Téléphone couché : la carte de fin dépassait de l'écran. On la tasse, et si ça ne suffit pas elle défile au lieu de rogner le bouton. */
#over .card { max-height: calc(100dvh - 12px); overflow-y: auto; }
@media (max-height: 440px) {
  #over { padding: 6px 16px; }
  #over .card { padding: 10px 20px; }
  #over .kicker { display: none; }
  #over h2 { margin-top: 0; font-size: 22px; }
  #over .big { font-size: 26px; margin: 0 0 4px; }
  #over .stats div { flex-direction: row; justify-content: center; gap: 6px; padding: 5px 4px; }
  #over .stats span, #over .stats b { font-size: 16px; }
  #over .best { margin-top: 4px; }
  #over .choice-label { margin: 6px 0 5px; }
  #over .character-option { height: 76px; }
  #over .btn { margin-top: 8px; }
}
