* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #1b1f2a; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

#app { position: fixed; inset: 0; touch-action: none; }
#scene { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

#boot-screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #2a3350, #1b1f2a);
  color: #f4f1e8; z-index: 50; transition: opacity 0.4s ease;
}
#boot-screen.hidden { opacity: 0; pointer-events: none; }
#boot-title { font-size: 2.4rem; font-weight: 800; letter-spacing: 0.02em; margin-bottom: 0.6rem; }
#boot-status { font-size: 1rem; opacity: 0.75; }
#boot-bar { width: 240px; height: 8px; border-radius: 4px; background: rgba(255,255,255,0.15); margin-top: 1rem; overflow: hidden; }
#boot-bar-fill { height: 100%; width: 0%; background: #5fa83d; transition: width 0.15s ease; }

#hud { position: absolute; inset: 0; pointer-events: none; }
#hud * { pointer-events: auto; }

/* Small reference dot only — taps act wherever your finger lands, not just
   center-screen, so this is no longer load-bearing for aiming. */
#crosshair {
  position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: 50%; background: rgba(255,255,255,0.6); box-shadow: 0 0 3px rgba(0,0,0,0.5);
  pointer-events: none;
}

#look-zone { position: absolute; inset: 0; }

#joystick-zone {
  position: absolute; left: 18px; bottom: 18px; width: 150px; height: 150px;
}
#joystick-base {
  position: absolute; inset: 0; border-radius: 50%; background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.25);
}
#joystick-nub {
  position: absolute; width: 60px; height: 60px; left: 45px; top: 45px; border-radius: 50%;
  background: rgba(255,255,255,0.55); border: 2px solid rgba(255,255,255,0.8);
}

.action-btn {
  position: absolute; width: 74px; height: 74px; border-radius: 50%;
  background: rgba(20,22,30,0.55); border: 2px solid rgba(255,255,255,0.35);
  color: #fff; font-size: 1.6rem; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.action-btn:active, .action-btn.active { background: rgba(95,168,61,0.65); border-color: #cdeab0; }

#btn-jump { right: 30px; bottom: 30px; width: 64px; height: 64px; font-size: 1.4rem; }
#btn-flydown { right: 104px; bottom: 30px; width: 64px; height: 64px; font-size: 1.4rem; opacity: 0.9; }

/* Tool toggle: pick Mine, Build, Paint, or Feed, then tap directly on a
   block (or animal, for Feed) in the world — no separate press-and-hold
   action button needed. 2x2 grid keeps it compact with 4 tools. */
#tool-toggle {
  position: absolute; right: 18px; bottom: 108px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.tool-btn {
  padding: 9px 12px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.35);
  background: rgba(20,22,30,0.55); color: #fff; font-weight: 700; font-size: 0.78rem;
  display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.tool-btn.active { background: rgba(95,168,61,0.7); border-color: #cdeab0; }

#top-bar {
  position: absolute; top: 12px; left: 18px; right: 18px; display: flex; align-items: center; justify-content: space-between;
  color: #fff; font-size: 0.85rem;
}
#mode-btn {
  padding: 8px 16px; border-radius: 20px; border: 2px solid rgba(255,255,255,0.4);
  background: rgba(20,22,30,0.55); color: #fff; font-weight: 700; font-size: 0.9rem;
}
#mode-btn.explore { background: rgba(47,111,184,0.5); }

#top-right { display: flex; align-items: center; gap: 8px; }
#gem-counter {
  padding: 8px 12px; border-radius: 20px; border: 2px solid rgba(127,227,224,0.5);
  background: rgba(20,22,30,0.55); color: #7fe3e0; font-weight: 800; font-size: 0.9rem;
  display: flex; align-items: center; gap: 4px;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35);
  background: rgba(20,22,30,0.55); color: #fff; font-size: 1rem; display: flex; align-items: center; justify-content: center;
}
.icon-btn.active { background: rgba(95,168,61,0.7); border-color: #cdeab0; }

#save-indicator {
  position: absolute; top: 54px; right: 18px; opacity: 0.55; font-size: 0.7rem; color: #fff;
}

/* Current-block chip: small and always visible, tap to open the full
   picker. Replaces a permanently-open scrolling strip. */
#current-block-btn {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%);
  width: 64px; height: 64px; border-radius: 14px; border: 3px solid rgba(255,255,255,0.55);
  background-color: rgba(20,22,30,0.55); background-size: cover; background-position: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
#current-block-label { display: none; }

.hidden { display: none !important; }

#toast {
  position: absolute; top: 90px; left: 50%; transform: translateX(-50%) translateY(-10px);
  max-width: min(86vw, 420px); padding: 12px 18px; border-radius: 14px;
  background: rgba(20,22,30,0.9); border: 2px solid rgba(245,201,90,0.6);
  color: #fff; font-weight: 700; font-size: 0.9rem; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease; z-index: 30;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

#picker-backdrop, #menu-backdrop {
  position: absolute; inset: 0; background: rgba(10,12,18,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 40;
}
#picker-panel, #menu-panel {
  width: min(92vw, 480px); max-height: 78vh; background: #232838; border-radius: 18px;
  border: 2px solid rgba(255,255,255,0.15); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
#picker-header {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  color: #fff; font-weight: 800; font-size: 1.05rem; border-bottom: 1px solid rgba(255,255,255,0.1);
}
#picker-close, #menu-close {
  width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255,255,255,0.12);
  color: #fff; font-size: 1rem;
}

#menu-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.menu-section-title { color: #fff; font-weight: 800; font-size: 0.9rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.04em; }
.slot-row {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.06);
  border-radius: 12px; padding: 6px; border: 2px solid transparent;
}
.slot-row.active { border-color: #cdeab0; background: rgba(95,168,61,0.18); }
.slot-btn {
  flex: 1; text-align: left; padding: 10px 12px; border-radius: 8px; border: none;
  background: transparent; color: #fff; font-weight: 700; font-size: 0.9rem;
}
.slot-btn:disabled { opacity: 0.85; }
.slot-icon-btn {
  width: 38px; height: 38px; border-radius: 8px; border: none; background: rgba(255,255,255,0.1);
  color: #fff; font-size: 1rem;
}
.menu-hint { color: #fff; opacity: 0.5; font-size: 0.75rem; margin-top: 4px; }
#picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px;
  padding: 16px; overflow-y: auto;
  /* #app sets touch-action:none globally (the 3D view needs raw touch
     events for look/mine/build) — without this override, that also blocks
     native touch scrolling here, which is what made the picker feel
     broken/oversensitive rather than just scrolling normally. */
  touch-action: pan-y;
}
/* Custom scrollbar so overflow is visible cross-platform (relying on the
   OS/WebView's native scrollbar chrome is what broke on the tablet). */
#picker-grid::-webkit-scrollbar { width: 8px; }
#picker-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 4px; }

.picker-slot {
  aspect-ratio: 1; border-radius: 10px; border: 2px solid rgba(255,255,255,0.25);
  background-size: cover; background-position: center; position: relative;
}
.picker-slot.selected { border-color: #f5c95a; box-shadow: 0 0 10px rgba(245,201,90,0.8); }
.picker-slot.locked { filter: grayscale(0.7) brightness(0.55); border-color: rgba(127,227,224,0.4); }
.lock-badge {
  position: absolute; inset: auto 0 0 0; text-align: center; padding: 3px 0;
  background: rgba(10,12,18,0.85); color: #7fe3e0; font-size: 0.68rem; font-weight: 800;
  border-radius: 0 0 8px 8px;
}
