/* Nusa Island Stage 19: Build tab, placement HUD, storage crate panel, performance settings. Loaded after stage18.css. */

/* ---------- Build tab (shares the craft card look) ---------- */
#ui .inv[data-tab="build"] .inv-grid,
#ui .inv[data-tab="build"] .inv-empty,
#ui .inv[data-tab="build"] .inv-actions { display: none !important; }
#ui .inv[data-tab="build"] .craft:not(.build) { display: none; }
#ui .inv:not([data-tab="build"]) .build { display: none; }
#ui .build-foot {
  grid-column: 1 / -1;
  padding: 6px 2px 0;
  font-family: var(--f-label);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
#ui .build-foot.is-full { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
#ui .build-card .craft-desc { display: block; }
@media (max-width: 640px) { #ui .inv-tab { font-size: 24px; padding-left: 8px; padding-right: 8px; } #ui .inv-tab::after { left: 8px; right: 8px; } }
@media (max-height: 500px), (max-width: 900px) {
  html.is-touch #ui .inv[data-tab="build"] .inv-detail { display: none; }
  html.is-touch #ui .inv-tab { font-size: 22px; padding: 0 8px 2px; }
  html.is-touch #ui .inv-tab::after { left: 8px; right: 8px; }
  html.is-touch #ui .inv-tab:first-child::after { left: 0; }
}

/* ---------- Placement HUD ---------- */
#ui .place {
  position: absolute;
  left: 50%;
  bottom: calc(var(--hb-top, 72px) + 16px);
  width: min(400px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none; /* only the buttons take the pointer: look-drag passes through */
}
#ui .place[hidden] { display: none; }
#ui .hud.is-inv .place, #ui .hud.is-examining .place { display: none; }
#ui .place-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 10px;
  border-radius: 3px;
  background: var(--canvas);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--hairline), 0 10px 30px rgba(0, 0, 0, .35);
  pointer-events: none;
}
#ui .place-card::after { content: ''; position: absolute; inset: 4px; border: 1.5px dashed var(--stitch); border-radius: 1px; pointer-events: none; }
#ui .place.is-valid .place-card::after { border-color: var(--signal); }
#ui .place-head { display: flex; align-items: flex-start; gap: 8px; }
#ui .place-info { flex: 1; min-width: 0; padding: 2px 0 0 4px; }
#ui .place-name { font-family: var(--f-display); font-weight: 900; font-size: 24px; line-height: 1; letter-spacing: .03em; text-transform: uppercase; }
#ui .place-cost { margin-top: 4px; font-family: var(--f-label); font-weight: 700; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); line-height: 1.15; }
#ui .place-reason { margin-top: 3px; font-family: var(--f-label); font-weight: 700; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
#ui .place-reason::before { content: '\2715  '; }
#ui .place-row { display: flex; gap: 8px; }
#ui .place-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; min-height: 48px; padding: 0 12px;
  border: 0; border-radius: 3px;
  background: var(--canvas);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--stitch);
  font-family: var(--f-label); font-weight: 700; font-size: 18px; letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative; z-index: 1;
}
#ui .place-btn:hover { background: #CFC4A9; }
#ui .place-btn:active { transform: translateY(1px); }
#ui .place-cancel { min-width: 44px; min-height: 44px; padding: 0; }
#ui .place-go { flex: 1; background: var(--signal); color: var(--signal-ink); box-shadow: none; }
#ui .place-go:hover { background: var(--signal); filter: brightness(1.06); }
#ui .place-go.is-off { background: repeating-linear-gradient(135deg, rgba(23, 20, 15, .07) 0 3px, transparent 3px 7px), var(--canvas); color: var(--ink-soft); box-shadow: inset 0 0 0 1px rgba(23, 20, 15, .3); }
#ui .place-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 0 4px; font-family: var(--f-label); font-weight: 700; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
#ui .place-keys .key { margin-left: 4px; min-width: 20px; height: 20px; font-size: 12px; }
#ui .place-keys .key:first-child { margin-left: 0; }

/* touch: a compact column on the right, left of the Jump / Use buttons and below the top-right system buttons,
   so the ghost in front of the player (screen centre) stays clear */
html.is-touch #ui .place {
  left: auto;
  transform: none;
  right: calc(max(16px, env(safe-area-inset-right, 0px)) + 96px);
  top: calc(max(12px, env(safe-area-inset-top, 0px)) + 54px);
  bottom: auto;
  width: 196px;
}
html.is-touch #ui .place-card { padding: 8px 8px 8px; gap: 6px; }
html.is-touch #ui .place-name { font-size: 20px; }
html.is-touch #ui .place-cost { font-size: 12px; margin-top: 2px; }
html.is-touch #ui .place-reason { font-size: 13px; margin-top: 2px; }
html.is-touch #ui .place-btn { min-height: 48px; min-width: 48px; padding: 0 8px; }
html.is-touch #ui .place-cancel { min-width: 48px; min-height: 48px; }
html.is-touch #ui .place-row { gap: 6px; }

/* ---------- Storage crate (19b): two-sided transfer view ---------- */
#ui .store {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 30;
  width: min(900px, calc(100vw - 24px));
  height: min(640px, calc(var(--vvh, 100vh) - 24px));
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 14px;
}
#ui .store[hidden] { display: none; }
#ui .store.is-in { animation: store-in .3s var(--ease); }
@keyframes store-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 14px)); } to { opacity: 1; transform: translate(-50%, -50%); } }
#ui .store-head { display: flex; align-items: center; gap: 12px; flex: none; }
#ui .store-title { flex: 1; min-width: 0; font-family: var(--f-display); font-weight: 900; font-size: 32px; line-height: 1; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ui .store-tools { display: flex; gap: 8px; flex: none; }
#ui .store-x { flex: none; }
#ui .store-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0 14px;
  border: 0; border-radius: 3px;
  background: var(--canvas); color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--stitch);
  font-family: var(--f-label); font-weight: 700; font-size: 16px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
#ui .store-btn:hover { background: #CFC4A9; }
#ui .store-btn:active { background: #CFC4A9; transform: translateY(1px); }
#ui .store-btn:focus-visible, #ui .store .slot:focus-visible, #ui .store input:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
#ui .store-btn:disabled { color: var(--ink-soft); background: repeating-linear-gradient(135deg, rgba(23, 20, 15, .07) 0 3px, transparent 3px 7px), var(--canvas); box-shadow: inset 0 0 0 1px rgba(23, 20, 15, .25); cursor: not-allowed; transform: none; }
#ui .store-go { background: var(--signal); color: var(--signal-ink); box-shadow: none; }
#ui .store-go:hover { background: var(--signal); filter: brightness(1.06); }
#ui .store-go:disabled { background: repeating-linear-gradient(135deg, rgba(23, 20, 15, .07) 0 3px, transparent 3px 7px), var(--canvas); color: var(--ink-soft); filter: none; }
#ui .store-danger.is-confirm { background: var(--ink); color: var(--signal); box-shadow: none; }

#ui .store-cols { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#ui .store-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; transition: background-color .12s; }
#ui .store-col + .store-col { border-left: 1.5px dashed var(--stitch); padding-left: 14px; }
#ui .store-col.is-drop { background: rgba(255, 91, 31, .14); box-shadow: inset 0 0 0 2px var(--signal); }
#ui .store-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: .06em; text-transform: uppercase; flex: none; }
#ui .store-h i { font-style: normal; font-family: var(--f-label); font-weight: 700; font-size: 15px; letter-spacing: .08em; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
#ui .store-full { margin-left: auto; padding: 3px 8px 2px; border-radius: 2px; background: var(--signal); color: var(--signal-ink); font-family: var(--f-label); font-weight: 800; font-size: 14px; letter-spacing: .1em; }
#ui .store-full[hidden] { display: none; }
#ui .store-meter { flex: none; height: 6px; margin-bottom: 8px; background: var(--canvas-shade); box-shadow: inset 0 0 0 1px var(--hairline); border-radius: 1px; overflow: hidden; }
#ui .store-meter i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .25s var(--ease); }
#ui .store-col.is-full .store-meter i { background: var(--signal); }
#ui .store-col.is-full .store-h i { color: var(--ink); }
#ui .store-grid {
  flex: 1 1 0; min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  grid-auto-rows: 104px;
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  padding: 3px 4px 4px 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink) transparent;
  overscroll-behavior: contain;
}
#ui .store-grid[hidden], #ui .store-empty[hidden] { display: none; }
#ui .store-empty { padding: 24px 6px; font-size: 16px; color: var(--ink-soft); }
#ui .store .slot { min-height: 44px; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; justify-content: center; overflow: hidden; }
#ui .store .slot-img, #ui .store .slot-img img { width: 52px; height: 52px; }
#ui .store .slot-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ui .store .slot.is-selected { background: #CFC4A9; box-shadow: inset 0 0 0 2px var(--ink); transform: none; }
#ui .store .slot.is-selected::after { border-color: var(--signal); }
#ui .store .slot.is-lifted { opacity: .35; transform: scale(.94); }
#ui .store .slot.is-locked .slot-img { opacity: .55; }
#ui .store .slot.is-empty { background: transparent; box-shadow: none; cursor: default; transform: none; }
#ui .store .slot.is-empty::after { inset: 0; border-color: var(--stitch); opacity: .7; border-radius: 3px; }
#ui .store .slot.is-empty > * { display: none; }
#ui .store.is-dragging .store-grid { overflow: hidden; }
#ui .store.is-dragging.is-drag-out { outline: 3px dashed var(--signal); outline-offset: 2px; }

#ui .store-pick {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 8px 10px; border-radius: 3px; background: var(--canvas-shade); box-shadow: inset 0 0 0 1px var(--hairline);
}
#ui .store-pick[hidden] { display: none; }
#ui .pk-id { display: flex; align-items: center; gap: 8px; min-width: 150px; flex: 0 1 auto; }
#ui .pk-img, #ui .pk-img img { width: 40px; height: 40px; display: grid; place-items: center; object-fit: contain; color: var(--ink-soft); flex: none; }
#ui .pk-txt { display: flex; flex-direction: column; min-width: 0; }
#ui .pk-name { font-family: var(--f-display); font-weight: 900; font-size: 20px; line-height: 1; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ui .pk-sub { font-style: normal; margin-top: 2px; font-family: var(--f-label); font-weight: 700; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
#ui .pk-sub.is-warn { color: var(--ink); }
#ui .pk-sub.is-warn::before { content: '\2715  '; color: var(--signal); }
#ui .pk-qty { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; min-width: 0; }
#ui .pk-qty[hidden] { display: none; }
#ui .pk-presets, #ui .pk-step { display: flex; gap: 4px; flex: none; }
#ui .pk-sm { padding: 0 8px; min-width: 44px; }
#ui .pk-sq { font-size: 22px; }
#ui .pk-num {
  width: 60px; min-height: 44px; padding: 0 4px; text-align: center; border: 0; border-radius: 3px;
  background: var(--canvas); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--stitch);
  font-family: var(--f-display); font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
#ui .pk-num::-webkit-outer-spin-button, #ui .pk-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#ui .pk-range { flex: 1 1 80px; min-width: 70px; min-height: 44px; margin: 0; accent-color: var(--signal); touch-action: pan-x; }
#ui .pk-acts { display: flex; gap: 6px; flex: none; margin-left: auto; }
#ui .store-tip { flex: none; font-family: var(--f-label); font-weight: 600; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
#ui .store-tip[hidden] { display: none; }
#ui .store-note {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 5; pointer-events: none; max-width: calc(100% - 24px);
  padding: 7px 14px 6px; border-radius: 3px; background: var(--ink); color: #F1E9D2;
  font-family: var(--f-label); font-weight: 700; font-size: 16px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
#ui .store-note[hidden] { display: none; }

html.is-touch #ui .store-btn, html.is-touch #ui .store .ov-x, html.is-touch #ui .pk-num, html.is-touch #ui .pk-range { min-height: 48px; }
html.is-touch #ui .store-btn, html.is-touch #ui .store .ov-x { min-width: 48px; }

@media (max-height: 500px) {
  #ui .store { width: calc(100vw - 16px); height: calc(var(--vvh, 100vh) - 12px); padding: 6px 10px 6px; gap: 6px; }
  #ui .store-head { gap: 8px; }
  #ui .store-title { font-size: 22px; }
  #ui .store-tools { gap: 6px; }
  #ui .store-btn { padding: 0 10px; font-size: 15px; }
  #ui .store-x span { display: none; }
  #ui .store-cols { gap: 10px; }
  #ui .store-col + .store-col { padding-left: 10px; }
  #ui .store-h { font-size: 17px; margin-bottom: 3px; gap: 8px; }
  #ui .store-h i { font-size: 13px; }
  #ui .store-meter { height: 4px; margin-bottom: 4px; }
  #ui .store-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); grid-auto-rows: 62px; gap: 5px; }
  #ui .store .slot { padding: 3px 3px 6px; gap: 2px; min-height: 48px; }
  #ui .store .slot-img, #ui .store .slot-img img { width: 28px; height: 28px; }
  #ui .store .slot-name { font-size: 11px; }
  #ui .store .slot-qty { font-size: 13px; top: 3px; right: 3px; padding: 1px 4px 0; }
  #ui .store-pick { flex-wrap: nowrap; gap: 6px; padding: 4px 6px; }
  #ui .pk-id { min-width: 0; width: 112px; gap: 6px; }
  #ui .pk-img, #ui .pk-img img { width: 30px; height: 30px; }
  #ui .pk-name { font-size: 15px; }
  #ui .pk-sub { font-size: 11px; letter-spacing: .04em; }
  #ui .pk-qty { gap: 6px; flex: 1 1 0; }
  #ui .pk-sm { min-width: 44px; padding: 0 6px; }
  #ui .pk-num { width: 48px; font-size: 18px; }
  #ui .pk-range { flex: 1 1 40px; min-width: 40px; }
  #ui .pk-acts { gap: 4px; }
  #ui .pk-acts .store-btn { padding: 0 8px; font-size: 14px; }
  #ui .store-tip { display: none; }
  #ui .store-note { bottom: 6px; font-size: 14px; }
}
@media (max-width: 520px) { #ui .store-cols { gap: 8px; } #ui .store-col + .store-col { padding-left: 8px; } }

/* ---------- Performance settings ---------- */
#ui .report-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
#ui .report-btn { width: auto; flex: none; padding: 0 16px; }
#ui .report-msg { font-family: var(--f-label); font-weight: 700; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
#ui .report-text {
  display: block;
  width: 100%;
  margin-top: 8px;
  height: 140px;
  padding: 8px;
  resize: none;
  border: 0;
  border-radius: 3px;
  background: var(--canvas-shade);
  box-shadow: inset 0 0 0 1px var(--stitch);
  color: var(--ink);
  font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  user-select: text;
  -webkit-user-select: text;
  touch-action: pan-y;
}
#ui .report-text[hidden] { display: none; }
#ui .report-btn { touch-action: manipulation; }

@media (prefers-reduced-motion: reduce) { #ui .store.is-in { animation: none !important; } #ui .store-meter i, #ui .store-col, #ui .store .slot { transition: none !important; } }
