:root { --bg:#1a1a2e; --cyan:#7ff3ff; --cyan2:#2fb8e6; --pearl:#fff1df; --panel:rgba(14,22,46,.86); --line:rgba(127,243,255,.35); }
* { box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
html, body { width:100%; height:100vh; overflow:hidden; background:var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color:#fff;
  user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; touch-action:none; }
#c { position:fixed; inset:0; width:100%; height:100%; display:block; }
.hidden { display:none !important; }
button { font-family:inherit; }

/* ---------- couche tactile + joystick ---------- */
#touch { position:fixed; inset:0; z-index:4; }
#stick { position:fixed; z-index:5; width:124px; height:124px; margin:-62px 0 0 -62px; border-radius:50%;
  border:2px solid rgba(160,240,255,.45); background:radial-gradient(rgba(120,220,255,.10), rgba(120,220,255,.02) 70%);
  pointer-events:none; }
#knob { position:absolute; left:50%; top:50%; width:54px; height:54px; margin:-27px 0 0 -27px; border-radius:50%;
  background:radial-gradient(circle at 40% 35%, rgba(230,255,255,.9), rgba(120,220,255,.55) 60%, rgba(60,160,220,.35));
  box-shadow:0 0 18px rgba(120,230,255,.6); }

/* ---------- HUD ---------- */
.hud-top { position:fixed; left:0; right:0; top:0; z-index:6; pointer-events:none;
  padding: calc(env(safe-area-inset-top, 44px) + 8px) 16px 0;
  display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.depth { text-shadow:0 2px 12px rgba(0,20,40,.7); }
.depth .val { font-size:36px; font-weight:800; line-height:1; font-variant-numeric:tabular-nums; letter-spacing:-.5px; }
.depth .val small { font-size:18px; font-weight:700; opacity:.8; margin-left:2px; }
.depth .zone { margin-top:4px; font-size:11px; font-weight:700; letter-spacing:2.5px; text-transform:uppercase; color:var(--cyan); opacity:.9; }
.radar { margin-top:10px; position:relative; width:108px; }
.radar canvas { width:108px; height:108px; display:block; border-radius:50%;
  background:radial-gradient(circle, rgba(4,40,60,.55), rgba(2,14,28,.75)); border:1.5px solid rgba(140,240,255,.45);
  box-shadow:0 0 14px rgba(60,200,255,.25), inset 0 0 18px rgba(0,0,0,.5); }
.radar-lbl { display:block; margin-top:4px; text-align:center; font-size:10px; font-weight:800; letter-spacing:1.5px;
  text-transform:uppercase; color:#9fefff; text-shadow:0 1px 2px rgba(0,15,35,.9); }
.radar-lbl b { color:#fff; }
@media (max-height: 430px) { .radar { margin-top:6px; width:84px; } .radar canvas { width:84px; height:84px; } }
.hud-right { display:flex; flex-direction:column; align-items:flex-end; gap:7px; text-shadow:0 1px 2px rgba(0,15,35,.9), 0 0 10px rgba(0,15,35,.6); }
.depth .zone { text-shadow:0 1px 2px rgba(0,15,35,.9), 0 0 10px rgba(0,15,35,.6); }
.pill { display:flex; align-items:center; gap:7px; padding:6px 12px 6px 8px; border-radius:12px;
  background:rgba(6,20,40,.42); border:1px solid rgba(160,240,255,.25); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  font-weight:800; font-size:16px; font-variant-numeric:tabular-nums; }
.pearl-ic { width:18px; height:18px; border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #fff, #ffe6cf 40%, #e0b9c8 75%, #9d8bb8); box-shadow:0 0 10px rgba(255,230,200,.8); }
.pill.bump { animation:bump .3s ease; }
@keyframes bump { 50% { transform:scale(1.15); } }
.o2 { width:150px; }
.o2 .lbl { display:flex; justify-content:space-between; font-size:10px; font-weight:800; letter-spacing:1.5px; color:#bfefff; margin-bottom:3px; }
.o2 .bar { height:8px; border-radius:10px; background:rgba(6,20,40,.5); border:1px solid rgba(160,240,255,.3); overflow:hidden; }
.o2 .bar i { display:block; height:100%; width:100%; border-radius:10px; background:linear-gradient(90deg, #39d0ff, #9ff6ff); transition:width .2s linear; }
.o2.low .bar i { background:linear-gradient(90deg, #ff4d5e, #ff9a7a); animation:blink .6s ease-in-out infinite alternate; }
.o2.refill .bar { box-shadow:0 0 12px rgba(140,240,255,.9); }
@keyframes blink { to { opacity:.45; } }
.compass { display:flex; align-items:center; gap:8px; font-size:12px; font-weight:700; color:#d8f7ff; }
.compass .arrow { width:26px; height:26px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  background:rgba(6,20,40,.45); border:1px solid rgba(160,240,255,.3); }
.compass .arrow svg { width:14px; height:14px; transition: transform .1s linear; }
.compass .lock { color:#ffd7a8; }

.hud-bottom { position:fixed; left:0; right:0; bottom:0; z-index:6; pointer-events:none;
  padding: 0 16px calc(env(safe-area-inset-bottom, 20px) + 8px);
  display:flex; justify-content:space-between; align-items:flex-end; gap:12px; }
.hint { max-width:220px; font-size:13px; font-weight:600; line-height:1.35; color:#dff8ff; opacity:.9;
  padding:10px 12px; border-radius:12px; background:rgba(6,20,40,.45); border:1px solid rgba(160,240,255,.22);
  transition:opacity .6s; }
.ctrl { display:flex; align-items:flex-end; gap:12px; pointer-events:auto; }
.vbtns { display:flex; flex-direction:column; gap:12px; }
.rbtn { width:64px; height:64px; border-radius:14px; border:1.5px solid rgba(160,240,255,.45);
  background:rgba(8,30,60,.42); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  color:#e4fbff; font-size:22px; font-weight:800; display:flex; align-items:center; justify-content:center; cursor:pointer;
  touch-action:none; }
.rbtn.on { background:rgba(80,200,255,.38); border-color:#bff6ff; }
.rbtn.small { width:48px; height:48px; font-size:18px; }

.banner { position:fixed; left:0; right:0; top:24%; z-index:7; pointer-events:none; text-align:center;
  opacity:0; transform:translateY(8px); transition:opacity .9s, transform .9s; }
.banner.show { opacity:1; transform:none; }
.banner .sub { font-size:12px; font-weight:700; letter-spacing:4px; text-transform:uppercase; color:var(--cyan); }
.banner .big { font-size:34px; font-weight:300; letter-spacing:6px; text-transform:uppercase; text-shadow:0 0 24px rgba(120,230,255,.6); }
.msg { position:fixed; left:50%; bottom:32%; z-index:7; pointer-events:none; transform:translateX(-50%);
  padding:8px 14px; border-radius:12px; background:rgba(6,20,40,.6); border:1px solid rgba(160,240,255,.3);
  font-size:14px; font-weight:700; white-space:nowrap; opacity:0; transition:opacity .4s; }
.msg.show { opacity:1; }

/* ---------- écrans ---------- */
.screen { position:fixed; inset:0; z-index:20; overflow-y:auto; touch-action:pan-y; -webkit-overflow-scrolling:touch;
  padding: calc(env(safe-area-inset-top, 44px) + 8px) 16px calc(env(safe-area-inset-bottom, 20px) + 8px);
  display:flex; flex-direction:column; align-items:center; }
#title { background:linear-gradient(rgba(26,26,46,.05), rgba(26,26,46,0) 35%, rgba(10,14,34,.55) 70%, rgba(10,12,30,.9)); }
.top-row { width:100%; max-width:480px; display:flex; justify-content:space-between; align-items:center; gap:10px; }
.link-btn { min-height:44px; padding:0 14px; border-radius:12px; display:inline-flex; align-items:center; gap:6px;
  background:rgba(14,22,46,.55); border:1px solid rgba(255,255,255,.22); color:#fff; text-decoration:none;
  font-weight:700; font-size:14px; cursor:pointer; backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); }
.logo { margin-top:6vh; text-align:center; }
.logo h1 { font-size:56px; line-height:1; font-weight:200; letter-spacing:12px; margin-right:-12px;
  background:linear-gradient(#ffffff, #bdf6ff 45%, #4fc6ec); -webkit-background-clip:text; background-clip:text;
  -webkit-text-fill-color:transparent; filter:drop-shadow(0 0 18px rgba(90,220,255,.55)); }
.logo p { margin-top:12px; font-size:15px; font-weight:500; color:#d9f6ff; text-shadow:0 2px 8px rgba(0,10,30,.8); line-height:1.4; }
.spacer { flex:1; min-height:18vh; }
.card { width:100%; max-width:420px; padding:16px; border-radius:14px; background:var(--panel);
  border:1px solid var(--line); box-shadow:0 12px 40px rgba(0,0,0,.4); backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px); }
.stats { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:14px; }
.stat { padding:10px; border-radius:10px; background:rgba(255,255,255,.05); text-align:center; }
.stat b { display:block; font-size:22px; font-weight:800; color:var(--pearl); font-variant-numeric:tabular-nums; }
.stat span { font-size:11px; letter-spacing:1px; text-transform:uppercase; color:#9fd8ea; }
.btn { width:100%; min-height:56px; border:none; border-radius:14px; cursor:pointer; font-size:19px; font-weight:800; letter-spacing:1px;
  color:#032233; background:linear-gradient(#c8fbff, #6fe0ff 55%, #33b6e8);
  box-shadow:0 0 24px rgba(90,220,255,.45), 0 4px 0 #1b6f93; }
.btn:active { transform:translateY(3px); box-shadow:0 0 18px rgba(90,220,255,.4), 0 1px 0 #1b6f93; }
.btn.ghost { color:#e9fbff; background:rgba(255,255,255,.07); border:1px solid rgba(160,240,255,.35); box-shadow:none; font-size:16px; min-height:50px; }
.row { display:flex; gap:10px; margin-top:10px; }
.row > * { flex:1; }
.help { margin-top:12px; font-size:12.5px; color:#a9d6e6; text-align:center; line-height:1.5; }

.overlay { position:fixed; inset:0; z-index:25; display:flex; align-items:center; justify-content:center; overflow-y:auto;
  padding: calc(env(safe-area-inset-top, 44px) + 8px) 16px calc(env(safe-area-inset-bottom, 20px) + 8px);
  background:rgba(4,10,24,.55); backdrop-filter:blur(3px); -webkit-backdrop-filter:blur(3px); touch-action:pan-y; }
.overlay .card { max-width:360px; text-align:center; animation:pop .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform:scale(.85); opacity:0; } }
.overlay h2 { font-size:28px; font-weight:300; letter-spacing:3px; margin-bottom:6px; }
.overlay .lead { color:#bfe9f5; font-size:14px; margin-bottom:14px; line-height:1.4; }
.badge { display:inline-block; margin:0 0 12px; padding:4px 10px; border-radius:10px; font-size:12px; font-weight:800;
  letter-spacing:1px; color:#2a1600; background:linear-gradient(#ffe7a8, #ffb84d); }
.opt { display:flex; justify-content:space-between; align-items:center; gap:10px; min-height:50px; padding:0 12px; margin-top:8px;
  border-radius:12px; background:rgba(255,255,255,.06); border:1px solid rgba(160,240,255,.2); color:#fff; font-size:15px; font-weight:700;
  width:100%; cursor:pointer; }
.opt span:last-child { color:var(--cyan); }

.screen, .overlay, .hud-top, .hud-bottom { padding-left:max(16px, env(safe-area-inset-left)); padding-right:max(16px, env(safe-area-inset-right)); }
@media (orientation: landscape) and (max-height: 560px) {
  #title { display:grid; grid-template-columns:1fr minmax(300px, 380px); grid-template-rows:auto 1fr; column-gap:24px; align-items:center; }
  #title .top-row { grid-column:1 / -1; max-width:none; }
  #title .logo { margin-top:0; }
  #title .logo h1 { font-size:46px; }
  #title .spacer { display:none; }
  #title .card { padding:12px; }
  .help { font-size:11.5px; margin-top:8px; }
  .stats { margin-bottom:10px; gap:8px; }
  .stat { padding:7px; }
  .stat b { font-size:18px; }
  .overlay .card { max-width:460px; padding:12px 16px; }
  .overlay h2 { font-size:22px; }
  #end .stats { grid-template-columns:repeat(4, 1fr); }
  .banner { top:14%; }
}
#loading { position:fixed; inset:0; z-index:40; display:flex; flex-direction:column; gap:16px;
  align-items:center; justify-content:center; text-align:center; background:radial-gradient(circle at 50% 30%, #123a5a, #0b1a33 55%, #1a1a2e);
  padding: calc(env(safe-area-inset-top, 44px) + 8px) 24px calc(env(safe-area-inset-bottom, 20px) + 8px); color:#cfefff; font-weight:600; }
#loading .orb { width:46px; height:46px; border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #fff, #ffe6cf 40%, #e0b9c8 75%, #9d8bb8);
  box-shadow:0 0 30px rgba(255,230,200,.8), 0 0 80px rgba(120,220,255,.4); animation:float 1.4s ease-in-out infinite alternate; }
#loading h3 { font-size:28px; font-weight:200; letter-spacing:10px; margin-right:-10px; color:#e8fbff; }
@keyframes float { to { transform:translateY(-10px); } }
#loading a { color:#9fe9ff; }
