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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #87b9e6;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}

#glcanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

/* ---------- Crosshair ---------- */
#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 20;
  opacity: 0.85;
}
#crosshair::before, #crosshair::after {
  content: "";
  position: absolute;
  background: #fff;
  box-shadow: 0 0 2px rgba(0,0,0,0.8);
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
#crosshair::after  { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }

/* ---------- HUD / Hotbar ---------- */
#hud {
  position: fixed;
  left: 0; right: 0; bottom: 18px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}
#hotbar {
  display: flex;
  gap: 4px;
  padding: 5px;
  background: rgba(0,0,0,0.35);
  border: 2px solid rgba(0,0,0,0.45);
  border-radius: 6px;
}
.slot {
  position: relative;
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.slot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5), inset 0 0 12px rgba(255,255,255,0.15);
  transform: scale(1.06);
}
.slot .swatch {
  width: 38px;
  height: 38px;
  border-radius: 3px;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.slot .key {
  position: absolute;
  top: 1px;
  left: 4px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 1px #000;
}
.slot .name {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
  opacity: 0;
  transition: opacity 0.15s;
}
.slot.active .name { opacity: 1; }

/* ---------- Debug ---------- */
#debug {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  color: #eaffea;
  text-shadow: 0 1px 2px #000, 0 0 2px #000;
  pointer-events: none;
  white-space: pre;
}

/* ---------- Inventory ---------- */
.hidden { display: none !important; }
#inventory {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.inv-panel {
  width: min(520px, 92vw);
  background: rgba(28,28,34,0.96);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  padding: 22px 24px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.inv-panel h2 { font-size: 22px; margin-bottom: 6px; }
.inv-sub { font-size: 13px; opacity: 0.75; margin-bottom: 16px; }
#inv-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.inv-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 6px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
}
.inv-item:hover { background: rgba(255,255,255,0.12); transform: translateY(-2px); }
.inv-item.selected { border-color: #ffd34d; background: rgba(255,211,77,0.12); }
.inv-item .swatch {
  width: 46px;
  height: 46px;
  border-radius: 5px;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.inv-item span { font-size: 12px; opacity: 0.9; }

/* ---------- Overlay / Splash ---------- */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #4a7cb5, #20354d);
}
.overlay-card {
  text-align: center;
  padding: 36px 44px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px;
  max-width: 440px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.overlay-card h1 {
  font-size: 46px;
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-shadow: 0 3px 0 rgba(0,0,0,0.4);
}
.overlay-card .tag { opacity: 0.8; margin-bottom: 22px; }
#playBtn {
  font-size: 18px;
  font-weight: 700;
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  background: #5fbf4e;
  color: #082b06;
  cursor: pointer;
  box-shadow: 0 5px 0 #3c8a2f;
  transition: transform 0.08s, box-shadow 0.08s;
}
#playBtn:hover { background: #6cd25a; }
#playBtn:active { transform: translateY(4px); box-shadow: 0 1px 0 #3c8a2f; }
.controls {
  list-style: none;
  text-align: left;
  margin: 24px auto 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 22px;
  font-size: 13px;
  opacity: 0.9;
  max-width: 360px;
}
.controls b { color: #ffd34d; }
.hint { margin-top: 16px; font-size: 12px; opacity: 0.65; }
.overlay-card.paused h1::after {
  content: " — Paused";
  font-size: 20px;
  opacity: 0.7;
  letter-spacing: 0;
}
