:root {
  color-scheme: dark;
  --bg: #050711;
  --panel: rgba(9, 14, 28, 0.88);
  --line: rgba(112, 231, 255, 0.22);
  --cyan: #5ee7ff;
  --gold: #ffd55c;
  --red: #ff4268;
  --violet: #b07cff;
  --green: #72ff9d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent 32%),
    radial-gradient(circle at 18% 12%, rgba(94, 231, 255, 0.15), transparent 28rem),
    radial-gradient(circle at 86% 78%, rgba(255, 213, 92, 0.12), transparent 24rem),
    var(--bg);
  color: #f4fbff;
  overflow: hidden;
}

button {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  width: 100vw;
  height: 100dvh;
  padding: 14px;
}

.stage,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 8, 18, 0.72);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.42),
    inset 0 0 48px rgba(94, 231, 255, 0.045);
}

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 0 50%, rgba(94, 231, 255, 0.018) 50% 51%, transparent 51% 100%),
    radial-gradient(circle at 50% 50%, transparent 0 64%, rgba(0, 0, 0, 0.24) 100%);
  background-size: 100% 4px, 100% 100%;
  mix-blend-mode: screen;
  z-index: 2;
}

.battlebar {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(94, 231, 255, 0.24);
  border-radius: 7px;
  background: rgba(5, 9, 20, 0.76);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.battlebar span,
.battlebar b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battlebar span {
  color: rgba(244, 251, 255, 0.72);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.battlebar b {
  color: var(--gold);
  font-size: 14px;
}

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

.banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 18px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 213, 92, 0.15), transparent 18rem),
    radial-gradient(circle, rgba(6, 11, 24, 0.28), rgba(3, 5, 12, 0.86));
  text-align: center;
  z-index: 3;
}

.banner.hidden {
  display: none;
}

.banner p {
  margin: 0;
  color: var(--gold);
  font-size: clamp(42px, 8vw, 96px);
  font-weight: 950;
  line-height: 0.92;
  text-transform: uppercase;
  text-shadow: 0 0 38px rgba(255, 213, 92, 0.28);
}

.banner button,
.controls button,
.actions button,
.abilities button,
.tower {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: #f4fbff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035));
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.banner button,
.controls button,
.actions button {
  min-height: 44px;
  padding: 0 14px;
  font-weight: 900;
}

.banner button,
#nextWave,
#upgrade {
  border-color: rgba(255, 213, 92, 0.48);
  color: #1b1200;
  background: linear-gradient(180deg, #ffe27c, #ff9f2f);
}

.panel {
  min-height: 0;
  overflow-y: auto;
  padding: 13px;
  backdrop-filter: blur(18px);
}

.brand span,
.stats span,
.soul span,
.intel span,
.selected-card span,
.tower span,
.abilities span {
  color: rgba(244, 251, 255, 0.64);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.brand h1 {
  margin: 4px 0 14px;
  color: var(--gold);
  font-size: 30px;
  line-height: 0.95;
  letter-spacing: 0;
}

.panel h2 {
  margin: 14px 0 8px;
  color: rgba(244, 251, 255, 0.68);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.stats div,
.soul,
.intel,
.passives,
.selected-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent),
    var(--panel);
}

.stats div {
  padding: 10px;
}

.stats strong {
  display: block;
  color: var(--cyan);
  font-size: 26px;
  line-height: 1.1;
}

.soul {
  margin-top: 10px;
  padding: 12px;
}

.soul > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.soul strong {
  color: var(--violet);
  font-size: 30px;
}

meter {
  width: 100%;
  height: 18px;
  margin: 8px 0 7px;
}

meter::-webkit-meter-bar {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

meter::-webkit-meter-optimum-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet), var(--cyan), var(--gold));
}

.soul p,
.intel p,
.selected-card p {
  margin: 0;
  color: rgba(244, 251, 255, 0.76);
  font-size: 13px;
  line-height: 1.35;
}

.intel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 10px;
}

.intel div {
  min-width: 0;
}

.intel strong {
  display: block;
  overflow: hidden;
  color: var(--gold);
  font-size: 17px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.intel p {
  grid-column: 1 / -1;
  min-height: 34px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.shop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 0;
}

.tower {
  display: grid;
  gap: 3px;
  min-height: 64px;
  padding: 10px 10px 10px 15px;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.tower::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--cyan);
  opacity: 0.28;
}

.tower.kyber::after {
  background: var(--gold);
}

.tower.pulse::after {
  background: var(--violet);
}

.tower.soul-forge::after {
  background: var(--green);
}

.tower.ion::after {
  background: #86a8ff;
}

.tower.missile::after {
  background: var(--red);
}

.tower b,
.abilities b {
  color: #fff;
  font-size: 14px;
  line-height: 1.1;
}

.tower span {
  line-height: 1.15;
}

.tower.selected {
  border-color: rgba(94, 231, 255, 0.76);
  background:
    radial-gradient(circle at 20% 20%, rgba(94, 231, 255, 0.2), transparent 12rem),
    rgba(94, 231, 255, 0.13);
  box-shadow:
    inset 0 0 24px rgba(94, 231, 255, 0.1),
    0 0 22px rgba(94, 231, 255, 0.09);
}

.selected-card {
  margin-top: 0;
  padding: 12px;
}

.selected-card strong {
  display: block;
  margin: 3px 0 7px;
  color: var(--gold);
  font-size: 20px;
}

.selected-card dl {
  display: grid;
  gap: 6px;
  margin: 9px 0 0;
}

.selected-card dl div {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: start;
}

.selected-card dt,
.selected-card dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.28;
}

.selected-card dt {
  color: rgba(244, 251, 255, 0.55);
  font-weight: 900;
  text-transform: uppercase;
}

.selected-card dd {
  color: rgba(244, 251, 255, 0.82);
}

.passives {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.passives span {
  padding-left: 10px;
  border-left: 3px solid rgba(176, 124, 255, 0.6);
  color: rgba(244, 251, 255, 0.76);
  font-size: 12px;
  line-height: 1.25;
}

.actions,
.abilities,
.controls {
  display: grid;
  gap: 8px;
  margin-top: 0;
}

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

#sell {
  border-color: rgba(255, 66, 104, 0.36);
  color: #ffd6dd;
}

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

.abilities button {
  min-height: 58px;
  padding: 8px;
  text-align: left;
}

.abilities button:first-child {
  border-color: rgba(176, 124, 255, 0.42);
  background:
    radial-gradient(circle at 25% 18%, rgba(176, 124, 255, 0.26), transparent 7rem),
    rgba(176, 124, 255, 0.12);
}

.abilities button:last-child {
  border-color: rgba(94, 231, 255, 0.42);
  background:
    radial-gradient(circle at 25% 18%, rgba(94, 231, 255, 0.22), transparent 7rem),
    rgba(94, 231, 255, 0.11);
}

.controls {
  grid-template-columns: 1fr 82px 62px;
}

.controls.secondary {
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 8px;
}

.controls.secondary button,
.map-row select {
  min-height: 40px;
  border: 1px solid rgba(94, 231, 255, 0.22);
  border-radius: 6px;
  color: #f4fbff;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 850;
}

.map-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.map-row label {
  color: rgba(244, 251, 255, 0.62);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.map-row select {
  padding: 0 10px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .stage {
    height: min(62vh, 620px);
    min-height: 390px;
  }

  .panel {
    overflow: visible;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 8px;
    gap: 8px;
  }

  .stage {
    min-height: 360px;
    height: 56vh;
  }

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

  .stats div {
    padding: 7px;
  }

  .stats strong {
    font-size: 19px;
  }

  .battlebar {
    left: 8px;
    right: 8px;
    top: 8px;
    min-height: 38px;
  }

  .battlebar span {
    display: none;
  }
}
