:root {
  --cyan: #19f0ff;
  --mag: #ff2bd6;
  --amber: #ffb627;
  --red: #ff3355;
  --ink: #e9f6ff;
  --dim: rgba(205, 225, 255, 0.62);
  --glass: rgba(14, 10, 32, 0.52);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: #07040f; color: var(--ink);
  font-family: var(--font);
  touch-action: none; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  position: fixed; inset: 0;
}
#app {
  position: fixed; inset: 0; overflow: hidden;
  touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
#scene {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none;
  outline: none;
}
button { font-family: inherit; color: inherit; border: none; background: none; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }

/* ---------- FX layers ---------- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .12s linear; }
#fx-vignette {
  background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 46%, rgba(0,220,255,.10) 66%, rgba(0,200,255,.38) 88%, rgba(120,60,255,.55) 100%);
  box-shadow: inset 0 0 60px rgba(25,240,255,.55), inset 0 0 6px rgba(25,240,255,.9);
}
#fx-vignette.on { opacity: 1; animation: pulse .32s ease-in-out infinite alternate; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.45); } }
#fx-flash { background: radial-gradient(ellipse at 50% 10%, rgba(220,235,255,.85), rgba(160,190,255,.25) 60%, rgba(120,140,255,0)); transition: none; }
#fx-danger { background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 55%, rgba(255,30,70,.35) 100%); }
#fx-danger.on { opacity: 1; animation: pulse .18s ease-in-out infinite alternate; }

/* ---------- corner ---------- */
#corner {
  position: absolute; z-index: 30;
  top: calc(var(--sat) + 8px); right: calc(var(--sar) + 8px);
  display: flex; gap: 6px;
}
.chip {
  height: 34px; min-width: 34px; padding: 0 8px; border-radius: 10px;
  background: rgba(12, 8, 28, .55); border: 1px solid rgba(25,240,255,.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: inline-flex; align-items: center; justify-content: center; color: var(--cyan);
  font-size: 13px; font-weight: 700; letter-spacing: .5px;
}
.chip .ico { width: 18px; height: 18px; }
.chip .ico-off { display: none; }
.chip.muted .ico-on { display: none; }
.chip.muted .ico-off { display: block; }
.chip.muted { color: var(--dim); border-color: rgba(255,255,255,.2); }

/* ---------- HUD ---------- */
#hud {
  position: absolute; z-index: 20; pointer-events: none;
  top: calc(var(--sat) + 8px); left: calc(var(--sal) + 10px); right: calc(var(--sar) + 96px);
  display: flex; flex-direction: column; gap: 6px;
  text-shadow: 0 0 8px rgba(25,240,255,.6);
}
.hud-row { display: flex; align-items: center; gap: 10px; }
.stat { font-family: var(--mono); font-weight: 800; font-size: 20px; line-height: 1; color: #fff; }
.stat small { font-size: 11px; color: var(--dim); margin-left: 2px; }
.stat-score { color: var(--cyan); }
.mult {
  font-family: var(--mono); font-weight: 900; font-size: 15px; padding: 3px 7px; border-radius: 7px;
  background: rgba(255,43,214,.16); border: 1px solid rgba(255,43,214,.55); color: #ffd6f6;
  text-shadow: 0 0 8px rgba(255,43,214,.9); transition: transform .15s;
}
.mult.pop { transform: scale(1.35); }
.hud-bars { gap: 8px; }
.bar-wrap { flex: 1; min-width: 0; }
.bar-label { display: flex; justify-content: space-between; gap: 4px; font-size: 10px; letter-spacing: .5px; color: var(--dim); margin-bottom: 3px; white-space: nowrap; }
.bar-label span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bar-label span:last-child { font-family: var(--mono); color: #fff; flex: 0 0 auto; }
.bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; border: 1px solid rgba(255,255,255,.08); }
.bar i { display: block; height: 100%; width: 100%; transform-origin: 0 50%; background: linear-gradient(90deg, #1fb6ff, var(--cyan)); box-shadow: 0 0 8px var(--cyan); }
.bar-ov i { background: linear-gradient(90deg, #22ffa0, #19f0ff); box-shadow: 0 0 8px #22ffa0; }
.bar-ov.warn i { background: linear-gradient(90deg, #ff8a00, var(--red)); box-shadow: 0 0 10px var(--red); animation: blink .16s steps(2) infinite; }
.bar-ov.drone i { background: linear-gradient(90deg, #ffe066, #ffb627); box-shadow: 0 0 8px var(--amber); }
#ov-wrap.idle { opacity: .55; }
@keyframes blink { 50% { opacity: .35; } }
.storm-badge {
  align-self: flex-start; font-family: var(--mono); font-size: 11px; font-weight: 800; letter-spacing: 1px;
  color: #dff3ff; padding: 3px 8px; border-radius: 6px; background: rgba(90,120,255,.25); border: 1px solid rgba(160,190,255,.6);
  animation: blink .5s steps(2) infinite;
}

#hud-scrim {
  position: absolute; z-index: 19; left: 0; right: 0; top: 0; height: calc(var(--sat) + 84px); pointer-events: none;
  background: linear-gradient(180deg, rgba(7,4,15,.62) 0%, rgba(7,4,15,.32) 60%, rgba(7,4,15,0) 100%);
}
#toasts {
  position: absolute; z-index: 21; left: 0; right: 0; top: calc(var(--sat) + 26%);
  display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none;
}
.toast {
  font-weight: 900; font-size: 20px; letter-spacing: 1px; color: #fff; white-space: nowrap;
  text-shadow: 0 0 10px var(--cyan), 0 0 22px rgba(25,240,255,.6);
  animation: toast 1.1s ease-out forwards;
}
.toast.mag { text-shadow: 0 0 10px var(--mag), 0 0 22px rgba(255,43,214,.7); }
.toast.red { text-shadow: 0 0 10px var(--red), 0 0 22px rgba(255,51,85,.8); }
.toast.gold { color: #fff3c4; text-shadow: 0 0 10px var(--amber), 0 0 22px rgba(255,182,39,.8); }
.toast small { display: block; text-align: center; font-size: 11px; font-weight: 600; opacity: .85; }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px) scale(.8); } 15% { opacity: 1; transform: translateY(0) scale(1.08); } 70% { opacity: 1; transform: translateY(-6px) scale(1); } 100% { opacity: 0; transform: translateY(-18px) scale(.96); } }

#hint-bar {
  position: absolute; z-index: 21; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sab) + 18px); padding: 7px 12px; border-radius: 10px; pointer-events: none;
  font-size: 12px; color: #dffcff; background: rgba(10,8,26,.55); border: 1px solid rgba(25,240,255,.35);
  white-space: nowrap; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}

/* ---------- overlays / cards ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  padding: calc(var(--sat) + 56px) calc(var(--sar) + 14px) calc(var(--sab) + 18px) calc(var(--sal) + 14px);
  background: linear-gradient(180deg, rgba(7,4,15,0) 0%, rgba(7,4,15,.0) 40%, rgba(7,4,15,.55) 100%);
}
.card {
  width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto;
  padding: 18px 18px 16px; border-radius: 20px;
  background: var(--glass);
  border: 1px solid rgba(25,240,255,.28);
  box-shadow: 0 0 0 1px rgba(255,43,214,.12) inset, 0 10px 40px rgba(0,0,0,.45), 0 0 30px rgba(25,240,255,.12);
  backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
}
.title-kicker { font-family: var(--mono); font-size: 10.5px; letter-spacing: 2.5px; color: var(--cyan); opacity: .9; }
.title {
  font-size: 44px; font-weight: 900; letter-spacing: 6px; line-height: 1.05; margin-top: 4px;
  background: linear-gradient(92deg, #7ffcff 0%, #ffffff 45%, #ff7ae6 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 10px rgba(25,240,255,.45)) drop-shadow(0 0 18px rgba(255,43,214,.3));
}
.title-sm { font-size: 30px; letter-spacing: 4px; }
.subtitle { font-family: var(--mono); font-weight: 800; letter-spacing: 7px; color: #ffc2f2; font-size: 13px; margin-top: 2px; text-shadow: 0 0 8px var(--mag); }
.howto { list-style: none; margin: 14px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.howto li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; line-height: 1.35; color: #e6f3ff; }
.howto b { color: #fff; margin-right: 6px; }
.howto small { color: var(--dim); font-size: 11.5px; }
.gest { flex: 0 0 44px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: rgba(25,240,255,.1); border: 1px solid rgba(25,240,255,.35); }
.gest svg { width: 30px; height: 20px; fill: none; stroke: var(--cyan); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.g-up { background: rgba(255,43,214,.1); border-color: rgba(255,43,214,.45); }
.g-up svg { stroke: #ff7ae6; }
.btn-primary {
  width: 100%; min-height: 58px; border-radius: 16px; font-size: 19px; font-weight: 900; letter-spacing: 3px; color: #04121a;
  background: linear-gradient(92deg, #19f0ff, #8affd8 50%, #ff7ae6);
  box-shadow: 0 0 22px rgba(25,240,255,.55), 0 0 2px #fff inset;
  transition: transform .08s;
}
.btn-primary:active { transform: scale(.97); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.btn-ghost {
  flex: 1; min-height: 46px; border-radius: 13px; font-size: 15px; font-weight: 800; letter-spacing: 1px;
  border: 1px solid rgba(25,240,255,.45); background: rgba(25,240,255,.08); color: #bff9ff;
}
.best { font-family: var(--mono); font-size: 13px; color: var(--dim); white-space: nowrap; }
.best span { color: #fff; font-weight: 800; }
.start-mount { margin-top: 9px; font-size: 12px; color: var(--dim); }
.start-mount span { color: #ffd6f6; font-weight: 700; }
.desk-hint { margin-top: 6px; font-size: 11px; color: rgba(205,225,255,.45); display: none; }
@media (pointer: fine) and (min-aspect-ratio: 1/1) { .desk-hint { display: block; } }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 8px; }
.result-grid div { padding: 9px 11px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); }
.result-grid small { display: block; font-size: 11px; color: var(--dim); }
.result-grid b { font-family: var(--mono); font-size: 22px; color: #fff; }
.best-line { font-family: var(--mono); font-size: 12px; color: var(--cyan); margin-bottom: 8px; }
#over-unlocks { font-size: 12.5px; color: #fff3c4; margin-bottom: 10px; min-height: 0; }

/* ---------- garage drawer ---------- */
.drawer { position: absolute; inset: 0; z-index: 60; background: rgba(4,2,10,.55); display: flex; align-items: flex-end; justify-content: center; }
.drawer-panel {
  width: 100%; max-width: 520px; max-height: calc(100% - var(--sat) - 24px); overflow-y: auto;
  padding: 16px 16px calc(var(--sab) + 16px); border-radius: 22px 22px 0 0;
  background: rgba(14, 10, 32, .86); border: 1px solid rgba(25,240,255,.3); border-bottom: none;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.drawer-head h3 { font-size: 19px; font-weight: 900; letter-spacing: 1px; margin-top: 2px; }
.drawer-foot { font-size: 11.5px; color: var(--dim); margin-top: 10px; line-height: 1.5; }
.mount-card {
  display: flex; gap: 12px; padding: 12px; border-radius: 14px; margin-bottom: 9px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); width: 100%; text-align: left;
}
.mount-card.sel { border-color: var(--cyan); box-shadow: 0 0 14px rgba(25,240,255,.35) inset; }
.mount-card.locked { opacity: .55; }
.mount-ico { flex: 0 0 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 900; font-family: var(--mono); }
.mount-info { flex: 1; min-width: 0; }
.mount-info h4 { font-size: 15px; font-weight: 900; display: flex; justify-content: space-between; gap: 6px; }
.mount-info h4 em { font-style: normal; font-size: 10.5px; font-family: var(--mono); color: var(--dim); align-self: center; }
.mount-info p { font-size: 12px; color: #cfe2ff; line-height: 1.45; margin-top: 3px; }
.mount-info .stats { font-family: var(--mono); font-size: 11px; color: var(--cyan); margin-top: 4px; }
.tag-sel { font-size: 10.5px; color: #04121a; background: var(--cyan); border-radius: 6px; padding: 1px 6px; font-style: normal; }

@media (min-aspect-ratio: 1/1) {
  .overlay { align-items: center; justify-content: flex-start; padding-left: calc(var(--sal) + 6vw); background: linear-gradient(90deg, rgba(7,4,15,.55), rgba(7,4,15,0) 55%); }
  .card { max-width: 380px; }
  #hud { right: auto; width: min(560px, 60vw); }
  #toasts { top: calc(var(--sat) + 13%); }
  .stat { font-size: 24px; }
}
@media (max-height: 640px) {
  .title { font-size: 34px; }
  .howto { margin: 10px 0; gap: 5px; }
  .btn-primary { min-height: 52px; }
  .card { padding: 14px; }
}
