:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  --bg: #0a0b12;
  --panel: rgba(15, 19, 32, 0.9);
  --accent: #29f3a6;
  --accent-2: #4a89ff;
  --danger: #ff6b6b;
  --warning: #ffb74d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #1b2140, #0a0b12 60%);
  color: #f4f5ff;
  min-height: 100vh;
}

.game-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(5, 8, 20, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.game-header h1 {
  margin: 0;
  font-size: 1.3rem;
}

.tagline {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
}

.back {
  color: #9fb4ff;
  text-decoration: none;
  font-weight: 600;
}

.game-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
}

.viewport-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #05060c;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.viewport {
  width: 100%;
  height: 100%;
}

.viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  bottom: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  align-items: start;
  gap: 10px;
  pointer-events: none;
}

.hud-card {
  background: rgba(10, 14, 30, 0.75);
  border-radius: 10px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud .label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.6);
}

.hud .value {
  font-size: 1rem;
  font-weight: 700;
}

.hud-progress {
  grid-column: span 3;
  background: rgba(10, 14, 30, 0.75);
  border-radius: 10px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-progress .bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-top: 6px;
}

.hud-progress .bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.hud-progress.boss .bar span {
  background: linear-gradient(90deg, var(--danger), var(--warning));
}

.hidden {
  display: none !important;
}

.hud-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(10, 14, 30, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 6px 10px;
  color: #fff;
  cursor: pointer;
  z-index: 2;
}

.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel ul {
  margin: 0;
  padding-left: 20px;
  color: rgba(255, 255, 255, 0.8);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 12, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  width: min(90vw, 360px);
  background: var(--panel);
  border-radius: 18px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.overlay-card h2,
.overlay-card h3 {
  margin: 0;
}

.overlay-card button {
  border: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.overlay-card button.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0a0b12;
}

.toggle,
.slider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
  border-radius: 12px;
}

.seed {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

@media (min-width: 900px) {
  .game-shell {
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    align-items: start;
  }

  .viewport-wrapper {
    aspect-ratio: 9 / 16;
  }
}
