/* DÉVALE ! : interface HTML/CSS par-dessus la scène 3D. */
:root {
  --ink: #10284a; --paper: #fbfdff; --red: #e8352e; --redD: #a8201b; --blue: #2f7fe8; --blueD: #14407a; --ice: #dff1ff; --gold: #ffc21f; --night: #0c2448;
  --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px);
  --font: "Avenir Next", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: var(--font); touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { position: fixed; inset: 0; -webkit-tap-highlight-color: transparent; }
/* appui long sur mobile : ni sélection de texte, ni menu copier/coller, ni aperçu d'image */
html, body, canvas, img, button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.fade { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .35s ease; z-index: 5; }
.fade.on { opacity: 1; }
.speed { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; z-index: 2;
  background: radial-gradient(ellipse 75% 70% at 45% 50%, transparent 60%, rgba(255, 255, 255, .28) 85%, rgba(160, 210, 255, .3) 100%); }
.speed.on { opacity: 1; }

.boot { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #3f8fe0, #0c2448); z-index: 50; color: #fff; }
.bootCard { display: grid; gap: 6px; justify-items: center; }
.bootCard b { font-size: 60px; font-weight: 900; font-style: italic; color: #fff; text-shadow: 0 4px 0 var(--red), 0 8px 18px #0008; }
.bootCard span { font-weight: 800; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); font-size: 13px; }
.bootCard i { width: 160px; height: 6px; border-radius: 6px; background: #ffffff22; overflow: hidden; position: relative; margin-top: 12px; }
.bootCard i::after { content: ""; position: absolute; inset: 0; width: 40%; border-radius: 6px; background: var(--gold); animation: load 1s ease-in-out infinite alternate; }
.bootCard small { opacity: .8; font-size: 13px; margin-top: 4px; }
@keyframes load { to { transform: translateX(150%); } }

.screen { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: calc(12px + var(--sat)) calc(16px + var(--sar)) calc(12px + var(--sab)) calc(16px + var(--sal)); overflow-y: auto; }
.home { background: linear-gradient(90deg, rgba(10, 36, 72, .66), rgba(10, 36, 72, .12) 60%, transparent); place-items: center start; }
.homeCard { width: min(430px, 100%); display: grid; gap: 14px; padding: 8px 4px; }
.logo { margin: 0; display: grid; line-height: .9; }
.logoZ { font-size: clamp(58px, 13vh, 104px); font-weight: 900; color: #fff; letter-spacing: .01em; -webkit-text-stroke: 3px var(--blueD); paint-order: stroke fill; text-shadow: 0 6px 0 var(--red), 0 12px 24px #0007; font-style: italic; }
.logoSub { font-size: clamp(16px, 3.4vh, 24px); font-weight: 900; color: var(--gold); letter-spacing: .2em; text-transform: uppercase; -webkit-text-stroke: 1.5px #5a3a00; paint-order: stroke fill; margin: 8px 0 0 6px; }
.tag { margin: 0; color: #fff; font-weight: 700; text-shadow: 0 2px 6px #0009; }
.menu { display: grid; gap: 9px; }
.btn { min-height: 48px; border: 0; border-radius: 16px; padding: 10px 18px; background: rgba(251, 253, 255, .95); color: var(--ink); font-weight: 800; font-size: 17px; text-align: left; box-shadow: 0 4px 0 #2a4a7a, 0 10px 20px #0004; transition: transform .08s; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #2a4a7a, 0 6px 12px #0004; }
.btn:focus-visible, .iconBtn:focus-visible, .back:focus-visible, .mapArrow:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: linear-gradient(180deg, #ff5a4a, var(--red)); color: #fff; box-shadow: 0 5px 0 var(--redD), 0 12px 24px #0005; text-shadow: 0 2px 0 #8a1810; }
.btn.big { min-height: 62px; font-size: 25px; justify-content: center; font-style: italic; }
.homeFoot { margin: 4px 0 0; font-size: 12px; color: #eaf4ff; opacity: .9; text-shadow: 0 1px 3px #000a; }

.panelScreen { background: rgba(10, 36, 72, .55); }
.panel { width: min(760px, 100%); max-height: 100%; overflow-y: auto; background: var(--paper); border-radius: 22px; padding: 16px 18px 20px; box-shadow: 0 20px 50px #0007; }
.panelHead { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.panelHead h2 { margin: 0; font-size: 24px; font-weight: 900; }
.back { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--ice); font-size: 22px; font-weight: 900; }
.note { margin: 0 0 12px; font-size: 14px; color: #3a5274; }
.note.m0 { margin: 0; }
h3.sub { margin: 14px 0 6px; font-size: 15px; color: var(--blue); text-transform: uppercase; letter-spacing: .05em; }
.mList { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mList li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: #eef5fc; font-weight: 700; font-size: 14px; }
.mList li.done { background: #e2f7e4; color: #2a6a32; }
.mList li.on { background: #fff3cf; box-shadow: inset 0 0 0 2px var(--gold); }
.mList li.later { color: #8a9ab0; }
.mi { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #fff; font-weight: 900; font-size: 13px; box-shadow: inset 0 0 0 2px #0001; }

/* HUD */
.hud { position: fixed; z-index: 8; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: calc(8px + var(--sat)) calc(12px + var(--sar)) 0 calc(12px + var(--sal)); pointer-events: none; }
.hudLeft, .hudRight, .hudMid { display: flex; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(10, 36, 72, .62); color: #fff; font-weight: 900; font-size: 18px; text-shadow: 0 1px 2px #000a; font-variant-numeric: tabular-nums; }
.chip.dist { flex-direction: column; align-items: flex-start; gap: 0; border-radius: 16px; padding: 4px 12px; }
.chip.dist small { font-size: 11px; font-weight: 700; opacity: .8; }
.chip.score em { font-style: normal; color: var(--gold); font-size: 15px; }
.ico.ring { width: 18px; height: 18px; border-radius: 50%; border: 4px solid var(--gold); box-shadow: 0 0 6px #ffb21f; }
.chase { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(10, 36, 72, .62); color: #fff; }
.chase i { position: relative; width: clamp(80px, 18vw, 160px); height: 10px; border-radius: 6px; background: #ffffff30; overflow: hidden; }
.chase i b { position: absolute; inset: 0; background: linear-gradient(90deg, #ffd23a, #ff5a3a); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
.chase.danger { animation: danger .5s ease-in-out infinite alternate; }
.chase.danger i b { background: #ff3a2a; }
@keyframes danger { to { background: rgba(200, 30, 20, .75); } }
.chaseIco, .chaseMe { font-size: 16px; }
.power { position: relative; width: 70px; height: 26px; border-radius: 999px; background: rgba(10, 36, 72, .62); overflow: hidden; box-shadow: inset 0 0 0 2px #ffffff50; }
.power i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, #ff8a1e, #ffd23a); }
.power.umbrella i { background: linear-gradient(90deg, #ff5d8f, #ffb8d0); } .power.magnet i { background: linear-gradient(90deg, #4ac0ff, #bfefff); }
.power::after { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; }
.power.choc::after { content: "☕"; } .power.umbrella::after { content: "☂"; } .power.magnet::after { content: "🧲"; }
.chip.shield { padding: 4px 8px; font-size: 18px; }
.iconBtn { pointer-events: auto; width: 46px; height: 46px; border-radius: 14px; border: 0; background: rgba(10, 36, 72, .62); color: #fff; font-size: 16px; font-weight: 900; }
.pops { position: fixed; z-index: 8; left: 50%; top: calc(58px + var(--sat)); transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; pointer-events: none; }
.pop { font-weight: 900; font-size: 22px; color: #fff; -webkit-text-stroke: 1px var(--blueD); paint-order: stroke fill; text-shadow: 0 3px 0 var(--blueD), 0 6px 14px #0006; animation: popUp 1.5s ease-out forwards; white-space: nowrap; font-style: italic; }
.pop.big { font-size: 30px; color: var(--gold); }
.pop.bad { color: #ffd0c8; text-shadow: 0 3px 0 var(--redD), 0 6px 14px #0006; }
@keyframes popUp { 0% { opacity: 0; transform: translateY(14px) scale(.8); } 12% { opacity: 1; transform: translateY(0) scale(1.08); } 22% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-18px); } }
.toast { position: fixed; z-index: 9; left: 50%; bottom: calc(18px + var(--sab)); transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); padding: 10px 18px; border-radius: 16px; background: rgba(251, 253, 255, .95); font-weight: 800; font-size: 16px; text-align: center; box-shadow: 0 8px 20px #0005; pointer-events: none; animation: toastIn .25s ease-out; }
.toast.mission { background: #fff3cf; box-shadow: 0 0 0 3px var(--gold), 0 8px 20px #0005; }
.toast.tip { background: #e6f3ff; }
.toast.choc { background: #ffe2c8; } .toast.umbrella { background: #ffe0ec; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* commandes tactiles : deux grandes moitiés d'écran */
.touch { position: fixed; inset: 0; z-index: 7; display: grid; grid-template-columns: 2fr 3fr; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; padding-top: calc(70px + var(--sat)); }
.touch.mirror { grid-template-columns: 3fr 2fr; }
.touch.mirror .down { order: 2; } .touch.mirror .jump { order: 1; }
.tZone { position: relative; touch-action: none; }
.tZone span { position: absolute; bottom: calc(18px + var(--sab)); display: grid; place-items: center; text-align: center; width: 104px; height: 104px; border-radius: 50%; color: #fff; font-weight: 900; font-size: 20px; text-shadow: 0 2px 3px #0009; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .6); line-height: 1; }
.tZone span small { display: block; font-size: 10px; font-weight: 800; opacity: .9; margin-top: -18px; }
.tZone.down span { left: calc(20px + var(--sal)); background: rgba(47, 127, 232, .42); font-size: 34px; }
.tZone.jump span { right: calc(20px + var(--sar)); background: rgba(232, 53, 46, .5); width: 120px; height: 120px; }
.touch.mirror .down span { left: auto; right: calc(20px + var(--sar)); } .touch.mirror .jump span { right: auto; left: calc(20px + var(--sal)); }
.tZone.on span { filter: brightness(1.4); transform: scale(.94); }
@media (max-height: 420px) { .tZone span { width: 88px; height: 88px; } .tZone.jump span { width: 100px; height: 100px; } }

/* modales maison (jamais d'alert/confirm natif) */
.modalWrap { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: calc(12px + var(--sat)) calc(16px + var(--sar)) calc(12px + var(--sab)) calc(16px + var(--sal)); background: rgba(8, 24, 50, .6); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { width: min(500px, 100%); max-height: 100%; overflow-y: auto; background: var(--paper); border-radius: 22px; padding: 18px 20px; box-shadow: 0 24px 60px #000a; display: grid; gap: 12px; }
.modal h2 { margin: 0; font-size: 24px; font-weight: 900; }
.modalBody { display: grid; gap: 10px; font-size: 15px; }
.modalBody p { margin: 0; }
.modalActions { display: grid; gap: 8px; }
.modalActions .btn { justify-content: center; text-align: center; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 12px; background: #eef5fc; font-weight: 700; }
.opt small { display: block; font-weight: 500; font-size: 12px; color: #4b6080; }
.opt input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--red); flex: none; }
.opt input[type=range] { width: 140px; accent-color: var(--red); }
.opt select { font: inherit; padding: 6px; border-radius: 10px; border: 1px solid #b9cbe3; background: #fff; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.keys kbd { font-family: inherit; font-weight: 800; background: var(--ice); border-radius: 8px; padding: 2px 8px; box-shadow: 0 2px 0 #b9cbe3; white-space: nowrap; align-self: start; }
.result { display: grid; gap: 8px; }
.resBig { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.resBig div { display: grid; justify-items: center; padding: 10px; border-radius: 14px; background: linear-gradient(180deg, #e6f3ff, #cfe6ff); }
.resBig b { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; } .resBig span { font-size: 12px; font-weight: 800; color: #4b6080; text-transform: uppercase; }
.resRow { display: flex; justify-content: space-between; gap: 10px; padding: 7px 12px; border-radius: 12px; background: #eef5fc; font-weight: 700; font-size: 14px; }
.resRow b { font-variant-numeric: tabular-nums; text-align: right; }
.record { color: var(--red); font-weight: 900; text-align: center; font-size: 18px; }
.won { margin: 0; padding: 8px 12px; border-radius: 12px; background: #fff3cf; font-weight: 800; font-size: 14px; }
.miniMissions { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; font-weight: 700; color: #6a5200; }
.bigIcon { font-size: 42px; text-align: center; margin: 0; }

.update { position: fixed; z-index: 40; left: 50%; bottom: calc(12px + var(--sab)); transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; border-radius: 16px; background: var(--paper); box-shadow: 0 10px 30px #0006; font-weight: 700; font-size: 14px; }
.update span { flex: 1 1 200px; }
.update button { min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 0; background: var(--blueD); color: #fff; font-weight: 800; }
.update button:last-child { background: #fff; color: var(--blueD); box-shadow: inset 0 0 0 2px var(--blueD); }
.noscript { color: #fff; padding: 20px; }

/* carte des départs */
.mapScreen { display: flex; flex-direction: column; justify-content: space-between; align-items: stretch; background: transparent; pointer-events: none; overflow: hidden; }
.mapScreen > * { pointer-events: auto; }
.mapHead { display: flex; align-items: center; gap: 12px; align-self: start; }
.mapInfo { display: grid; gap: 2px; padding: 8px 16px; border-radius: 16px; background: rgba(251, 253, 255, .94); box-shadow: 0 6px 16px #0004; min-width: 220px; }
.mapInfo small { font-size: 12px; font-weight: 800; color: var(--red); text-transform: uppercase; letter-spacing: .04em; }
.mapInfo b { font-size: 20px; }
.mapInfo span { font-size: 13px; font-weight: 700; color: #3a5274; }
.mapNav { display: flex; justify-content: center; align-items: center; gap: 14px; }
.mapNav .btn { min-width: 190px; justify-content: center; }
.mapArrow { width: 60px; height: 60px; border: 0; border-radius: 50%; background: rgba(251, 253, 255, .94); color: var(--ink); font-size: 24px; box-shadow: 0 4px 0 #2a4a7a, 0 10px 20px #0004; }
.mapArrow:disabled { opacity: .35; }
.titleCard { position: fixed; z-index: 8; left: 50%; top: 32%; transform: translate(-50%, -50%); display: grid; gap: 4px; text-align: center; padding: 12px 26px; border-radius: 22px; background: rgba(251, 253, 255, .95); box-shadow: 0 12px 30px #0005; pointer-events: none; animation: tcIn 2.6s ease-in-out forwards; }
.titleCard small { font-weight: 800; color: var(--red); text-transform: uppercase; letter-spacing: .05em; font-size: 13px; }
.titleCard b { font-size: 26px; font-style: italic; }
@keyframes tcIn { 0% { opacity: 0; transform: translate(-50%, -40%) scale(.9); } 12%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60%); } }

@media (max-width: 560px) { .home { place-items: end center; background: linear-gradient(0deg, rgba(10, 36, 72, .7), transparent 75%); } }
@media (max-height: 520px) and (orientation: landscape) {
  .homeCard { width: min(440px, 52vw); gap: 8px; }
  .logoZ { font-size: 54px; } .logoSub { font-size: 14px; } .tag { font-size: 14px; }
  .menu { grid-template-columns: 1fr 1fr; gap: 7px; } .menu .big { grid-column: 1 / -1; min-height: 52px; font-size: 22px; }
  .btn { min-height: 44px; font-size: 15px; padding: 8px 14px; }
  .homeFoot { font-size: 11px; }
  .chip { font-size: 15px; padding: 4px 10px; } .pop { font-size: 18px; } .pop.big { font-size: 24px; }
  .mapInfo { padding: 6px 12px; } .mapInfo b { font-size: 16px; } .mapArrow { width: 50px; height: 50px; } .mapNav .btn.big { min-height: 50px; font-size: 19px; } .titleCard b { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) { .bootCard i::after, .chase.danger { animation: none; } .titleCard { animation-timing-function: steps(1, end); } }
/* Options : sections, réglage des touches */
.optH { margin: 6px 0 -4px; font-size: 13px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--redD); }
.btn.optKeys { min-height: 0; padding: 10px 12px; font-size: 16px; background: #eef5fc; box-shadow: 0 3px 0 #b9cbe3; flex-direction: column; align-items: flex-start; gap: 2px; }
.btn.optKeys small { font-weight: 500; font-size: 12px; color: #4b6080; }
.keyIntro { margin: 0; font-size: 13px; color: #4b6080; }
.keyRows { display: grid; gap: 6px; }
.keyRow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 6px 10px; border-radius: 12px; background: #eef5fc; font-weight: 700; font-size: 15px; }
.keySlots { display: flex; gap: 6px; flex: none; }
.keySlot { min-width: 64px; height: 38px; padding: 0 8px; border: 2px solid #b9cbe3; border-bottom-width: 4px; border-radius: 10px; background: #fff; font-weight: 800; font-size: 14px; color: var(--ink); white-space: nowrap; }
.keySlot.empty { color: #9db0c9; border-style: dashed; border-bottom-width: 2px; }
.keySlot.wait { border-color: var(--red); color: var(--red); animation: keyBlink .8s ease-in-out infinite; }
.keySlot:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.keyNote { margin: 0; min-height: 2.6em; font-size: 13px; font-weight: 700; color: var(--blueD); }
.keyNote.warn { color: var(--redD); }
@keyframes keyBlink { 50% { background: #ffe9e6; } }
@media (max-width: 520px) { .keySlot { min-width: 48px; } .keyRow { font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .keySlot.wait { animation: none; background: #ffe9e6; } }
/* Carte : choix de l'univers */
.mapUnis { position: absolute; top: calc(10px + var(--sat)); right: calc(12px + var(--sar)); display: flex; gap: 8px; pointer-events: auto; }
.uniTab { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; border: 0; border-radius: 14px; background: rgba(251, 253, 255, .9); box-shadow: 0 4px 0 #2a4a7a55, 0 6px 14px #0003; font-weight: 800; font-size: 14px; color: var(--ink); }
.uniTab span { font-size: 20px; line-height: 1; }
.uniTab.on { background: linear-gradient(180deg, #ff5a4a, var(--red)); color: #fff; box-shadow: 0 4px 0 var(--redD), 0 6px 14px #0004; }
.uniTab.locked { opacity: .72; }
.uniTab.locked b { color: #5a6a84; }
.uniTab:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
@media (max-width: 1500px) { .uniTab:not(.on) b { display: none; } .uniTab:not(.on) { padding: 6px 10px; } }
@media (max-width: 1100px) { .uniTab b { display: none; } .uniTab { padding: 6px 10px; } }
@media (max-height: 520px) and (orientation: landscape) { .uniTab { min-height: 40px; } }
@media (max-width: 760px) and (orientation: portrait) { .mapUnis { top: calc(112px + var(--sat)); right: auto; left: 50%; transform: translateX(-50%); } }
