:root {
  --bg: #070b14;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-line: rgba(120, 200, 180, 0.16);
  --ink: #e9f4ff;
  --muted: #93a7bd;
  --green: #4fdc86;
  --green-dark: #1f7047;
  --amber: #ffc65c;
  --cyan: #5ad7ff;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(circle at 15% 5%, rgba(79, 220, 134, 0.12), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(255, 198, 92, 0.10), transparent 38%),
    linear-gradient(160deg, #0a1120 0%, #070b14 60%, #05080f 100%);
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
}

.orb-green {
  top: -80px;
  left: 8%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(79, 220, 134, 0.35), transparent 70%);
}

.orb-amber {
  right: -60px;
  bottom: -100px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(255, 198, 92, 0.22), transparent 70%);
}

.grid-glow {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(120, 200, 180, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 200, 180, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
}

.app {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 13px;
  border: 1px solid rgba(79, 220, 134, 0.35);
  background: linear-gradient(145deg, rgba(79, 220, 134, 0.22), rgba(90, 215, 255, 0.12));
}

.tank-dot {
  width: 18px;
  height: 13px;
  border-radius: 4px;
  background: var(--green);
  box-shadow: 0 0 14px rgba(79, 220, 134, 0.6);
  position: relative;
}

.tank-dot::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 7px;
  width: 4px;
  height: 8px;
  border-radius: 2px;
  background: #d8ffe8;
}

.brand-copy .eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.brand-copy h1 {
  margin: 3px 0 0;
  font-size: 22px;
  letter-spacing: 0.04em;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.chip-btn {
  padding: 8px 14px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.chip-btn:hover:not(:disabled) {
  border-color: rgba(79, 220, 134, 0.5);
  color: var(--green);
}

.chip-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chip-btn.off {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.12);
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 18px;
  align-items: start;
}

.board-column { min-width: 0; }

.board-frame {
  position: relative;
  width: 100%;
  max-width: 416px;
  margin: 0 auto;
  border-radius: 18px;
  border: 1px solid rgba(79, 220, 134, 0.28);
  background: #05080f;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 22px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  aspect-ratio: 1 / 1;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scanline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035) 0,
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(circle at 50% 40%, rgba(6, 16, 26, 0.72), rgba(4, 8, 14, 0.94));
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

.overlay.visible {
  opacity: 1;
  visibility: visible;
}

.overlay-card {
  width: min(360px, 100%);
  text-align: center;
}

.overlay-eyebrow {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(79, 220, 134, 0.35);
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.overlay h2 {
  margin: 14px 0 8px;
  font-size: 24px;
  letter-spacing: 0.02em;
}

.overlay p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

.primary-btn {
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  color: #04230f;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  background: linear-gradient(145deg, var(--green), #7ff0a8);
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(79, 220, 134, 0.28);
}

.primary-btn:active { transform: translateY(1px); }

.ghost-btn {
  padding: 10px 16px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.overlay-hint {
  margin-top: 12px;
  color: rgba(147, 167, 189, 0.75);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  padding: 16px;
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  background: var(--panel);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.level-chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 198, 92, 0.3);
  color: var(--amber);
  letter-spacing: 0.06em;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.score-stat strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 0 24px rgba(79, 220, 134, 0.35);
}

.best-stat {
  margin-top: 10px;
}

.best-stat strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.stat-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.mini-stat {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.mini-stat strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
  color: var(--cyan);
}

.buff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.buff-chip {
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(147, 167, 189, 0.6);
  font-size: 11px;
  font-weight: 700;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.buff-chip.on {
  color: var(--amber);
  border-color: rgba(255, 198, 92, 0.5);
  box-shadow: 0 0 16px rgba(255, 198, 92, 0.25);
}

.key-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 12px;
}

.key-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.keys { display: inline-flex; gap: 4px; }

kbd {
  display: inline-flex;
  min-width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
}

.space-key { min-width: 62px; }

.tips {
  margin: 12px 0 0;
  color: rgba(147, 167, 189, 0.8);
  font-size: 11.5px;
  line-height: 1.7;
}

.touch-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  gap: 6px;
}

.dpad button,
.fire-btn {
  border: 1px solid rgba(79, 220, 134, 0.3);
  border-radius: 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dpad button[data-dir="0"] { grid-column: 2; grid-row: 1; }
.dpad button[data-dir="3"] { grid-column: 1; grid-row: 2; }
.dpad button[data-dir="2"] { grid-column: 2; grid-row: 3; }
.dpad button[data-dir="1"] { grid-column: 3; grid-row: 2; }

.dpad button.active,
.fire-btn.active {
  background: rgba(79, 220, 134, 0.28);
  border-color: var(--green);
}

.fire-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  color: #04230f;
  font-size: 16px;
  background: linear-gradient(145deg, var(--green), #7ff0a8);
  box-shadow: 0 14px 30px rgba(79, 220, 134, 0.25);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  color: rgba(147, 167, 189, 0.75);
  font-size: 11.5px;
}

.footer i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(147, 167, 189, 0.5);
}

@media (max-width: 900px) {
  .game-shell { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; flex-wrap: wrap; }
  .panel { flex: 1 1 240px; }
}

@media (max-width: 560px) {
  .app { width: calc(100% - 22px); padding-top: 12px; }
  .brand-copy h1 { font-size: 19px; }
  .chip-btn { padding: 7px 11px; font-size: 11px; }
  .board-frame { border-radius: 14px; }
  .overlay h2 { font-size: 20px; }
  .side { flex-direction: column; }
  .footer { display: none; }
}

@media (hover: none) and (pointer: coarse) {
  .touch-controls { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
