:root {
  --bg: #07080f;
  --panel: rgba(10, 12, 22, 0.92);
  --line: rgba(120, 180, 255, 0.18);
  --text: #eef3ff;
  --muted: #8b97b8;
  --cyan: #4de1ff;
  --pink: #ff4d9a;
  --gold: #ffd166;
  --green: #3dff9a;
  --red: #ff4d6a;
  --purple: #9b6bff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Rajdhani", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* kill double-tap zoom + 300ms delay site-wide */
  touch-action: manipulation;
}

/* Explicit on controls — iOS still zooms buttons if they only inherit from body */
button,
a,
input,
select,
textarea,
.btn-hero,
.btn-ghost,
.btn-icon,
.panel,
.view,
#app {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* canvas / dual-pad own all gestures */
#game,
.touch-surface,
#touch-controls {
  touch-action: none;
  -ms-touch-action: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

/* ─── TITLE ─── */
.title-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 30%;
  filter: saturate(1.15) contrast(1.05);
  transform: scale(1.05);
  animation: ken 22s ease-in-out infinite alternate;
}
@keyframes ken {
  from { transform: scale(1.05) translate(0, 0); }
  to { transform: scale(1.12) translate(-1.5%, -1%); }
}
.title-veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 10%, rgba(0,0,0,0.55) 55%, rgba(0,0,0,0.9) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(5,6,14,0.85) 100%);
}
.title-ui {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 780px;
  padding: 2rem;
}
.eyebrow {
  font-family: "Orbitron", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.9rem;
  text-shadow: 0 0 18px rgba(77, 225, 255, 0.55);
}
h1 {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff 10%, #7ad7ff 45%, #ff6ec7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #1a0a2e) drop-shadow(0 0 28px rgba(77, 225, 255, 0.35));
  margin-bottom: 1rem;
}
.lede {
  font-size: 1.15rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 1.4rem;
}
.lede.sm { font-size: 1rem; margin-bottom: 1.2rem; }
.title-feats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.6rem;
}
.title-feats span {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  color: #c9d4f0;
}
.btn-hero {
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  padding: 1rem 2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #061018;
  background: linear-gradient(135deg, #4de1ff, #9b6bff 50%, #ff4d9a);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15), 0 10px 40px rgba(155, 107, 255, 0.4);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-hero:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.08); }
.btn-hero:active { transform: translateY(0) scale(0.99); }
.title-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.btn-ghost {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  padding: 0.85rem 1.4rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan); }
.fineprint {
  margin-top: 1.1rem;
  color: #6a7694;
  font-size: 0.95rem;
}
.touch-hint { display: none; }

/* ─── PANELS ─── */
.panel {
  width: min(560px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(12px);
}
.panel.wide { width: min(860px, 94vw); }
.panel h2 {
  font-family: "Orbitron", sans-serif;
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: 0.04em;
}
.brief-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.brief-head .eyebrow { margin-bottom: 0; }
.btn-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--cyan);
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
}
.btn-icon:hover { border-color: var(--cyan); box-shadow: 0 0 16px rgba(77,225,255,0.25); }
.btn-icon.is-muted { color: var(--muted); border-color: rgba(120,180,255,0.12); }
.brief-level-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.brief-lvl {
  flex: 0 0 auto;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: #061018;
  background: linear-gradient(135deg, #4de1ff, #9b6bff);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  min-width: 2.6rem;
  text-align: center;
  box-shadow: 0 0 18px rgba(77,225,255,0.3);
}
.brief-level-row h2 {
  margin: 0;
  font-size: clamp(1.15rem, 3.5vw, 1.55rem);
  line-height: 1.15;
}
.brief-body {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}
.brief-tips {
  list-style: none;
  margin-bottom: 1.4rem;
}
.brief-tips li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
  color: #c5d0ea;
  font-size: 1.02rem;
}
.brief-tips li::before {
  content: "▸ ";
  color: var(--cyan);
}
.brief-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.4rem;
}
.brief-stats div, .shop-foot .stat, .hud-right .stat, .shop-slabs-pill {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  text-align: center;
}
.brief-stats span, .stat {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.brief-stats b, .stat b {
  display: block;
  font-family: "Orbitron", sans-serif;
  font-size: 1.05rem;
  color: var(--gold);
  margin-top: 0.15rem;
}
.btn-deploy {
  width: 100%;
  margin-top: 0.15rem;
}
.brief-scroll {
  /* desktop: no special scroll needed */
  min-height: 0;
}
.shop-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.shop-title-row h2 { margin: 0; }
.shop-pills {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.shop-slabs-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  white-space: nowrap;
}
.shop-slabs-pill b { margin: 0; font-size: 0.95rem; }
.shop-tagline { margin-bottom: 0.6rem; }

/* ─── GAME ─── */
#game-view {
  background: #000;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
}
.game-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}
#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
  cursor: crosshair;
  touch-action: none;
}
#hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.65), transparent);
}
.hud-left, .hud-right, .hud-center {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.hud-right {
  align-items: flex-end;
  pointer-events: auto;
}
.hud-center { align-items: center; text-align: center; }
.bar-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
  min-width: 220px;
}
.bar-label, .bar-num {
  font-family: "Orbitron", sans-serif;
  font-size: 0.7rem;
  color: var(--muted);
}
.bar {
  height: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  transition: width 0.12s linear;
}
.bar-fill.hp {
  background: linear-gradient(90deg, #ff4d6a, #ffd166 70%, #3dff9a);
  box-shadow: 0 0 12px rgba(61, 255, 154, 0.4);
}
.hud-pills { display: flex; gap: 0.35rem; }
.pill {
  font-family: "Orbitron", sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.pill.off {
  opacity: 0.35;
  border-color: var(--line);
  color: var(--muted);
}
.pill.on.diamond {
  opacity: 1;
  color: #9be7ff;
  border-color: #4de1ff;
  background: rgba(77, 225, 255, 0.15);
  box-shadow: 0 0 16px rgba(77, 225, 255, 0.35);
  animation: pulse 0.8s ease infinite alternate;
}
.pill.on.bullish {
  opacity: 1;
  color: #b8ff9a;
  border-color: #3dff9a;
  background: rgba(61, 255, 154, 0.15);
  box-shadow: 0 0 16px rgba(61, 255, 154, 0.4);
  animation: pulse 0.5s ease infinite alternate;
}
@keyframes pulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.25); }
}
.level-name {
  font-family: "Orbitron", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  color: var(--cyan);
}
.objective {
  font-size: 1rem;
  color: #d7e0f7;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.link {
  pointer-events: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-family: "Rajdhani", sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.link:hover { color: var(--cyan); }
.pause-hint {
  position: absolute;
  bottom: 0.7rem;
  right: 1rem;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.1em;
}

#touch-controls { display: none; }
.toast {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.1em;
  padding: 0.7rem 1.2rem;
  border-radius: 10px;
  background: rgba(8, 10, 20, 0.88);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 30px rgba(77, 225, 255, 0.25);
  pointer-events: none;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ─── SHOP ─── */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin: 1.2rem 0 1.4rem;
}
.shop-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  background: rgba(255,255,255,0.03);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.shop-item.owned {
  border-color: rgba(61, 255, 154, 0.45);
  background: rgba(61, 255, 154, 0.06);
}
.shop-item h3 {
  font-family: "Orbitron", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}
.shop-item p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
  flex: 1;
}
.shop-item .cost {
  color: var(--gold);
  font-family: "Orbitron", sans-serif;
  font-size: 0.85rem;
}
.shop-item button {
  font-family: "Orbitron", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  padding: 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  cursor: pointer;
}
.shop-item button:hover:not(:disabled) {
  border-color: var(--pink);
  color: var(--pink);
}
.shop-item button:disabled {
  opacity: 0.45;
  cursor: default;
}
.shop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ─── OVERLAY ─── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}
.card {
  width: min(440px, 92vw);
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem 1.6rem;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
}
.card-icon { font-size: 2.4rem; margin-bottom: 0.5rem; }
.card h2 {
  font-family: "Orbitron", sans-serif;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}
.card p {
  color: var(--muted);
  margin-bottom: 1.3rem;
  line-height: 1.45;
  font-size: 1.05rem;
}
.card-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── MOBILE-FIRST SHELL + CONTROLS ─── */
@media (hover: none) and (pointer: coarse), (max-width: 900px) {
  .view {
    min-height: 100%;
    height: 100%;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
  }

  /* Keep screens in-viewport — no page scroll / double-tap zoom bait */
  #title,
  #briefing,
  #shop {
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
    /* lock to visible viewport (Safari URL bar friendly) */
    height: 100%;
    max-height: 100dvh;
  }

  .title-ui {
    width: 100%;
    max-width: 620px;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: auto;
    padding: max(0.5rem, env(safe-area-inset-top, 0px)) 0.85rem max(0.5rem, env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }
  .title-bg { background-position: 52% center; }
  .title-ui .eyebrow { font-size: 0.58rem; margin-bottom: 0.4rem; }
  .title-ui h1 { font-size: clamp(1.55rem, 8vw, 2.7rem); margin-bottom: 0.4rem; line-height: 1.05; }
  .title-ui .lede { font-size: 0.86rem; margin-bottom: 0.45rem; line-height: 1.3; }
  .title-feats {
    margin-bottom: 0.55rem;
    gap: 0.3rem;
    justify-content: center;
    max-width: 100%;
  }
  .title-feats span { font-size: 0.68rem; padding: 0.22rem 0.4rem; }
  .title-actions { width: 100%; flex-shrink: 0; gap: 0.4rem; }
  .title-actions .btn-hero { min-height: 48px; width: 100%; }
  .title-actions .btn-ghost { min-height: 40px; width: 100%; }
  .title-ui .fineprint { margin-top: 0.4rem; font-size: 0.74rem; }
  /* sticky :hover scale on iOS can feel like a zoom */
  .btn-hero:hover { transform: none; filter: none; }
  .btn-hero:active { transform: scale(0.98); }
  .desktop-hint { display: none; }
  .touch-hint {
    display: block;
    max-width: 28rem;
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .panel,
  .panel.wide {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background:
      radial-gradient(ellipse at 10% 0%, rgba(77,225,255,0.1), transparent 45%),
      radial-gradient(ellipse at 90% 100%, rgba(155,107,255,0.1), transparent 40%),
      rgba(8, 10, 18, 0.97);
    box-shadow: none;
  }
  .brief-head { margin-bottom: 0.35rem; flex: 0 0 auto; }
  .brief-head .eyebrow { font-size: 0.55rem; letter-spacing: 0.14em; }
  .btn-icon { width: 34px; height: 34px; font-size: 0.85rem; }
  .brief-level-row { margin-bottom: 0.35rem; flex: 0 0 auto; gap: 0.5rem; }
  .brief-lvl { font-size: 0.68rem; padding: 0.32rem 0.4rem; min-width: 2.15rem; }
  .brief-level-row h2 {
    font-size: clamp(0.98rem, 4.4vw, 1.2rem);
    margin: 0;
    line-height: 1.1;
  }
  /* Scrollable middle — full brief + all tips, CTA stays pinned */
  .brief-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    margin-bottom: 0.45rem;
    padding-right: 0.15rem;
    /* fade hint that more content may exist */
    mask-image: linear-gradient(180deg, #000 0%, #000 88%, transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 88%, transparent 100%);
  }
  .brief-body {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.55rem;
    overflow: visible;
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
  }
  .brief-tips {
    margin-bottom: 0.25rem;
    overflow: visible;
    max-height: none;
  }
  .brief-tips li {
    font-size: 0.86rem;
    padding: 0.32rem 0;
    line-height: 1.3;
    border-top-color: rgba(120,180,255,0.12);
  }
  .brief-tips li:nth-child(n+3) { display: list-item; }
  .brief-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.28rem;
    margin-bottom: 0.5rem;
    flex: 0 0 auto;
  }
  .brief-stats div {
    padding: 0.32rem 0.15rem;
    border-radius: 8px;
  }
  .brief-stats span { font-size: 0.52rem; letter-spacing: 0.05em; }
  .brief-stats b { font-size: 0.74rem; margin-top: 0.05rem; }
  .btn-deploy {
    flex: 0 0 auto !important;
    min-height: 50px;
    margin-top: 0;
    font-size: 0.84rem;
    padding: 0.8rem 1rem;
    position: relative;
    z-index: 2;
    touch-action: manipulation;
  }
  .shop-title-row { flex: 0 0 auto; margin-bottom: 0.15rem; }
  .shop-title-row h2 { font-size: 1rem; }
  .shop-tagline {
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
    flex: 0 0 auto;
  }
  .shop-grid {
    grid-template-columns: 1fr;
    gap: 0.45rem;
    margin: 0 0 0.45rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  .shop-item {
    padding: 0.55rem 0.65rem;
    gap: 0.2rem;
    border-radius: 10px;
  }
  .shop-item h3 { font-size: 0.78rem; }
  .shop-item p { font-size: 0.76rem; line-height: 1.22; }
  .shop-item .cost { font-size: 0.68rem; }
  .shop-item button { min-height: 38px; padding: 0.35rem; font-size: 0.66rem; }
  .shop-foot {
    width: 100%;
    flex: 0 0 auto;
    margin: 0;
  }
  .shop-foot .btn-deploy { margin-top: 0; }

  #game-view {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: stretch;
    justify-items: stretch;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    background:
      radial-gradient(circle at 50% 42%, rgba(35, 63, 115, 0.22), transparent 42%),
      #02040a;
  }

  #hud {
    position: relative;
    z-index: 6;
    inset: auto;
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.32rem;
    padding: 0.55rem 0.65rem 0.5rem;
    background: linear-gradient(180deg, rgba(3, 6, 15, 0.98), rgba(3, 6, 15, 0.88));
    border-bottom: 1px solid rgba(77, 225, 255, 0.2);
  }
  .hud-left {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
  }
  .bar-wrap { min-width: 0; }
  .hud-pills { justify-content: flex-end; }
  .pill { font-size: 0.52rem; padding: 0.24rem 0.38rem; }
  .hud-center {
    min-width: 0;
    flex-direction: row;
    align-items: baseline;
    justify-content: center;
    gap: 0.55rem;
    text-align: left;
  }
  .level-name {
    flex: 0 1 auto;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
  }
  .objective {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.84rem;
  }
  .hud-right {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    align-items: stretch;
    gap: 0.3rem;
  }
  .hud-right .stat {
    min-width: 0;
    padding: 0.28rem 0.35rem;
    border-radius: 7px;
    font-size: 0.58rem;
  }
  .hud-right .stat b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.78rem;
  }
  .hud-sound {
    min-width: 44px;
    min-height: 38px;
    padding: 0 0.35rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.66rem;
  }

  .game-stage {
    position: relative;
    inset: auto;
    z-index: 1;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
  }
  #game {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: var(--game-aspect, 16 / 9);
    cursor: default;
    box-shadow: 0 0 36px rgba(31, 87, 160, 0.18);
  }

  #touch-controls {
    position: relative;
    z-index: 8;
    grid-row: 3;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 132px;
    padding: 0.45rem max(0.5rem, env(safe-area-inset-right, 0px)) max(0.45rem, env(safe-area-inset-bottom, 0px)) max(0.5rem, env(safe-area-inset-left, 0px));
    background:
      linear-gradient(180deg, rgba(2, 4, 10, 0.2), rgba(2, 4, 10, 0.96) 28%),
      #050812;
    border-top: 1px solid rgba(77, 225, 255, 0.18);
    touch-action: none;
  }
  .touch-surface {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    min-height: 118px;
    overflow: hidden;
    border: 1px solid rgba(151, 189, 255, 0.28);
    border-radius: 22px;
    color: #eff6ff;
    background:
      radial-gradient(circle at 50% 55%, rgba(77, 225, 255, 0.1), transparent 55%),
      linear-gradient(165deg, rgba(22, 34, 58, 0.96), rgba(7, 11, 22, 0.98));
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.1),
      inset 0 -18px 28px rgba(0,0,0,0.25),
      0 10px 22px rgba(0,0,0,0.28);
    touch-action: none;
  }
  .action-surface {
    border-color: rgba(255, 77, 154, 0.4);
    background:
      radial-gradient(circle at 50% 52%, rgba(255, 77, 154, 0.16), transparent 52%),
      linear-gradient(165deg, rgba(48, 22, 54, 0.96), rgba(12, 10, 24, 0.98));
  }
  .touch-surface::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 0 rgba(77,225,255,0);
    transition: box-shadow 0.14s ease;
    pointer-events: none;
  }
  .touch-surface.is-active::after {
    box-shadow: inset 0 0 40px rgba(77,225,255,0.2);
  }
  .action-surface.is-active::after {
    box-shadow: inset 0 0 40px rgba(255,77,154,0.24);
  }
  .surface-title {
    position: absolute;
    top: 0.45rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    font-family: "Orbitron", sans-serif;
    pointer-events: none;
    z-index: 2;
  }
  .surface-title b {
    font-size: 0.58rem;
    letter-spacing: 0.18em;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    color: #cfe8ff;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(151,189,255,0.22);
  }
  .action-surface .surface-title b {
    color: #ffd6ea;
    border-color: rgba(255,77,154,0.3);
  }
  .move-ring {
    position: absolute;
    left: 50%;
    top: 54%;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 1px dashed rgba(77, 225, 255, 0.28);
    box-shadow: inset 0 0 24px rgba(77, 225, 255, 0.08);
    pointer-events: none;
  }
  .move-guide {
    position: absolute;
    inset: 1.85rem 0.7rem 0.45rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: rgba(190, 218, 255, 0.55);
    font-family: "Orbitron", sans-serif;
    pointer-events: none;
    z-index: 1;
  }
  .move-guide span { font-size: 1.15rem; opacity: 0.75; }
  .move-guide em { font-style: normal; font-size: 0.55rem; letter-spacing: 0.22em; opacity: 0.55; }
  .move-origin {
    position: absolute;
    left: 50%;
    top: 54%;
    width: 78px;
    height: 78px;
    display: none;
    border: 1px solid rgba(77, 225, 255, 0.55);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: rgba(7, 18, 35, 0.55);
    box-shadow: 0 0 28px rgba(77, 225, 255, 0.22);
    pointer-events: none;
    z-index: 2;
  }
  .move-surface.is-active .move-origin { display: block; }
  .move-surface.is-active .move-guide,
  .move-surface.is-active .move-ring { opacity: 0.15; }
  .move-stick {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at 35% 30%, #d8f8ff, #4de1ff 48%, #1c4f7a 100%);
    box-shadow: 0 4px 14px rgba(0,0,0,0.45), 0 0 20px rgba(77,225,255,0.45);
    border: 1px solid rgba(255,255,255,0.35);
  }
  .fire-core {
    position: absolute;
    left: 50%;
    top: 54%;
    width: 64px;
    height: 64px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid rgba(255, 77, 154, 0.55);
    background:
      radial-gradient(circle at 50% 45%, rgba(255,180,220,0.35), rgba(255,77,154,0.12) 45%, transparent 70%);
    box-shadow: 0 0 24px rgba(255,77,154,0.28), inset 0 0 18px rgba(255,77,154,0.18);
    pointer-events: none;
    z-index: 1;
  }
  .fire-core span {
    position: absolute;
    inset: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #ffd0e8, #ff4d9a 55%, #7a1848 100%);
    box-shadow: 0 0 16px rgba(255,77,154,0.55);
  }
  .action-surface.is-active .fire-core {
    transform: translate(-50%, -50%) scale(1.06);
    box-shadow: 0 0 34px rgba(255,77,154,0.5), inset 0 0 22px rgba(255,77,154,0.28);
  }
  .gesture-map {
    position: absolute;
    inset: 0.35rem 0.45rem 0.3rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    align-items: center;
    justify-items: center;
    font-family: "Orbitron", sans-serif;
    color: rgba(255, 220, 235, 0.7);
    pointer-events: none;
    z-index: 2;
  }
  .gesture-map span {
    font-size: 0.56rem;
    letter-spacing: 0.06em;
    text-shadow: 0 1px 6px rgba(0,0,0,0.55);
  }
  .gesture-jump { grid-column: 1 / -1; grid-row: 1; align-self: start; }
  .gesture-dash {
    grid-column: 1 / -1;
    grid-row: 2;
    align-self: center;
    margin-top: 3.1rem;
    opacity: 0.75;
  }
  .gesture-pause { grid-column: 1 / -1; grid-row: 3; align-self: end; opacity: 0.65; }
  .gesture-feedback {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    color: #fff;
    font-family: "Orbitron", sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    opacity: 0;
    transform: scale(0.88);
    transition: opacity 0.12s ease, transform 0.12s ease;
    pointer-events: none;
    text-shadow: 0 0 18px rgba(255,77,154,0.8);
  }
  .gesture-feedback.show { opacity: 1; transform: scale(1); }
  .touch-trace {
    position: absolute;
    z-index: 3;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255,255,255,0.5), rgba(255,77,154,0.22) 42%, transparent 72%);
    box-shadow: 0 0 22px rgba(255,77,154,0.42);
    pointer-events: none;
  }
  .pause-hint { display: none; }
  .toast {
    z-index: 10;
    top: 36%;
    max-width: calc(100% - 2rem);
    text-align: center;
    font-size: 0.78rem;
  }
}

@media (max-width: 380px) {
  #touch-controls { gap: 0.35rem; padding-inline: 0.38rem; min-height: 120px; }
  .touch-surface { border-radius: 18px; min-height: 108px; }
  .move-ring, .move-origin { width: 72px; height: 72px; }
  .fire-core { width: 56px; height: 56px; }
  .fire-core span { inset: 13px; }
  .pill { letter-spacing: 0; }
  .brief-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .brief-stats b { font-size: 0.7rem; }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape),
       (max-width: 900px) and (orientation: landscape) and (max-height: 600px) {
  #game-view { display: block; }
  .game-stage { position: absolute; inset: 0; width: 100%; height: 100%; }
  #game { width: auto; height: 100%; max-width: 100%; }
  #hud {
    position: absolute;
    inset: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) auto env(safe-area-inset-left, 0px);
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.85fr) minmax(250px, 1fr);
    align-items: start;
    gap: 0.65rem;
    padding: 0.45rem 0.65rem;
    background: linear-gradient(180deg, rgba(0,0,0,0.78), transparent);
    border: 0;
  }
  .hud-left { display: flex; align-items: stretch; }
  .hud-center { flex-direction: column; align-items: center; gap: 0.2rem; }
  .hud-right { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
  #touch-controls {
    position: absolute;
    inset: auto 0 env(safe-area-inset-bottom, 0px) 0;
    min-height: 128px;
    padding: 0.45rem max(0.65rem, env(safe-area-inset-right, 0px)) max(0.45rem, env(safe-area-inset-bottom, 0px)) max(0.65rem, env(safe-area-inset-left, 0px));
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.66));
    border: 0;
    pointer-events: none;
  }
  .touch-surface {
    flex: 0 1 250px;
    min-height: 112px;
    max-width: 250px;
    border-radius: 28px;
    pointer-events: auto;
    opacity: 0.8;
  }
  .touch-surface.is-active { opacity: 1; }
}

@media (max-height: 560px) and (orientation: portrait) {
  #hud { gap: 0.2rem; padding-block: 0.3rem; }
  .hud-center { display: none; }
  #touch-controls { min-height: 108px; padding-block: 0.3rem; }
  .touch-surface { min-height: 96px; }
  .move-ring, .move-origin { width: 64px; height: 64px; }
  .fire-core { width: 48px; height: 48px; }
  .fire-core span { inset: 11px; }
}

/* Short phones: still show full content via scroll; only tighten chrome */
@media (max-height: 820px) and (orientation: portrait) {
  #briefing .brief-body { font-size: 0.86rem; margin-bottom: 0.4rem; }
  #briefing .brief-tips li { font-size: 0.82rem; padding: 0.26rem 0; }
  #briefing .brief-stats { margin-bottom: 0.4rem; gap: 0.22rem; }
  #briefing .btn-deploy { min-height: 48px; font-size: 0.8rem; }
  #title .title-feats { max-height: 4.5rem; overflow: hidden; }
  #title .lede br { display: none; }
}

@media (max-height: 700px) and (orientation: portrait) {
  #briefing .brief-stats span { font-size: 0.48rem; }
  #briefing .brief-stats b { font-size: 0.68rem; }
  #briefing .brief-stats div { padding: 0.22rem 0.1rem; }
  #title .title-feats { display: none; }
  #title .touch-hint { font-size: 0.72rem; }
}
