:root {
  color-scheme: only light;
  --bg: #1b1b2a;
  --panel: #2d2d44;
  --accent: #f7d95c;
  --text: #f1f1f1;
  --shadow: #0d0d16;
}

* {
  box-sizing: border-box;
  font-family: "Trebuchet MS", system-ui, sans-serif;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #32325b, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.header {
  text-align: center;
  margin-bottom: 12px;
}

.header h1 {
  margin: 8px 0 4px;
  font-size: clamp(1.6rem, 2.5vw, 2.4rem);
}

.subtitle {
  margin: 0;
  color: #cfd0ff;
}

.game-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.hud {
  position: sticky;
  top: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, auto) 1fr;
  align-items: center;
  gap: 12px 18px;
  width: min(92vw, 640px);
  background: rgba(32, 32, 55, 0.85);
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: 0 10px 0 var(--shadow);
  backdrop-filter: blur(6px);
  font-weight: 600;
}

.hud-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.canvas-wrap {
  position: relative;
  width: min(90vw, 520px);
  aspect-ratio: 3 / 4;
  background: #222;
  border: 4px solid #3c3c5f;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 0 #11111c;
}

canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
  background: #5dbb63;
}

.controls {
  position: sticky;
  bottom: 12px;
  display: flex;
  gap: 16px;
  z-index: 4;
}

.btn {
  border: none;
  padding: 10px 18px;
  background: var(--accent);
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #ae9032;
  transition: transform 0.1s ease;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #ae9032;
}

.btn.ghost {
  background: #3a3a63;
  color: #f0f0ff;
  min-width: 72px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 16, 32, 0.75);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.panel {
  background: var(--panel);
  padding: 20px 24px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 0 var(--shadow);
}

.instructions {
  max-width: 520px;
  background: #272744;
  border-radius: 14px;
  padding: 16px;
  box-shadow: inset 0 0 0 2px #33335a;
}

.instructions h3 {
  margin-top: 0;
}

.instructions ul {
  padding-left: 18px;
  margin: 8px 0 0;
  color: #d8d8ff;
}

@media (max-width: 600px) {
  .hud {
    grid-template-columns: repeat(2, auto);
    justify-content: center;
  }

  .controls {
    width: 100%;
    justify-content: space-evenly;
  }
}

@media (max-width: 480px) {
  .hud {
    gap: 8px 14px;
    font-size: 0.95rem;
  }

  .controls {
    position: fixed;
    bottom: 16px;
  }

  .canvas-wrap {
    width: min(92vw, 420px);
  }
}
