:root {
  --bg-top: #0f1c27;
  --bg-mid: #152a35;
  --bg-bottom: #061017;
  --card: rgba(7, 13, 18, 0.78);
  --card-border: rgba(255, 255, 255, 0.08);
  --lime: #c6ff5c;
  --cyan: #7be7ff;
  --orange: #ffb24a;
  --red: #ff6b6b;
  --blue: #6da8ff;
  --text: #f2f7fb;
  --muted: #a7bac5;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
  background: #061017;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, rgba(123, 231, 255, 0.1), transparent 20%),
    radial-gradient(circle at 85% 10%, rgba(198, 255, 92, 0.1), transparent 18%),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid) 55%, var(--bg-bottom));
}

.shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  min-height: 100dvh;
  padding: clamp(14px, 2vw, 24px) 0 clamp(28px, 4vw, 40px);
}

.hud-card,
.tips {
  display: grid;
  gap: 18px;
}

.hud-card {
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  align-items: stretch;
  gap: 22px;
  padding: clamp(18px, 2.2vw, 26px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.eyebrow,
.panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--lime);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.device-hint {
  margin: 14px 0 0;
  color: var(--cyan);
  font-size: 0.95rem;
  line-height: 1.6;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "ZCOOL KuaiLe", cursive;
  font-weight: 400;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.intro {
  max-width: 40rem;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 14px;
  align-content: start;
}

.stat,
.tip,
.panel,
.mission-bar {
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: clamp(82px, 10vw, 96px);
  padding: 14px 16px;
}

.stat span {
  color: var(--muted);
  font-size: 0.94rem;
}

.stat strong {
  margin-top: 10px;
  font-size: clamp(1.05rem, 1.8vw, 1.55rem);
  word-break: break-word;
}

.stat-wide {
  grid-column: span 2;
}

.stat-wide strong {
  font-size: 1rem;
  line-height: 1.45;
}

.game-area {
  position: relative;
  margin-top: 18px;
  isolation: isolate;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

canvas {
  width: 100%;
  aspect-ratio: 16 / 10;
  height: auto;
  max-height: min(72dvh, 780px);
  display: block;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #11242e;
  box-shadow: 0 28px 65px rgba(0, 0, 0, 0.38);
  cursor: crosshair;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 9, 14, 0.54);
  border-radius: 28px;
}

.overlay.hidden {
  display: none;
}

.touch-controls {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
  touch-action: none;
  overscroll-behavior: none;
}

.touch-cluster {
  position: absolute;
  pointer-events: auto;
}

.touch-cluster-move {
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
}

.touch-cluster-utility {
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 12px;
}

.touch-cluster-fire {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
}

.touch-label {
  margin: 0 0 10px 8px;
  color: rgba(242, 247, 251, 0.86);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.joystick-base {
  position: relative;
  width: clamp(118px, 14vw, 148px);
  height: clamp(118px, 14vw, 148px);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 18px 38px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(198, 255, 92, 0.95), rgba(123, 231, 255, 0.85));
  box-shadow: 0 10px 24px rgba(123, 231, 255, 0.18);
}

.touch-button {
  min-width: 88px;
  min-height: 58px;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(13, 24, 32, 0.48);
  color: var(--text);
  box-shadow:
    0 16px 35px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.touch-button:hover {
  transform: none;
}

.touch-button-ghost {
  background: rgba(10, 18, 24, 0.52);
}

.touch-button.touch-button-primary {
  background: linear-gradient(135deg, var(--lime), #efffaa);
  color: #10212f;
  box-shadow: 0 12px 30px rgba(198, 255, 92, 0.2);
}

.touch-button-fire {
  min-width: clamp(92px, 12vw, 122px);
  min-height: clamp(92px, 12vw, 122px);
  border-radius: 50%;
  font-size: 1.06rem;
}

.panel {
  max-width: 450px;
  padding: 28px;
  text-align: center;
  background:
    radial-gradient(circle at top, rgba(198, 255, 92, 0.14), transparent 55%),
    rgba(8, 14, 20, 0.92);
}

.panel h2 {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
}

.panel p {
  margin: 12px 0 22px;
  line-height: 1.7;
  color: var(--muted);
}

.panel-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

button {
  padding: 12px 24px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--lime), #efffaa);
  color: #10212f;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 12px 30px rgba(198, 255, 92, 0.24);
}

button:hover {
  transform: translateY(-2px) scale(1.02);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.tips {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 20px;
}

.tip {
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.03);
}

.tip h3 {
  font-size: 1.36rem;
}

.tip p {
  margin: 10px 0 0;
  line-height: 1.6;
  color: var(--muted);
}

body.device-touch-ui .tips {
  opacity: 0.86;
}

body.device-touch-ui .tip {
  padding: 16px;
}

body.device-touch-ui.mode-ingame .touch-controls {
  opacity: 1;
}

body.device-touch-ui.mode-paused .touch-controls {
  opacity: 0;
}

html.scroll-lock,
body.scroll-lock {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body.scroll-lock {
  position: fixed;
  inset: 0;
  width: 100%;
  touch-action: none;
}

body.mode-ingame .shell {
  width: min(1480px, calc(100vw - 18px));
  min-height: 100dvh;
  padding-top: 10px;
}

body.mode-ingame .hud-card {
  grid-template-columns: minmax(180px, 0.62fr) minmax(0, 1.38fr);
  gap: 14px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(7, 13, 18, 0.68);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

body.mode-ingame .hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body.mode-ingame .eyebrow,
body.mode-ingame .intro,
body.mode-ingame .device-hint {
  display: none;
}

body.mode-ingame h1 {
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
}

body.mode-ingame .stats {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}

body.mode-ingame .stat {
  min-height: 68px;
  padding: 10px 12px;
  border-radius: 16px;
}

body.mode-ingame .stat span {
  font-size: 0.78rem;
}

body.mode-ingame .stat strong {
  margin-top: 6px;
  font-size: clamp(0.96rem, 1.35vw, 1.22rem);
}

body.mode-ingame .stat-wide strong {
  font-size: 0.92rem;
}

body.mode-ingame .game-area {
  margin-top: 12px;
}

body.mode-ingame canvas {
  max-height: min(80dvh, 920px);
  border-radius: 30px;
  box-shadow:
    0 32px 84px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(123, 231, 255, 0.08);
}

body.mode-ingame .tips {
  margin-top: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

body.device-touch-ui.mode-ingame .hud-card,
body.device-touch-ui.mode-paused .hud-card {
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px 12px;
}

body.device-touch-ui.mode-ingame .stats,
body.device-touch-ui.mode-paused .stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

body.device-touch-ui.mode-ingame .stat-wide,
body.device-touch-ui.mode-paused .stat-wide {
  grid-column: span 3;
}

body.device-touch-ui.mode-ingame canvas,
body.device-touch-ui.mode-paused canvas {
  max-height: min(calc(100dvh - 150px), 980px);
}

body.device-touch-ui.mode-ingame .shell,
body.device-touch-ui.mode-paused .shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding-top: 8px;
  padding-bottom: 8px;
  width: min(100vw - 12px, 1380px);
}

body.device-touch-ui.mode-ingame .hero-copy,
body.device-touch-ui.mode-paused .hero-copy {
  display: none;
}

body.device-touch-ui.mode-ingame .stat,
body.device-touch-ui.mode-paused .stat {
  min-height: 58px;
  padding: 8px 10px;
}

body.device-touch-ui.mode-ingame .stat span,
body.device-touch-ui.mode-paused .stat span {
  font-size: 0.72rem;
}

body.device-touch-ui.mode-ingame .stat strong,
body.device-touch-ui.mode-paused .stat strong {
  margin-top: 4px;
  font-size: 0.92rem;
}

body.device-touch-ui.mode-ingame .stat-wide strong,
body.device-touch-ui.mode-paused .stat-wide strong {
  font-size: 0.84rem;
  line-height: 1.35;
}

body.device-touch-ui.mode-ingame,
body.device-touch-ui.mode-paused,
body.device-touch-ui.mode-ingame .shell,
body.device-touch-ui.mode-paused .shell,
body.device-touch-ui.mode-ingame .game-area,
body.device-touch-ui.mode-paused .game-area {
  overscroll-behavior: none;
}

body.device-touch-ui.mode-ingame,
body.device-touch-ui.mode-paused {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.device-touch-ui.mode-ingame .game-area,
body.device-touch-ui.mode-paused .game-area,
body.device-touch-ui.mode-ingame canvas,
body.device-touch-ui.mode-paused canvas,
body.device-touch-ui.mode-ingame .touch-controls,
body.device-touch-ui.mode-paused .touch-controls,
body.device-touch-ui.mode-ingame .touch-button,
body.device-touch-ui.mode-paused .touch-button,
body.device-touch-ui.mode-ingame .joystick-base,
body.device-touch-ui.mode-paused .joystick-base {
  touch-action: none;
}

body.device-touch-ui.mode-ingame .game-area,
body.device-touch-ui.mode-paused .game-area {
  min-height: 0;
  margin-top: 0;
  display: grid;
  place-items: start center;
}

body.device-touch-ui.mode-ingame canvas,
body.device-touch-ui.mode-paused canvas {
  width: auto;
  max-width: 100%;
}

body.device-touch-ui.touch-landscape.mode-ingame .shell,
body.device-touch-ui.touch-landscape.mode-paused .shell {
  position: relative;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

body.device-touch-ui.touch-landscape.mode-ingame .hud-card,
body.device-touch-ui.touch-landscape.mode-paused .hud-card {
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  z-index: 5;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(7, 13, 18, 0.48);
  backdrop-filter: blur(14px);
}

body.device-touch-ui.touch-landscape.mode-ingame .stats,
body.device-touch-ui.touch-landscape.mode-paused .stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
}

body.device-touch-ui.touch-landscape.mode-ingame .stat,
body.device-touch-ui.touch-landscape.mode-paused .stat {
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 12px;
}

body.device-touch-ui.touch-landscape.mode-ingame .stat span,
body.device-touch-ui.touch-landscape.mode-paused .stat span {
  font-size: 0.66rem;
}

body.device-touch-ui.touch-landscape.mode-ingame .stat strong,
body.device-touch-ui.touch-landscape.mode-paused .stat strong {
  margin-top: 2px;
  font-size: 0.78rem;
}

body.device-touch-ui.touch-landscape.mode-ingame .stat-wide,
body.device-touch-ui.touch-landscape.mode-paused .stat-wide {
  grid-column: span 2;
}

body.device-touch-ui.touch-landscape.mode-ingame .stat-wide strong,
body.device-touch-ui.touch-landscape.mode-paused .stat-wide strong {
  font-size: 0.72rem;
  line-height: 1.2;
}

body.device-touch-ui.touch-landscape.mode-ingame .game-area,
body.device-touch-ui.touch-landscape.mode-paused .game-area {
  align-self: stretch;
}

@media (max-width: 1100px) {
  .hud-card,
  .tips {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .touch-controls {
    font-size: 0.95rem;
  }
}

@media (max-width: 900px) {
  .shell {
    width: min(100vw - 24px, 1380px);
  }

  .stat-wide {
    grid-column: span 2;
  }

  .touch-cluster-utility {
    gap: 10px;
  }

  body.device-touch-ui.mode-ingame .stats,
  body.device-touch-ui.mode-paused .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.device-touch-ui.mode-ingame .stat-wide,
  body.device-touch-ui.mode-paused .stat-wide {
    grid-column: span 4;
  }

  body.device-touch-ui.mode-ingame canvas,
  body.device-touch-ui.mode-paused canvas {
    max-height: min(calc(100dvh - 180px), 980px);
  }
}

@media (max-width: 580px) {
  .shell {
    width: min(100vw - 18px, 1380px);
    padding-top: 10px;
  }

  .panel-actions {
    flex-direction: column;
  }

  .hud-card {
    padding: 16px;
    gap: 16px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-wide {
    grid-column: span 2;
  }

  .stat {
    min-height: 76px;
    padding: 12px 13px;
  }

  .stat strong {
    margin-top: 8px;
    font-size: 1rem;
  }

  canvas {
    max-height: 52dvh;
  }

  .touch-cluster-utility {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    flex-direction: column;
  }

  .touch-cluster-fire {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .touch-cluster-move {
    left: max(12px, env(safe-area-inset-left));
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .stat-wide {
    grid-column: span 1;
  }

  canvas {
    max-height: 46dvh;
  }
}
