:root {
  --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);
  --blue: #46aaff;
  --orange: #ff8c28;
  --gold: #ffd24a;
  --ink: #e6ecff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #07060f; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: none;
}
canvas { position: fixed; inset: 0; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* ---------- HUD ---------- */
#btnPause {
  position: fixed; top: calc(var(--sat) + 10px); left: 50%; transform: translateX(-50%);
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3);
  background: rgba(10,8,24,.6); display: flex; gap: 5px; align-items: center; justify-content: center;
}
#btnPause span { width: 5px; height: 15px; background: var(--ink); border-radius: 2px; }

#touch .tleft, #touch .tright {
  position: fixed; bottom: calc(var(--sab) + 14px); display: flex; gap: 12px; align-items: flex-end;
}
#touch .tleft { left: calc(var(--sal) + 14px); }
#touch .tright { right: calc(var(--sar) + 14px); }
#touch button {
  width: 74px; height: 74px; border-radius: 50%; font-size: 30px; color: #fff;
  background: rgba(20,16,40,.45); border: 2px solid rgba(255,255,255,.35);
}
#touch button.on { background: rgba(255,255,255,.25); }
#touch #tJump { width: 86px; height: 86px; font-size: 36px; }
#touch .tportal { width: 54px; height: 54px; margin-bottom: 16px; opacity: .55; }
#touch .tportal.p0 { background: radial-gradient(circle, #10142a 0 30%, var(--blue) 48%, var(--gold) 62%, transparent 66%); }
#touch .tportal.p1 { background: radial-gradient(circle, #2a140a 0 30%, var(--orange) 48%, var(--gold) 62%, transparent 66%); }
#touch .tportal.sel { opacity: 1; border-color: #fff; box-shadow: 0 0 14px rgba(255,255,255,.6); }

#toast {
  position: fixed; left: 50%; top: calc(var(--sat) + 60px); transform: translate(-50%, -8px);
  max-width: min(90vw, 620px); padding: 10px 16px; border-radius: 12px; text-align: center;
  background: rgba(10,8,24,.85); border: 1px solid rgba(255,210,74,.45); font-size: 16px; line-height: 1.4;
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast kbd, .how kbd, .keys kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 5px; text-align: center;
  background: #25223d; border: 1px solid #4a4670; border-bottom-width: 3px; font: 700 13px system-ui; color: #fff;
}

#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate {
    display: flex; position: fixed; inset: 0; z-index: 50; background: #07060f; align-items: center; justify-content: center;
    text-align: center; font-size: 20px; line-height: 1.6;
  }
  #rotate div::first-line { font-size: 60px; }
}

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--sat) + 14px) calc(var(--sar) + 14px) calc(var(--sab) + 14px) calc(var(--sal) + 14px);
}
.title {
  background:
    linear-gradient(90deg, rgba(5,4,12,.92) 0%, rgba(5,4,12,.7) 45%, rgba(5,4,12,.1) 75%),
    url("assets/cover.webp") 70% 25% / cover no-repeat, #07060f;
  justify-content: flex-start; overflow-y: auto; touch-action: pan-y;
}
.title-inner { width: 100%; max-width: 440px; text-align: center; margin: auto 0 auto 4vw; }
h1 {
  margin: 0; font-size: clamp(40px, 9vw, 78px); font-weight: 900; letter-spacing: .04em; line-height: 1;
  color: #eaf4ff; text-shadow: 0 0 18px rgba(70,170,255,.9), 0 0 42px rgba(70,170,255,.5), 0 3px 0 #0a1630;
}
h1 span { color: #ff5a4a; text-shadow: 0 0 18px rgba(255,70,60,.8), 0 3px 0 #300a0a; }
.tag { margin: 8px 0 16px; font-size: 16px; color: #cfd8f5; }

.diff { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.diff button {
  flex: 1; padding: 9px 4px; border-radius: 12px; background: rgba(20,16,40,.8);
  border: 1px solid rgba(255,255,255,.2); font-weight: 800; font-size: 15px;
}
.diff button small { display: block; font-weight: 600; font-size: 12px; color: #ff8c9a; margin-top: 2px; }
.diff button.sel { border-color: var(--gold); box-shadow: 0 0 14px rgba(255,210,74,.5); background: rgba(60,45,10,.75); }
.row2 { display: flex; gap: 10px; }
.row2 .btn { margin: 6px 0; }
.credits { margin: 12px 0 0; font-size: 13px; line-height: 1.6; color: #b9c0dc; text-shadow: 0 1px 4px #000; }
.credits b { color: #ffd24a; }
.levels { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0 2px; min-height: 8px; }
.levels button {
  padding: 6px 10px; border-radius: 9px; background: rgba(20,16,40,.8); border: 1px solid rgba(255,255,255,.2);
  font-size: 13px; font-weight: 700;
}
.levels button:disabled { opacity: .35; cursor: default; }
.levels button.cur { border-color: var(--gold); }

.btn {
  display: block; width: 100%; max-width: 340px; margin: 9px auto; padding: 14px 16px; border-radius: 14px;
  font-size: 17px; font-weight: 800; letter-spacing: .08em;
  background: rgba(16,12,32,.85); border: 1px solid rgba(255,255,255,.25);
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(180deg, #57b4ff, #2462d8); border-color: #a8d8ff;
  box-shadow: 0 0 22px rgba(70,170,255,.5); color: #fff;
}

.panel { background: rgba(4,3,10,.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.card {
  width: 100%; max-width: 640px; max-height: 100%; overflow-y: auto; touch-action: pan-y;
  background: linear-gradient(180deg, #17122e, #0b0818); border: 1px solid rgba(255,210,74,.3);
  border-radius: 20px; padding: 20px; box-shadow: 0 0 40px rgba(70,170,255,.2);
}
.card.small { max-width: 380px; text-align: center; }
h2 { margin: 0 0 12px; font-size: 26px; color: #fff; text-shadow: 0 0 14px rgba(70,170,255,.7); }
h2.red { color: #ffd6cf; text-shadow: 0 0 14px rgba(255,60,40,.8); }
h3 { margin: 6px 0 8px; font-size: 18px; color: var(--gold); }
.stats { font-size: 17px; line-height: 1.7; margin-bottom: 10px; color: #d6dcf5; }
.stats b { color: #fff; }
.stats .big { font-size: 30px; font-weight: 900; color: var(--gold); }
.note { font-size: 14px; line-height: 1.5; color: #c6cbe6; }

.how { list-style: none; padding: 0; margin: 0 0 10px; }
.how li { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 12px; font-size: 15px; line-height: 1.4; color: #d6dcf5; }
.how b { color: #fff; }
.ic { flex: 0 0 32px; height: 32px; border-radius: 50%; margin-top: 2px; }
.ic.coin { background: radial-gradient(circle, #fff3b0 0 20%, var(--gold) 45%, #b07a10 70%); }
.ic.spike { border-radius: 0; background: linear-gradient(135deg, transparent 49%, #c8ccd8 50%) left/50% 100% no-repeat, linear-gradient(225deg, transparent 49%, #9aa0b2 50%) right/50% 100% no-repeat; }
.ic.pface { border-radius: 4px; background: repeating-linear-gradient(45deg, #111 0 3px, #2a2a30 3px 5px); border: 1px solid #6a4aa0; }
.ic.portal { background: radial-gradient(circle, #0a0a20 0 22%, #46aaff 40%, #9a5aff 52%, var(--gold) 62%, transparent 66%); }
.ic.drako { background: radial-gradient(circle at 62% 40%, #ff2a1a 0 8%, transparent 10%), #3f6b45; }
.keys { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
.keys th, .keys td { padding: 6px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; vertical-align: top; color: #d6dcf5; }
.keys th { color: #fff; }
