* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #8ec7ff; }
body { font-family: 'VT323', monospace; user-select: none; -webkit-user-select: none; touch-action: none; }

#scene-container { position: fixed; inset: 0; }
#scene-container canvas { display: block; }

/* Crosshair */
#crosshair {
  position: fixed; left: 50%; top: 50%;
  width: 22px; height: 22px; transform: translate(-50%,-50%);
  pointer-events: none; z-index: 5;
}
#crosshair::before, #crosshair::after {
  content: ''; position: absolute; background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
}
#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%); }

/* Status HUD */
#hud {
  position: fixed; top: 10px; left: 12px; z-index: 6;
  color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
}
#status {
  font-size: 22px; letter-spacing: 1px;
  background: rgba(0,0,0,0.35); padding: 4px 10px; border-radius: 6px;
}

/* Hotbar */
#hotbar {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 6;
}
.slot {
  position: relative; width: 52px; height: 52px;
  background: rgba(0,0,0,0.5); border: 3px solid rgba(255,255,255,0.25);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .08s, border-color .08s;
}
.slot.active { border-color: #fff; transform: scale(1.12); }
.slot .sw {
  width: 34px; height: 34px; border-radius: 4px;
  border-top: 6px solid; filter: brightness(0.92);
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.25);
  image-rendering: pixelated;
}
.slot .num {
  position: absolute; bottom: -2px; right: 3px;
  color: #fff; font-size: 16px; text-shadow: 1px 1px 0 #000;
}

/* Overlay */
#overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(60,120,180,0.65), rgba(10,20,35,0.9));
  backdrop-filter: blur(3px);
}
#overlay.hidden, .hidden { display: none !important; }

.panel {
  text-align: center; color: #e8f4ff;
  background: rgba(15,25,40,0.85);
  border: 4px solid #2e4a66; border-radius: 12px;
  padding: 28px 26px; max-width: 420px; width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.panel h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 26px; color: #7ee06a; letter-spacing: 2px;
  text-shadow: 3px 3px 0 #1c5216; margin-bottom: 6px;
}
.tag { font-size: 20px; color: #a9c8e0; margin-bottom: 16px; font-style: italic; }
.keys {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px;
  font-size: 20px; text-align: left; margin: 0 auto 18px; max-width: 320px;
}
.keys b { color: #ffd867; }

.panel button {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px; cursor: pointer; display: block;
  width: 100%; margin: 8px 0; padding: 14px;
  border: none; border-radius: 8px;
  background: #4caf50; color: #fff;
  box-shadow: 0 5px 0 #2e7d32; transition: transform .05s;
}
.panel button:active { transform: translateY(3px); box-shadow: 0 2px 0 #2e7d32; }
.panel button.secondary { background: #607d8b; box-shadow: 0 5px 0 #37474f; font-size: 11px; }

.mobilehint { font-size: 18px; color: #ffd867; margin-top: 10px; }
.footer { margin-top: 14px; font-size: 18px; }
.footer a { color: #7ecbff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* Mobile touch controls */
#touch { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
#joystick {
  position: fixed; bottom: 90px; left: 24px;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.3);
  pointer-events: auto; touch-action: none;
}
#stick {
  position: absolute; left: 50%; top: 50%; width: 50px; height: 50px;
  margin: -25px 0 0 -25px; border-radius: 50%;
  background: rgba(255,255,255,0.45);
}
#tbtns {
  position: fixed; bottom: 90px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: auto;
}
#tbtns button {
  font-family: 'Press Start 2P', monospace; font-size: 11px;
  width: 92px; padding: 14px 0; border: none; border-radius: 10px;
  background: rgba(0,0,0,0.55); color: #fff; border: 2px solid rgba(255,255,255,0.3);
}
#btnMine { background: rgba(180,60,60,0.65); }
#btnPlace { background: rgba(60,120,180,0.65); }

@media (max-width: 500px){
  .panel h1 { font-size: 20px; }
  #status { font-size: 18px; }
}