:root {
  color-scheme: dark;
  --navy: #142437;
  --cyan: #71dbed;
  --gold: #ffd078;
  --muted: #8191a2;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #0d1520;
  color: #e9f1f7;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background-image:
    radial-gradient(ellipse at 42% 30%, #20334888, transparent 60%),
    linear-gradient(115deg, #111d2a, #0c141f);
}
button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: inherit;
}
button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
button:disabled {
  cursor: default;
  opacity: 0.46;
}
button:hover:not(:disabled) {
  filter: brightness(1.15);
}
[hidden] {
  display: none !important;
}
.layout {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 70px;
  padding: 28px 25px;
}
.intro {
  width: 326px;
  flex-shrink: 0;
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 1.7px;
  color: #8c9bad;
  display: flex;
  align-items: center;
  gap: 9px;
}
.eyebrow span {
  height: 5px;
  width: 5px;
  background: var(--cyan);
  box-shadow: 0 0 12px #59d4ef;
}
.chapter {
  color: var(--gold);
  font-size: 13px;
  margin: 45px 0 16px;
  letter-spacing: 5px;
}
h1 {
  font-size: 53px;
  line-height: 1.3;
  letter-spacing: 3px;
  margin: 0;
  font-weight: 900;
}
h1 em {
  font-style: normal;
  color: var(--cyan);
}
h1 > span {
  display: block;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 4px;
  color: #91a4b5;
  margin-top: 18px;
}
.intro-copy {
  font-size: 14px;
  color: #9aa9b8;
  line-height: 2.1;
  margin-top: 32px;
}
.intro-rule {
  width: 38px;
  height: 2px;
  background: #d4a960;
  margin: 32px 0;
}
.instructions {
  display: grid;
  grid-template-columns: 25px 1fr;
  align-items: center;
  gap: 16px 8px;
}
.instructions b {
  color: #6b9ca8;
  font-size: 10px;
}
.instructions p {
  margin: 0;
  color: #a0aebe;
  font-size: 11px;
}
.desktop-note {
  font-size: 10px;
  color: #566b7e;
  margin-top: 48px;
  letter-spacing: 1px;
}
.game {
  width: 432px;
  flex-shrink: 0;
  background: #111f2d;
  border: 1px solid #3c5265;
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 30px 100px #0008,
    0 0 0 6px #0b131b,
    0 0 0 7px #293c4b;
  position: relative;
}
.topbar {
  height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid #304354;
  background: linear-gradient(#1c3043, #142434);
}
.wordmark {
  display: flex;
  gap: 10px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
}
.wordmark i {
  font-style: normal;
  color: #7ae8f6;
  font-size: 32px;
  line-height: 38px;
}
.wordmark small {
  display: block;
  font-size: 7px;
  color: #809bab;
  letter-spacing: 2px;
  margin-top: 3px;
  font-weight: 500;
}
.header-actions {
  display: flex;
  gap: 7px;
}
.icon-btn {
  background: #102232;
  border: 1px solid #3a5265;
  border-radius: 7px;
  width: 30px;
  height: 30px;
  color: #bbccd7;
  font-weight: 800;
}
.stats {
  height: 68px;
  display: grid;
  grid-template-columns: 1.05fr 1.15fr 1fr;
  background: #152737;
  padding: 11px 18px;
  gap: 15px;
}
.stats > div + div {
  border-left: 1px solid #324657;
  padding-left: 16px;
}
.stats small {
  font-size: 9px;
  color: #9aaebe;
  display: block;
  margin-bottom: 3px;
}
.stats strong {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1;
}
.stats strong span {
  color: #6f8597;
  font-size: 11px;
  font-weight: 500;
}
.gold,
.coin {
  color: var(--gold);
}
.heart {
  color: #e68478;
  font-style: normal;
}
.field {
  position: relative;
  background: #b48c55;
  line-height: 0;
}
.field canvas {
  display: block;
  width: 100%;
  aspect-ratio: 480/650;
  touch-action: none;
}
.field-caption {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  line-height: 1;
  font-size: 9px;
  color: #e9f4f7;
  text-shadow: 0 1px 3px #000;
  background: #142434c4;
  border: 1px solid #60708066;
  border-radius: 4px;
  padding: 7px 8px;
  pointer-events: none;
}
.live-dot {
  width: 5px;
  height: 5px;
  background: #6ce0c9;
  border-radius: 100%;
  box-shadow: 0 0 6px #61d9d2;
}
.zone {
  margin-left: auto;
  letter-spacing: 1.7px;
  font-size: 8px;
  color: #a8bdc6;
}
.boss-bar {
  position: absolute;
  top: 43px;
  left: 40px;
  right: 40px;
  line-height: 1.4;
  background: #13212ee8;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid #bc755d;
}
.boss-bar > div:first-child {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #ffd1ad;
}
.boss-track {
  height: 6px;
  background: #0b121c;
  margin-top: 5px;
  border-radius: 3px;
  overflow: hidden;
}
.boss-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #cc5c3c, #ffab63);
}
.controls {
  padding: 12px 14px 9px;
  background: linear-gradient(#172a3c, #111f2e);
}
.build-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #b5c5d0;
  margin-bottom: 10px;
}
.build-heading > span:before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 9px;
  background: var(--cyan);
  margin-right: 7px;
  vertical-align: -1px;
}
#speedBtn {
  background: #102030;
  border: 1px solid #31495e;
  font-size: 9px;
  padding: 4px 8px;
  border-radius: 4px;
  color: #92a9ba;
}
#speedBtn b {
  color: #a0e4ef;
  margin-left: 5px;
}
.build-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tower-card {
  position: relative;
  background: #142739 url("assets/ui-cyan.png") center/100% 100%;
  border: 1px solid #365569;
  border-radius: 9px;
  padding: 4px 3px 7px;
  display: flex;
  align-items: center;
  flex-direction: column;
  min-height: 120px;
  transition:
    transform 0.15s,
    border-color 0.15s;
}
.tower-card.selected {
  border-color: #f2c576;
  box-shadow:
    inset 0 0 12px #e0a34222,
    0 0 0 1px #cca15e;
}
.tower-card.selected:after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ffcf75;
  right: 8px;
  top: 8px;
}
.tower-card strong {
  font-size: 11px;
  font-weight: 700;
}
.tower-card small {
  font-size: 8px;
  color: #8fa7b8;
  margin-top: 2px;
}
.price {
  font-size: 11px;
  color: #ffd48a;
  margin-top: 4px;
  font-weight: 700;
}
.tower-art {
  height: 52px;
  width: 62px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}
.gun-art {
  background-image: url("assets/tower-gun.png");
}
.ice-art {
  background-image: url("assets/tower-ice.png");
}
.fire-art {
  background-image: url("assets/tower-fire.png");
}
kbd {
  position: absolute;
  left: 6px;
  top: 6px;
  font: 8px sans-serif;
  color: #7d95a8;
  background: #0e1d2a;
  padding: 2px 3px;
  border-radius: 2px;
}
.primary {
  border: 1px solid #f7cf82;
  border-radius: 7px;
  background: #d5a451 url("assets/ui-gold.png") center/100% 100%;
  color: #fff2cf;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  min-height: 42px;
  box-shadow: 0 3px 0 #060e1788;
  text-shadow: 0 1px 3px #000;
}
.wave-button {
  width: 100%;
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 22px;
  align-items: center;
}
.wave-button span {
  font-size: 20px;
}
.bottom-line {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: #627f93;
  margin-top: 10px;
  align-items: center;
}
.bottom-line button {
  background: none;
  border: 0;
  color: #92a8b9;
  font-size: 8px;
  padding: 0;
}
.overlay {
  position: absolute;
  inset: 0;
  background: #09131bcc;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.5;
  padding: 22px;
  z-index: 5;
  backdrop-filter: blur(3px);
}
.dialog {
  width: 100%;
  max-height: 96%;
  overflow: auto;
  background: #152a3e url("assets/ui-modal.png") center/100% 100%;
  border: 1px solid #5b9bad;
  border-radius: 14px;
  padding: 25px 20px;
  text-align: center;
  box-shadow: 0 18px 40px #0008;
}
.dialog .tag {
  font-size: 9px;
  color: #8bdfe9;
  letter-spacing: 3px;
}
.dialog h2 {
  font-size: 25px;
  margin: 12px 0 8px;
  color: #ffe1a1;
  letter-spacing: 2px;
}
.dialog p {
  font-size: 11px;
  color: #b7c8d3;
  line-height: 1.9;
  margin: 10px 0 18px;
}
.dialog .reactor {
  font-size: 48px;
  color: #78ecff;
  line-height: 1.2;
  text-shadow: 0 0 28px #4cddff;
  display: block;
  margin: 10px 0;
}
.dialog .primary {
  display: block;
  width: 100%;
  margin-top: 10px;
}
.secondary {
  border: 1px solid #446078;
  background: #122335;
  border-radius: 7px;
  padding: 10px 15px;
  font-size: 11px;
  color: #b7cbd8;
  width: 100%;
  margin-top: 8px;
}
.upgrade-card {
  width: 100%;
  background: #112438;
  border: 1px solid #45647c;
  border-radius: 8px;
  display: flex;
  text-align: left;
  gap: 12px;
  align-items: center;
  padding: 12px;
  margin-top: 9px;
}
.upgrade-card:hover {
  border-color: #82d6e5;
}
.upgrade-card .upgrade-icon {
  font-size: 24px;
  width: 36px;
  text-align: center;
  color: var(--cyan);
}
.upgrade-card strong {
  display: block;
  font-size: 13px;
  color: #f4d89a;
}
.upgrade-card small {
  font-size: 10px;
  color: #b0c6d5;
  display: block;
  margin-top: 3px;
}
.toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #102334ec;
  border: 1px solid #718b91;
  border-radius: 6px;
  padding: 9px 15px;
  font-size: 11px;
  color: #ffe2a1;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 7;
}
.toast.show {
  opacity: 1;
}
.tower-panel {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  background: #102235f5;
  border: 1px solid #7ba8b5;
  border-radius: 9px;
  padding: 10px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 7px;
  z-index: 3;
}
.tower-panel > div {
  flex: 1;
}
.tower-panel strong {
  font-size: 12px;
  color: #d8edf4;
  display: block;
}
.tower-panel small {
  display: block;
  font-size: 8px;
  color: #91afc2;
}
.tower-panel button {
  border: 1px solid #c6a365;
  background: #67512e;
  border-radius: 5px;
  font-size: 10px;
  padding: 7px;
  color: #ffe5a8;
}
.tower-panel .sell {
  border-color: #49667b;
  background: #20374a;
  color: #acbfcd;
}
.tower-panel .close {
  border: 0;
  background: none;
  color: #94aab8;
  padding: 0 2px;
  font-size: 19px;
}
.right-note {
  height: 500px;
  width: 26px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-direction: column;
  color: #4d6c80;
}
.right-note span {
  font-size: 9px;
  writing-mode: vertical-rl;
  letter-spacing: 2px;
}
.right-note div {
  width: 1px;
  flex: 1;
  background: linear-gradient(#3b596b, transparent);
}
.right-note p {
  writing-mode: vertical-rl;
  font-size: 10px;
  letter-spacing: 5px;
  margin: 0;
}
@media (min-width: 1100px) and (max-height: 1000px) {
  .game {
    width: 380px;
  }
  .layout {
    gap: 60px;
    padding: 20px;
  }
  .controls {
    padding-top: 9px;
  }
  .tower-card {
    min-height: 105px;
  }
  .tower-art {
    height: 42px;
  }
  .topbar {
    height: 54px;
  }
  .stats {
    height: 60px;
  }
  .intro h1 {
    font-size: 48px;
  }
}
@media (max-width: 1000px) {
  .intro {
    width: 265px;
  }
  .layout {
    gap: 35px;
  }
  .intro h1 {
    font-size: 43px;
  }
  .right-note {
    display: none;
  }
}
@media (max-width: 760px) {
  .intro {
    display: none;
  }
  .layout {
    padding: 16px;
    align-items: flex-start;
  }
  .game {
    width: min(100%, 440px);
  }
}
@media (max-width: 480px) {
  body {
    background: #111f2d;
  }
  .layout {
    padding: 0;
  }
  .game {
    width: 100%;
    max-width: 480px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .topbar {
    height: 55px;
  }
  .stats {
    height: 60px;
  }
  .field canvas {
    max-height: calc(100dvh - 322px);
    min-height: 335px;
    object-fit: fill;
  }
  .tower-art {
    height: 42px;
  }
  .tower-card {
    min-height: 105px;
  }
  .controls {
    padding-top: 9px;
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }
  .dialog {
    padding: 20px 16px;
  }
  .dialog h2 {
    font-size: 22px;
  }
  .dialog p {
    margin: 8px 0 12px;
  }
}
/* Preserve image-generated bevel proportions on variable-size mobile panels. */
.dialog {
  background: #14283c;
  border: 18px solid transparent;
  border-image: url("assets/ui-modal.png") 78 fill / 18px stretch;
  padding: 18px 8px 17px;
  border-radius: 0;
}
.dialog .tag {
  font-size: 8px;
  letter-spacing: 2px;
}
.tower-card {
  background: #142739;
  border-image: url("assets/ui-cyan.png") 64 fill / 8px stretch;
}
.primary {
  background: #162b40;
  border-image: url("assets/ui-gold.png") 65 fill / 9px stretch;
  box-shadow: 0 3px 0 #060e1788;
}
@supports (padding: max(0px)) {
  .topbar {
    padding-top: env(safe-area-inset-top);
    height: calc(55px + env(safe-area-inset-top));
  }
  .controls {
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }
}
@media (max-width: 480px) {
  .field canvas {
    max-height: calc(100dvh - 348px);
  }
}
.circuit-hint {
  position: absolute;
  top: 44px;
  left: 12px;
  right: 12px;
  color: #eee1bc;
  font-size: 8px;
  line-height: 1.4;
  background: #172d3ab8;
  padding: 5px 7px;
  border-left: 2px solid #bda66e;
  pointer-events: none;
  letter-spacing: 0.2px;
}
.circuit-hint.active {
  border-color: #7fe8ec;
  color: #b8f4ec;
  background: #133d45cb;
}
.overload-btn {
  --charge: 0%;
  position: absolute;
  bottom: 12px;
  left: 12px;
  width: 96px;
  min-height: 60px;
  padding: 5px 3px;
  border: 1px solid #739eac;
  border-radius: 7px;
  background: linear-gradient(
    90deg,
    #316878 var(--charge),
    #152c3ce8 var(--charge)
  );
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 3px 10px #0003;
}
.overload-btn:disabled {
  opacity: 0.75;
}
.overload-btn i {
  display: block;
  font-style: normal;
  font-size: 21px;
  line-height: 1.1;
  color: #98edf2;
}
.overload-btn b {
  font-size: 10px;
  display: block;
  color: #d3e9eb;
}
.overload-btn span {
  font-size: 7px;
  color: #a9c6d1;
  display: block;
}
.overload-btn.ready {
  box-shadow: 0 0 15px #7ef4ff77;
  border-color: #9fefff;
  animation: charge-pulse 1.4s infinite;
}
.boss-bar {
  top: 71px;
}
.tower-panel {
  z-index: 4;
}
.tower-panel button {
  padding: 7px 5px;
  font-size: 9px;
}
@keyframes charge-pulse {
  50% {
    filter: brightness(1.3);
  }
}
@media (max-width: 480px) {
  .tower-panel small {
    font-size: 7px;
  }
  .dialog p {
    font-size: 10px;
  }
}
@media (max-width: 480px) {
  .field canvas {
    min-height: 280px;
    max-height: calc(
      100dvh - 348px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
    );
  }
}
.overload-btn {
  border-image: url("assets/ui-hud.png") 72 fill / 6px stretch;
}
