/* ============================================================
   Minecraft JS — UI styling (Minecraft-flavored chrome)
   ============================================================ */

:root {
  --pixel-font: 'VT323', 'Courier New', monospace;
  --logo-font: 'Press Start 2P', 'VT323', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--pixel-font);
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* Pixel curtain that masks the 3D world (the menu BACKGROUND) while it streams
   in, then dissolves block by block to reveal it (see ui.js _initTitleCurtain).
   Sits BELOW the menu (z 10 < title-screen z 20) so the options are visible and
   clickable from the start. No background: cleared cells must be transparent. */
#title-curtain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  image-rendering: pixelated;
}

/* ======================= overlays ======================= */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

/* Sleep modal: brief rest overlay (survival). Reuses .overlay + .modal-card. */
#sleep-modal { background: rgba(8, 10, 22, 0.72); backdrop-filter: blur(2px); }
.sleep-card { text-align: center; max-width: 320px; }
.sleep-icon { font-size: 44px; line-height: 1; }
.sleep-title { margin: 10px 0 14px; font-size: 20px; color: #e8ecff; }
.sleep-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.sleep-fill { width: 0; height: 100%; background: #6f8cff; border-radius: 4px; }

#pause-menu, #options-menu, #controls-menu {
  background: rgba(16, 16, 16, 0.62);
  backdrop-filter: blur(1px);
  z-index: 30; /* cover #touch (z-index 25) so on-screen controls don't float over the menu */
}

#title-screen { background: transparent; pointer-events: auto; }

/* ======================= MC buttons ======================= */

.mc-button {
  font-family: var(--pixel-font);
  font-size: 22px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  background: linear-gradient(#828282, #6a6a6a 45%, #5a5a5a);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.45), inset -2px -2px 0 rgba(0,0,0,0.45);
  padding: 8px 18px;
  min-width: 300px;
  cursor: pointer;
  image-rendering: pixelated;
}
.mc-button:hover {
  background: linear-gradient(#8f9ad1, #707bb4 45%, #5e69a3);
  border-color: #fff;
}
.mc-button:active { transform: translateY(1px); }
.mc-button.small { min-width: 0; font-size: 18px; padding: 6px 12px; }
.mc-button.toggle { min-width: 230px; }

/* ======================= title screen ======================= */

.title-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.mc-logo {
  font-family: var(--logo-font);
  font-size: clamp(38px, 8vw, 84px);
  color: #d8d8d8;
  letter-spacing: 4px;
  text-shadow:
    3px 3px 0 #3a3a3a,
    6px 6px 0 rgba(0,0,0,0.55);
  -webkit-text-stroke: 2px #1f1f1f;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.3));
}

.mc-sublogo {
  font-family: var(--pixel-font);
  font-size: 24px;
  color: #ffce3d;
  text-shadow: 2px 2px 0 #3e2e00;
  margin-top: -10px;
  letter-spacing: 6px;
}

.mode-badge {
  font-family: var(--pixel-font);
  font-size: 20px;
  color: #dbeafe;
  background: rgba(18, 20, 34, 0.78);
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.24), inset -1px -1px 0 rgba(0,0,0,0.52);
  padding: 3px 12px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.7);
}

.creator-mode .mode-badge {
  color: #ffe08a;
}

.splash {
  display: none;
}
@keyframes splash-pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.08; }
}

.menu-buttons {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(300px, 92vw);
}

.menu-buttons > .mc-button {
  width: 100%;
  min-width: 0;
}

/* ---- Title entrance: items rise in (staggered) + the subtitle types out,
   so the brief world-stream "pop" + layer-load wait hide behind motion. Items
   start hidden via the `.intro` base rule (FOUC-free, in <head>); ui.js adds
   `.mk-in` with a per-item animation-delay to reveal them. ---- */
@keyframes mk-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes mk-caret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.title-stack.intro > .mc-logo,
.title-stack.intro > .mc-sublogo,
.title-stack.intro > .mode-badge,
.title-stack.intro > .menu-buttons > #btn-play,
.title-stack.intro > .menu-buttons > #btn-creator-mode,
.title-stack.intro > .menu-buttons > #btn-title-profile,
.title-stack.intro > .menu-buttons > #btn-title-controls,
.title-stack.intro > .title-footer { opacity: 0; }
.title-stack .mk-in { animation: mk-rise 0.5s ease-out both; }
.mc-sublogo.is-typing::after {
  content: '▌'; margin-left: 2px; color: #ffce3d; -webkit-text-stroke: 0;
  animation: mk-caret 0.7s steps(1, end) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .title-stack.intro > *,
  .title-stack.intro > .menu-buttons > * { opacity: 1 !important; }
  .title-stack .mk-in { animation: none !important; }
}

.seed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  width: 100%;
}

.seed-row .mc-button.small {
  width: 100%;
  font-size: 14px;
  padding: 6px 8px;
  white-space: nowrap;
}

#seed-input {
  font-family: var(--pixel-font);
  font-size: 14px;
  width: 100%;
  min-width: 0;
  background: #000;
  color: #e0e0e0;
  border: 2px solid #a0a0a0;
  padding: 6px 8px;
  outline: none;
}
#seed-input:focus { border-color: #fff; }

.mode-creator #top-hud,
.mode-creator #cubito-hud,
.mode-creator #interact-prompt,
.mode-creator #btn-title-profile {
  display: none !important;
}

.mode-player #creator-tools { display: none !important; }

#creator-tools {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 40;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 8px;
  background: rgba(12, 17, 23, 0.94);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  color: #e5edf6;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.35;
  text-shadow: none;
  pointer-events: auto;
}

.creator-head,
.creator-section-head,
.creator-actions,
.creator-rule-row,
.creator-load {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

/* Rotation buttons read as their own group, not crammed under the build row. */
.creator-rotate-row {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid #1e293b;
}

.creator-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.creator-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.creator-collapse-btn {
  min-width: 34px;
  padding: 6px 8px;
  font-size: 14px;
  line-height: 1;
}

/* Collapsed: shrink to just the header so the panel stops covering the build view. */
#creator-tools.collapsed {
  width: auto;
  padding: 8px 10px;
}

#creator-tools.collapsed .creator-head {
  margin-bottom: 0;
}

#creator-tools.collapsed .creator-section,
#creator-tools.collapsed .creator-tabs,
#creator-tools.collapsed #creator-export-status,
#creator-tools.collapsed #creator-rebuild-prefabs {
  display: none;
}

/* Tabbed sections — Prefabs / Reglas / Mundo. Segmented control under the head. */
.creator-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  padding: 4px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
}

.creator-tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #8ea0b8;
  padding: 6px 8px;
  font: 700 12px/1.1 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.creator-tab:hover {
  color: #cbd5e1;
  background: rgba(38, 54, 76, 0.6);
}

.creator-tab.selected {
  border-color: #0284c7;
  background: #0369a1;
  color: #f8fafc;
}

.creator-tab:focus-visible {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}

/* The tab bar already separates the first section, so drop its top divider. */
.creator-tab-panel > .creator-section:first-child {
  border-top: none;
  padding-top: 4px;
}

.creator-kicker {
  color: #8ea0b8;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.creator-title {
  color: #f8fafc;
  font-size: 18px;
  font-weight: 720;
  line-height: 1.1;
}

.creator-section {
  padding: 10px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.creator-section-title {
  margin-bottom: 8px;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
}

.creator-section-head {
  justify-content: space-between;
}

.creator-fields {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.creator-fields.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.creator-fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.creator-field {
  display: grid;
  min-width: 0;
  gap: 4px;
  color: #8ea0b8;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
}

#creator-tools input,
#creator-tools select {
  min-width: 0;
  min-height: 32px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
  color: #e5edf6;
  padding: 6px 8px;
  font: 500 13px/1.2 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  outline: none;
}

#creator-tools input:focus,
#creator-tools select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}

#creator-tools input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: #38bdf8;
}

/* Labels carrying a definition get a help cursor + dotted underline hint. */
.creator-field span[title],
.creator-toggle span[title] {
  cursor: help;
  text-decoration: underline dotted rgba(148, 163, 184, 0.55);
  text-underline-offset: 3px;
}

.creator-hint {
  color: #6b7c93;
  font-weight: 600;
  text-transform: none;
}

#creator-tools select.creator-multiselect {
  height: auto;
  min-height: 0;
  padding: 4px;
}

.creator-multiselect option {
  padding: 4px 6px;
  border-radius: 4px;
  text-transform: none;
  font-weight: 600;
}

.creator-multiselect option:checked {
  /* The gradient is the cross-browser way to force a selected-option color. */
  background: #0369a1 linear-gradient(#0369a1, #0369a1);
  color: #f8fafc;
}

.creator-load {
  align-items: stretch;
}

.creator-load select,
.creator-rule-row select { flex: 1 1 auto; }

.creator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.creator-adjust {
  display: grid;
  gap: 6px;
}

/* One row per corner: the A/B label, then its six ± nudges in a single line. */
.creator-adjust-row {
  display: grid;
  grid-template-columns: 34px repeat(6, 1fr);
  gap: 6px;
}

.creator-adjust-row .nudge {
  padding: 6px 2px;
  text-align: center;
}

.creator-btn {
  min-width: 0;
  min-height: 32px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #1e293b;
  color: #e5edf6;
  padding: 6px 10px;
  font: 700 12px/1.1 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  white-space: nowrap;
}

.creator-btn:hover {
  border-color: #64748b;
  background: #26364c;
}

.creator-btn.primary {
  border-color: #0284c7;
  background: #0369a1;
  color: #f8fafc;
}

.creator-btn.ghost {
  background: transparent;
  color: #bfdbfe;
}

.creator-btn.danger {
  border-color: #7f1d1d;
  background: #3f1518;
  color: #fecaca;
}

.creator-btn.selected {
  border-color: #22c55e;
  background: #14532d;
  color: #dcfce7;
}

.creator-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 8px;
  color: #dbeafe;
  font-size: 13px;
  font-weight: 650;
}

.creator-info,
.creator-status {
  margin-top: 8px;
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.creator-status {
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  color: #86efac;
}

.creator-status.err { color: #fca5a5; }

@media (max-width: 560px) {
  .menu-buttons { width: min(300px, 92vw); }
  .mc-button { min-width: 100%; }
  .seed-row { grid-template-columns: 1fr; }
  #seed-input { width: 100%; }
  .title-footer { font-size: 15px; gap: 12px; }
  #creator-tools { font-size: 13px; }
  .creator-head,
  .creator-load,
  .creator-rule-row,
  .creator-actions { align-items: stretch; flex-direction: column; }
  .creator-fields.two,
  .creator-fields.three { grid-template-columns: 1fr; }
  .creator-grid { grid-template-columns: 1fr; }
}

.title-footer {
  display: none;
}

/* ======================= menus ======================= */

.menu-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.menu-stack.wide { width: min(560px, 92vw); }

.menu-title {
  font-size: 30px;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  margin-bottom: 12px;
}

.opt-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #e8e8e8;
  font-size: 20px;
  text-shadow: 1px 1px 0 #303030;
}
.opt-row input[type="range"] {
  width: 100%;
  accent-color: #7fbf4f;
  cursor: pointer;
}
.opt-row select {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 2px solid #555;
  background: #1b1b24;
  color: #fff;
  font: inherit;
  text-shadow: none;
  cursor: pointer;
}
.opt-row select:focus {
  outline: none;
  border-color: #fff;
}
.opt-row.checks {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 8px 0;
}

.controls-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 28px;
  color: #e8e8e8;
  font-size: 20px;
  text-shadow: 1px 1px 0 #303030;
  background: rgba(0,0,0,0.35);
  border: 2px solid #555;
  padding: 14px 20px;
}
.controls-grid span:nth-child(odd) { color: #a8d08f; }

/* ---- Tabbed controls help (Mouse+keyboard / Gamepad / Touch) ---- */
.controls-tabs {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-bottom: 4px;
}
.controls-tab {
  flex: 1 1 0;
  min-width: 0;
  font-family: var(--pixel-font);
  font-size: 18px;
  letter-spacing: 1px;
  color: #d8d8d8;
  text-shadow: 2px 2px 0 #3f3f3f;
  background: linear-gradient(#4a4a4a, #3c3c3c);
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.18), inset -1px -1px 0 rgba(0,0,0,0.5);
  padding: 8px 6px;
  cursor: pointer;
  image-rendering: pixelated;
}
.controls-tab:hover { background: linear-gradient(#565656, #484848); color: #fff; }
.controls-tab.selected {
  color: #fff;
  background: linear-gradient(#7fbf4f, #5fa23a);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.4), inset -2px -2px 0 rgba(0,0,0,0.4);
}
.controls-tab:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
/* The touch tab only makes sense on coarse-pointer devices. */
.controls-tab-touch { display: none; }
@media (pointer: coarse) { .controls-tab-touch { display: block; } }

/* Each tab panel is a .controls-grid; full-width rows (label left, keys right),
   capped height so the tallest (keyboard) scrolls instead of pushing Done off. */
#controls-menu .controls-grid {
  width: 100%;
  grid-template-columns: 1fr auto;
  max-height: min(62vh, 560px);
  overflow-y: auto;
}

/* ======================= developer console ======================= */

#dev-console {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 12px;
  background: rgba(4, 6, 10, 0.88);
  border-bottom: 2px solid rgba(138, 170, 255, 0.65);
  color: #d9e6ff;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.35;
  text-shadow: none;
  z-index: 100;
  pointer-events: auto;
}

#dev-console-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  white-space: pre-wrap;
}

.dev-console-line.cmd { color: #9fd0ff; }
.dev-console-line.err { color: #ff8f8f; }

#dev-console-row {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid rgba(217, 230, 255, 0.2);
  padding-top: 6px;
}

#dev-console-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: #ffffff;
  font: inherit;
}

/* ======================= loading ======================= */

#loading-screen { background: #2c2156; background: linear-gradient(#1c1633, #3a2d6b); }

.loading-stack { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.loading-text { color: #fff; font-size: 28px; text-shadow: 2px 2px 0 #1a1a1a; }
.loading-bar {
  width: min(420px, 80vw);
  display: flex;
  gap: 3px;
  border: 2px solid #fff;
  background: #000;
  padding: 3px;
  box-sizing: border-box;
}
/* One square per block; lit one-by-one as progress advances. Hue per cell echoes
   the title curtain's cyan -> magenta sweep (see _buildLoadingCells / _paintTitleCurtain). */
.loading-cell {
  flex: 1 1 0;
  aspect-ratio: 1 / 1;
  background: hsl(var(--hue), 30%, 14%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  transition: background 0.18s ease, box-shadow 0.18s ease;
  image-rendering: pixelated;
}
.loading-cell.on {
  background: hsl(var(--hue), 72%, 56%);
  box-shadow: inset 0 0 0 1px hsla(var(--hue), 80%, 78%, 0.6),
              0 0 6px hsla(var(--hue), 85%, 60%, 0.7);
}
@media (prefers-reduced-motion: reduce) {
  .loading-cell { transition: none; }
}
.loading-tip { color: #b9b9d8; font-size: 20px; }

/* ======================= HUD ======================= */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: #ddd;
}
#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%); }

/* --------- hotbar --------- */

#hotbar {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  background: rgba(12, 12, 12, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.8);
  outline: 2px solid rgba(255, 255, 255, 0.25);
}

.hotbar-slot {
  width: 54px;
  height: 54px;
  border: 2px solid rgba(255,255,255,0.18);
  border-right-width: 1px;
  border-left-width: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.hotbar-slot img { width: 44px; height: 44px; image-rendering: auto; }
.hotbar-slot .slot-num {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  text-shadow: 1px 1px 0 #000;
}
.hotbar-slot .slot-count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000;
  pointer-events: none;
}
.hotbar-slot.selected {
  border: 3px solid #fff;
  outline: 2px solid #999;
  z-index: 2;
}

#item-name {
  position: absolute;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 24px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.7);
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* --------- debug (F3) --------- */

#debug {
  position: absolute;
  top: 6px;
  left: 6px;
  color: #fff;
  font-size: 17px;
  line-height: 1.25;
  text-shadow: 1px 1px 0 #000;
  background: rgba(16,16,16,0.35);
  padding: 6px 10px;
  white-space: pre;
}

/* --------- water / effects --------- */

#underwater-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 60, 160, 0.28);
  opacity: 0;
  transition: opacity 0.2s;
}

#damage-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 120px rgba(255, 40, 20, 0.85);
  opacity: 0;
  transition: opacity 0.1s;
}

/* ======================= picker ======================= */

/* above #touch (z-index 25) so the on-screen controls don't float over the
   inventory on touch devices */
#picker { background: rgba(16, 16, 16, 0.55); pointer-events: auto; z-index: 30; }

.picker-window {
  background: #c6c6c6;
  border: 3px solid #000;
  box-shadow:
    inset 3px 3px 0 #ffffff,
    inset -3px -3px 0 #555555,
    0 10px 30px rgba(0,0,0,0.5);
  padding: 14px 16px;
  max-width: min(640px, 94vw);
}

.picker-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.picker-title {
  font-size: 22px;
  color: #3f3f3f;
  flex: 1; min-width: 0;
}
.picker-hint { font-size: 16px; color: #6e6e6e; }
.picker-close {
  flex: none; width: 36px; height: 36px; padding: 0; font-size: 18px; line-height: 1;
  color: #3f3f3f; background: #c6c6c6; border: 2px solid #000; cursor: pointer;
  box-shadow: inset 2px 2px 0 #ffffff, inset -2px -2px 0 #555555;
  -webkit-tap-highlight-color: transparent;
}
.picker-close:active { box-shadow: inset 2px 2px 0 #555555, inset -2px -2px 0 #ffffff; }
.picker-close:focus { outline: 3px solid #f2c94c; outline-offset: 2px; }

#picker-grid {
  display: grid;
  grid-template-columns: repeat(9, 52px);
  gap: 4px;
  max-height: 52vh;
  overflow-y: auto;
  /* Extra top padding so the FIRST row's tooltip (it sits above the cell at
     bottom:105%) fits inside the scroll area — otherwise overflow-y:auto clips
     it. Same grey as the cells, so the gap reads as a margin, not a hole. */
  padding: 30px 6px 6px;
  background: #8b8b8b;
  border: 2px solid #373737;
  box-shadow: inset 2px 2px 0 #313131, inset -2px -2px 0 #ffffff;
}

.picker-cell {
  width: 52px;
  height: 52px;
  background: #8b8b8b;
  border: 1px solid #6f6f6f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.picker-cell:hover { background: #a8a8c0; }
.picker-cell img { width: 42px; height: 42px; }
.picker-cell.empty { background: #777; cursor: default; }
.picker-cell.inventory-slot { cursor: pointer; }
.picker-cell.inventory-slot.empty:hover { background: #777; }
.picker-cell .slot-count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000;
  pointer-events: none;
}
.picker-book {
  background: #7d6f96;
  box-shadow: inset 0 0 0 2px #d9c879;
}
.picker-book .book-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(1px 1px 0 #373737);
}

.picker-empty {
  grid-column: 1 / -1;
  min-height: 52px;
  display: grid;
  place-items: center;
  color: #e4e4e4;
  font-size: 18px;
  text-shadow: 1px 1px 0 #373737;
}

/* read-only collection view (player mode) */
.picker-cell.readonly { cursor: default; }
.picker-cell.have { background: #7a8c6a; box-shadow: inset 0 0 0 2px #c9e29b; }
.picker-cell.locked { cursor: default; }
.picker-cell.locked img { filter: grayscale(1) brightness(0.55); opacity: 0.5; }
.picker-cell .cell-count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000;
  pointer-events: none;
}
.picker-cell .cell-lock {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 13px;
  pointer-events: none;
}

.picker-hotbar {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 4px;
}
.picker-hotbar .hotbar-slot {
  background: #8b8b8b;
  border: 2px solid #373737;
  cursor: pointer;
}
.picker-hotbar .hotbar-slot.selected { border-color: #fff; background: #a8a8c0; }

/* tooltip */
.picker-cell::after {
  content: attr(data-name);
  position: absolute;
  bottom: 105%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 0, 32, 0.92);
  border: 1px solid #4a2a7a;
  color: #fff;
  font-size: 17px;
  padding: 2px 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.picker-cell:hover::after { opacity: 1; }

/* scrollbars */
#picker-grid::-webkit-scrollbar { width: 12px; }
#picker-grid::-webkit-scrollbar-track { background: #6f6f6f; }
#picker-grid::-webkit-scrollbar-thumb { background: #c6c6c6; border: 2px solid #373737; }
