* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #050811;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  font-family: "Silkscreen", monospace;
  color: #eef5ff;
}
body {
  display: grid;
  place-items: center;
}
#wrap {
  position: relative;
  container-type: size;
  width: min(100vw, calc(100vh * 1.6));
  height: min(100vh, calc(100vw / 1.6));
  aspect-ratio: 16 / 10;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(130, 195, 255, 0.18);
  background: #050811;
  overflow: hidden;
}
#game {
  width: 100%;
  height: 100%;
  image-rendering: auto;
  cursor: crosshair;
  touch-action: none;
  display: block;
}

/* Crisp retro-pixel Title & Debrief Overlays over live voxel flyover (scales cleanly to any container size!) */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(6, 12, 26, 0.54) 0%, rgba(4, 7, 15, 0.84) 100%);
  z-index: 20;
  padding: clamp(8px, 3cqh, 24px);
  text-align: center;
  overflow-y: auto;
}
.overlay.hidden { display: none; }

.badge {
  display: inline-block;
  font-size: clamp(8px, 1.5cqh, 11px);
  letter-spacing: 0.14em;
  color: #ffe066;
  background: rgba(14, 22, 40, 0.90);
  border: 1px solid rgba(255, 224, 102, 0.45);
  padding: clamp(3px, 0.8cqh, 6px) clamp(8px, 1.4cqw, 14px);
  border-radius: 4px;
  margin-bottom: clamp(6px, 1.8cqh, 14px);
}
.title {
  margin: 0;
  font-size: clamp(20px, 6.8cqh, 56px);
  line-height: 0.98;
  letter-spacing: -0.01em;
  color: #ffffff;
  text-shadow: 0 4px 0 #7a121b, 0 0 28px rgba(255, 76, 66, 0.45);
}
.title span { color: #ff4e44; }
.sub {
  margin: clamp(6px, 1.8cqh, 14px) 0 clamp(8px, 2.2cqh, 18px);
  max-width: min(86cqw, 640px);
  font-size: clamp(8px, 1.65cqh, 13px);
  line-height: 1.55;
  color: #e4f0ff;
  background: rgba(6, 11, 24, 0.78);
  border: 1px solid rgba(150, 200, 255, 0.18);
  border-radius: 6px;
  padding: clamp(6px, 1.2cqh, 10px) clamp(10px, 1.8cqw, 18px);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85);
}

.panel {
  background: rgba(9, 15, 28, 0.88);
  border: 1px solid rgba(155, 205, 255, 0.25);
  border-radius: 8px;
  padding: clamp(8px, 2cqh, 16px) clamp(10px, 2cqw, 22px);
  margin-bottom: clamp(8px, 2.4cqh, 20px);
  max-width: min(90cqw, 680px);
  width: 100%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(5px, 1.2cqh, 10px) clamp(8px, 1.4cqw, 14px);
  text-align: left;
  font-size: clamp(7.5px, 1.45cqh, 11px);
  line-height: 1.42;
  color: #b5cae6;
}
.controls-grid b {
  display: block;
  color: #ffe066;
  font-size: clamp(7.5px, 1.45cqh, 11px);
  margin-bottom: 2px;
}

.btn-row {
  display: flex;
  gap: clamp(8px, 1.4cqw, 14px);
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  font-family: "Silkscreen", monospace;
  font-size: clamp(9px, 1.8cqh, 14px);
  letter-spacing: 0.06em;
  padding: clamp(7px, 1.6cqh, 13px) clamp(14px, 2.2cqw, 24px);
  border-radius: 6px;
  border: 2px solid #ffd866;
  background: linear-gradient(180deg, #e63636 0%, #a81c24 100%);
  color: #fffdf5;
  cursor: pointer;
  box-shadow: 0 4px 0 #560d14, 0 10px 26px rgba(0, 0, 0, 0.55);
  transition: transform 0.1s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(2px); }
.btn.sec {
  background: rgba(14, 24, 44, 0.92);
  border-color: rgba(140, 205, 255, 0.45);
  color: #d8ebff;
  box-shadow: 0 4px 0 #091020;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(6px, 1.2cqw, 12px);
  margin-top: clamp(4px, 1cqh, 8px);
}
.st-box {
  background: rgba(5, 10, 20, 0.85);
  border: 1px solid rgba(140, 195, 255, 0.22);
  border-radius: 6px;
  padding: clamp(6px, 1.4cqh, 12px) 6px;
}
.st-v { font-size: clamp(13px, 2.8cqh, 22px); color: #ffe066; }
.st-k { font-size: clamp(7px, 1.3cqh, 10px); color: #90a8c8; margin-top: 3px; }
.rank-pill {
  font-size: clamp(18px, 4.6cqh, 36px);
  color: #68ff96;
  text-shadow: 0 0 24px rgba(104, 255, 150, 0.55);
  margin: clamp(2px, 0.8cqh, 6px) 0 clamp(4px, 1.2cqh, 8px);
}

.vbtn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 15;
  font: 12px "Silkscreen", monospace;
  color: #f6fbff;
  background: rgba(12, 20, 36, 0.88);
  border: 1px solid rgba(255, 212, 110, 0.45);
  border-radius: 6px;
  padding: 8px 13px;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .vbtn { display: none; }
}
