/* ZIG — Turbo Worlds : interface HTML/CSS par-dessus la scène 3D. */
:root {
  --ink: #0d2a33; --paper: #fffaf0; --leaf: #46c93a; --leafD: #2a8f2a; --orange: #ff8a1e; --orangeD: #e36a00;
  --teal: #19b8c4; --tealD: #0f6f80; --sky: #8fdcff; --gold: #ffc21f; --night: #0f3d4a;
  --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: #071c22; opacity: 0; pointer-events: none; transition: opacity .35s ease; z-index: 5; }
.fade.on { opacity: 1; }
/* effet de vitesse : périphérique, faible opacité, coupé en mode Confort */
.speed { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; z-index: 2;
  background: radial-gradient(ellipse 72% 70% at 50% 50%, transparent 62%, rgba(140, 230, 255, .22) 82%, rgba(255, 170, 60, .2) 100%); }
.speed.on { opacity: 1; }

/* chargement */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #1c6b78, #0b2c35); z-index: 50; color: #fff; }
.bootCard { display: grid; gap: 6px; justify-items: center; }
.bootCard b { font-size: 64px; font-weight: 900; letter-spacing: .04em; color: var(--leaf); text-shadow: 0 4px 0 var(--leafD), 0 8px 18px #0008; }
.bootCard span { font-weight: 800; letter-spacing: .3em; text-transform: uppercase; color: var(--orange); 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(--orange); animation: load 1s ease-in-out infinite alternate; }
.bootCard small { opacity: .8; font-size: 13px; margin-top: 4px; }
@keyframes load { to { transform: translateX(150%); } }

/* écrans */
.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(7, 40, 50, .62), rgba(7, 40, 50, .15) 62%, transparent); place-items: center start; }
.homeCard { width: min(420px, 100%); display: grid; gap: 14px; padding: 8px 4px; }
.logo { margin: 0; display: grid; line-height: .9; }
.logoZ { font-size: clamp(64px, 14vh, 110px); font-weight: 900; color: var(--leaf); letter-spacing: .02em; -webkit-text-stroke: 3px #0d3b1a; paint-order: stroke fill; text-shadow: 0 6px 0 #1f6e22, 0 12px 24px #0007; font-style: italic; }
.logoSub { font-size: clamp(18px, 3.6vh, 26px); font-weight: 900; color: var(--orange); letter-spacing: .22em; text-transform: uppercase; -webkit-text-stroke: 1.5px #5a2400; paint-order: stroke fill; margin-left: 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(255, 250, 240, .94); color: var(--ink); font-weight: 800; font-size: 17px; text-align: left; box-shadow: 0 4px 0 #0e3a46, 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 #0e3a46, 0 6px 12px #0004; }
.btn:focus-visible, .iconBtn:focus-visible, .card:focus-visible, .back:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: linear-gradient(180deg, #ffa13a, var(--orange)); color: #fff; box-shadow: 0 5px 0 var(--orangeD), 0 12px 24px #0005; text-shadow: 0 2px 0 #b24f00; }
.btn.big { min-height: 62px; font-size: 24px; }
.btn .sub { font-size: 13px; font-weight: 700; opacity: .92; text-shadow: none; }
.btn.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px #ffffff88; }
.homeFoot { margin: 4px 0 0; font-size: 12px; color: #e8fbff; opacity: .85; text-shadow: 0 1px 3px #000a; }

.panelScreen { background: rgba(6, 34, 42, .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: #e9f6f1; font-size: 22px; font-weight: 900; }
.note { margin: 0 0 12px; font-size: 14px; color: #3c5a60; }
.worldList { display: grid; gap: 16px; }
.world h3 { margin: 4px 0 8px; font-size: 16px; color: var(--tealD); display: flex; justify-content: space-between; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { border: 0; border-radius: 16px; padding: 12px; min-height: 104px; text-align: left; display: grid; gap: 4px; align-content: start; background: linear-gradient(160deg, #d9f7c9, #9fe3a4); box-shadow: 0 4px 0 #4f9b56; color: var(--ink); }
.card.bonus { background: linear-gradient(160deg, #ffe7b8, #ffc56b); box-shadow: 0 4px 0 #c98420; }
.card.locked { background: #e4e8ea; box-shadow: 0 4px 0 #b8c0c4; color: #73858b; }
.card b { font-size: 15px; } .card small { font-size: 12px; opacity: .85; }
.card .num { font-size: 12px; font-weight: 900; letter-spacing: .08em; color: var(--tealD); text-transform: uppercase; }
.medals { display: flex; gap: 4px; margin-top: 4px; }
.medal { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 900; background: #ffffff88; color: #9aa; box-shadow: inset 0 0 0 2px #0001; }
.medal.m1 { background: #e3a06a; color: #5a2a00; } .medal.m2 { background: #d9e3ea; color: #3b4a55; } .medal.m3 { background: #ffd23a; color: #6a4a00; }
.chalTable { display: grid; gap: 6px; }
.chalRow { display: grid; grid-template-columns: 1fr repeat(3, 76px); gap: 6px; align-items: center; padding: 8px 10px; border-radius: 12px; background: #eef8f3; font-size: 14px; }
.chalRow.head { background: transparent; font-weight: 800; font-size: 12px; color: #4b6a70; text-transform: uppercase; }
.chalRow span { text-align: center; }

/* 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 { display: flex; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(8, 40, 50, .62); color: #fff; font-weight: 900; font-size: 18px; text-shadow: 0 1px 2px #000a; font-variant-numeric: tabular-nums; }
.ico.ring { width: 18px; height: 18px; border-radius: 50%; border: 4px solid var(--gold); box-shadow: 0 0 6px #ffb21f; }
.stars { gap: 3px; font-size: 18px; } .stars .s { color: #ffffff44; } .stars .s.on { color: var(--gold); text-shadow: 0 0 6px #ffae00; } .stars .c { color: #ffffff44; margin-left: 4px; } .stars .c.on { color: #5cffc8; text-shadow: 0 0 6px #18d39a; }
.time { min-width: 96px; justify-content: center; }
.gauge { position: relative; width: 120px; height: 26px; border-radius: 999px; background: rgba(8, 40, 50, .62); overflow: hidden; box-shadow: inset 0 0 0 2px #ffffff40; }
.gauge i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #29c8ff, #7ff0ff); transition: width .15s; }
.gauge span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 900; letter-spacing: .2em; color: #fff; text-shadow: 0 1px 2px #000; }
.gauge.full i { background: linear-gradient(90deg, #ff8a1e, #ffd23a); animation: pulse .6s ease-in-out infinite alternate; }
.gauge.active i { background: linear-gradient(90deg, #ffd23a, #ff8a1e); }
@keyframes pulse { to { filter: brightness(1.25); } }
.iconBtn { pointer-events: auto; width: 48px; height: 48px; border-radius: 14px; border: 0; background: rgba(8, 40, 50, .62); color: #fff; font-size: 16px; font-weight: 900; }
.powers { position: fixed; z-index: 8; top: calc(56px + var(--sat)); left: calc(12px + var(--sal)); display: flex; gap: 6px; pointer-events: none; }
.powers span { padding: 4px 10px; border-radius: 999px; background: rgba(8, 40, 50, .62); color: #fff; font-size: 13px; font-weight: 800; }
.toast { position: fixed; z-index: 9; left: 50%; top: calc(64px + var(--sat)); transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); padding: 10px 18px; border-radius: 16px; background: rgba(255, 250, 240, .95); font-weight: 800; font-size: 17px; text-align: center; box-shadow: 0 8px 20px #0005; pointer-events: none; animation: toastIn .25s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

/* commandes tactiles */
.touch { position: fixed; inset: 0; z-index: 7; pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.touch .pad, .touch .tBtn { pointer-events: auto; touch-action: none; }
.pad { position: absolute; left: calc(22px + var(--sal)); bottom: calc(22px + var(--sab)); width: 210px; height: 104px; border-radius: 52px; background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .45); display: grid; grid-template-columns: 1fr 1fr; color: #fff; font-size: 34px; }
.pad span { display: grid; place-items: center; border-radius: 52px; text-shadow: 0 2px 4px #0008; }
.pad span.on { background: rgba(255, 255, 255, .35); }
.actions { position: absolute; right: calc(22px + var(--sar)); bottom: calc(22px + var(--sab)); width: 250px; height: 200px; }
.tBtn { position: absolute; display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 900; text-shadow: 0 2px 3px #0009; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55); }
.tBtn.jump { right: 0; bottom: 0; width: 116px; height: 116px; background: rgba(255, 138, 30, .55); font-size: 20px; }
.tBtn.slide { right: 132px; bottom: 0; width: 84px; height: 84px; background: rgba(25, 184, 196, .45); font-size: 14px; }
.tBtn.turbo { right: 112px; bottom: 104px; width: 76px; height: 76px; background: rgba(255, 255, 255, .12); font-size: 12px; opacity: .55; }
.tBtn.turbo.ready { background: rgba(255, 194, 31, .75); opacity: 1; animation: pulse .6s ease-in-out infinite alternate; }
.tBtn.on { filter: brightness(1.35); transform: scale(.95); }
.touch.mirror .pad { left: auto; right: calc(22px + var(--sar)); }
.touch.mirror .actions { right: auto; left: calc(22px + var(--sal)); transform: scaleX(-1); }
.touch.mirror .actions .tBtn { transform: scaleX(-1); }
@media (max-height: 420px) { .pad { width: 180px; height: 92px; } .actions { transform-origin: bottom right; scale: .86; } .touch.mirror .actions { transform-origin: bottom left; } }

/* 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(5, 25, 32, .6); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { width: min(480px, 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: #eef8f3; font-weight: 700; }
.opt small { display: block; font-weight: 500; font-size: 12px; color: #4b6a70; }
.opt input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--orange); flex: none; }
.opt input[type=range] { width: 140px; accent-color: var(--orange); }
.opt select { font: inherit; padding: 6px; border-radius: 10px; border: 1px solid #b9d3cc; 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: #e9f6f1; border-radius: 8px; padding: 2px 8px; box-shadow: 0 2px 0 #b9d3cc; white-space: nowrap; }
.result { display: grid; gap: 8px; }
.resRow { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 12px; background: #eef8f3; font-weight: 700; }
.resRow b { font-variant-numeric: tabular-nums; }
.resMedals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; font-size: 12px; font-weight: 800; }
.resMedals div { padding: 8px 4px; border-radius: 12px; background: #f4efe2; display: grid; gap: 4px; justify-items: center; }
.resMedals .medal { width: 34px; height: 34px; font-size: 16px; }
.record { color: var(--orangeD); font-weight: 900; text-align: center; }

.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(--tealD); color: #fff; font-weight: 800; }
.update button:last-child { background: #fff; color: var(--tealD); box-shadow: inset 0 0 0 2px var(--tealD); }
.noscript { color: #fff; padding: 20px; }
@media (max-width: 560px) { .home { place-items: end center; background: linear-gradient(0deg, rgba(7, 40, 50, .7), transparent 75%); } .chalRow { grid-template-columns: 1fr repeat(3, 56px); font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .bootCard i::after, .gauge.full i, .tBtn.turbo.ready { animation: none; } }
@media (max-height: 520px) and (orientation: landscape) {
  .homeCard { width: min(440px, 52vw); gap: 8px; }
  .logoZ { font-size: 58px; } .logoSub { font-size: 15px; } .tag { font-size: 14px; }
  .menu { grid-template-columns: 1fr 1fr; gap: 7px; } .menu .big { grid-column: 1 / -1; min-height: 52px; font-size: 21px; }
  .btn { min-height: 44px; font-size: 15px; padding: 8px 14px; }
  .homeFoot { font-size: 11px; }
}
.chalRow .left { text-align: left; }
.note.m0 { margin: 0; }
.bigIcon { font-size: 42px; text-align: center; margin: 0; }

/* --- carte du monde --- */
.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(255, 250, 240, .94); box-shadow: 0 6px 16px #0004; min-width: 220px; }
.mapInfo small { font-size: 12px; font-weight: 800; color: var(--orangeD); text-transform: uppercase; letter-spacing: .04em; }
.mapInfo b { font-size: 19px; }
.mapInfo span { font-size: 13px; font-weight: 700; color: #3a5a62; }
.mapInfo .medal { font-size: 15px; }
.mapNav { display: flex; justify-content: center; align-items: center; gap: 14px; }
.mapNav .btn { min-width: 170px; justify-content: center; }
.mapNav .btn:disabled { filter: grayscale(1); opacity: .7; }
.mapArrow { width: 60px; height: 60px; border: 0; border-radius: 50%; background: rgba(255, 250, 240, .94); color: var(--ink); font-size: 24px; box-shadow: 0 4px 0 #0e3a46, 0 10px 20px #0004; touch-action: manipulation; }
.mapArrow:disabled { opacity: .35; }
.mapArrow:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
.titleCard { position: fixed; z-index: 8; left: 50%; top: 34%; transform: translate(-50%, -50%); display: grid; gap: 4px; text-align: center; padding: 14px 28px; border-radius: 22px; background: rgba(255, 250, 240, .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(--orangeD); text-transform: uppercase; letter-spacing: .05em; font-size: 13px; }
.titleCard b { font-size: 26px; }
@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 (prefers-reduced-motion: reduce) { .titleCard { animation-duration: 2.6s; animation-timing-function: steps(1, end); } }
@media (max-height: 480px) { .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; } }
.toast.low { top: calc(100px + var(--sat)); }
