:root {
  color-scheme: dark;
  --ink: #080812;
  --night: #161126;
  --violet: #6a4aa3;
  --rose: #d2517d;
  --mist: #f1ecff;
  --silver: #a9a1bd;
  --gold: #f0c56a;
  --panel: #12101f;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(135deg, #080812 0%, #1b1430 55%, #090911 100%);
  background-size: 18px 18px, auto;
  color: var(--mist);
  font-family: "Courier New", Courier, monospace;
}

.game-shell {
  width: min(1240px, 96vw);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  border: 4px solid #33264f;
  border-radius: 0;
  background: #0a0910;
  box-shadow: 0 0 0 4px #080812, 0 22px 0 rgba(0, 0, 0, 0.28);
}

.stage-wrap:fullscreen {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  border: 0;
  background: #05050b;
}

.stage-wrap:fullscreen canvas {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
}

canvas {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: none;
}

.hud {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  right: 210px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.hud > div,
.panel {
  border: 3px solid #3a2b5b;
  border-radius: 0;
  background: rgba(18, 16, 31, 0.9);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.03);
}

.hud > div {
  min-width: 96px;
  padding: 9px 12px;
}

.label {
  display: block;
  color: var(--silver);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hud strong {
  color: #f1ecff;
  font-size: 1rem;
}

.top-actions {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.top-actions button {
  min-height: 30px;
  padding: 0 7px;
  border-width: 2px;
  font-size: 0.68rem;
  box-shadow: 3px 3px 0 #080812;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  background:
    linear-gradient(rgba(5, 5, 9, 0.8), rgba(5, 5, 9, 0.8)),
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(255, 255, 255, 0.04) 7px 8px);
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  color: #f5efff;
  font-size: clamp(2.1rem, 7vw, 4.8rem);
  font-weight: 700;
  text-shadow: 4px 4px 0 #4b2f71, 8px 8px 0 #07070c;
}

.overlay p {
  max-width: 560px;
  margin: 0;
  color: var(--mist);
  font-size: 1rem;
  line-height: 1.55;
}

button {
  min-height: 44px;
  padding: 0 22px;
  border: 3px solid #f0c56a;
  border-radius: 0;
  background: #8a3f7d;
  color: #fff8ee;
  font: 700 0.92rem "Courier New", Courier, monospace;
  cursor: pointer;
  box-shadow: 4px 4px 0 #080812;
}

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

.level-select-label {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
}

select {
  min-width: 180px;
  min-height: 38px;
  border: 3px solid #f0c56a;
  border-radius: 0;
  background: #171521;
  color: #fff8ee;
  font: 700 0.9rem "Courier New", Courier, monospace;
  text-align: center;
}

.panel {
  padding: 18px;
  min-height: 540px;
}

.panel h2 {
  margin: 0 0 14px;
  color: #f3edf9;
  font-size: 1.25rem;
}

.panel p {
  margin: 12px 0;
  line-height: 1.45;
  color: #ddd6ef;
  font-size: 0.92rem;
}

.mission {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 3px solid #2a213e;
}

.mission h3 {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 1rem;
}

kbd {
  display: inline-grid;
  min-width: 30px;
  min-height: 26px;
  place-items: center;
  padding: 2px 7px;
  border: 2px solid rgba(200, 195, 215, 0.35);
  border-radius: 0;
  background: #171521;
  color: #fff;
  font: 700 0.78rem "Courier New", Courier, monospace;
}

@media (max-width: 860px) {
  body {
    align-items: start;
    padding: 12px 0;
  }

  .game-shell {
    grid-template-columns: 1fr;
  }

  .hud {
    position: static;
    padding: 8px;
    background: #08080e;
    flex-wrap: wrap;
  }

  .hud > div {
    min-width: 0;
    flex: 1;
  }

  .top-actions {
    top: 82px;
  }

  .panel {
    min-height: 0;
  }
}
