@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --ink: #2c2214;
  --ink-soft: rgba(44, 34, 20, 0.66);
  --ink-faint: rgba(44, 34, 20, 0.4);
  --cloud: #f6f0e1;
  --panel: rgba(244, 236, 218, 0.94);
  --panel-strong: rgba(244, 236, 218, 0.985);
  --panel-soft: rgba(255, 252, 240, 0.88);
  --panel-border: rgba(95, 138, 58, 0.24);
  --panel-border-strong: rgba(95, 138, 58, 0.42);
  --accent: #c48a1a;
  --accent-2: #5c8638;
  --accent-3: #e1c15b;
  --shadow: rgba(14, 23, 12, 0.2);
  --shadow-strong: rgba(4, 12, 4, 0.56);
  --glow: rgba(196, 138, 26, 0.32);
  --vine-tint: rgba(88, 132, 54, 0.15);
  --vine-tint-strong: rgba(88, 132, 54, 0.22);
  --vine-text: #3b5f18;
  --bead: #87c3d7;
  --mobile-toolbar-clearance: 0px;
  --mobile-toolbar-top-clearance: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(
      ellipse 55% 45% at 18% 22%,
      rgba(36, 72, 28, 0.9) 0%,
      transparent 55%
    ),
    radial-gradient(
      ellipse 45% 55% at 82% 65%,
      rgba(18, 45, 65, 0.85) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse 70% 50% at 50% 90%,
      rgba(8, 22, 12, 0.95) 0%,
      transparent 65%
    ),
    linear-gradient(165deg, #1d3c21 0%, #0e1f0e 42%, #0b1d2c 100%);
}

#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#mode-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 32;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  animation: floatIn 0.55s ease-out;
}

#mode-hud[data-surface-mode="play"] .mode-hud-left,
#mode-hud[data-surface-mode="play"] .mode-hud-history {
  display: none !important;
}

.mode-hud-left,
.mode-hud-history,
.mode-hud-right {
  pointer-events: auto;
}

.mode-hud-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 12%, rgba(180, 210, 140, 0.12), transparent 36%),
    var(--panel);
  border: 1.5px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 238, 0.62),
    0 12px 28px rgba(4, 12, 4, 0.28);
  backdrop-filter: blur(12px);
}

.mode-hud-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
}

.mode-hud-history {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: var(--panel);
  border: 1.5px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 238, 0.62),
    0 12px 28px rgba(4, 12, 4, 0.24);
  backdrop-filter: blur(12px);
}

.mode-hud-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mode-hud-icon {
  font-size: 16px;
  width: 18px;
  text-align: center;
  line-height: 1;
  color: var(--vine-text);
}

.mode-hud-label {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ink);
}

#mode-hud-clear,
#mode-hud-undo,
#mode-hud-redo,
#mode-hud-surface-toggle {
  appearance: none;
  border: 1.5px solid var(--panel-border-strong);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink-soft);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  width: 42px;
  height: 42px;
  padding: 0;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 252, 240, 0.82),
    0 6px 14px rgba(12, 28, 8, 0.14);
}

#mode-hud-clear i,
#mode-hud-undo i,
#mode-hud-redo i,
#mode-hud-surface-toggle i {
  font-size: 14px;
  line-height: 1;
}

#mode-hud-clear:hover:not(:disabled),
#mode-hud-undo:hover:not(:disabled),
#mode-hud-redo:hover:not(:disabled),
#mode-hud-surface-toggle:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--vine-tint);
  border-color: rgba(88, 132, 54, 0.54);
  color: var(--vine-text);
  box-shadow:
    inset 0 1px 0 rgba(255, 252, 240, 0.82),
    0 10px 20px rgba(12, 28, 8, 0.18);
}

#mode-hud-clear:disabled,
#mode-hud-undo:disabled,
#mode-hud-redo:disabled,
#mode-hud-surface-toggle:disabled {
  opacity: 0.55;
  cursor: default;
}

#hud {
  position: absolute;
  top: 84px;
  left: 24px;
  padding: 16px 18px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 82% 12%, rgba(195, 155, 75, 0.08), transparent 22%),
    var(--panel);
  border: 1.5px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 238, 0.6),
    0 18px 38px rgba(4, 12, 4, 0.24);
  backdrop-filter: blur(14px);
  display: grid;
  gap: 10px;
  max-width: 280px;
  animation: floatIn 0.8s ease-out;
}

.brand {
  display: grid;
  gap: 4px;
}

.logo {
  font-family: "Cinzel", serif;
  font-size: 20px;
  letter-spacing: 0.04em;
}

.tag {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1.6px;
  color: var(--ink-soft);
}

.controls {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}

.status {
  display: grid;
  gap: 6px;
}

.status-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(196, 138, 26, 0.12);
  color: #8d6516;
  border: 1px solid rgba(196, 138, 26, 0.18);
  transition: all 0.2s ease;
}

.status-pill.active {
  background: var(--vine-tint);
  color: var(--vine-text);
  border-color: rgba(88, 132, 54, 0.22);
  box-shadow: 0 0 0 1px rgba(88, 132, 54, 0.08);
}

#paint-indicator {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(196, 138, 26, 0.12);
  color: #8d6516;
  border: 1px solid rgba(196, 138, 26, 0.18);
  transition: all 0.2s ease;
}

#paint-indicator.active {
  background: var(--vine-tint);
  color: var(--vine-text);
  border-color: rgba(88, 132, 54, 0.22);
  box-shadow: 0 0 0 1px rgba(88, 132, 54, 0.08);
}

#brush-indicator {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(196, 138, 26, 0.12);
  color: #8d6516;
  border: 1px solid rgba(196, 138, 26, 0.18);
  transition: all 0.2s ease;
  display: none;
}

#brush-indicator.active {
  background: var(--vine-tint);
  color: var(--vine-text);
  border-color: rgba(88, 132, 54, 0.22);
  box-shadow: 0 0 0 1px rgba(88, 132, 54, 0.08);
}

#brush-indicator.flash {
  animation: brush-indicator-flash 0.45s ease-out;
}

@keyframes brush-indicator-flash {
  0% {
    background: rgba(255, 200, 60, 0.5);
    transform: scale(1.08);
  }
  100% {
    background: var(--vine-tint);
    transform: scale(1);
  }
}

#mode-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

#mode-controls button {
  appearance: none;
  border: 1.5px solid rgba(95, 138, 58, 0.26);
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 6px 7px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: grid;
  grid-template-rows: auto auto;
  gap: 4px;
  text-align: center;
}

#mode-controls button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(18, 23, 26, 0.12);
}

#mode-controls button.active {
  background: var(--vine-tint);
  color: var(--vine-text);
  box-shadow: 0 0 0 1px rgba(88, 132, 54, 0.24);
}

.mode-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
}

.mode-icon svg {
  width: 14px;
  height: 14px;
}

.mode-key {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(95, 138, 58, 0.2);
  background: rgba(255, 252, 240, 0.96);
  color: var(--ink-soft);
}

.mode-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#mode-controls button.active .mode-key {
  border-color: rgba(88, 132, 54, 0.3);
  color: var(--vine-text);
  background: rgba(255, 255, 255, 0.54);
}

#scene {
  position: fixed;
  top: 0;
  left: 0;
  outline: none;
}

#radial-menu {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 12;
}

#radial-menu.active {
  pointer-events: auto;
}

.radial-center {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px dashed rgba(95, 138, 58, 0.28);
  box-shadow: 0 10px 20px rgba(4, 12, 4, 0.2);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-soft);
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.radial-option {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%) translate(var(--x), var(--y));
  background: var(--panel-strong);
  border: 1.5px solid rgba(95, 138, 58, 0.28);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow:
    inset 0 1px 0 rgba(255, 252, 240, 0.8),
    0 12px 28px rgba(4, 12, 4, 0.22);
  cursor: pointer;
  pointer-events: auto;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.radial-option:hover {
  transform: translate(-50%, -50%) translate(var(--x), var(--y)) scale(1.05);
  box-shadow:
    inset 0 1px 0 rgba(255, 252, 240, 0.8),
    0 16px 36px rgba(4, 12, 4, 0.28);
}

#pickup-toast,
#status-toast {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink);
  border: 1.5px solid var(--panel-border-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 252, 240, 0.8),
    0 14px 32px rgba(4, 12, 4, 0.28);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 40;
  max-width: min(420px, 80vw);
  text-align: center;
  line-height: 1.3;
}

#pickup-toast {
  bottom: calc(120px + var(--mobile-toolbar-clearance));
}

#status-toast {
  bottom: calc(168px + var(--mobile-toolbar-clearance));
}

#pickup-toast.active,
#status-toast.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

#hud[hidden],
#tweakpane[hidden] {
  display: none !important;
}

#user-toolbar-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

#user-toolbar-root .ut-shell,
#user-toolbar-root .ut-panel-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#user-toolbar-root .ut-dock,
#user-toolbar-root .ut-panel,
#user-toolbar-root .ut-confirm-backdrop {
  pointer-events: auto;
}

.ut-shell.is-desktop .ut-dock {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  width: min(390px, calc(100vw - 32px));
  padding: 9px 10px;
  border-radius: 999px;
  background: rgba(244, 236, 218, 0.97);
  border: 2px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 252, 238, 0.6),
    0 18px 40px rgba(4, 12, 4, 0.34);
  backdrop-filter: blur(14px);
}

.ut-shell.is-desktop .ut-panel {
  position: absolute;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  width: min(390px, calc(100vw - 32px));
}

.ut-shell.is-desktop[data-sheet-state="collapsed"] .ut-panel {
  height: auto;
}

.ut-shell.is-desktop[data-sheet-state="half"] .ut-panel {
  height: auto;
}

.ut-shell.is-desktop[data-sheet-state="full"] .ut-panel {
  height: auto;
}

.ut-shell.is-mobile .ut-dock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 9px 10px;
  border-radius: 28px;
  background: rgba(244, 236, 218, 0.98);
  border: 2px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 252, 238, 0.6),
    0 18px 36px rgba(4, 12, 4, 0.36);
  backdrop-filter: blur(16px);
}

.ut-shell.is-mobile .ut-panel {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--mobile-toolbar-clearance));
  height: min(56dvh, 440px);
}

.ut-shell.is-mobile[data-sheet-state="collapsed"] .ut-panel {
  height: min(34dvh, 280px);
}

.ut-shell.is-mobile[data-sheet-state="half"] .ut-panel {
  height: min(56dvh, 440px);
}

.ut-shell.is-mobile[data-sheet-state="full"] .ut-panel {
  top: max(
    calc(12px + env(safe-area-inset-top, 0px)),
    var(--mobile-toolbar-top-clearance)
  );
  bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--mobile-toolbar-clearance));
  height: auto;
}

.ut-panel {
  position: relative;
  border-radius: 26px;
  background: var(--panel);
  border: 2px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 252, 238, 0.62),
    0 32px 80px rgba(4, 12, 4, 0.44),
    0 2px 0 rgba(255, 252, 238, 0.28);
  overflow: visible;
  backdrop-filter: blur(16px);
}

.ut-panel-bg {
  position: relative;
  height: 100%;
  max-height: 70vh;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 65% 35% at 85% 8%, rgba(155, 205, 115, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse 50% 45% at 12% 88%, rgba(195, 155, 75, 0.08) 0%, transparent 42%),
    var(--panel);
}

.vine-frame {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  overflow: visible;
}

.vine-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ut-shell.is-desktop[data-sheet-state="collapsed"] .ut-panel-bg {
  max-height: min(40vh, 360px);
}

.ut-shell.is-desktop[data-sheet-state="half"] .ut-panel-bg {
  max-height: min(74vh, 660px);
}

.ut-shell.is-desktop[data-sheet-state="full"] .ut-panel-bg {
  max-height: min(84vh, 800px);
}

.ut-shell.is-mobile .ut-panel-bg {
  max-height: none;
}

.ut-panel-scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 22px 22px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(95, 138, 58, 0.3) transparent;
}

.ut-sheet-handle {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  width: 52px;
  height: 7px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(95, 138, 58, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 252, 240, 0.6);
}

.ut-shell.is-desktop .ut-sheet-handle {
  opacity: 0;
  pointer-events: none;
  margin-top: 0;
  height: 0;
}

.ut-dock-button,
.ut-primary-button,
.ut-secondary-button,
.ut-chip,
.ut-subtab,
.ut-card,
.ut-pattern-card,
.ut-icon-button,
.ut-segmented-option,
.ut-asset-card,
.ut-toggle-row,
.ut-icon-toggle,
.ut-confirm-button {
  appearance: none;
  border: 1.5px solid rgba(95, 138, 58, 0.3);
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.ut-dock-button:hover,
.ut-primary-button:hover,
.ut-secondary-button:hover,
.ut-chip:hover,
.ut-subtab:hover,
.ut-card:hover,
.ut-pattern-card:hover,
.ut-icon-button:hover,
.ut-segmented-option:hover,
.ut-asset-card:hover,
.ut-toggle-row:hover,
.ut-icon-toggle:hover,
.ut-confirm-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(12, 28, 8, 0.14);
}

.ut-dock-button.is-active,
.ut-chip.is-active,
.ut-subtab.is-active,
.ut-card.is-active,
.ut-pattern-card.is-active,
.ut-segmented-option.is-active,
.ut-asset-card.is-active,
.ut-icon-toggle.is-active {
  background: var(--vine-tint);
  border-color: rgba(88, 132, 54, 0.54);
  color: var(--vine-text);
  box-shadow: inset 0 0 0 1px rgba(88, 132, 54, 0.15);
}

.ut-dock-button {
  position: relative;
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 60px;
  padding: 8px 4px;
  border-radius: 999px;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
}

.ut-dock-icon {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.ut-dock-label {
  font-size: 11px;
  font-weight: 700;
}

.ut-dock-indicator {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(244, 236, 218, 0.96);
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.ut-dock-button.is-armed .ut-dock-indicator {
  opacity: 1;
  transform: scale(1);
}

.ut-dock-button:hover {
  color: var(--vine-text);
  transform: none;
  box-shadow: none;
}

.ut-dock-button.is-active {
  background: var(--vine-tint-strong);
  color: var(--vine-text);
  box-shadow: inset 0 0 0 1.5px rgba(88, 132, 54, 0.54);
}

.ut-dock-button.is-active .ut-dock-icon {
  transform: none;
}

.ut-panel-header {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 18px 22px 12px;
  background:
    linear-gradient(
      180deg,
      rgba(244, 236, 218, 1) 0%,
      rgba(244, 236, 218, 1) 72%,
      rgba(244, 236, 218, 0) 100%
    );
  transition:
    padding 0.18s ease,
    border-color 0.18s ease;
}

.ut-panel-heading,
.ut-panel-actions {
  position: relative;
  z-index: 9;
}

.ut-panel-heading {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ut-panel-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 22px;
  right: 22px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(95, 138, 58, 0.45) 18%,
    rgba(95, 138, 58, 0.45) 82%,
    transparent 100%
  );
}

.ut-panel-header.is-condensed {
  padding: 10px 22px 8px;
}

.ut-panel-heading h2 {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1;
  transition: font-size 0.18s ease;
}

.ut-panel-header.is-condensed .ut-panel-heading h2 {
  font-size: 22px;
}

.ut-panel-mode {
  font-size: 12px;
  color: var(--ink-soft);
}

.ut-panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  transition: gap 0.18s ease;
}

.ut-panel-header.is-condensed .ut-panel-actions {
  gap: 6px;
}

.ut-icon-button,
.ut-primary-button,
.ut-secondary-button,
.ut-subtab,
.ut-chip,
.ut-segmented-option,
.ut-confirm-button {
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 14px;
}

.ut-icon-button {
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 252, 240, 0.82);
  transition:
    min-width 0.18s ease,
    min-height 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.ut-panel-header.is-condensed .ut-icon-button {
  min-width: 28px;
  min-height: 28px;
}

.ut-icon-button i {
  font-size: 13px;
  transition: font-size 0.18s ease;
}

.ut-icon-button svg {
  width: 13px;
  height: 13px;
}

.ut-panel-header.is-condensed .ut-icon-button i {
  font-size: 11px;
}

.ut-panel-header.is-condensed .ut-icon-button svg {
  width: 11px;
  height: 11px;
}

.ut-icon-button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.ut-primary-button {
  border-color: rgba(190, 140, 40, 0.55);
  background: linear-gradient(
    130deg,
    #bf8914 0%,
    #deb030 40%,
    #e8c040 55%,
    #c8901a 100%
  );
  color: #2a1a04;
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 180, 0.5),
    0 5px 20px rgba(170, 110, 14, 0.38);
}

.ut-secondary-button {
  background: rgba(255, 252, 240, 0.88);
}

.ut-button--danger-subtle {
  color: #9a5345;
  border-color: rgba(154, 83, 69, 0.24);
  background: rgba(255, 240, 236, 0.84);
}

.ut-button--danger-subtle:hover {
  border-color: rgba(154, 83, 69, 0.36);
  background: rgba(255, 235, 231, 0.96);
}

.ut-section,
.ut-section-card,
.ut-slider,
.ut-toggle-row,
.ut-advanced,
.ut-control-group {
  margin-top: 14px;
}

.ut-section-card:first-child,
.ut-control-group:first-child,
.ut-section:first-child {
  margin-top: 4px;
}

.ut-section-title {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #587830;
}

.ut-section-title::before {
  content: none;
}

.ut-quick-row,
.ut-chip-row,
.ut-subtabs,
.ut-segmented,
.ut-panel-actions {
  display: flex;
  flex-wrap: wrap;
}

.ut-quick-row {
  gap: 10px;
}

.ut-quick-row--full > * {
  flex: 1 1 100%;
}

.ut-quick-row--spread > * {
  flex: 1 1 120px;
}

.ut-chip-row,
.ut-subtabs,
.ut-segmented {
  gap: 8px;
}

.ut-chip-row--nowrap,
.ut-segmented--single-line {
  flex-wrap: nowrap;
}

.ut-chip-row--scroll,
.ut-segmented--scroll {
  overflow-x: auto;
  padding-bottom: 2px;
}

.ut-chip-row--fade-right {
  padding-right: 18px;
  -webkit-mask-image: linear-gradient(
    90deg,
    #000 0,
    #000 calc(100% - 34px),
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    #000 0,
    #000 calc(100% - 34px),
    transparent 100%
  );
}

.ut-chip-row--scroll > *,
.ut-segmented--scroll > * {
  flex: 0 0 auto;
}

.ut-segmented--terrain-biome {
  flex-wrap: wrap;
}

.ut-segmented--terrain-biome .ut-segmented-option {
  flex: 1 1 calc(33.333% - 8px);
}

.ut-chip--compact {
  padding-inline: 12px;
}

.ut-slider {
  display: grid;
  gap: 10px;
  padding-bottom: 10px;
}

.ut-slider-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
}

.ut-slider-value {
  color: var(--ink-soft);
}

.ut-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  accent-color: var(--accent-2);
  background: linear-gradient(
    to right,
    var(--accent-2) 0%,
    var(--accent-2) var(--pct, 40%),
    rgba(92, 134, 56, 0.22) var(--pct, 40%),
    rgba(92, 134, 56, 0.22) 100%
  );
}

.ut-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #eef5df, #c2dc96 42%, #8ab858);
  border: 2px solid rgba(88, 132, 54, 0.72);
  box-shadow: 0 3px 10px rgba(12, 28, 8, 0.38);
  cursor: grab;
}

.ut-slider input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #eef5df, #c2dc96 42%, #8ab858);
  border: 2px solid rgba(88, 132, 54, 0.72);
  box-shadow: 0 3px 10px rgba(12, 28, 8, 0.38);
  cursor: grab;
}

.ut-toggle-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 252, 240, 0.8);
}

.ut-section-card,
.ut-control-group {
  border: 1.5px solid rgba(95, 138, 58, 0.2);
  border-radius: 22px;
  background: rgba(255, 252, 240, 0.34);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 240, 0.35),
    0 10px 26px rgba(12, 28, 8, 0.04);
  backdrop-filter: blur(10px);
  padding: 16px 16px 18px;
}

.ut-section-card > .ut-section-title:first-child,
.ut-control-group > .ut-section-title:first-child {
  margin-top: 0;
}

.ut-section-card > .ut-advanced,
.ut-control-group > .ut-advanced {
  margin-top: 12px;
}

.ut-section-card .ut-section-title:not(:first-child),
.ut-control-group .ut-section-title:not(:first-child) {
  margin-top: 14px;
}

.ut-toggle {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(44, 34, 20, 0.16);
}

.ut-toggle.is-active {
  background: rgba(88, 132, 54, 0.5);
}

.ut-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 252, 240, 1);
  box-shadow: 0 2px 6px rgba(12, 28, 8, 0.18);
  transition: transform 0.18s ease;
}

.ut-toggle.is-active .ut-toggle-knob {
  transform: translateX(18px);
}

.ut-card-grid,
.ut-asset-grid,
.ut-pattern-grid,
.ut-icon-toggle-grid,
.ut-chip-grid {
  display: grid;
  gap: 10px;
}

.ut-card-grid,
.ut-pattern-grid {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.ut-icon-toggle-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.ut-asset-grid {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.ut-chip-grid--two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ut-card,
.ut-pattern-card,
.ut-asset-card,
.ut-icon-toggle,
.ut-chip--grid {
  border-radius: 18px;
  padding: 14px;
  text-align: left;
}

.ut-chip--grid {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ut-card strong,
.ut-pattern-card strong,
.ut-asset-card strong {
  display: block;
  font-size: 13px;
}

.ut-card span,
.ut-asset-card span {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}

.ut-icon-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  border-radius: 14px;
  background: rgba(255, 252, 240, 0.9);
}

.ut-icon-toggle-emoji {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid rgba(95, 138, 58, 0.18);
  background: rgba(255, 252, 240, 0.7);
}

.ut-icon-toggle-label {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.ut-pattern-thumb {
  width: 100%;
  aspect-ratio: 1.8;
  margin-bottom: 10px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(88, 132, 54, 0.2), transparent 50%),
    rgba(244, 236, 218, 0.8);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.ut-pattern-thumb svg {
  width: 100%;
  height: 100%;
}

.ut-pattern-svg__strokes {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ut-pattern-svg__lines {
  fill: none;
  stroke: rgba(44, 34, 20, 0.46);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ut-pattern-card strong,
.ut-pattern-card {
  text-align: center;
}

.ut-search-wrap {
  margin-bottom: 10px;
}

.ut-search {
  width: 100%;
  border: 1.5px solid rgba(95, 138, 58, 0.32);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  background: rgba(255, 252, 240, 0.9);
  color: var(--ink);
}

.ut-search::placeholder {
  color: var(--ink-faint);
}

.ut-advanced {
  border: 0;
  border-radius: 18px;
  overflow: visible;
  background: transparent;
}

.ut-advanced-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid rgba(95, 138, 58, 0.2);
  border-radius: 18px;
  background: rgba(255, 252, 240, 0.42);
  font: inherit;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.ut-advanced-toggle:hover {
  background: rgba(255, 252, 240, 0.54);
  border-color: rgba(95, 138, 58, 0.32);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(12, 28, 8, 0.08);
}

.ut-advanced-body {
  display: none;
  padding: 12px 4px 10px;
}

.ut-advanced.is-open .ut-advanced-body {
  display: block;
}

.ut-caption,
.ut-footer-hint {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-faint);
  font-style: italic;
}

.ut-fine-tune-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--ink-faint);
}

.ut-fine-tune-divider::before,
.ut-fine-tune-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: rgba(95, 138, 58, 0.18);
}

.ut-fine-tune-divider span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ut-confirm-backdrop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 24, 10, 0.34);
  backdrop-filter: blur(6px);
}

.ut-confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border-radius: 24px;
  background: var(--panel-strong);
  border: 2px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 238, 0.62),
    0 24px 56px rgba(4, 12, 4, 0.28);
}

.ut-confirm-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 50%;
  color: #a56c11;
  background: rgba(225, 193, 91, 0.28);
}

.ut-confirm-dialog h3 {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 24px;
  font-weight: 400;
}

.ut-confirm-dialog p {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.ut-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.ut-confirm-button--warning {
  background: linear-gradient(135deg, rgba(241, 201, 106, 0.98), rgba(255, 143, 74, 0.92));
}

.ut-confirm-button--danger {
  background: linear-gradient(135deg, rgba(238, 112, 88, 0.98), rgba(255, 143, 74, 0.92));
}

#tweakpane {
  position: fixed;
  --tweakpane-margin: 24px;
  --tweakpane-bottom-gap: 24px;
  top: calc(var(--tweakpane-margin) + env(safe-area-inset-top, 0px));
  right: var(--tweakpane-margin);
  min-width: 280px;
  z-index: 10;
  height: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  pointer-events: none;
  max-height: calc(
    100vh - var(--tweakpane-margin) - env(safe-area-inset-top, 0px) -
      var(--tweakpane-bottom-gap)
  );
  max-height: calc(
    100dvh - var(--tweakpane-margin) - env(safe-area-inset-top, 0px) -
      var(--tweakpane-bottom-gap)
  );
  --tp-base-background-color: rgba(244, 236, 218, 0.88);
  --tp-base-shadow-color: rgba(4, 12, 4, 0.22);
  --tp-button-background-color: rgba(191, 137, 20, 0.92);
  --tp-button-background-color-hover: rgba(201, 147, 24, 1);
  --tp-button-background-color-active: rgba(174, 125, 18, 1);
  --tp-button-foreground-color: #2c2214;
  --tp-container-background-color: rgba(255, 252, 240, 0.96);
  --tp-container-background-color-hover: rgba(255, 255, 248, 1);
  --tp-input-background-color: rgba(255, 252, 240, 0.92);
  --tp-input-border-color: rgba(95, 138, 58, 0.26);
  --tp-input-foreground-color: #2c2214;
  --tp-label-foreground-color: rgba(44, 34, 20, 0.76);
  --tp-font-family: "Space Grotesk", sans-serif;
  --tp-base-radius: 12px;
  --tp-blade-spacing: 8px;
}

/* Tweakpane UI Contrast Fixes */
#tweakpane .tp-lblv_v input:disabled,
#tweakpane .tp-lblv_v input[readonly],
#tweakpane .tp-monv_v {
  color: var(--ink) !important;
  opacity: 1 !important;
  font-weight: 600 !important;
}

#tweakpane .tp-lblv_v input:disabled {
  background-color: rgba(255, 255, 255, 0.95) !important;
}

#tweakpane .tp-rotv {
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

#tweakpane .tp-rotv_t,
#tweakpane .tp-rotv_c {
  pointer-events: auto;
}

#tweakpane .tp-rotv_c {
  border-radius: 16px;
  border: 1.5px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 238, 0.55),
    0 18px 45px rgba(4, 12, 4, 0.28);
  flex: 0 1 auto;
  min-height: 0;
  max-height: calc(
    100vh - var(--tweakpane-margin) - env(safe-area-inset-top, 0px) -
      var(--tweakpane-bottom-gap) - 56px
  );
  max-height: calc(
    100dvh - var(--tweakpane-margin) - env(safe-area-inset-top, 0px) -
      var(--tweakpane-bottom-gap) - 56px
  );
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#joystick {
  position: fixed;
  left: calc(var(--joystick-safe-left, 24px) + env(safe-area-inset-left, 0px));
  bottom: calc(
    var(--joystick-safe-bottom, 24px) + env(safe-area-inset-bottom, 0px)
  );
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(244, 236, 218, 0.8);
  border: 2px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 238, 0.58),
    0 12px 28px rgba(4, 12, 4, 0.26);
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  z-index: 25;
}

#joystick-stick {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #eef5df, #c2dc96 42%, #8ab858);
  border: 2px solid rgba(88, 132, 54, 0.72);
  box-shadow: 0 8px 18px rgba(12, 28, 8, 0.28);
  transform: translate3d(0, 0, 0);
  transition: transform 0.08s ease-out;
}

#action-jump {
  position: fixed;
  right: calc(var(--jump-safe-right, 24px) + env(safe-area-inset-right, 0px));
  bottom: calc(
    var(--jump-safe-bottom, 24px) + env(safe-area-inset-bottom, 0px)
  );
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--panel-border-strong);
  background: rgba(244, 236, 218, 0.82);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 238, 0.58),
    0 12px 28px rgba(4, 12, 4, 0.26);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  z-index: 25;
  transition: transform 0.1s ease-out, background 0.15s ease;
}

#action-jump:active {
  transform: scale(0.9);
  background: rgba(244, 236, 218, 0.94);
}

#action-jump svg {
  width: 28px;
  height: 28px;
  color: var(--accent-2);
  transition: transform 0.25s ease;
}

#action-jump.action-jump--dive svg {
  transform: rotate(180deg);
}

body.joystick-dragging,
body.joystick-dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}

body.canvas-gesture-lock,
body.canvas-gesture-lock * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}

@media (max-width: 900px) {
  #mode-hud {
    top: 12px;
    left: 12px;
    right: 12px;
  }

  #hud {
    top: 72px;
    left: 16px;
    max-width: 220px;
  }

  #tweakpane {
    --tweakpane-margin: 12px;
    --tweakpane-bottom-gap: 12px;
    top: calc(var(--tweakpane-margin) + env(safe-area-inset-top, 0px));
    right: var(--tweakpane-margin);
    min-width: 240px;
  }

  #joystick {
    --joystick-safe-left: 16px;
    --joystick-safe-bottom: 16px;
  }
}

@media (max-width: 700px) {
  #hud {
    display: none;
  }

  #mode-hud {
    gap: 8px;
  }

  .mode-hud-label {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mode-hud-left {
    padding: 8px 10px;
  }

  .mode-hud-history {
    padding: 6px;
  }

  .mode-hud-right {
    padding: 0;
  }

  #mode-hud-clear,
  #mode-hud-undo,
  #mode-hud-redo,
  #mode-hud-surface-toggle {
    width: 38px;
    height: 38px;
    font-size: 13px;
  }

  #tweakpane {
    --tweakpane-margin: 8px;
    --tweakpane-bottom-gap: 8px;
    top: calc(var(--tweakpane-margin) + env(safe-area-inset-top, 0px));
    right: var(--tweakpane-margin);
    bottom: 0;
    height: auto;
    max-height: calc(
      100svh - var(--tweakpane-margin) - env(safe-area-inset-top, 0px) - 2px
    );
    max-height: calc(
      100dvh - var(--tweakpane-margin) - env(safe-area-inset-top, 0px) - 2px
    );
  }

  #pickup-toast,
  #status-toast {
    max-width: min(320px, calc(100vw - 24px));
    font-size: 12px;
  }
}

@media (max-width: 1023px) {
  #tweakpane {
    z-index: 24;
  }

  .ut-panel-heading h2 {
    font-size: 24px;
  }

  .ut-panel-header,
  .ut-panel-heading h2,
  .ut-panel-actions,
  .ut-icon-button,
  .ut-icon-button i {
    transition: none;
  }
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.oottm-vc {
  position: absolute;
  width: 76px;
  height: 76px;
  pointer-events: none;
  z-index: 8;
}

.oottm-vc svg {
  width: 100%;
  height: 100%;
}

.oottm-vc--tl {
  top: -3px;
  left: -3px;
}

.oottm-vc--tr {
  top: -3px;
  right: -3px;
  transform: scaleX(-1);
}

.oottm-vc--bl {
  bottom: -3px;
  left: -3px;
  transform: scaleY(-1);
}

.oottm-vc--br {
  right: -3px;
  bottom: -3px;
  transform: scale(-1, -1);
}
