:root {
  color-scheme: dark;
  --bg: #050816;
  --panel: #071126;
  --cyan: #65e7ff;
  --pink: #ff5ecf;
  --yellow: #ffe66d;
  --green: #7cffb2;
  --text: #f7fbff;
  --muted: #8197ad;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: #02040b;
}
body {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
button, a { -webkit-tap-highlight-color: transparent; font: inherit; }

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 620px;
  margin: 0 auto;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 14%, rgba(101,231,255,.12), transparent 34%),
    linear-gradient(180deg, #071126, #030711 62%, #010308);
}

#hud {
  position: absolute;
  z-index: 5;
  top: calc(env(safe-area-inset-top) + 9px);
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  pointer-events: none;
}
#hud > div {
  padding: 7px 8px;
  border: 1px solid rgba(101,231,255,.18);
  border-radius: 10px;
  background: rgba(2,8,20,.68);
  backdrop-filter: blur(8px);
}
#hud > div:nth-child(2) { text-align: center; }
#hud > div:nth-child(3) { text-align: right; }
.hud-label {
  display: block;
  color: #68839c;
  font-size: 8px;
  letter-spacing: .15em;
}
#hud strong {
  display: block;
  margin-top: 1px;
  font-size: 15px;
}

#topbar {
  position: absolute;
  z-index: 7;
  top: calc(env(safe-area-inset-top) + 58px);
  right: 10px;
  display: flex;
  gap: 7px;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  color: white;
  text-decoration: none;
  background: rgba(3,10,25,.74);
  backdrop-filter: blur(8px);
}

#gameWrap {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 104px);
  left: 8px;
  right: 8px;
  bottom: calc(env(safe-area-inset-bottom) + 158px);
  display: grid;
  place-items: center;
  min-height: 280px;
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#statusPill {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  color: #8da5bb;
  background: rgba(2,7,18,.72);
  font-size: 8px;
  letter-spacing: .12em;
  pointer-events: none;
}

#controls {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 34px);
  width: 184px;
  height: 112px;
  transform: translateX(-50%);
}
.dir {
  position: absolute;
  width: 54px;
  height: 48px;
  border: 1px solid rgba(101,231,255,.19);
  border-radius: 14px;
  color: #dffaff;
  background: linear-gradient(180deg, rgba(18,37,65,.9), rgba(6,14,30,.94));
  box-shadow: inset 0 1px rgba(255,255,255,.05);
}
.dir:active {
  transform: scale(.96);
  background: rgba(101,231,255,.16);
}
.dir.up { left: 65px; top: 0; }
.dir.left { left: 5px; top: 52px; }
.dir.down { left: 65px; top: 52px; }
.dir.right { right: 5px; top: 52px; }

.gesture-hint {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  margin: 0;
  color: #50677d;
  text-align: center;
  font-size: 8px;
  pointer-events: none;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(rgba(2,5,14,.76), rgba(2,5,14,.94));
  backdrop-filter: blur(5px);
}
#overlay.visible { display: flex; }
.panel {
  width: min(100%, 410px);
  text-align: center;
}
.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 9px;
  letter-spacing: .2em;
}
h1 {
  margin: 7px 0 17px;
  font-size: clamp(48px, 15vw, 82px);
  line-height: .78;
  letter-spacing: -.08em;
  text-shadow: 0 0 24px rgba(101,231,255,.18);
}
h1 span { color: var(--green); }
#overlayText {
  max-width: 35ch;
  margin: 0 auto 18px;
  color: #a7bacb;
  font-size: 12px;
  line-height: 1.55;
}
.stats-line {
  margin-bottom: 14px;
  color: #6d8398;
  font-size: 10px;
  letter-spacing: .15em;
}
.stats-line strong { color: var(--yellow); }
.primary-btn {
  width: min(100%, 290px);
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  color: #031118;
  background: linear-gradient(135deg, var(--green), #c1ffda);
  font-weight: 900;
  letter-spacing: .13em;
}
.primary-btn:active { transform: scale(.99); }
.hint {
  margin-top: 11px;
  color: #536a7f;
  font-size: 9px;
}

@media (max-height: 680px) {
  #gameWrap { top: calc(env(safe-area-inset-top) + 92px); bottom: calc(env(safe-area-inset-bottom) + 126px); }
  #controls { bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%) scale(.86); transform-origin: 50% 100%; }
  .gesture-hint { display: none; }
}
@media (min-width: 621px) {
  #app { box-shadow: 0 0 80px rgba(0,0,0,.75); }
}
