:root {
  --bg-1: #080c26;
  --bg-2: #141d44;
  --panel: rgba(15, 25, 58, 0.86);
  --panel-border: #4ea1ff;
  --text: #f2f6ff;
  --accent: #ffe03b;
  --danger: #ff4f4f;
  --good: #5dff9f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 20%, #1d2c66 0%, #0c1336 45%, #06091b 100%);
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#globalNav {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 70;
  display: flex;
  gap: 6px;
}

.navBtn {
  text-decoration: none;
  color: #d5e8ff;
  border: 1px solid rgba(138, 179, 255, 0.8);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  background: rgba(16, 30, 72, 0.85);
}

.navBtn.active {
  border-color: #ffe170;
  color: #ffe170;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 50% 50%, rgba(18, 33, 85, 0.4), rgba(8, 12, 38, 0.96)),
    linear-gradient(transparent 95%, rgba(120, 170, 255, 0.1) 95%),
    linear-gradient(90deg, transparent 95%, rgba(120, 170, 255, 0.1) 95%);
  background-size:
    auto,
    64px 64px,
    64px 64px;
}

.hidden {
  display: none !important;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 20, 0.72);
  z-index: 20;
  padding: 24px;
}

.screen.active {
  display: flex;
}

.menuCard,
.classCardWrap,
.upgradeCardWrap,
.resultCard,
.pauseCard {
  width: min(1200px, 94vw);
  border-radius: 18px;
  border: 2px solid rgba(92, 163, 255, 0.7);
  background: linear-gradient(170deg, rgba(20, 35, 86, 0.86), rgba(8, 14, 39, 0.94));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), inset 0 0 60px rgba(90, 160, 255, 0.12);
}

.menuCard {
  max-width: 900px;
  padding: 38px 48px;
  text-align: center;
}

h1 {
  margin: 8px 0 10px;
  font-size: clamp(40px, 7vw, 78px);
  color: #ff5252;
  text-shadow: 0 4px 0 #9e1111, 0 0 28px rgba(255, 48, 48, 0.56);
}

h2 {
  margin: 0;
  text-align: center;
  font-size: clamp(34px, 5vw, 64px);
  color: #ffe300;
  text-shadow: 0 3px 0 #7f6400;
}

.subtitle {
  margin: 0 0 24px;
  color: #ffe136;
  font-size: clamp(22px, 3.2vw, 36px);
}

.features {
  margin-top: 28px;
  border-radius: 14px;
  padding: 18px 22px;
  border: 2px solid rgba(88, 164, 255, 0.76);
  background: rgba(11, 20, 52, 0.74);
}

.features h3 {
  margin: 0 0 10px;
  color: #ffe400;
  font-size: clamp(26px, 4vw, 46px);
}

.features p {
  margin: 8px 0;
  font-size: clamp(19px, 2.1vw, 30px);
}

.primaryBtn,
.ghostBtn {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 14px 30px;
  font-size: clamp(22px, 2.3vw, 32px);
  font-weight: 800;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.primaryBtn {
  background: linear-gradient(180deg, #70beff, #4a8fe1);
  color: #092450;
  box-shadow: 0 8px 0 #2a5ea2;
}

.ghostBtn {
  background: rgba(33, 50, 103, 0.84);
  color: #d8e8ff;
  border: 2px solid rgba(130, 175, 255, 0.75);
}

.primaryBtn:hover,
.ghostBtn:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.classCardWrap {
  padding: 28px;
}

.classGrid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}

.classOption {
  border-radius: 16px;
  border: 3px solid;
  padding: 18px;
  background: rgba(14, 22, 58, 0.92);
  cursor: pointer;
  min-height: 220px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.classOption:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.35);
}

.classOption .icon {
  font-size: 46px;
}

.classOption .name {
  margin-top: 10px;
  font-size: 38px;
  font-weight: 900;
}

.classOption .desc {
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.4;
}

#backToMenuBtn {
  display: block;
  margin: 18px auto 0;
}

#upgradeScreen {
  z-index: 40;
  background: rgba(2, 4, 16, 0.7);
}

.upgradeCardWrap {
  padding: 24px;
}

.upgradeGrid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.upgradeOption {
  border-radius: 14px;
  border: 3px solid #66b2ff;
  background: rgba(20, 26, 46, 0.95);
  padding: 16px;
  min-height: 260px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.upgradeOption:hover {
  transform: translateY(-3px);
  background: rgba(34, 45, 78, 0.96);
}

.upgradeOption .title {
  font-size: 34px;
  font-weight: 900;
  color: #fff2a8;
}

.upgradeOption .desc {
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.45;
  color: #f2f7ff;
}

.upgradeOption .key {
  margin-top: 18px;
  font-size: 34px;
  color: #ffe300;
  text-align: center;
  font-weight: 900;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

#topHud {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 94vw);
}

#timerBox {
  text-align: center;
  font-size: clamp(36px, 3vw, 54px);
  font-weight: 900;
  border: 2px solid rgba(90, 156, 255, 0.9);
  border-radius: 12px;
  padding: 4px 12px;
  background: rgba(8, 17, 44, 0.84);
}

#bossBarWrap {
  margin-top: 8px;
  border: 2px solid rgba(255, 110, 110, 0.9);
  border-radius: 10px;
  padding: 8px;
  background: rgba(44, 8, 8, 0.82);
}

#bossName {
  font-size: 20px;
  font-weight: 800;
  color: #ffd0d0;
  margin-bottom: 4px;
  text-align: center;
}

#bossBar {
  width: 100%;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(70, 20, 20, 0.9);
}

#bossBarFill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff7d7d, #ff3030);
}

#rightHud {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 8px;
}

.statBox {
  min-width: 190px;
  text-align: center;
  font-weight: 900;
  font-size: 38px;
  border-radius: 12px;
  padding: 4px 10px;
  background: rgba(15, 25, 60, 0.86);
  border: 2px solid #ff7a7a;
}

.statBox.gold {
  border-color: #ffd300;
}

.statBox.shard {
  border-color: #61dbff;
}

#leftHud {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 230px;
}

.panelTitle {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 6px;
}

#weaponSlots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.weaponSlot {
  border: 2px solid rgba(115, 160, 255, 0.7);
  border-radius: 8px;
  background: rgba(20, 29, 62, 0.85);
  min-height: 52px;
  padding: 6px;
  font-size: 18px;
  line-height: 1.3;
}

.hint {
  margin-top: 6px;
  font-size: 16px;
  opacity: 0.9;
}

#bottomHud {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(820px, calc(100vw - 24px));
  border-radius: 12px;
  background: rgba(8, 16, 44, 0.88);
  border: 2px solid rgba(96, 151, 255, 0.88);
  padding: 10px;
}

.barRow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
}

.barLabel {
  min-width: 54px;
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  color: #ffe658;
}

.bar {
  position: relative;
  flex: 1;
  height: 24px;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.hpBar {
  background: rgba(57, 20, 20, 0.82);
}

.xpBar {
  background: rgba(20, 40, 72, 0.82);
}

.fill {
  height: 100%;
  width: 100%;
}

#hpFill {
  background: linear-gradient(90deg, #6cfb60, #2ac730);
}

#xpFill {
  background: linear-gradient(90deg, #67c7ff, #2d8fe6);
}

.barText {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

#warningOverlay {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(150, 12, 12, 0.52);
  animation: warningBlink 0.5s infinite alternate;
}

.warningInner {
  text-align: center;
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.55));
}

.warningTitle {
  font-size: clamp(50px, 9vw, 160px);
  font-weight: 900;
  color: #ff312c;
  text-shadow: 0 3px 0 #ffffff, 0 0 30px rgba(255, 70, 70, 0.7);
}

.warningSub {
  font-size: clamp(34px, 4.2vw, 76px);
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 3px 0 #000;
}

@keyframes warningBlink {
  from {
    background: rgba(150, 12, 12, 0.48);
  }
  to {
    background: rgba(190, 8, 8, 0.63);
  }
}

#frenzyBanner,
#messageToast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 42;
  font-size: clamp(30px, 3vw, 56px);
  font-weight: 900;
  color: #ffe300;
  text-shadow: 0 3px 0 #5e1a1a;
  padding: 8px 20px;
  border-radius: 12px;
  border: 2px solid rgba(255, 207, 82, 0.8);
  background: rgba(75, 18, 18, 0.82);
  pointer-events: none;
}

#siteFooter {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  z-index: 70;
  pointer-events: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(122, 168, 255, 0.7);
  background: rgba(7, 16, 44, 0.82);
}

#siteFooter a {
  color: #dbeaff;
  text-decoration: none;
}

#siteFooter a:hover {
  color: #ffe56d;
}

#frenzyBanner {
  top: 26%;
}

#messageToast {
  top: 18%;
}

.resultCard {
  max-width: 760px;
  padding: 26px;
  text-align: center;
}

.pauseCard {
  max-width: 680px;
  padding: 24px;
  text-align: center;
}

.pauseCard p {
  font-size: 24px;
}

#resultTitle {
  margin-bottom: 10px;
}

#resultReason {
  font-size: 28px;
}

#resultStats {
  margin: 10px auto;
  width: min(560px, 90%);
  text-align: left;
  font-size: 24px;
  line-height: 1.7;
  border-radius: 12px;
  border: 2px solid rgba(132, 170, 255, 0.8);
  background: rgba(16, 25, 56, 0.9);
  padding: 12px 16px;
}

.resultButtons {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

@media (max-width: 1080px) {
  #leftHud {
    width: 180px;
  }

  .weaponSlot {
    font-size: 14px;
  }

  .classGrid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .upgradeGrid {
    grid-template-columns: 1fr;
  }

  .resultButtons {
    flex-direction: column;
  }

  #siteFooter {
    font-size: 12px;
    gap: 8px;
    width: min(96vw, 640px);
  }
}
