* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0b0710;
  color: #f6e9d2;
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Stage matches the visible (letterboxed) canvas exactly, so corner-pinned
   HUD controls like the pause button track the canvas on any screen size. */
#stage {
  position: relative;
  width: min(100vw, 177.78vh);   /* keep 16:9 */
  height: min(56.25vw, 100vh);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  background: #120a18;
  box-shadow: 0 0 60px rgba(255, 150, 40, 0.18);
  border-radius: 6px;
  touch-action: none;
}

/* On-screen pause button (touch devices have no Esc key) */
#pause-btn {
  position: absolute;
  top: 3%;
  right: 2.4%;
  width: 6.4%;
  min-width: 40px;
  max-width: 54px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18%;
  padding: 0;
  border: 2px solid rgba(255, 215, 106, 0.7);
  border-radius: 50%;
  background: rgba(18, 10, 22, 0.55);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s, border-color .12s, transform .08s;
}
#pause-btn::before,
#pause-btn::after {
  content: "";
  width: 14%;
  height: 42%;
  background: #ffd76a;
  border-radius: 2px;
}
#pause-btn:hover { border-color: #ffd76a; background: rgba(40, 18, 50, 0.72); }
#pause-btn:active { transform: scale(0.92); }

/* Overlays sit centered over the canvas — and above the in-canvas pause button */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding: 24px;
  background: radial-gradient(ellipse at center, rgba(40, 18, 50, 0.78), rgba(8, 4, 12, 0.94));
  backdrop-filter: blur(2px);
}

.overlay.hidden { display: none; }
.hidden { display: none !important; }

h1 {
  font-size: clamp(26px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: 1px;
  color: #ffd76a;
  text-shadow: 0 3px 0 #7a2f8a, 0 0 24px rgba(255, 170, 60, 0.5);
}

h1 .big {
  font-size: clamp(34px, 7vw, 76px);
  color: #ff8fc4;
  text-shadow: 0 4px 0 #5a1f6a, 0 0 30px rgba(255, 120, 190, 0.6);
}

.tag {
  font-size: clamp(14px, 2.2vw, 20px);
  color: #f3d9b8;
  max-width: 600px;
  font-style: italic;
}

.level-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.lvl {
  font: inherit;
  font-size: 18px;
  font-weight: bold;
  padding: 12px 22px;
  border-radius: 12px;
  border: 2px solid #6b3a7a;
  background: #241030;
  color: #f6e9d2;
  cursor: pointer;
  transition: transform .08s, border-color .12s, background .12s;
}
.lvl small { display: block; font-weight: normal; color: #b69bd0; font-size: 12px; }
.lvl:hover { transform: translateY(-2px); border-color: #c98bff; }
.lvl.selected {
  background: #4a1f5e;
  border-color: #5ad7ff;
  box-shadow: 0 0 18px rgba(90, 215, 255, 0.4);
}
.lvl.locked {
  opacity: 0.55;
  cursor: not-allowed;
  border-style: dashed;
}
.lvl.locked:hover { transform: none; border-color: #6b3a7a; }
.lvl .lock { font-size: 14px; }

.diff-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.diff {
  font: inherit;
  font-size: 18px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 2px solid #6b3a7a;
  background: #241030;
  color: #f6e9d2;
  cursor: pointer;
  transition: transform .08s, border-color .12s, background .12s;
}
.diff small { color: #b69bd0; font-size: 12px; }
.diff:hover { transform: translateY(-2px); border-color: #c98bff; }
.diff.selected {
  background: #4a1f5e;
  border-color: #ffd76a;
  box-shadow: 0 0 18px rgba(255, 200, 90, 0.4);
}

.primary {
  font: inherit;
  font-weight: bold;
  font-size: 26px;
  letter-spacing: 2px;
  padding: 14px 46px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: #2a0c14;
  background: linear-gradient(180deg, #ffd76a, #ff9d3c);
  box-shadow: 0 6px 0 #b85c12, 0 0 30px rgba(255, 160, 60, 0.5);
  transition: transform .08s, box-shadow .08s;
}
.primary:hover { transform: translateY(-2px); }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #b85c12; }

.btn-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center; }

.secondary {
  font: inherit;
  font-weight: bold;
  font-size: 18px;
  letter-spacing: 1px;
  padding: 13px 28px;
  border-radius: 12px;
  cursor: pointer;
  color: #f6e9d2;
  background: #2a1238;
  border: 2px solid #8a5aa6;
  box-shadow: 0 4px 0 #3a1b4a;
  transition: transform .08s, box-shadow .08s, border-color .12s;
}
.secondary:hover { transform: translateY(-2px); border-color: #ffd76a; }
.secondary:active { transform: translateY(3px); box-shadow: 0 1px 0 #3a1b4a; }

.controls {
  font-size: 14px;
  color: #cdb8e6;
  max-width: 560px;
  line-height: 1.6;
}
.controls b { color: #ffd76a; }

.stats { font-size: 18px; color: #ffd76a; }
