:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  --page: #111820;
  --panel: #19222c;
  --surface: #1e2934;
  --line: #2f3c49;
  --text: #f1f3f5;
  --muted: #a1adba;
  --orange: #ffad63;
  --green: #82d7af;
  background: var(--page);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}
svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
h1, h2, h3, p { margin: 0; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
.identity, .session, .player-count, .connection {
  display: flex;
  align-items: center;
}
.identity { gap: 12px; }
.brand-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border-radius: 9px;
  background: var(--orange);
  color: #262019;
}
.brand-icon svg { width: 23px; height: 23px; }
h1 { font-size: 1.125rem; font-weight: 690; letter-spacing: -0.027em; }
.session { gap: 12px; }
.player-count, .connection {
  gap: 8px;
  font-size: 0.875rem;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 11px;
}
.player-count { color: #bdc8d2; }
.player-count svg { width: 16px; height: 16px; }
.connection { font-weight: 650; color: #e6bd86; }
.connection[data-state="online"] { color: var(--green); }
.connection[data-state="offline"] { color: #f49f8b; }
.status-dot, .floor-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  min-height: 480px;
  height: calc(100dvh - 130px);
  padding: 14px 16px 0;
}
.workspace.inventory-closed { grid-template-columns: minmax(0, 1fr); }
.viewport, .inventory {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}
.viewport {
  position: relative;
  isolation: isolate;
  min-width: 0;
  background: #4b5c64;
}
#scene {
  display: block;
  height: 100%;
  width: 100%;
  touch-action: none;
}
.viewport-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #101a2245, transparent 22%, transparent 77%, #10182098),
    radial-gradient(ellipse at center, transparent 44%, #11192338 100%);
}
.floor-label, .icon-button, .tools, .target {
  background: #111a24eb;
  border: 1px solid #53606d;
  box-shadow: 0 4px 20px #0d162332;
}
.floor-label {
  position: absolute;
  top: 17px;
  left: 17px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 37px;
  padding: 0 11px;
  border-radius: 7px;
  color: #e8ebee;
  font-size: 0.875rem;
  font-weight: 570;
}
.floor-dot { background: var(--orange); }
.floor-divider { width: 1px; height: 14px; background: #4b5967; }
#item-count { color: #bac6d0; font-weight: 430; }
.icon-button {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border-radius: 7px;
  color: #d9e2ea;
}
.icon-button:hover { color: var(--orange); border-color: var(--orange); }
.toggle-panel { position: absolute; top: 17px; right: 17px; }

.entry {
  position: absolute;
  left: 50%;
  top: 52%;
  translate: -50% -50%;
  display: grid;
  justify-items: center;
  gap: 9px;
  width: max-content;
  max-width: 90%;
}
.enter-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #ffc691;
  background: var(--orange);
  color: #211b16;
  border-radius: 8px;
  padding: 12px 21px;
  font-size: 1rem;
  font-weight: 730;
  box-shadow: 0 8px 32px #16212bb3;
}
.enter-button:hover { background: #ffc38d; }
.enter-button:disabled { opacity: 0.72; }
#entry-note {
  padding: 5px 9px;
  border-radius: 5px;
  background: #18222bd4;
  color: #edf1f4;
  font-size: 0.82rem;
  text-align: center;
}
.crosshair {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: 17px;
  height: 17px;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px #10202c);
}
.crosshair.active { display: block; }
.crosshair::after, .crosshair::before {
  content: "";
  position: absolute;
  background: white;
  border-radius: 2px;
}
.crosshair::before { width: 2px; height: 15px; left: 7px; top: 1px; }
.crosshair::after { height: 2px; width: 15px; left: 1px; top: 7px; }
.target, .message {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  pointer-events: none;
  border-radius: 7px;
  padding: 7px 10px;
  max-width: 88%;
  width: max-content;
  text-align: center;
  font-size: 0.875rem;
}
.target { bottom: 84px; color: #e3ebf1; }
#target-usage:not(:empty) { display: block; margin-top: 2px; color: var(--green); font-size: 0.8125rem; }
.message { top: 67px; background: #1b3a32; border: 1px solid #659d83; color: #d1f5e2; z-index: 2; }
.message.error { background: #422821; border-color: #ad695a; color: #ffdbce; }

.tools {
  position: absolute;
  display: flex;
  align-items: stretch;
  gap: 3px;
  left: 50%;
  bottom: 17px;
  padding: 5px;
  translate: -50% 0;
  border-radius: 10px;
}
.tool {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
  color: #e4e9ee;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}
.tool:hover { background: #2b3744; }
.tool[aria-pressed="true"] { color: #ffd2a9; background: #463326; border-color: #93613e; }
.tool[aria-pressed="true"] svg { color: var(--orange); }
kbd {
  display: inline-grid;
  place-items: center;
  background: #25313d;
  border: 1px solid #445260;
  border-radius: 4px;
  padding: 2px 5px;
  min-width: 19px;
  color: #dce4ec;
  font: 650 0.75rem/1.2 Inter, "Segoe UI", system-ui, sans-serif;
}
.tool[aria-pressed="true"] kbd { background: #62452f; border-color: #865d3d; color: #ffe5ce; }

.inventory {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 17px 14px 13px;
  background: var(--panel);
}
.inventory-header { display: flex; gap: 10px; align-items: center; }
.inventory-icon {
  display: grid;
  place-items: center;
  border: 1px solid #6b4b33;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  background: #382d25;
  color: var(--orange);
}
.inventory h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.018em; }
.inventory-header p { color: var(--muted); font-size: 0.8125rem; margin-top: 2px; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  margin-top: 17px;
  border: 1px solid #394856;
  border-radius: 6px;
  background: #141d26;
  color: var(--muted);
}
.search:focus-within { border-color: var(--orange); }
.search svg { width: 17px; height: 17px; }
.search input, #import-url {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 8px 0;
  font-size: 0.875rem;
}
.search input:focus { outline: none; }
input::placeholder { color: #a1adba; }
.catalog-heading {
  display: flex;
  justify-content: space-between;
  margin: 16px 1px 8px;
  color: #dfe5eb;
  font-size: 0.875rem;
  font-weight: 650;
}
#product-count { color: var(--muted); font-weight: 450; }
.catalog {
  display: flex;
  flex-direction: column;
  min-height: 72px;
  flex: 1 1 auto;
  gap: 5px;
  overflow: auto;
  scrollbar-color: #566577 transparent;
  scrollbar-width: thin;
}
.product-row {
  display: flex;
  align-items: center;
  min-height: 55px;
  flex: 0 0 auto;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid #2e3b48;
  text-align: left;
}
.product-row:hover { background: #293643; }
.product-row[aria-pressed="true"] { border-color: #ac744e; background: #332b26; }
.product-row:focus-visible { outline-offset: -3px; }
.product-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #253b4e;
  color: #9ec5df;
  flex: none;
}
.product-icon[data-tint="graphite"] { background: #3b434b; color: #c6d5de; }
.product-icon[data-tint="olive"] { background: #3b4435; color: #bccfa6; }
.product-icon[data-tint="sand"] { background: #4e3d32; color: #e5bb94; }
.product-icon svg { width: 18px; height: 18px; }
.product-copy { display: grid; gap: 3px; min-width: 0; flex: 1; }
.product-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; font-weight: 650; }
.product-size { font-size: 0.8125rem; color: #b2bdc8; font-variant-numeric: tabular-nums; }
.product-indicator { animation: none; width: 7px; height: 7px; margin: 0 3px; border-radius: 50%; flex: none; }
.product-row[aria-pressed="true"] .product-indicator { background: var(--orange); }
.empty { padding: 10px 3px; color: var(--muted); font-size: 0.875rem; }

.selection {
  flex: 0 0 auto;
  margin-top: 12px;
  padding: 10px 10px 9px;
  border: 1px solid #394856;
  border-radius: 7px;
  background: #151e28;
}
.selection-header { display: flex; justify-content: space-between; align-items: center; gap: 7px; }
.selection-header p, .dimensions span, .selected-basis { color: var(--muted); font-size: 0.8125rem; }
.selection-header h3 { margin-top: 3px; font-size: 0.9375rem; overflow-wrap: anywhere; }
.source { width: 30px; height: 30px; flex: none; background: #202c38; border-color: #394856; box-shadow: none; }
.source svg { width: 16px; height: 16px; }
.dimensions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 10px 0 8px;
  border: 1px solid #2d3a49;
  border-radius: 5px;
  overflow: hidden;
}
.dimensions div { display: grid; gap: 3px; padding: 5px 7px 6px; }
.dimensions div + div { border-left: 1px solid #2d3a49; }
.dimensions strong { font-size: 0.875rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.selected-basis { font-size: 0.75rem; }
.import { margin-top: 9px; flex: 0 0 auto; }
.import summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  border: 1px solid #405060;
  padding: 8px;
  border-radius: 6px;
  color: #e2e8ee;
  font-size: 0.875rem;
  font-weight: 630;
  list-style: none;
}
.import summary::-webkit-details-marker { display: none; }
.import summary:hover { border-color: var(--orange); }
.import summary svg { color: var(--orange); width: 16px; height: 16px; }
.import[open] summary svg { rotate: 45deg; }
#import-form { display: grid; gap: 7px; margin-top: 9px; }
#import-form label, #import-status { color: #c0cbd5; font-size: 0.8125rem; }
#import-url { padding: 7px; background: #151e28; border: 1px solid #405060; border-radius: 5px; }
#import-button {
  padding: 7px;
  border: 1px solid #a66f43;
  border-radius: 5px;
  background: #463326;
  color: #ffe1c6;
  font-size: 0.875rem;
}
#import-button:disabled { opacity: 0.6; }

.controls {
  min-height: 54px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 19px;
  padding: 10px 16px;
  color: #b7c2cf;
  font-size: 0.875rem;
}
.controls span { display: inline-flex; gap: 4px; align-items: center; }
.controls span kbd:last-of-type { margin-right: 3px; }
.touch-controls {
  position: absolute;
  bottom: 85px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}
.touch-controls button {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  color: #e5edf3;
  border: 1px solid #718393;
  background: #18212bdf;
  border-radius: 6px;
  touch-action: none;
  pointer-events: auto;
}
.touch-controls button:active { background: #754e31; }
.move-pad { display: grid; grid-template-columns: repeat(3, 37px); gap: 3px; }
.move-pad button:first-child { grid-column: 2; }
.move-pad button:nth-child(2) { grid-column: 1; }
.touch-actions { display: grid; gap: 4px; }

@media (max-width: 850px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 274px; gap: 9px; padding: 9px 9px 0; }
  .inventory { padding-inline: 11px; }
  .topbar { padding-inline: 14px; }
}

@media (max-width: 680px) {
  .topbar { height: 62px; }
  h1 { font-size: 1rem; }
  .brand-icon { width: 31px; height: 31px; }
  .brand-icon svg { width: 19px; height: 19px; }
  .identity, .session { gap: 7px; }
  .connection, .player-count { padding-inline: 6px; font-size: 0.75rem; gap: 4px; }
  .player-count svg { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); height: auto; min-height: calc(100dvh - 110px); }
  .viewport { height: max(420px, 60dvh); }
  .inventory-closed .viewport { height: max(420px, calc(100dvh - 120px)); }
  .inventory { max-height: 630px; }
  .floor-label, .toggle-panel { top: 11px; }
  .floor-label { left: 11px; font-size: 0.8125rem; gap: 6px; }
  .toggle-panel { right: 11px; }
  .target { bottom: 160px; }
  .controls { gap: 6px 10px; font-size: 0.75rem; }
}

@media (pointer: coarse) {
  .controls { display: none; }
  .tool kbd { display: none; }
  .target { bottom: 163px; }
}
