:root {
  --panel: #2b2b2b;
  --border: #6b6b6b;
  --accent: #7bc74d;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #8fd0ff;
  font-family: 'VT323', monospace;
  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%;
  transform: translate(-50%, -50%);
  color: #fff; font-size: 28px; font-family: monospace;
  text-shadow: 0 0 2px #000, 1px 1px 0 #000;
  pointer-events: none; z-index: 5; line-height: 1;
}

/* HUD info */
#hud-info {
  position: fixed; top: 10px; left: 12px; z-index: 6;
  display: flex; flex-direction: column; gap: 2px;
  color: #fff; font-size: 22px;
  text-shadow: 1px 1px 0 #000, 2px 2px 0 rgba(0,0,0,0.4);
  pointer-events: none;
}
#fps { opacity: 0.7; font-size: 18px; }

/* Toast */
#toast {
  position: fixed; top: 18%; left: 50%; transform: translate(-50%, -20px);
  background: rgba(20,20,20,0.88); color: #fff;
  padding: 12px 22px; border: 3px solid var(--accent);
  font-size: 26px; z-index: 20; border-radius: 4px;
  opacity: 0; pointer-events: none; transition: all .35s ease;
  text-shadow: 1px 1px 0 #000; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Hotbar */
#hotbar {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 8; padding: 6px;
  background: rgba(0,0,0,0.35); border-radius: 6px;
}
.slot {
  width: 62px; position: relative; cursor: pointer;
  background: rgba(30,30,30,0.75);
  border: 3px solid #555;
  border-radius: 3px; padding: 6px 4px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: transform .1s, border-color .1s;
}
.slot:hover { transform: translateY(-3px); }
.slot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.4), 0 0 14px rgba(255,255,255,0.3);
  transform: translateY(-4px);
}
.slot .key {
  position: absolute; top: 1px; left: 4px;
  font-size: 16px; color: #ffe37b; text-shadow: 1px 1px 0 #000;
}
.slot .cube {
  width: 34px; height: 34px; margin-top: 8px;
  border: 2px solid rgba(0,0,0,0.4);
  border-radius: 2px;
  box-shadow: inset -4px -6px 0 rgba(0,0,0,0.25), inset 4px 4px 0 rgba(255,255,255,0.18);
}
.slot .label {
  font-size: 13px; color: #ddd; text-align: center; line-height: 1;
  text-shadow: 1px 1px 0 #000;
}

/* Overlay */
#overlay {
  position: fixed; inset: 0; z-index: 30;
  display: none; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(60,120,180,0.55), rgba(0,0,0,0.82));
  backdrop-filter: blur(3px);
}
#overlay.show { display: flex; }
.panel {
  background: linear-gradient(180deg, #3a3a3a, #262626);
  border: 5px solid #111;
  box-shadow: 0 0 0 3px #6b6b6b, 0 20px 50px rgba(0,0,0,0.6);
  padding: 28px 34px; max-width: 560px; width: 92%;
  text-align: center; border-radius: 6px;
}
.panel h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 30px; color: var(--accent); letter-spacing: 1px;
  text-shadow: 3px 3px 0 #1a4d0f, 4px 4px 0 rgba(0,0,0,0.4);
  margin-bottom: 6px;
}
.panel h1 span { color: #d9b25a; text-shadow: 3px 3px 0 #5c4310; }
.quip {
  color: #cfa; font-size: 20px; margin: 4px 0 18px;
  font-style: italic; opacity: 0.9;
}
.controls-list { display: flex; gap: 20px; justify-content: center; margin-bottom: 20px; }
.ctrl-col h3 { color: #ffe37b; font-size: 22px; margin-bottom: 6px; text-shadow: 1px 1px 0 #000; }
.ctrl-col ul { list-style: none; text-align: left; }
.ctrl-col li { color: #ddd; font-size: 19px; line-height: 1.4; }
.ctrl-col b { color: #7bc74d; }

#play-btn, #reset-btn {
  font-family: 'Press Start 2P', monospace;
  cursor: pointer; border: 3px solid #111;
  padding: 14px 22px; margin: 6px; font-size: 15px;
  border-radius: 4px; color: #fff; transition: transform .1s, filter .1s;
}
#play-btn { background: linear-gradient(180deg, #7bc74d, #4f9a2c); box-shadow: 0 4px 0 #2f6018; }
#reset-btn { background: linear-gradient(180deg, #b04a3a, #7a3226); box-shadow: 0 4px 0 #4d1f16; font-size: 12px; }
#play-btn:hover, #reset-btn:hover { filter: brightness(1.1); }
#play-btn:active, #reset-btn:active { transform: translateY(3px); box-shadow: none; }

.remix {
  display: block; margin-top: 16px; color: #9fd2ff;
  font-size: 20px; text-decoration: none;
}
.remix:hover { color: #fff; text-decoration: underline; }

/* Mobile controls */
#mobile-controls { display: none; }
#joystick {
  position: fixed; left: 20px; bottom: 90px; z-index: 9;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 3px solid rgba(255,255,255,0.4);
  touch-action: none;
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%; background: rgba(255,255,255,0.55);
  border: 2px solid #fff;
}
#mobile-buttons {
  position: fixed; right: 16px; bottom: 90px; z-index: 9;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.mbtn {
  font-family: 'VT323', monospace; font-size: 20px;
  width: 82px; height: 60px; border-radius: 8px;
  border: 3px solid #111; color: #fff; cursor: pointer;
  background: rgba(60,60,60,0.85); text-shadow: 1px 1px 0 #000;
}
.mbtn.place { background: rgba(70,150,60,0.9); }
.mbtn.break { background: rgba(170,70,55,0.9); }
.mbtn:active { filter: brightness(1.3); }

/* show/hide by platform via body class set in JS not needed;
   use media-ish: default show desktop instructions */
.mobile-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .desktop-only { display: none; }
  .mobile-only { display: block; }
  #hotbar { bottom: 8px; }
  .slot { width: 54px; }
  .slot .cube { width: 28px; height: 28px; }
  .slot .label { font-size: 11px; }
}