:root {
  --bg: #070914;
  --panel: #0f1631;
  --panel-border: #2f4dac;
  --text: #e9f1ff;
  --muted: #9db3e7;
  --accent: #2df8ff;
  --danger: #ff3a79;
  --ok: #66ff9a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, #1a2a67 0%, transparent 36%),
    radial-gradient(circle at 80% 80%, #4a1f61 0%, transparent 33%),
    var(--bg);
  display: grid;
  place-items: center;
}

.game-shell {
  width: min(1100px, 96vw);
  display: grid;
  gap: 0.8rem;
}

.hud-top,
.hud-bottom {
  background: color-mix(in srgb, var(--panel) 90%, black);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 0.7rem 1rem;
  box-shadow: 0 8px 30px #00000075;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.brand p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats {
  display: flex;
  gap: 0.8rem;
}

.actions-top {
  display: flex;
  gap: 0.45rem;
}

.controls-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.control-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #cfe0ff;
  background: #091334;
  border: 1px solid #2f4dac;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
}

.stat {
  background: #0a0f23;
  border: 1px solid #2a3c8e;
  border-radius: 10px;
  min-width: 98px;
  text-align: center;
  padding: 0.4rem 0.7rem;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.stat strong {
  font-size: 1.05rem;
}

.arena-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #2d44a0;
  box-shadow: 0 16px 45px #00000095;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #070d1d;
}

.overlay {
  position: absolute;
  inset: 0;
  background: #02040fcc;
  display: none;
  place-items: center;
  padding: 1.2rem;
}

.overlay.active {
  display: grid;
}

.card {
  width: min(560px, 92%);
  background: linear-gradient(160deg, #141d3c, #0a122b);
  border: 1px solid #3250b5;
  border-radius: 16px;
  padding: 1.2rem 1.3rem;
  box-shadow: 0 12px 30px #0000008a;
}

.card h2 {
  margin: 0 0 0.45rem;
}

.card p {
  margin: 0 0 1rem;
  color: #c5d5ff;
}

kbd {
  border: 1px solid #4b66ca;
  background: #081133;
  border-radius: 6px;
  padding: 0.12rem 0.4rem;
  color: #d9e7ff;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.68rem 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #071120;
  background: linear-gradient(120deg, #46e3ff, #56ffb4);
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
}

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

.secondary-btn {
  color: #dbe8ff;
  background: linear-gradient(130deg, #1c274d, #0e1838);
  border: 1px solid #405ec9;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
}

.upgrade-btn {
  text-align: left;
  color: #e6efff;
  background: linear-gradient(160deg, #15203f, #0d1530);
  border: 1px solid #3e63d4;
}

.upgrade-btn strong {
  display: block;
  color: #8fd6ff;
  margin-bottom: 0.2rem;
}

.hud-bottom {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.bar-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55rem;
}

.bar-wrap label {
  color: var(--muted);
  font-weight: 600;
  min-width: 44px;
}

.bar {
  height: 13px;
  border-radius: 999px;
  border: 1px solid #3550b8;
  background: #0a1231;
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 100%;
  transition: width 0.18s linear;
}

.hp {
  background: linear-gradient(90deg, #4cff9b, #9dff7f);
}

.dash {
  background: linear-gradient(90deg, #31d4ff, #4f8bff);
}

.boss {
  background: linear-gradient(90deg, #ff3e87, #ff7450);
}

.boss-wrap.hidden {
  opacity: 0.35;
}

.modules-wrap {
  display: grid;
  gap: 0.35rem;
}

.module-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 36px;
  align-content: flex-start;
}

.module-chip {
  font-size: 0.73rem;
  color: #d8e5ff;
  border: 1px solid #3d57b6;
  background: #0a1332;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.tip {
  margin-top: -0.35rem;
  color: #9cd8ff;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.5rem 0.8rem;
  align-items: center;
  margin-bottom: 1rem;
}

.settings-grid label {
  color: #c0d2ff;
  font-size: 0.9rem;
}

.settings-grid input[type="range"],
.settings-grid select {
  width: 100%;
}

.pause-actions {
  display: flex;
  gap: 0.55rem;
}

.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  align-items: end;
  justify-content: space-between;
  padding: 1rem;
}

.touch-stick,
.touch-actions button {
  pointer-events: auto;
}

.touch-stick {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 2px solid #4d68cc;
  background: #0a1335aa;
  position: relative;
  touch-action: none;
}

.touch-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #5de8ff;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.touch-actions {
  display: grid;
  gap: 0.55rem;
}

.touch-actions button {
  min-width: 80px;
}

@media (pointer: coarse), (max-width: 850px) {
  .touch-controls {
    display: flex;
  }
}

@media (max-width: 850px) {
  .hud-top {
    flex-direction: column;
    align-items: stretch;
  }

  .controls-top {
    justify-content: flex-start;
  }

  .stats {
    justify-content: space-between;
  }

  .hud-bottom {
    grid-template-columns: 1fr;
  }

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