:root {
  color-scheme: dark;
  --bg: #0d0f15;
  --panel: #171923;
  --panel-2: #202330;
  --line: #2b3040;
  --text: #f7f3e8;
  --muted: #aab0c3;
  --cyan: #72e7d5;
  --rose: #ff6f9f;
  --gold: #f7c85f;
  --green: #7bf29c;
  --danger: #ff5c61;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(114, 231, 213, 0.05), transparent 34%),
    linear-gradient(135deg, rgba(247, 200, 95, 0.025), transparent 44%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--cyan);
  color: #101217;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  padding: 0 18px;
}

.primary-button {
  background: linear-gradient(135deg, var(--gold), var(--cyan));
  box-shadow: 0 10px 30px rgba(114, 231, 213, 0.2);
  min-width: 180px;
}

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

button:focus-visible {
  outline: 3px solid rgba(247, 200, 95, 0.7);
  outline-offset: 3px;
}

.game-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 18px;
}

.game-panel {
  background: rgba(23, 25, 35, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.38);
  max-width: 1180px;
  padding: 16px;
  width: min(100%, 1180px);
}

.topbar,
.bottombar {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 12px;
}

.brand-block {
  min-width: 240px;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: center;
}

.sound-toggle {
  background: rgba(35, 38, 51, 0.96);
  border: 1px solid rgba(114, 231, 213, 0.42);
  color: var(--cyan);
  min-width: 118px;
  padding: 0 14px;
}

.sound-toggle[aria-pressed="false"] {
  border-color: rgba(170, 176, 195, 0.32);
  color: var(--muted);
}

.bottombar {
  margin-top: 12px;
}

.eyebrow {
  color: var(--cyan);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.35rem, 3vw, 2.15rem);
  line-height: 1;
  margin-bottom: 6px;
}

h2 {
  font-size: clamp(1.35rem, 4vw, 2.35rem);
  line-height: 1.05;
  margin-bottom: 12px;
}

.tagline {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  margin: 0;
}

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

.hud-item {
  background: linear-gradient(180deg, rgba(35, 38, 51, 0.96), rgba(25, 27, 36, 0.96));
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 92px;
  padding: 10px 12px;
}

.hud-item span,
.meter-label span {
  color: var(--muted);
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
}

.hud-item strong {
  display: block;
  font-size: 1.24rem;
  line-height: 1.1;
}

.arena-wrap {
  aspect-ratio: 16 / 9;
  background: #0b0e14;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

canvas {
  display: block;
  height: 100%;
  image-rendering: auto;
  width: 100%;
}

.overlay {
  align-items: center;
  background: rgba(7, 8, 12, 0.62);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: absolute;
}

.hidden {
  display: none;
}

.dialog {
  background: rgba(25, 27, 36, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 460px;
  padding: clamp(18px, 4vw, 28px);
  text-align: center;
}

.start-dialog,
.result-dialog {
  max-width: 560px;
}

.dialog.wide {
  max-width: 720px;
  width: min(100%, 720px);
}

.dialog-copy,
.hint {
  color: var(--muted);
  line-height: 1.5;
}

.hint {
  font-size: 0.86rem;
  margin: 14px 0 0;
}

.hero-copy {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 18px;
}

.start-help {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  text-align: left;
}

.start-help p {
  align-items: start;
  background: rgba(35, 38, 51, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 86px 1fr;
  line-height: 1.35;
  margin: 0;
  padding: 10px 12px;
}

.start-help strong,
.control-help strong {
  color: var(--gold);
}

.start-help span {
  color: var(--text);
  font-weight: 700;
}

.control-help {
  background: rgba(35, 38, 51, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
  padding: 10px;
}

.control-help span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.control-help b {
  color: var(--text);
  font-size: 1rem;
}

.control-help strong {
  display: block;
  font-size: 0.75rem;
}

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

.upgrade-card {
  background:
    linear-gradient(180deg, rgba(247, 200, 95, 0.07), transparent 46%),
    var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 148px;
  padding: 16px;
  text-align: left;
}

.upgrade-card:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(114, 231, 213, 0.32), 0 14px 28px rgba(0, 0, 0, 0.24);
}

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

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

.final-stats {
  display: grid;
  gap: 8px;
  margin: 16px 0 20px;
  text-align: left;
}

.final-stats p {
  align-items: center;
  background: rgba(35, 38, 51, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 10px 12px;
}

.final-stats span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.final-stats strong {
  color: var(--text);
  font-size: 1.05rem;
}

.meter {
  flex: 1;
  min-width: 0;
}

.meter-label {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.meter-label strong {
  font-size: 0.82rem;
}

.meter-track {
  background: #0e1016;
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  transition: width 140ms ease;
  width: 0%;
}

.meter-fill.hp {
  background: linear-gradient(90deg, var(--danger), var(--rose));
}

.meter-fill.xp {
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

@media (max-width: 780px) {
  .game-shell {
    align-items: start;
    padding: 10px;
  }

  .game-panel {
    padding: 10px;
  }

  .topbar,
  .bottombar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .sound-toggle {
    width: 100%;
  }

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

  .start-help p {
    grid-template-columns: 1fr;
  }

  .control-help {
    grid-template-columns: 1fr;
  }

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