:root {
  --bg: #07090f;
  --panel: rgba(10, 15, 24, 0.88);
  --panel-strong: rgba(14, 21, 34, 0.96);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f4f7fb;
  --muted: rgba(244, 247, 251, 0.68);
  --cyan: #38dff2;
  --pink: #ff4fd8;
  --lime: #b9ff50;
  --amber: #ffbd4a;
  --red: #ff5568;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at 14% 18%, rgba(56, 223, 242, 0.16), transparent 30%),
    radial-gradient(circle at 86% 10%, rgba(255, 79, 216, 0.14), transparent 26%),
    linear-gradient(145deg, #080a10, #111827 48%, #080a10);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
}

button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #071018;
  background: linear-gradient(135deg, var(--cyan), var(--lime));
  cursor: pointer;
  font: 800 0.82rem Inter, system-ui, sans-serif;
  min-height: 40px;
  padding: 0 16px;
  text-transform: uppercase;
}

button:hover { filter: brightness(1.08); }

.shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 10px;
}

.hud {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.brand { min-width: 0; }
.kicker,
.eyebrow {
  display: block;
  color: var(--cyan);
  font: 600 0.68rem "Roboto Mono", monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p { margin: 0; }

h1 {
  margin-top: 3px;
  font-size: clamp(1.15rem, 2.8vw, 1.7rem);
  line-height: 1;
}

.meters {
  display: grid;
  grid-template-columns: repeat(4, minmax(68px, 1fr));
  gap: 8px;
}

.meters div {
  min-width: 68px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.meters span {
  display: block;
  color: var(--muted);
  font: 600 0.62rem "Roboto Mono", monospace;
  text-transform: uppercase;
}

.meters strong {
  display: block;
  margin-top: 2px;
  font-size: 1.04rem;
  line-height: 1;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.actions button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.audio-controls button {
  min-width: 74px;
  padding: 0 12px;
}

.audio-controls button.is-muted {
  border-color: rgba(255, 85, 104, 0.78);
  color: #071018;
  background: linear-gradient(135deg, var(--red), var(--amber));
  box-shadow: 0 0 18px rgba(255, 85, 104, 0.34);
}

.audio-controls label {
  color: var(--muted);
  font: 600 0.62rem "Roboto Mono", monospace;
  text-transform: uppercase;
}

.audio-controls input[type="range"] {
  width: 112px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.stage-wrap {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #07090f;
  touch-action: none;
}

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

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100% - 28px));
  transform: translate(-50%, -50%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.5);
}

.panel.hidden { display: none; }

.start-panel {
  display: grid;
  gap: 14px;
  text-align: left;
}

.start-panel h2,
.upgrade-panel h2 {
  font-size: clamp(1.8rem, 6vw, 3.4rem);
  line-height: 0.94;
}

.start-panel p:not(.eyebrow) {
  max-width: 44ch;
  color: var(--muted);
  line-height: 1.45;
}

.start-panel button {
  justify-self: start;
  min-width: 140px;
}

.upgrade-panel {
  display: grid;
  gap: 16px;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.upgrade-card {
  min-height: 148px;
  padding: 14px;
  color: var(--text);
  text-align: left;
  text-transform: none;
  background: rgba(255, 255, 255, 0.07);
}

.upgrade-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--lime);
  font-size: 1rem;
}

.upgrade-card span {
  display: block;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.35;
}

.help {
  display: flex;
  justify-content: center;
  gap: 18px;
  min-height: 28px;
  color: var(--muted);
  font: 600 0.72rem "Roboto Mono", monospace;
  text-transform: uppercase;
}

.touch { display: none; }

@media (max-width: 900px) {
  .shell {
    gap: 6px;
    padding: 6px;
  }

  .hud {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
    min-height: 0;
    padding: 8px;
  }

  h1 {
    font-size: 1.05rem;
  }

  .meters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .meters div {
    min-width: 0;
    padding: 6px;
  }

  .meters strong {
    font-size: 0.9rem;
  }

  .actions {
    justify-content: flex-start;
    gap: 6px;
  }

  .actions > button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.7rem;
  }

  .audio-controls {
    min-height: 34px;
    padding: 0 6px;
    gap: 6px;
  }

  .audio-controls button {
    min-width: 66px;
    min-height: 30px;
    padding: 0 8px;
    font-size: 0.68rem;
  }

  .audio-controls input[type="range"] {
    width: min(32vw, 112px);
  }

  .help {
    display: none;
  }

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

  .panel {
    max-height: calc(100% - 24px);
    overflow: auto;
    padding: 18px;
  }
}

@media (pointer: coarse) {
  .touch { display: grid; }

  .touch-move {
    position: absolute;
    left: 14px;
    bottom: 14px;
    width: 168px;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    gap: 4px;
    z-index: 5;
    touch-action: none;
  }

  .touch-move button {
    padding: 0;
    color: var(--text);
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(12px);
    touch-action: none;
    user-select: none;
  }

  .touch-move button[data-move="up"] { grid-column: 2; grid-row: 1; }
  .touch-move button[data-move="left"] { grid-column: 1; grid-row: 2; }
  .touch-move button[data-move="down"] { grid-column: 2; grid-row: 3; }
  .touch-move button[data-move="right"] { grid-column: 3; grid-row: 2; }

  .dash-touch {
    display: block;
    position: absolute;
    right: 18px;
    bottom: 22px;
    width: 86px;
    height: 86px;
    padding: 0;
    border-radius: 50%;
    z-index: 5;
    touch-action: none;
    user-select: none;
  }
}

@media (max-width: 520px) {
  .kicker {
    display: none;
  }

  .meters span {
    font-size: 0.52rem;
  }

  .audio-controls label {
    display: none;
  }

  .touch-move {
    left: 10px;
    bottom: 10px;
    width: 138px;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 3px;
  }

  .dash-touch {
    right: 12px;
    bottom: 14px;
    width: 72px;
    height: 72px;
  }
}
