:root {
  --bg: #08131f;
  --bg-deep: #050b12;
  --panel: rgba(8, 20, 29, 0.88);
  --panel-edge: rgba(153, 216, 255, 0.18);
  --text: #ebf8ff;
  --muted: #92b8c9;
  --accent: #75f2d1;
  --lava: #ff7756;
  --gold: #ffdb7a;
  --vine: #7fd569;
  --brick: #9b6b53;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(48, 115, 163, 0.25), transparent 32%),
    radial-gradient(circle at bottom right, rgba(117, 242, 209, 0.16), transparent 22%),
    linear-gradient(180deg, #0e2436 0%, var(--bg) 48%, var(--bg-deep) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
}

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  min-height: 100vh;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.intro {
  padding: 24px;
}

.eyebrow,
.label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
}

.summary {
  margin: 18px 0 24px;
  line-height: 1.7;
  color: #d7f2ff;
}

.mode-select,
.actions {
  display: grid;
  gap: 12px;
}

.mode-select {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
}

button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

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

.mode,
.secondary {
  padding: 14px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.mode.is-active {
  background: linear-gradient(180deg, rgba(117, 242, 209, 0.28), rgba(70, 146, 132, 0.32));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    0 0 0 1px rgba(117, 242, 209, 0.28);
}

.primary {
  padding: 16px 18px;
  color: #06262a;
  font-weight: 700;
  background: linear-gradient(180deg, #9fffe6, var(--accent));
}

.secondary {
  margin-top: 4px;
}

.legend {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #d8ebf3;
}

.chip {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.chip.floor { background: #27506d; }
.chip.brick { background: #9b6b53; }
.chip.spike { background: #d7dee3; }
.chip.vine { background: #7fd569; }
.chip.turret { background: #c45a76; }
.chip.exit { background: #ffd867; }

.stage-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 4px 8px 18px;
}

.hud strong {
  display: block;
  font-size: 1.1rem;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(117, 242, 209, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.hint-button {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.18);
  opacity: 0.26;
}

.hint-button:hover,
.hint-button.is-active {
  opacity: 0.68;
  background: rgba(117, 242, 209, 0.45);
}

canvas {
  display: block;
  width: min(100%, 864px);
  height: auto;
  border-radius: 16px;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 12px;
  padding: 24px;
  background: linear-gradient(180deg, rgba(2, 6, 14, 0.12), rgba(2, 6, 14, 0.58));
}

.overlay.is-hidden {
  display: none;
}

.overlay h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.overlay p {
  max-width: 460px;
  margin: 0;
  color: #d8edf6;
  line-height: 1.6;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .mode-select,
  .hud {
    grid-template-columns: 1fr;
  }

  .hint-button {
    right: 10px;
    bottom: 10px;
  }
}
