:root {
  color-scheme: dark;
  --bg: #050812;
  --panel: rgba(10, 15, 31, 0.91);
  --panel-solid: #0b1123;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f8fbff;
  --muted: #aab4cf;
  --gold: #e8c67a;
  --cyan: #55e7ff;
  --violet: #9d7cff;
  --danger: #ff7095;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% -10%, #142043 0%, var(--bg) 54%, #02040a 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
body { min-height: 100vh; min-height: 100dvh; }
button, a { font: inherit; }
button { -webkit-user-select: none; user-select: none; }
a { color: var(--cyan); }

.game-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px max(14px, env(safe-area-inset-right)) 11px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(3, 6, 14, 0.76);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 8;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand-mark {
  width: 39px;
  height: 39px;
  flex: 0 0 39px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #07111d;
  background: linear-gradient(135deg, #fff1b3, var(--gold));
  box-shadow: 0 0 26px rgba(232, 198, 122, .34);
}
.brand-mark svg { width: 27px; height: 27px; }
.brand strong { display: block; font-size: 12.5px; letter-spacing: .14em; white-space: nowrap; }
.brand small { display: block; color: var(--muted); margin-top: 3px; font-size: 10.5px; white-space: nowrap; }
.top-actions { display: flex; gap: 7px; align-items: center; }
.icon-btn, .secondary-btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255,255,255,.055);
  border-radius: 11px;
  padding: 9px 12px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.icon-btn:hover, .secondary-btn:hover { background: rgba(255,255,255,.1); border-color: var(--line-strong); }
.icon-btn:active, .secondary-btn:active, .primary-btn:active { transform: scale(.97); }

.canvas-wrap { position: relative; min-height: 0; overflow: hidden; isolation: isolate; }
#gameCanvas { display: block; width: 100%; height: 100%; touch-action: none; }

.hud {
  position: absolute;
  top: 13px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 2;
  pointer-events: none;
}
.hud > div {
  min-width: 76px;
  padding: 7px 11px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 13px;
  background: rgba(5, 9, 21, .62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
  box-shadow: 0 9px 30px rgba(0,0,0,.16);
}
.hud span, .result-grid span {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
}
.hud strong { display: block; margin-top: 2px; font-size: 18px; }

.overlay-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(rgba(2,4,10,.16), rgba(2,4,10,.7));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .24s ease, visibility .24s ease;
  z-index: 5;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.overlay-panel.visible { opacity: 1; visibility: visible; pointer-events: auto; }
.panel-card {
  width: min(590px, 94vw);
  max-height: calc(100dvh - 125px);
  overflow-y: auto;
  padding: 29px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.14);
  background: var(--panel);
  backdrop-filter: blur(19px);
  -webkit-backdrop-filter: blur(19px);
  text-align: center;
  box-shadow: 0 26px 90px rgba(0,0,0,.48), inset 0 1px rgba(255,255,255,.05);
}
.panel-card.compact { width: min(405px, 92vw); }
.panel-card.info-card { width: min(600px, 94vw); }
.eyebrow { margin: 0 0 10px; color: var(--gold); font-size: 10.5px; font-weight: 800; letter-spacing: .21em; }
.title-lockup { display: flex; justify-content: center; align-items: center; gap: 18px; }
.title-orb {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 33% 30%, #fff 0 8%, #bff9ff 18%, #55e7ff 48%, #146a82 78%, #08293a 100%);
  box-shadow: 0 0 12px #fff, 0 0 34px rgba(85,231,255,.85), 0 0 70px rgba(85,231,255,.32);
}
h1 { margin: 0; font-size: clamp(40px, 8vw, 72px); letter-spacing: .075em; line-height: .94; }
h2 { margin: 7px 0 15px; color: var(--cyan); font-size: clamp(22px, 4vw, 33px); line-height: 1.15; }
.lead { color: var(--muted); line-height: 1.58; margin: 0 auto 18px; max-width: 485px; }
.lead.small { font-size: 13px; }
.feature-pills { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin: 17px 0 21px; }
.feature-pills span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.035); color: #cdd6ec; font-size: 11px; }
.menu-actions { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.primary-btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 24px;
  color: #07111d;
  background: linear-gradient(135deg, var(--cyan), #c9f9ff);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 9px 32px rgba(85,231,255,.23);
  transition: transform .15s ease, box-shadow .15s ease;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 36px rgba(85,231,255,.31); }
.best-line { margin: 15px 0 0; color: var(--muted); font-size: 13px; }
.best-line strong { color: var(--text); }
.version-line { margin: 10px 0 0; color: #73809f; font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; }

.instruction-list { display: grid; gap: 10px; margin: 18px 0 22px; text-align: left; }
.instruction-list article { display: flex; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.035); }
.instruction-list article > span { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 10px; color: #07111d; background: linear-gradient(135deg, var(--gold), #fff0b6); font-weight: 900; }
.instruction-list strong { font-size: 13px; }
.instruction-list p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.42; }
.info-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 18px 0; text-align: left; }
.info-sections section { padding: 13px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.info-sections strong { color: var(--gold); font-size: 11px; text-transform: uppercase; letter-spacing: .11em; }
.info-sections p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.48; }
.legal-links { font-size: 12px; margin: 0 0 18px; }
.rank-label { display: inline-block; margin: 0 0 4px; padding: 6px 10px; border: 1px solid rgba(232,198,122,.34); border-radius: 999px; color: var(--gold); background: rgba(232,198,122,.07); font-size: 10px; letter-spacing: .15em; font-weight: 800; }
.score-heading { font-size: clamp(29px, 7vw, 46px); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 17px 0 21px; }
.result-grid > div { padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.035); }
.result-grid strong { display: block; margin-top: 3px; font-size: 22px; }

.milestone-banner {
  position: absolute;
  top: 93px;
  left: 50%;
  transform: translate(-50%, -16px) scale(.96);
  z-index: 3;
  min-width: 210px;
  padding: 10px 17px;
  border: 1px solid rgba(232,198,122,.34);
  border-radius: 15px;
  background: rgba(9,13,28,.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.milestone-banner.visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.milestone-banner span { display: block; color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.milestone-banner strong { display: block; margin-top: 3px; font-size: 14px; }

.footer-note {
  padding: 8px max(15px, env(safe-area-inset-right)) 8px max(15px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  color: #74809d;
  font-size: 9.5px;
  text-align: center;
  background: rgba(3,5,12,.78);
}
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .topbar { padding-top: 8px; padding-bottom: 8px; }
  .brand-mark { width: 35px; height: 35px; flex-basis: 35px; border-radius: 10px; }
  .brand-mark svg { width: 24px; height: 24px; }
  .brand small { display: none; }
  .brand strong { font-size: 10.5px; letter-spacing: .11em; }
  .icon-btn { padding: 8px 8px; font-size: 11px; }
  .top-actions { gap: 5px; }
  .hud { top: 9px; gap: 5px; }
  .hud > div { min-width: 62px; padding: 6px 7px; }
  .hud strong { font-size: 15px; }
  .panel-card { padding: 22px 17px; max-height: calc(100dvh - 108px); }
  .title-lockup { gap: 10px; }
  .title-orb { width: 36px; height: 36px; flex-basis: 36px; }
  .info-sections { grid-template-columns: 1fr; }
  .milestone-banner { top: 78px; }
}

@media (max-width: 420px) {
  .brand-mark { display: none; }
  .topbar { gap: 7px; }
  .icon-btn { padding: 7px 7px; font-size: 10px; }
  .panel-card { width: 95vw; border-radius: 20px; }
  h1 { font-size: 38px; }
  .lead { font-size: 13px; }
  .feature-pills span { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}


/* ============================================================
   Gate Glide opening-screen correction
   Reference: compact Lumen Shift opening card
   ============================================================ */

.brand-logo {
  width: 39px;
  height: 39px;
  flex: 0 0 39px;
  display: block;
  border-radius: 12px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(232, 198, 122, .22));
}

#startPanel {
  padding: clamp(12px, 2.4vh, 24px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(22, 75, 120, .18), transparent 36%),
    rgba(2, 5, 12, .72);
}

#startPanel .hero-card {
  width: min(510px, 92vw);
  max-height: none;
  overflow: hidden;
  padding: clamp(24px, 4vh, 38px) clamp(22px, 4vw, 42px) clamp(25px, 4vh, 36px);
  border-radius: 24px;
  border: 1px solid rgba(79, 161, 219, .20);
  background:
    radial-gradient(circle at 76% 0%, rgba(52, 174, 238, .18), transparent 34%),
    linear-gradient(155deg, rgba(20, 54, 91, .98), rgba(11, 22, 43, .98) 72%);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, .50),
    inset 0 1px rgba(255, 255, 255, .055);
}

.intro-brand-logo {
  width: 68px;
  height: 68px;
  display: block;
  margin: 0 auto 18px;
  border-radius: 18px;
  object-fit: contain;
  filter: drop-shadow(0 13px 26px rgba(232, 198, 122, .22));
}

#startPanel .eyebrow {
  margin: 0 0 15px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
}

#startPanel h1 {
  margin: 0;
  font-size: clamp(39px, 5.2vw, 55px);
  line-height: 1;
  letter-spacing: -.025em;
  text-align: center;
}

#startPanel h2 {
  margin: 17px 0 22px;
  color: var(--cyan);
  font-size: clamp(19px, 2.5vw, 25px);
  line-height: 1.05;
  letter-spacing: .22em;
  text-transform: uppercase;
}

#startPanel .lead {
  max-width: 420px;
  margin: 0 auto 25px;
  color: #c0cbdd;
  font-size: 14px;
  line-height: 1.65;
}

#startPanel .menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: min(375px, 100%);
  margin: 0 auto;
}

#startPanel .primary-btn,
#startPanel .secondary-btn {
  min-height: 47px;
  padding: 0 18px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 850;
}

#startPanel .primary-btn {
  color: #101722;
  background: linear-gradient(135deg, #fff0aa, #f1c654);
  box-shadow: 0 10px 28px rgba(232, 198, 122, .18);
}

#startPanel .primary-btn:hover {
  box-shadow: 0 13px 34px rgba(232, 198, 122, .27);
}

#startPanel .secondary-btn {
  color: var(--text);
  background: rgba(255, 255, 255, .035);
  border-color: rgba(255, 255, 255, .15);
}

.start-hidden-data {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-height: 700px) and (min-width: 721px) {
  #startPanel .hero-card {
    width: min(500px, 90vw);
    padding: 19px 32px 22px;
  }

  .intro-brand-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 11px;
  }

  #startPanel .eyebrow {
    margin-bottom: 10px;
  }

  #startPanel h1 {
    font-size: 42px;
  }

  #startPanel h2 {
    margin: 11px 0 14px;
    font-size: 19px;
  }

  #startPanel .lead {
    margin-bottom: 17px;
    font-size: 12.5px;
    line-height: 1.48;
  }

  #startPanel .primary-btn,
  #startPanel .secondary-btn {
    min-height: 42px;
  }
}

@media (max-width: 720px) {
  .brand-logo {
    width: 35px;
    height: 35px;
    flex-basis: 35px;
    border-radius: 10px;
  }

  #startPanel {
    padding: 10px;
    overflow-y: auto;
  }

  #startPanel .hero-card {
    width: min(94vw, 500px);
    max-height: calc(100dvh - 88px);
    overflow-y: auto;
    padding: 23px 18px 24px;
    border-radius: 22px;
  }

  .intro-brand-logo {
    width: 61px;
    height: 61px;
    margin-bottom: 13px;
  }

  #startPanel h1 {
    font-size: clamp(35px, 11vw, 46px);
  }

  #startPanel h2 {
    margin: 13px 0 17px;
    font-size: 18px;
    letter-spacing: .17em;
  }

  #startPanel .lead {
    margin-bottom: 20px;
    font-size: 13px;
    line-height: 1.52;
  }
}

@media (max-width: 440px) {
  .brand-logo {
    display: block;
    width: 33px;
    height: 33px;
    flex-basis: 33px;
  }

  #startPanel .hero-card {
    padding: 20px 14px 21px;
  }

  #startPanel .menu-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  #startPanel h1 {
    font-size: 35px;
  }

  #startPanel h2 {
    font-size: 16px;
  }
}
