:root {
  --bg: #111827;
  --panel: rgba(17, 24, 39, 0.82);
  --panel-strong: rgba(30, 41, 59, 0.92);
  --line: rgba(226, 232, 240, 0.18);
  --text: #f8fafc;
  --muted: #b6c2d2;
  --cyan: #22d3ee;
  --amber: #f59e0b;
  --rose: #fb7185;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.16), transparent 38%),
    linear-gradient(225deg, rgba(245, 158, 11, 0.14), transparent 34%),
    linear-gradient(180deg, #132033 0%, #101827 52%, #111827 100%);
}

.shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3.3vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 620px;
}

button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  min-height: 40px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

#restartBtn {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  padding: 10px 15px;
  white-space: nowrap;
}

.hud {
  margin: 12px 0;
  display: grid;
  grid-template-columns: 1.25fr repeat(3, 1fr);
  gap: 8px;
}

.chip {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.chip span {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.chip strong {
  color: #fff;
  font-size: 1.05rem;
}

.hp-chip {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.hp-chip > span,
.hp-chip > strong { line-height: 1; }

.hp-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.86);
  border-radius: 6px;
  overflow: hidden;
}

.hp-bar-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rose), var(--amber), #22c55e);
  transition: width 0.2s ease-out;
}

.stage-shell {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #07111f;
  box-shadow: 0 22px 60px rgba(2, 6, 23, 0.35);
}

#game-stage,
#game-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.controls {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr minmax(96px, auto) minmax(170px, auto);
  gap: 10px;
  align-items: end;
}

.controls label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.controls input[type='range'] {
  width: 100%;
  accent-color: var(--amber);
}

#shootBtn {
  background: linear-gradient(135deg, #f97316, #dc2626);
  padding: 10px 16px;
}

#rewardBtn {
  background: linear-gradient(135deg, #14b8a6, #2563eb);
  padding: 10px 16px;
}

#rewardBtn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.reward-note,
.tip {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.tip { text-align: center; }

@media (max-width: 760px) {
  .shell { padding: 10px; }
  .topbar { align-items: center; }
  .topbar p { font-size: 0.85rem; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls { grid-template-columns: 1fr 1fr; }
  #shootBtn,
  #rewardBtn { width: 100%; }
}

@media (max-width: 480px) {
  .topbar { display: grid; }
  .controls { grid-template-columns: 1fr; }
}
