:root {
  color-scheme: dark;
  --bg-1: #050816;
  --bg-2: #08172e;
  --panel: rgba(10, 18, 38, 0.64);
  --panel-border: rgba(140, 190, 255, 0.18);
  --text: #eff7ff;
  --muted: #9ab3d5;
  --accent: #79d7ff;
  --accent-2: #8cffc1;
  --danger: #ff8c9b;
  --warning: #ffd66a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(64, 132, 255, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(108, 255, 205, 0.12), transparent 26%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--text);
}

#game {
  display: block;
  width: 100vw;
  height: 100dvh;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.topbar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.card {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  padding: 14px 18px;
  min-width: min(56vw, 420px);
}

.brand h1 {
  margin: 0 0 6px;
  font-size: clamp(20px, 3vw, 30px);
  letter-spacing: 0.06em;
}

.brand p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.buffs {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--accent-2);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.buff {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.guide {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: #cde2ff;
  display: grid;
  gap: 5px;
  max-width: 520px;
}

.guide b {
  color: var(--text);
  margin-right: 6px;
}

.danger-hl {
  color: #ffd66a;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, auto));
  gap: 10px;
  padding: 12px;
}

.stat {
  min-width: 80px;
  padding: 10px 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
}

.stat .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stat .value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.boss {
  position: absolute;
  top: 150px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 560px);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.boss.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.boss-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.boss-name {
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--warning);
  text-transform: uppercase;
}

.boss-value {
  font-size: 12px;
  color: var(--muted);
}

.boss-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.boss-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8c9b, #ffd66a, #79d7ff);
  box-shadow: 0 0 18px rgba(255, 180, 120, 0.5);
  transition: width 0.1s linear;
}

.center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 620px);
  padding: 24px;
  text-align: center;
  display: grid;
  gap: 16px;
}

.center.hidden {
  display: none;
}

.ui-hidden {
  display: none !important;
}

.title {
  font-size: clamp(34px, 8vw, 64px);
  margin: 0;
  letter-spacing: 0.14em;
  text-shadow: 0 0 24px rgba(121, 215, 255, 0.3);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  font-size: 15px;
}

.summary {
  margin: 0;
  color: var(--accent-2);
  font-size: 13px;
  letter-spacing: 0.04em;
  min-height: 18px;
}

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

.mode-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-btn {
  padding: 10px 14px;
  font-size: 13px;
  min-width: 94px;
  opacity: 0.88;
}

.mode-btn.active {
  opacity: 1;
  box-shadow:
    0 0 0 1px rgba(140, 255, 193, 0.28),
    0 14px 36px rgba(56, 176, 236, 0.24);
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(121, 215, 255, 0.95), rgba(140, 255, 193, 0.92));
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 14px 36px rgba(56, 176, 236, 0.24);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease;
}

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

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

.footer-tip {
  position: absolute;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(8, 17, 36, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  text-align: center;
  max-width: calc(100vw - 32px);
}

.mobile-controls {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(76px + env(safe-area-inset-bottom));
  display: none;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
}
.perf {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #cfe7ff;
  background: rgba(10, 20, 38, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.stick-wrap {
  width: 102px;
  height: 102px;
  border-radius: 50%;
  position: relative;
  display: none;
}
.stick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.16), rgba(20, 42, 80, 0.78));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin-left: -21px;
  margin-top: -21px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.92),
    rgba(121, 215, 255, 0.86)
  );
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.05s linear;
}

.action-stack {
  display: none;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.dash-btn,
.pulse-btn {
  min-width: 94px;
  padding: 12px 16px;
  border-radius: 999px;
  letter-spacing: 0.16em;
  font-size: 14px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.22);
}

.dash-btn {
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.34),
    rgba(255, 214, 106, 0.96) 58%,
    rgba(255, 140, 155, 0.84)
  );
}

.pulse-btn {
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.28),
    rgba(121, 215, 255, 0.95) 58%,
    rgba(140, 255, 193, 0.88)
  );
}

.dash-btn:active,
.pulse-btn:active {
  transform: scale(0.96);
}

@media (hover: none), (pointer: coarse) {
  .mobile-controls {
    display: flex;
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
  }
  .action-stack {
    display: flex;
  }
  .stick-wrap {
    display: block;
  }

  #game {
    cursor: default;
  }
}

@media (max-width: 900px) {
  .topbar {
    gap: 8px;
  }

  .brand {
    padding: 12px 14px;
  }

  .brand h1 {
    margin-bottom: 4px;
    font-size: clamp(16px, 5vw, 22px);
  }

  .brand p {
    font-size: 12px;
  }

  .guide {
    font-size: 11px;
  }

  .stats {
    gap: 8px;
    padding: 10px;
  }

  .stat {
    padding: 8px 10px;
  }

  .stat .value {
    font-size: 17px;
  }

  .boss {
    top: calc(138px + env(safe-area-inset-top));
  }

  .center {
    width: min(95vw, 620px);
    padding: 18px 14px;
    gap: 12px;
  }

  .subtitle {
    font-size: 13px;
    line-height: 1.6;
  }

  .summary {
    font-size: 12px;
  }

  .mode-btn {
    min-width: 82px;
    padding: 9px 10px;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    min-width: 0;
  }

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

  .stat {
    min-width: 0;
  }

  .footer-tip {
    font-size: 12px;
  }

  .mobile-controls {
    bottom: calc(92px + env(safe-area-inset-bottom));
  }
  .stick-wrap {
    width: 92px;
    height: 92px;
  }

  .dash-btn,
  .pulse-btn {
    min-width: 82px;
    padding: 10px 12px;
    font-size: 12px;
  }

  .boss {
    top: calc(220px + env(safe-area-inset-top));
  }
}

@media (max-width: 420px) {
  .brand {
    max-height: 34vh;
    overflow: auto;
  }

  .footer-tip {
    font-size: 11px;
    padding: 8px 10px;
  }
}
