:root {
  --ink: #1b1030;
  --pink: #ff4fa3;
  --gold: #ffd23f;
  --sand: #f3d9a4;
  --paper: #fffaf0;
  --white: #fff;
  --shadow: 0 4px 0 rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  height: 100%; overflow: hidden; background: var(--ink); color: var(--white);
  font-family: Nunito, system-ui, sans-serif; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }

/* ---------- textes de jeu ---------- */
.big, #count, #banner, #lap, #pos, #timer, .logo, .cta, .end-title {
  font-family: 'Luckiest Guy', Nunito, sans-serif; letter-spacing: .02em;
}
#hud { position: fixed; inset: 0; pointer-events: none; }
#lap, #timer {
  position: absolute; left: 16px; font-size: 26px;
  -webkit-text-stroke: 1.5px var(--ink); text-shadow: var(--shadow);
}
#lap { top: calc(12px + env(safe-area-inset-top)); color: var(--gold); }
#timer { top: calc(44px + env(safe-area-inset-top)); font-size: 20px; }
#item {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: 64px; height: 64px; border-radius: 14px; border: 4px solid var(--white);
  background: rgba(27, 16, 48, .55); display: grid; place-items: center; font-size: 36px;
}
#item.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: translateX(-50%) scale(1.5); } 100% { transform: translateX(-50%) scale(1); } }
#posbox { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 16px; text-align: right; }
#pos {
  font-size: 54px; line-height: 1; color: var(--white);
  -webkit-text-stroke: 2px var(--ink); text-shadow: var(--shadow);
}
#pos sup { font-size: 26px; }
#ranking { list-style: none; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
#ranking li {
  display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 13px;
  background: rgba(27, 16, 48, .55); border-radius: 20px; padding: 2px 8px 2px 2px;
}
#ranking li.me { background: var(--pink); }
#ranking .av { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; background: #fff3; overflow: hidden; }
#ranking .av img { width: 100%; height: 100%; }

#count, #banner {
  position: fixed; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none;
  -webkit-text-stroke: 3px var(--ink); text-shadow: 0 6px 0 rgba(0, 0, 0, .35);
}
#count { font-size: 120px; color: var(--gold); top: 12%; }
#count.go { color: #5dff7a; }
#count.tick { animation: tick .9s ease-out; }
@keyframes tick { 0% { transform: scale(2); opacity: 0; } 20% { transform: scale(1); opacity: 1; } 100% { transform: scale(.9); opacity: 1; } }
#banner { font-size: 64px; color: var(--white); line-height: 1.05; }
#banner small { display: block; font-size: 28px; color: var(--gold); margin-top: 10px; }
#banner.show { animation: tick 1s ease-out; }

#caption {
  position: fixed; left: 16px; right: 16px; bottom: calc(14% + env(safe-area-inset-bottom)); text-align: center;
  font-family: 'Luckiest Guy', sans-serif; font-size: clamp(24px, 6vw, 44px); line-height: 1.15;
  -webkit-text-stroke: 1.5px var(--ink); text-shadow: var(--shadow); pointer-events: none;
  opacity: 0; transition: opacity .5s;
}
#caption.on { opacity: 1; }
#caption.huge { font-size: clamp(44px, 13vw, 96px); color: var(--gold); top: 22%; bottom: auto; }
#fade { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; }

/* ---------- commandes tactiles ---------- */
#controls {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 0 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none;
}
#controls button {
  pointer-events: auto; width: 96px; height: 96px; border-radius: 50%;
  border: 4px solid var(--white); background: rgba(27, 16, 48, .45); color: var(--white);
  font-size: 40px; touch-action: none;
}
#controls button.active { background: rgba(255, 79, 163, .75); transform: scale(.94); }
#controls .pad { display: flex; align-items: flex-end; gap: 10px; pointer-events: none; }
#btnItem { width: 78px !important; height: 78px !important; font-size: 34px !important; margin-bottom: 10px; }
#btnItem:disabled { opacity: .35; }
#btnDrift { width: 78px !important; height: 78px !important; font-size: 32px !important; margin-bottom: 10px; border-color: #4fb8ff !important; }
#btnDrift.active { background: rgba(79, 184, 255, .75) !important; }

/* ---------- compteur, jauge de dérapage, mini-carte, lignes de vitesse ---------- */
#speedo {
  position: absolute; left: 16px; bottom: calc(132px + env(safe-area-inset-bottom)); display: flex; align-items: baseline; gap: 4px;
  font-family: 'Luckiest Guy', Nunito, sans-serif; color: var(--white); -webkit-text-stroke: 1.5px var(--ink); text-shadow: var(--shadow);
  flex-wrap: wrap; width: 120px;
}
#speedo #speed { font-size: 44px; line-height: 1; min-width: 72px; text-align: right; transition: color .15s; }
#speedo small { font-size: 14px; letter-spacing: .04em; }
#speedo.boost #speed { color: var(--gold); }
#gauge {
  --g: 0; width: 100%; height: 10px; border-radius: 6px; border: 2px solid var(--white); background: rgba(27, 16, 48, .55);
  overflow: hidden; opacity: 0; transition: opacity .2s; margin-top: 2px;
}
#gauge.on { opacity: 1; }
#gauge i { display: block; height: 100%; width: calc(var(--g) * 100%); background: #4fb8ff; transition: background .15s; }
#gauge.full i { background: #ffa020; box-shadow: 0 0 10px #ffa020; }
#minimap {
  position: absolute; left: 16px; top: calc(74px + env(safe-area-inset-top)); width: 186px; height: 62px;
}
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
@media (max-width: 480px) {
  #minimap { width: 150px; height: 50px; }
  #speedo #speed { font-size: 36px; min-width: 60px; }
  #speedo { width: 100px; }
}

/* ---------- écrans ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto; touch-action: pan-y;
}
#title { background: linear-gradient(180deg, rgba(27, 16, 48, .35) 0%, rgba(27, 16, 48, 0) 30%, rgba(27, 16, 48, 0) 62%, rgba(27, 16, 48, .7) 100%); }
.title-inner { text-align: center; max-width: 420px; width: 100%; display: flex; flex-direction: column; align-items: center; }
.logo { display: flex; flex-direction: column; line-height: .9; font-weight: 400; }
.logo span:first-child { font-size: clamp(56px, 17vw, 88px); color: var(--pink); -webkit-text-stroke: 3px var(--white); text-shadow: 0 6px 0 var(--ink); }
.logo span:last-child { font-size: clamp(46px, 14vw, 72px); color: var(--gold); -webkit-text-stroke: 3px var(--ink); text-shadow: 0 6px 0 rgba(0,0,0,.35); transform: rotate(-3deg); }
.sub { font-weight: 900; font-size: 18px; margin-top: 8px; text-shadow: 0 2px 0 var(--ink); }
.duo { height: min(38vh, 340px); margin: 8px 0 4px; }
.hint { font-weight: 900; font-size: 18px; text-shadow: 0 2px 0 var(--ink); }
.small { font-size: 13px; opacity: .9; margin-top: 12px; font-weight: 800; }
.q { display: inline-block; background: var(--gold); color: var(--ink); border-radius: 4px; padding: 0 5px; }
.cta {
  margin-top: 14px; font-size: 28px; color: var(--ink); background: var(--gold);
  border: 4px solid var(--white); border-radius: 999px; padding: 12px 34px; cursor: pointer;
  box-shadow: 0 6px 0 var(--ink); animation: bounce 1.4s ease-in-out infinite;
}
.cta:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
@keyframes bounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

#end { background: rgba(27, 16, 48, .45); align-items: flex-start; }
.end-inner { max-width: 560px; width: 100%; text-align: center; margin: auto; padding: 8px 0 24px; }
.end-title { font-size: clamp(34px, 9vw, 56px); color: var(--gold); -webkit-text-stroke: 2px var(--ink); text-shadow: var(--shadow); line-height: 1.05; }
.reveal { font-size: clamp(22px, 6vw, 30px); font-weight: 900; margin-top: 10px; text-shadow: 0 2px 0 var(--ink); }
.reveal b { color: var(--gold); }
.dates { font-weight: 800; margin-top: 4px; text-shadow: 0 2px 0 var(--ink); }
.passes { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.pass {
  display: flex; background: var(--paper); color: var(--ink); border-radius: 16px; overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35); text-align: left; opacity: 0; transform: translateY(40px) rotate(-2deg);
}
.pass.in { animation: passIn .8s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.pass:nth-child(2).in { animation-delay: .35s; }
@keyframes passIn { to { opacity: 1; transform: none; } }
.pass-main { flex: 1; padding: 12px 14px; min-width: 0; }
.pass header {
  display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 900;
  text-transform: uppercase; letter-spacing: .06em; color: #8a6a4a;
}
.pass .air { color: var(--pink); }
.route { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 8px; }
.route b { display: block; font-family: 'Luckiest Guy', sans-serif; font-size: 40px; line-height: 1; font-weight: 400; }
.route small { font-weight: 800; font-size: 12px; color: #8a6a4a; }
.route div:last-child { text-align: right; }
.route .mid { flex: 1; text-align: center; font-size: 26px; color: var(--pink); position: relative; }
.route .mid::before { content: ''; position: absolute; left: 12%; right: 12%; top: 50%; border-top: 2px dashed #d9c3a0; z-index: 0; }
dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; }
dt { font-size: 10px; font-weight: 900; text-transform: uppercase; color: #8a6a4a; letter-spacing: .05em; }
dd { font-weight: 900; font-size: 13px; }
.pass-stub {
  width: 84px; flex: none; background: var(--sand); border-left: 3px dashed #c9a46a;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 6px;
}
.pass-stub small { font-size: 10px; font-weight: 900; text-transform: uppercase; color: #8a6a4a; }
.pass-stub b { font-family: 'Luckiest Guy', sans-serif; font-size: 34px; font-weight: 400; }
.barcode { width: 60px; height: 44px; margin-top: 4px; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px, var(--ink) 8px 11px, transparent 11px 12px); }
.small-cta { font-size: 20px; padding: 10px 24px; margin-top: 22px; animation: none; }

#confetti { position: fixed; inset: 0; pointer-events: none; width: 100%; height: 100%; }
#mute {
  position: fixed; bottom: calc(130px + env(safe-area-inset-bottom)); right: 16px; width: 40px; height: 40px;
  border-radius: 50%; border: 2px solid var(--white); background: rgba(27, 16, 48, .5); font-size: 18px; z-index: 5;
}
#title:not([hidden]) ~ #mute { bottom: calc(16px + env(safe-area-inset-bottom)); }
#end:not([hidden]) ~ #mute, #voyage:not([hidden]) ~ #mute { display: none; }

/* ---------- programme du voyage ---------- */
.end-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cta.ghost { background: transparent; color: var(--white); border-color: rgba(255, 255, 255, .7); box-shadow: 0 4px 0 rgba(0, 0, 0, .35); font-size: 17px; margin-top: 12px; }
#voyage { background: linear-gradient(180deg, #2a1d5e 0%, #7d3b6c 45%, #e3634f 100%); align-items: flex-start; overscroll-behavior: contain; }
.voyage-inner { max-width: 560px; width: 100%; margin: 0 auto; padding: 4px 0 32px; }
.voyage-head { position: relative; text-align: center; padding: 8px 44px 14px; }
.voyage-title { font-family: 'Luckiest Guy', Nunito, sans-serif; font-weight: 400; font-size: clamp(30px, 8vw, 46px); color: var(--gold); -webkit-text-stroke: 2px var(--ink); text-shadow: var(--shadow); line-height: 1.05; }
.voyage-sub { font-weight: 800; margin-top: 4px; text-shadow: 0 2px 0 var(--ink); }
.back {
  position: absolute; left: 0; top: 8px; width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--white); background: rgba(27, 16, 48, .5); color: var(--white); font-size: 26px; line-height: 1; cursor: pointer;
}
.days { list-style: none; position: relative; padding-left: 56px; display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.days::before { content: ''; position: absolute; left: 21px; top: 10px; bottom: 10px; border-left: 3px dashed rgba(255, 255, 255, .45); }
.day { position: relative; opacity: 0; transform: translateY(26px); animation: dayIn .6s cubic-bezier(.2, 1.2, .4, 1) forwards; animation-delay: calc(var(--i, 0) * 80ms); }
@keyframes dayIn { to { opacity: 1; transform: none; } }
.day-num {
  position: absolute; left: -56px; top: 10px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--pink); border: 3px solid var(--white); box-shadow: 0 4px 0 rgba(0, 0, 0, .3);
  display: grid; place-items: center; font-family: 'Luckiest Guy', sans-serif; font-size: 18px; color: var(--white);
}
.day-card { background: var(--paper); color: var(--ink); border-radius: 16px; padding: 12px 14px; box-shadow: 0 10px 24px rgba(0, 0, 0, .3); text-align: left; position: relative; }
.day-date { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: #8a6a4a; }
.day-title { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: 24px; line-height: 1.1; margin-top: 2px; color: var(--ink); }
.day-place { font-weight: 800; font-size: 13px; color: var(--pink); margin-top: 4px; }
.day-text { font-weight: 700; font-size: 14px; margin-top: 6px; line-height: 1.4; }
.day-list { margin: 8px 0 0 18px; font-weight: 700; font-size: 13px; line-height: 1.5; }
.tag { display: inline-block; margin-top: 8px; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; background: var(--gold); color: var(--ink); border-radius: 999px; padding: 2px 8px; }
.voyage-note { margin: 18px 10px 0; font-weight: 800; font-size: 13px; text-align: center; text-shadow: 0 2px 0 var(--ink); opacity: .9; }
#voyage .small-cta { display: block; margin: 20px auto 0; }
@media (max-width: 480px) {
  dl { grid-template-columns: repeat(2, 1fr); }
  .pass-stub { width: 66px; }
  .pass header span:last-child { display: none; }
  .route b { font-size: 34px; }
}

/* ---------- à plusieurs : salon et écran partagé (players.js, net.js) ---------- */
.cta.alt { font-size: 18px; padding: 10px 22px; margin-top: 10px; background: rgba(27, 16, 48, .55); color: var(--white); animation: none; box-shadow: 0 4px 0 rgba(0, 0, 0, .35); }
#lobby { background: rgba(27, 16, 48, .78); }
.lobby-inner { width: 100%; max-width: 640px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lobby-title { font-family: 'Luckiest Guy', sans-serif; font-size: clamp(36px, 8vw, 56px); color: var(--gold); -webkit-text-stroke: 2px var(--ink); text-shadow: var(--shadow); font-weight: 400; }
.lobby-hint { font-weight: 800; font-size: 15px; }
.lobby-hint span { color: var(--gold); word-break: break-all; }
.lobby-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; justify-content: center; }
#qr { width: 180px; height: 180px; background: var(--white); border-radius: 14px; padding: 8px; display: grid; place-items: center; }
#qr svg, #qr img { width: 100% !important; height: 100% !important; display: block; }
.code-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.code-box small { font-weight: 900; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; opacity: .85; }
.code { font-family: 'Luckiest Guy', sans-serif; font-size: 72px; letter-spacing: .18em; color: var(--white); -webkit-text-stroke: 2px var(--ink); text-shadow: 0 6px 0 rgba(0, 0, 0, .35); line-height: 1; }
.slots { list-style: none; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.slot { width: 180px; padding: 12px 10px; border-radius: 18px; border: 3px solid rgba(255, 255, 255, .35); background: rgba(27, 16, 48, .55); display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 900; font-size: 18px; }
.slot .av { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; background: #fff3; overflow: hidden; }
.slot .av img { width: 100%; height: 100%; }
.slot small { font-size: 12px; font-weight: 800; opacity: .9; min-height: 2.6em; display: flex; align-items: center; }
.slot.connected { border-color: var(--gold); }
.slot.ready { border-color: #5dff7a; background: rgba(93, 255, 122, .18); }
.slot.lost { border-color: #ff6b6b; }
.lobby-status { font-weight: 800; font-size: 14px; min-height: 1.4em; opacity: .9; }
.lobby-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lobby-actions .cta { animation: none; margin-top: 4px; font-size: 24px; }
.lobby-actions .cta.pulse { animation: bounce 1.2s ease-in-out infinite; }
.link { background: none; border: 0; color: var(--white); font-weight: 800; text-decoration: underline; font-size: 14px; cursor: pointer; opacity: .85; }

#views { position: fixed; inset: 0; pointer-events: none; }
#views .view, #views .vpanel { position: absolute; }
#views .view { box-shadow: inset 0 0 0 3px var(--ink); }
.vtag { position: absolute; left: 10px; top: 8px; display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 14px; padding: 3px 10px 3px 3px; border-radius: 20px; background: var(--c, var(--pink)); color: var(--white); text-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.vtag .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; background: #fff3; overflow: hidden; }
.vtag .av img { width: 100%; height: 100%; }
.vtag .vstage { font-family: 'Luckiest Guy', sans-serif; color: var(--gold); -webkit-text-stroke: .8px var(--ink); margin-left: 4px; }
.view.lost .vtag::after { content: '📵 autopilote'; margin-left: 6px; font-size: 12px; }
.vitem { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 48px; height: 48px; border-radius: 12px; border: 3px solid var(--white); background: rgba(27, 16, 48, .55); display: grid; place-items: center; font-size: 27px; }
.vitem.pop { animation: pop .35s ease-out; }
.vpos { position: absolute; right: 12px; top: 2px; font-family: 'Luckiest Guy', sans-serif; font-size: 40px; line-height: 1; color: var(--white); -webkit-text-stroke: 1.5px var(--ink); text-shadow: var(--shadow); }
.vpos sup { font-size: 20px; }
.vspeed { position: absolute; left: 10px; bottom: 8px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px; width: 92px; font-family: 'Luckiest Guy', Nunito, sans-serif; color: var(--white); -webkit-text-stroke: 1px var(--ink); text-shadow: var(--shadow); }
.vspeed span { font-size: 30px; line-height: 1; min-width: 52px; text-align: right; transition: color .15s; }
.vspeed small { font-size: 11px; letter-spacing: .04em; }
.vspeed.boost span { color: var(--gold); }
.vgauge { --g: 0; width: 100%; height: 8px; border-radius: 5px; border: 2px solid var(--white); background: rgba(27, 16, 48, .55); overflow: hidden; opacity: 0; transition: opacity .2s; margin-top: 2px; }
.vgauge.on { opacity: 1; }
.vgauge i { display: block; height: 100%; width: calc(var(--g) * 100%); background: #4fb8ff; transition: background .15s; }
.vgauge.full i { background: #ffa020; box-shadow: 0 0 10px #ffa020; }
.vpanel { background: radial-gradient(circle at 50% 110%, #3a2160 0%, var(--ink) 70%); box-shadow: inset 0 0 0 3px var(--ink); display: flex; }
.vpanel .vmap { width: 55%; height: 100%; display: block; }
.vpanel .vrank { flex: 1; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; padding: 10px 14px; }
.vpanel .vtimer { font-family: 'Luckiest Guy', sans-serif; font-size: 26px; -webkit-text-stroke: 1px var(--ink); text-shadow: var(--shadow); }
.vpanel ol { list-style: none; counter-reset: rank; display: flex; flex-direction: column; gap: 5px; align-items: stretch; width: 100%; max-width: 220px; }
.vpanel li { counter-increment: rank; display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 15px; background: rgba(255, 255, 255, .1); border-radius: 20px; padding: 3px 10px 3px 4px; }
.vpanel li::before { content: counter(rank); font-family: 'Luckiest Guy', sans-serif; width: 22px; text-align: center; color: var(--gold); }
.vpanel li.human { background: var(--c); }
.vpanel li .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; background: #fff3; overflow: hidden; }
.vpanel li .av img { width: 100%; height: 100%; }

/* billets : Istanbul barré par un tampon, puis Le Caire */
.route .dest { position: relative; text-align: right; min-width: 92px; }
.route .dest .fake, .route .dest .real { display: block; transition: opacity .35s, transform .35s; }
.route .dest .real { position: absolute; right: 0; top: 0; opacity: 0; transform: scale(1.4); }
.route .dest .stamp {
  position: absolute; right: -6px; top: 6px; padding: 2px 6px; border: 3px solid #d0202a; border-radius: 6px;
  color: #d0202a; font-style: normal; font-weight: 900; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; transform: rotate(-14deg) scale(2.2); opacity: 0; pointer-events: none; background: rgba(255,250,240,.85);
}
.pass.twist .dest .fake { opacity: .35; text-decoration: line-through 3px #d0202a; }
.pass.twist .dest .stamp { animation: stamp .35s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.pass.revealed .dest .fake { opacity: 0; transform: translateY(-8px); }
.pass.revealed .dest .real { opacity: 1; transform: none; }
.pass.revealed .dest .stamp { top: 44px; }
@keyframes stamp { to { opacity: 1; transform: rotate(-14deg) scale(1); } }

/* ---------- histoire : présentation des pilotes, bulles d'indices, podium (story.js) ---------- */
#story { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.icard-wrap { position: absolute; left: 0; right: 0; bottom: calc(8% + env(safe-area-inset-bottom)); display: flex; justify-content: center; padding: 0 16px; }
.icard {
  display: flex; align-items: center; gap: 16px; min-width: min(540px, 100%); max-width: 100%;
  background: linear-gradient(135deg, var(--pink), #ff8ac6); color: var(--white);
  border: 5px solid var(--white); border-radius: 26px; padding: 12px 28px 12px 14px;
  box-shadow: 0 8px 0 var(--ink), 0 16px 30px rgba(0, 0, 0, .35); opacity: 0;
}
.icard.hero { background: linear-gradient(135deg, var(--gold), #ffb340); color: var(--ink); }
.icard.in { animation: cardIn .5s cubic-bezier(.2, 1.5, .4, 1) forwards; }
.icard.out { animation: cardOut .3s ease-in forwards; }
@keyframes cardIn { from { opacity: 0; transform: translateY(70px) rotate(-5deg) scale(.75); } to { opacity: 1; transform: none; } }
@keyframes cardOut { to { opacity: 0; transform: translateY(40px) scale(.9); } }
.icard-av { width: 104px; height: 104px; border-radius: 50%; border: 4px solid var(--white); background: #fff3; object-fit: cover; flex: none; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.icard-txt { display: flex; flex-direction: column; min-width: 0; }
.icard-name { font-family: 'Luckiest Guy', Nunito, sans-serif; font-size: clamp(34px, 6vw, 50px); line-height: 1; color: var(--white); -webkit-text-stroke: 2px var(--ink); text-shadow: 0 5px 0 var(--ink); }
.icard.hero .icard-name { color: var(--pink); -webkit-text-stroke: 2px var(--white); }
.icard-nick { font-weight: 900; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; margin-top: 6px; opacity: .95; }
.icard-line { font-weight: 800; font-size: 17px; line-height: 1.25; margin-top: 6px; }
.icard.hero .icard-line { font-family: 'Luckiest Guy', Nunito, sans-serif; font-weight: 400; font-size: clamp(26px, 4.5vw, 36px); color: var(--white); -webkit-text-stroke: 1.5px var(--ink); text-shadow: 0 3px 0 var(--ink); }
.icard-sub { font-weight: 800; font-size: 14px; margin-top: 4px; }
.icard-sub:empty, .icard-nick:empty { display: none; }
.iskip { position: absolute; right: 18px; bottom: calc(16px + env(safe-area-inset-bottom)); font-weight: 800; font-size: 13px; background: rgba(27, 16, 48, .55); border-radius: 999px; padding: 5px 12px; opacity: .85; animation: bounce 1.6s ease-in-out infinite; }

.bubble { position: absolute; left: 16px; bottom: calc(215px + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 10px; opacity: 0; max-width: min(420px, 80vw); }
.bubble.in { animation: bubbleIn .45s cubic-bezier(.2, 1.5, .4, 1) forwards; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(30px) scale(.7); } to { opacity: 1; transform: none; } }
.bubble img { width: 76px; height: 76px; border-radius: 50%; border: 4px solid var(--white); background: #fff3; flex: none; box-shadow: var(--shadow); }
.bubble-txt {
  position: relative; background: var(--white); color: var(--ink); font-weight: 800; font-size: 16px; line-height: 1.3;
  border-radius: 18px; padding: 10px 14px; margin-bottom: 14px; border: 3px solid var(--ink); box-shadow: 0 5px 0 rgba(0, 0, 0, .3);
}
.bubble-txt::before { content: ''; position: absolute; left: -14px; bottom: 10px; border: 8px solid transparent; border-right: 10px solid var(--ink); border-left: 0; }
.bubble-txt::after { content: ''; position: absolute; left: -9px; bottom: 12px; border: 6px solid transparent; border-right: 8px solid var(--white); border-left: 0; }

.podboard { position: absolute; left: 16px; top: calc(16px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; width: min(340px, 70vw); }
.podboard-title { font-family: 'Luckiest Guy', Nunito, sans-serif; font-size: clamp(34px, 6vw, 48px); color: var(--gold); -webkit-text-stroke: 2px var(--ink); text-shadow: 0 5px 0 rgba(0, 0, 0, .35); line-height: 1; margin-bottom: 4px; opacity: 0; }
.podboard.in .podboard-title { animation: rowIn .5s cubic-bezier(.2, 1.4, .4, 1) .2s forwards; }
.podboard ol { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.prow { display: flex; align-items: center; gap: 10px; background: rgba(27, 16, 48, .65); border: 3px solid rgba(255, 255, 255, .5); border-radius: 999px; padding: 4px 16px 4px 6px; opacity: 0; }
.podboard.in .prow { animation: rowIn .5s cubic-bezier(.2, 1.4, .4, 1) forwards; animation-delay: calc(2.4s - var(--i, 0) * .8s); }
.podboard.in .prow:nth-child(n+4) { animation-delay: 3s; }
.prow.me { background: var(--pink); border-color: var(--white); }
.prow .medal { font-size: 26px; width: 34px; text-align: center; font-weight: 900; }
.prow .av { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #fff3; border: 2px solid var(--white); flex: none; }
.prow .av img { width: 100%; height: 100%; }
.prow .pname { font-family: 'Luckiest Guy', Nunito, sans-serif; font-size: 22px; -webkit-text-stroke: 1px var(--ink); text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.prow .ptime { margin-left: auto; font-weight: 900; font-size: 15px; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
@keyframes rowIn { from { opacity: 0; transform: translateX(-50px) scale(.8); } to { opacity: 1; transform: none; } }

#story-title {
  position: absolute; left: 16px; right: 16px; top: calc(5% + env(safe-area-inset-top)); text-align: center;
  font-family: 'Luckiest Guy', Nunito, sans-serif; font-size: clamp(28px, 5.5vw, 56px); line-height: 1.05; color: var(--gold);
  -webkit-text-stroke: 2.5px var(--ink); text-shadow: 0 7px 0 rgba(0, 0, 0, .35);
  opacity: 0; transform: scale(.7); transition: opacity .5s, transform .5s cubic-bezier(.2, 1.4, .4, 1);
}
#story-title.on { opacity: 1; transform: none; }
#story-title small { display: block; font-family: Nunito, sans-serif; font-weight: 900; font-size: clamp(16px, 3vw, 24px); color: var(--white); -webkit-text-stroke: 0; text-shadow: 0 2px 0 var(--ink); margin-top: 8px; }
#story-title small:empty { display: none; }
@media (max-width: 600px) {
  .icard { gap: 10px; padding: 10px 16px 10px 10px; }
  .icard-av { width: 72px; height: 72px; }
  .podboard { width: min(300px, 80vw); }
  .prow .pname { font-size: 18px; }
}

/* ---------------------------------------------------------------- final : vidéos des amis et message */
.fv-slot { position: fixed; z-index: 6; margin: 0; width: min(17vw, 29vh); pointer-events: none; opacity: 0;
  transform: translate(var(--dx), var(--dy)) rotate(var(--tilt)) scale(.8); transition: opacity .6s, transform .8s cubic-bezier(.2, 1.3, .4, 1); }
.fv-slot.in { opacity: 1; transform: rotate(var(--tilt)); }
/* coins : chaque vidéo glisse depuis son coin, inclinée vers le centre */
.fv-tl { top: 5vh; left: 3vw; --tilt: -7deg; --dx: -30vw; --dy: -30vh; }
.fv-br { bottom: 5vh; right: 3vw; --tilt: -7deg; --dx: 30vw; --dy: 30vh; }
.fv-tr { top: 5vh; right: 3vw; --tilt: 7deg; --dx: 30vw; --dy: -30vh; }
.fv-bl { bottom: 5vh; left: 3vw; --tilt: 7deg; --dx: -30vw; --dy: 30vh; }
.fv-slot.land { width: min(30vw, 50vh); }
.fv-frame { aspect-ratio: 9 / 16; border-radius: 16px; overflow: hidden; border: 5px solid #fff; background: #1b1030;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5), 0 0 26px rgba(255, 79, 163, .4); }
.fv-slot.land .fv-frame { aspect-ratio: 16 / 9; }
.fv-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.fv-slot figcaption { margin-top: 8px; text-align: center; color: #fff; font-family: 'Luckiest Guy', system-ui, sans-serif;
  font-size: clamp(18px, 2vw, 28px); text-shadow: 0 3px 0 #ff4fa3, 0 6px 16px rgba(0, 0, 0, .6); }
#finale-sign { position: fixed; left: 0; right: 0; bottom: 7vh; z-index: 7; text-align: center; pointer-events: none; color: #fff;
  opacity: 0; transform: translateY(20px) scale(.9); transition: opacity .8s, transform .8s cubic-bezier(.2, 1.4, .4, 1); }
#finale-sign.in { opacity: 1; transform: none; }
#finale-sign b { display: block; font-family: 'Luckiest Guy', system-ui, sans-serif; font-size: clamp(30px, 5.4vw, 72px); letter-spacing: 1px;
  color: #ffd23f; text-shadow: 0 4px 0 #ff4fa3, 0 8px 24px rgba(0, 0, 0, .6); }
#finale-sign small { display: block; margin-top: 6px; font-weight: 800; font-size: clamp(15px, 1.8vw, 24px); text-shadow: 0 2px 8px rgba(0, 0, 0, .7); }

/* bouton « Passer la course » : visible de la présentation à l'arrivée */
.skip-race { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%) translateY(64px); z-index: 8;
  border: 2px solid rgba(255, 255, 255, .85); background: rgba(27, 16, 48, .6); color: #fff; font: 800 14px Nunito, system-ui, sans-serif;
  border-radius: 999px; padding: 7px 16px; cursor: pointer; backdrop-filter: blur(4px); }
.skip-race:hover { background: #ff4fa3; }

.cta:disabled { opacity: .75; cursor: progress; font-size: 18px; }
/* téléphone en portrait : vidéos du final bien plus grandes, toujours en diagonale autour de Manon */
@media (orientation: portrait) {
  .fv-slot { width: 46vw; }
  .fv-slot.land { width: 74vw; }
  .fv-tl, .fv-tr { top: 3vh; } .fv-bl, .fv-br { bottom: 3vh; }
}
