/* Mushfront Box3D game shell — layered over the brick lab styling */

/* Author display rules below (e.g. .overlay-screen { display: grid }) would
   otherwise override the UA stylesheet's [hidden] { display: none }, leaving
   "hidden" screens painted on top of live ones. Restore hidden semantics. */
[hidden] {
  display: none !important;
}

:root {
  --ink: #e6f5ee;
  --ink-dim: #8fb3a6;
  --accent: #6fd3b8;
  --accent-hot: #ffd76a;
  --panel: rgba(10, 20, 17, 0.82);
  --panel-edge: rgba(111, 211, 184, 0.28);
  --panel-glow: 0 0 0 1px rgba(111, 211, 184, 0.14), 0 18px 50px rgba(0, 0, 0, 0.55);
}

/* ------------------------------------------------------------- screens -- */

.overlay-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  /* vignette, not a blackout — the living world renders behind the menu */
  background:
    radial-gradient(ellipse 90% 75% at 50% 45%, rgba(5, 10, 9, 0.18) 0%, rgba(5, 10, 9, 0.62) 78%, rgba(4, 8, 7, 0.85) 100%);
  z-index: 30;
  animation: screen-in 380ms ease-out;
}

@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

body[data-screen="playing"] .overlay-screen { display: none; }

.menu-card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow: var(--panel-glow);
  backdrop-filter: blur(10px) saturate(1.15);
  padding: 34px 42px 28px;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  position: relative;
  animation: card-in 420ms cubic-bezier(0.2, 0.9, 0.25, 1.15);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* stud strip across the card top — the brick motif */
.menu-card::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 22px;
  right: 22px;
  height: 8px;
  background-image: radial-gradient(circle 3px at 8px 4px, rgba(111, 211, 184, 0.5) 0 3px, transparent 3px);
  background-size: 20px 8px;
  background-repeat: repeat-x;
  opacity: 0.6;
}

.menu-card h1 {
  margin: 10px 0 0;
  font-size: 38px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 22px rgba(111, 211, 184, 0.45), 0 2px 0 rgba(0, 0, 0, 0.6);
}

.menu-card h2 { margin: 8px 0 4px; font-size: 20px; letter-spacing: 0.1em; text-transform: uppercase; }

.menu-sub {
  margin: -2px 0 14px;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.menu-note { color: var(--ink-dim); font-size: 11px; margin: 8px 0 0; letter-spacing: 0.06em; }

.menu-card button {
  background: linear-gradient(180deg, #223c34 0%, #17282300 60%), rgba(18, 32, 28, 0.9);
  color: var(--ink);
  border: 1px solid rgba(111, 211, 184, 0.35);
  border-radius: 8px;
  padding: 12px 16px;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.menu-card button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(111, 211, 184, 0.25), inset 0 0 12px rgba(111, 211, 184, 0.08);
  transform: translateY(-1px);
}

.menu-card button:active { transform: translateY(1px) scale(0.99); box-shadow: none; }

.menu-card label { font-size: 13px; display: flex; gap: 10px; align-items: center; color: var(--ink-dim); }
.menu-card input[type="range"] { accent-color: var(--accent); }
.menu-card input[type="checkbox"] { accent-color: var(--accent); }

.setting-card {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid rgba(111, 211, 184, 0.18);
  border-radius: 8px;
  background: rgba(8, 24, 20, 0.48);
}
.setting-card label { display: grid; grid-template-columns: 138px minmax(120px, 1fr) 42px; gap: 10px; }
.setting-card label span { color: var(--ink); }
.setting-card label b { color: var(--accent); font-variant-numeric: tabular-nums; text-align: right; }
.setting-card small { max-width: 410px; color: #78988e; font-size: 10px; line-height: 1.45; }

/* ----------------------------------------------------------------- hud -- */

#game-ui { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#game-ui .engine-panel { pointer-events: auto; }

.showcase-caption {
  position: absolute;
  left: 22px;
  bottom: 22px;
  z-index: 40;
  display: grid;
  gap: 3px;
  padding: 11px 14px 10px;
  border-left: 2px solid rgba(174, 241, 255, 0.82);
  background: linear-gradient(90deg, rgba(4, 19, 25, 0.76), rgba(4, 19, 25, 0.08));
  color: #effdff;
  text-shadow: 0 2px 8px rgba(0, 10, 14, 0.92);
  transition: opacity 180ms ease, transform 180ms ease;
}

.game-hotkey-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 42;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.78);
  font: 600 10px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.035em;
  text-shadow: 0 1px 6px #000, 0 2px 14px #000;
  pointer-events: none;
}
.game-hotkey-hint kbd { color: #fff; font: inherit; }

.showcase-caption strong { font: 800 14px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.16em; }
.showcase-caption span { color: #a9e5ed; font: 10px/1.3 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.06em; }
.showcase-caption small { margin-top: 3px; color: rgba(218, 244, 244, 0.56); font: 8px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.08em; }
.showcase-caption kbd { color: #f7ffff; }

#game-ui.is-showcase-clean .game-topbar,
#game-ui.is-showcase-clean .game-palette,
#game-ui.is-showcase-clean .game-inspector,
#game-ui.is-showcase-clean .river-lab-panel,
#game-ui.is-showcase-clean .water-tuning-panel,
#game-ui.is-showcase-clean #world-bars,
#game-ui.is-showcase-clean #hud-message {
  opacity: 0;
  pointer-events: none;
}

#game-ui.is-showcase-clean .showcase-caption { opacity: 0.9; }

/* Hydrology scenes are world simulations, not campaign build screens. Their
   authoring and telemetry live in the Debug Workbench; only the clock and an
   optional showcase caption remain in the world HUD. */
body[data-game-mode^="hydrology"] #game-ui .game-topbar,
body[data-game-mode^="hydrology"] #game-ui .game-palette,
body[data-game-mode^="hydrology"] #game-ui .game-inspector,
body[data-game-mode^="hydrology"] #game-ui .river-lab-panel,
body[data-game-mode^="hydrology"] #game-ui .water-tuning-panel,
body[data-game-mode^="hydrology"] #game-ui #world-bars,
body[data-game-mode^="hydrology"] #game-ui #hud-message {
  display: none !important;
}

body[data-game-mode^="hydrology"] #game-ui .world-time-controls {
  top: 14px;
  right: 14px;
  left: auto;
}

.world-time-controls {
  position: absolute;
  top: 68px;
  left: 14px;
  z-index: 44;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
  border: 1px solid rgba(221, 243, 245, 0.22);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(27, 38, 42, 0.94), rgba(7, 13, 16, 0.94));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42), inset 0 1px rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}
.world-time-controls > div { display: flex; gap: 0; padding: 2px; border-radius: 7px; background: rgba(0,0,0,0.3); }
.world-time-controls button {
  min-width: 30px;
  height: 27px;
  padding: 0 6px;
  border: 1px solid rgba(158, 222, 227, 0.2);
  border-radius: 6px;
  background: transparent;
  color: rgba(227, 250, 252, 0.72);
  font: 700 9px/1 ui-monospace, "SF Mono", Menlo, monospace;
  cursor: pointer;
}
.world-time-controls button:hover { background: rgba(151, 226, 235, 0.16); color: #efffff; }
.world-time-controls button.is-active {
  border-color: rgba(161, 238, 247, 0.7);
  background: rgba(108, 216, 227, 0.24);
  color: #f5ffff;
  box-shadow: 0 2px 8px rgba(60, 208, 224, 0.18), inset 0 1px rgba(255,255,255,0.14);
}
.world-time-controls .time-play { width: 31px; border-radius: 8px; color: #fff; background: rgba(118, 214, 224, 0.12); }
.world-time-controls .time-status { display: grid; min-width: 82px; padding: 0 7px; align-content: center; border-left: 1px solid rgba(255,255,255,0.1); }
.world-time-controls output {
  color: #dffcff;
  text-align: left;
  font: 800 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.world-time-controls small {
  color: rgba(199, 235, 237, 0.48);
  font: 7px/1.1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}
#game-ui.is-showcase-clean .world-time-controls { top: 16px; right: 16px; left: auto; opacity: 0.82; }

#world-bars {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

#tile-hover-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 8;
}

.tile-hover-readout {
  position: absolute;
  display: grid;
  gap: 4px;
  min-width: 142px;
  transform: translate(28px, -50%);
  color: #efffff;
  filter: drop-shadow(0 5px 13px rgba(0, 7, 10, 0.62));
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.tile-hover-readout::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 24px;
  height: 1px;
  background: linear-gradient(90deg, rgba(225, 255, 255, 0.08), rgba(225, 255, 255, 0.76));
  box-shadow: 0 0 8px rgba(144, 238, 255, 0.35);
}

.tile-hover-primary,
.tile-hover-motion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 6px 8px;
  border: 1px solid rgba(202, 248, 255, 0.34);
  border-radius: 7px;
  background: linear-gradient(110deg, rgba(7, 19, 22, 0.91), rgba(9, 27, 32, 0.76));
  backdrop-filter: blur(8px) saturate(1.25);
}

.tile-hover-primary b {
  overflow: hidden;
  color: rgba(224, 251, 250, 0.72);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.075em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.tile-hover-primary strong {
  color: #f7ffff;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tile-hover-motion {
  justify-content: flex-start;
  width: max-content;
  min-width: 112px;
  padding: 4px 7px;
  border-color: rgba(112, 220, 249, 0.28);
  color: rgba(218, 247, 252, 0.68);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.tile-hover-motion b { color: #ffffff; letter-spacing: 0.08em; }
.tile-flow-arrow {
  display: inline-grid;
  width: 16px;
  height: 16px;
  place-items: center;
  transform: rotate(var(--flow-angle));
  border-radius: 50%;
  background: rgba(102, 220, 247, 0.15);
  color: #dffaff;
  font-size: 12px;
  text-shadow: 0 0 6px rgba(150, 238, 255, 0.8);
}
.tile-flow-still {
  display: inline-grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid rgba(151, 225, 233, 0.2);
  border-radius: 50%;
  color: rgba(217, 249, 250, 0.74);
  font-size: 14px;
}
.tile-hover-readout.is-dry .tile-hover-motion { color: rgba(221, 247, 235, 0.64); }

.world-bar-stack {
  position: absolute;
  width: var(--bar-width);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform: translate(-50%, calc(-100% - 5px));
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.65));
}

.world-status-bar {
  display: block;
  width: 100%;
  height: 5px;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid rgba(5, 10, 9, 0.82);
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 55%), var(--track-color);
}

.world-status-bar b {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--fill));
  transform-origin: left center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 55%), var(--fill-color);
}

.world-status-bar.cycle {
  height: 4px;
  opacity: 0.94;
}

.world-status-bar.stalled {
  outline: 1px solid rgba(255, 215, 106, 0.55);
}

.world-device-tag {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 7px;
  transform: translate(-50%, calc(-100% - 7px));
  padding: 4px 7px;
  border: 1px solid rgba(93, 213, 255, 0.5);
  background: rgba(3, 18, 28, 0.86);
  color: #ccefff;
  font: 8px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.1em;
  box-shadow: 0 4px 15px rgba(0, 8, 16, 0.5);
}
.world-device-tag::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 1px;
  height: 7px;
  background: rgba(93, 213, 255, 0.65);
}
.world-device-tag b { color: #83e4ff; font-weight: 800; }
.world-device-tag span { color: #eefcff; font-variant-numeric: tabular-nums; }
.world-device-tag.sink { border-color: rgba(255, 207, 100, 0.5); }
.world-device-tag.sink b { color: #ffd477; }

#game-ui .engine-panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  box-shadow: var(--panel-glow);
  backdrop-filter: blur(8px);
}

.game-topbar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 9px 18px;
  font-size: 12px;
  animation: hud-drop 320ms ease-out;
}

@keyframes hud-drop {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.game-topbar div { display: flex; gap: 6px; align-items: baseline; }
.game-topbar dt { color: var(--accent); text-transform: uppercase; font-size: 9px; letter-spacing: 0.14em; }
.game-topbar dd { margin: 0; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.game-topbar button {
  background: rgba(28, 47, 42, 0.9);
  color: var(--ink);
  border: 1px solid rgba(111, 211, 184, 0.3);
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.game-topbar button:hover { border-color: var(--accent); box-shadow: 0 0 10px rgba(111, 211, 184, 0.2); }

.game-palette {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 11px;
  max-width: min(92vw, 880px);
  animation: hud-rise 320ms ease-out;
}

@keyframes hud-rise {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.palette-tabs { display: flex; gap: 6px; }
.palette-tabs button {
  background: rgba(15, 26, 23, 0.85);
  color: var(--ink-dim);
  border: 1px solid rgba(111, 211, 184, 0.18);
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 120ms ease;
}
.palette-tabs button:hover { color: var(--ink); border-color: rgba(111, 211, 184, 0.4); }
.palette-tabs button.is-selected {
  background: rgba(43, 74, 64, 0.95);
  color: #eafff5;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(111, 211, 184, 0.18);
}

.palette-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.palette-tools button {
  background: rgba(20, 34, 30, 0.9);
  color: var(--ink);
  border: 1px solid rgba(111, 211, 184, 0.22);
  border-radius: 7px;
  padding: 7px 11px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 88px;
  transition: all 120ms ease;
}
.palette-tools button:hover { border-color: var(--accent); transform: translateY(-1px); }
.palette-tools button .cost { color: var(--accent-hot); font-size: 10px; font-variant-numeric: tabular-nums; }
.palette-tools button .lvl { color: #82e7ff; font-size: 10px; }
.palette-tools button.is-selected {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 16px rgba(111, 211, 184, 0.3);
  background: rgba(34, 60, 52, 0.95);
}
.palette-tools button:disabled { opacity: 0.4; cursor: default; }
.palette-tools button[data-tool="paintWater"],
.palette-tools button[data-tool="riverSource"] { border-color: rgba(82, 207, 250, 0.48); }
.palette-tools button[data-tool="riverSource"] span:first-child { color: #91e8ff; }
.palette-tools button[data-tool="riverSink"] { border-color: rgba(255, 207, 100, 0.5); }
.palette-tools button[data-tool="riverSink"] span:first-child { color: #ffd477; }

.game-inspector {
  position: absolute;
  right: 12px;
  top: 72px;
  width: 234px;
  padding: 12px 14px;
  font-size: 12px;
}
.game-inspector.river-lab-offset { top: 372px; }
.game-inspector h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #eafff5;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(111, 211, 184, 0.2);
  padding-bottom: 6px;
}
.game-inspector .row { display: flex; justify-content: space-between; margin: 3px 0; color: var(--ink-dim); }
.game-inspector .row b { color: var(--ink); font-variant-numeric: tabular-nums; }

#engine-canvas.is-targeting { cursor: crosshair; }
.target-controls { margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(255, 215, 106, .28); }
.target-mode-label { margin-bottom: 6px; color: #ffd76a; font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.target-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.target-mode-grid button { min-height: 29px; padding: 5px 7px; border: 1px solid rgba(255,255,255,.16); background: rgba(5,12,15,.82); color: var(--ink-dim); font: 800 9px/1.1 inherit; letter-spacing: .05em; }
.target-mode-grid button.is-active { border-color: #ffd76a; color: #fff3b0; background: rgba(117,78,17,.45); box-shadow: inset 0 0 12px rgba(255,190,55,.12), 0 0 9px rgba(255,190,55,.1); }
.target-order { display: flex; justify-content: space-between; margin-top: 6px; padding: 6px 7px; background: rgba(255,194,60,.08); color: #ffd76a; font-size: 10px; }
.self-fill-control { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin-top: 8px; color: var(--ink-dim); font-size: 10px; }
.self-fill-control b { color: #6effdc; }
.self-fill-control input { grid-column: 1 / -1; width: 100%; accent-color: #6effdc; }

.hover-panel {
  position: absolute;
  left: 16px;
  bottom: 18px;
  z-index: 45;
  width: 292px;
  padding: 0;
  overflow: hidden;
  font-size: 11px;
  pointer-events: none !important;
  border-color: rgba(196, 239, 232, 0.24) !important;
  border-radius: 14px !important;
  background:
    radial-gradient(circle at 74% 22%, rgba(74, 178, 189, 0.08), transparent 42%),
    rgba(7, 15, 16, 0.91) !important;
  box-shadow: 0 18px 55px rgba(0, 6, 8, 0.58), inset 0 1px rgba(255, 255, 255, 0.055) !important;
  backdrop-filter: blur(15px) saturate(1.2) !important;
}

.admin-check span[data-admin-help],
.admin-range span[data-admin-help],
.admin-select span[data-admin-help] { position: relative; cursor: help; text-decoration: underline dotted rgba(255,255,255,0.3); text-underline-offset: 2px; }
.admin-check span[data-admin-help]:hover::after,
.admin-range span[data-admin-help]:hover::after,
.admin-select span[data-admin-help]:hover::after {
  content: attr(data-admin-help);
  position: fixed;
  z-index: 10000;
  width: 250px;
  margin: 17px 0 0 -4px;
  padding: 7px 9px;
  color: #f2f2f2;
  white-space: normal;
  font: 10px/1.38 system-ui, sans-serif;
  background: rgba(13, 14, 16, 0.98);
  border: 1px solid rgba(180, 182, 186, 0.48);
  box-shadow: 0 8px 24px rgba(0,0,0,0.55);
  pointer-events: none;
}
.tile-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(195, 239, 235, 0.12);
  color: rgba(224, 248, 244, 0.57);
  font: 700 8px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.tile-profile-header b { color: #eafff8; font-size: 9px; font-variant-numeric: tabular-nums; }

.tile-profile-stage {
  position: relative;
  height: 204px;
  margin: 0 10px;
  border-bottom: 1px solid rgba(200, 237, 232, 0.1);
  background:
    linear-gradient(90deg, transparent 0 51px, rgba(255,255,255,0.025) 51px 52px, transparent 52px),
    linear-gradient(180deg, rgba(118, 203, 213, 0.028), transparent 50%);
}
.tile-profile-stage > small {
  position: absolute;
  left: 8px;
  bottom: 3px;
  color: rgba(205, 235, 232, 0.38);
  font: 7px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.05em;
}
.tile-profile-column {
  position: absolute;
  left: 53px;
  right: 12px;
  bottom: 18px;
  height: 170px;
}
.tile-profile-material,
.tile-profile-liquid {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  box-sizing: border-box;
}
.tile-profile-material {
  height: var(--material-height);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--material-color), white 12%);
  border-bottom-color: var(--material-deep);
  border-radius: 4px 4px 2px 2px;
  background:
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(8, 19, 16, 0.17) 7px 8px),
    repeating-linear-gradient(90deg, transparent 0 17px, rgba(255,255,255,0.045) 17px 18px),
    linear-gradient(180deg, var(--material-color), var(--material-side) 58%, var(--material-deep));
  box-shadow: inset 0 1px rgba(255,255,255,0.13), 0 4px 9px rgba(0,0,0,0.32);
}
.tile-profile-material::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 8px;
  width: 18px;
  height: 5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--material-color), white 11%);
  box-shadow: 32px 0 color-mix(in srgb, var(--material-color), white 8%), 64px 0 color-mix(in srgb, var(--material-color), white 9%), 96px 0 color-mix(in srgb, var(--material-color), white 7%);
  opacity: 0.72;
}
.tile-profile-material span,
.tile-profile-liquid span {
  position: absolute;
  right: 7px;
  bottom: 6px;
  overflow: hidden;
  max-width: 145px;
  color: rgba(247, 255, 252, 0.93);
  font: 800 8px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.055em;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.88);
  text-transform: uppercase;
  white-space: nowrap;
}
.tile-profile-liquid {
  bottom: var(--layer-bottom);
  height: var(--layer-height);
  min-height: 1px;
  overflow: hidden;
  border-right: 1px solid color-mix(in srgb, var(--liquid-color), white 22%);
  border-left: 1px solid color-mix(in srgb, var(--liquid-color), white 8%);
  background:
    radial-gradient(ellipse 34px 9px at 18% 17%, color-mix(in srgb, var(--liquid-highlight), transparent 62%), transparent 72%),
    radial-gradient(ellipse 44px 11px at 76% 42%, color-mix(in srgb, var(--liquid-highlight), transparent 74%), transparent 72%),
    linear-gradient(180deg, color-mix(in srgb, var(--liquid-color), white 10%), var(--liquid-color) 24%, var(--liquid-deep));
  box-shadow: inset 0 1px var(--liquid-highlight), inset 0 -8px 18px color-mix(in srgb, var(--liquid-deep), transparent 36%);
  opacity: 0.9;
}
.tile-profile-liquid::before {
  content: "";
  position: absolute;
  top: 0;
  right: -8%;
  left: -8%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--liquid-highlight) 22%, transparent 47%, var(--liquid-highlight) 74%, transparent);
  filter: blur(0.3px);
  opacity: 0.78;
}
.tile-profile-liquid.is-thin span { display: none; }

.tile-profile-ruler {
  position: absolute;
  left: 17px;
  bottom: 18px;
  width: 28px;
  height: 170px;
  border-right: 1px solid rgba(222, 249, 245, 0.16);
}
.tile-profile-ruler i {
  position: absolute;
  right: -1px;
  width: 7px;
  height: 1px;
  border-top: 1px solid rgba(222, 249, 245, 0.28);
}
.tile-profile-ruler i b {
  position: absolute;
  right: 10px;
  top: -4px;
  color: rgba(218, 243, 239, 0.45);
  font: 7px/1 ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.tile-profile-keys { display: grid; gap: 1px; padding: 8px 10px; }
.tile-profile-key {
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 20px;
  color: rgba(217, 243, 239, 0.68);
  font: 8px/1.1 ui-monospace, "SF Mono", Menlo, monospace;
}
.tile-profile-key > i {
  width: 12px;
  height: 12px;
  border: 1px solid color-mix(in srgb, var(--key-color), white 18%);
  border-radius: 3px;
  background: linear-gradient(145deg, var(--key-color), var(--key-deep));
  box-shadow: inset 0 1px rgba(255,255,255,0.15);
}
.tile-profile-key span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-profile-key b { color: #f1fffc; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-profile-key.is-material { padding-bottom: 4px; border-bottom: 1px solid rgba(209, 240, 236, 0.08); }
.tile-profile-empty { padding: 4px 2px 1px 22px; color: rgba(210, 235, 231, 0.38); font: 8px/1 ui-monospace, "SF Mono", Menlo, monospace; }

.tile-profile-flow {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 7px;
  margin: 0 10px 8px;
  padding: 8px 9px 7px;
  border: 1px solid rgba(109, 215, 240, 0.2);
  border-radius: 8px;
  background: rgba(40, 133, 156, 0.075);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.tile-profile-flow span { color: rgba(155, 226, 239, 0.5); font-size: 7px; letter-spacing: 0.12em; }
.tile-profile-flow b { color: #e9fcff; font-size: 10px; letter-spacing: 0.08em; }
.tile-profile-flow strong { justify-self: end; color: #ffffff; font-size: 10px; font-variant-numeric: tabular-nums; }
.tile-profile-flow small { grid-column: 1 / -1; color: rgba(198, 234, 239, 0.43); font-size: 7px; }
.tile-profile-status { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 10px; }
.tile-profile-status span {
  padding: 4px 6px;
  border: 1px solid rgba(212, 240, 234, 0.12);
  border-radius: 999px;
  background: rgba(255,255,255,0.025);
  color: rgba(219, 241, 237, 0.57);
  font: 7px/1 ui-monospace, "SF Mono", Menlo, monospace;
}

.river-lab-panel {
  position: absolute;
  top: 72px;
	right: 12px;
  width: 264px;
  overflow: hidden;
  color: #e8f9ff;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background:
    linear-gradient(135deg, rgba(34, 161, 211, 0.12), transparent 42%),
    rgba(4, 17, 25, 0.88) !important;
  border-color: rgba(75, 199, 243, 0.46) !important;
  box-shadow: 0 0 0 1px rgba(67, 194, 240, 0.12), 0 20px 52px rgba(0, 8, 15, 0.55) !important;
}

.river-lab-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(86, 205, 248, 0.22);
  letter-spacing: 0.13em;
  font-size: 11px;
}

.river-lab-panel header strong { color: #8ce7ff; }
.river-lab-panel header button {
  margin-left: auto;
  margin-right: 10px;
  padding: 3px 7px;
  border: 1px solid rgba(103, 218, 255, 0.38);
  border-radius: 4px;
  background: rgba(26, 106, 134, 0.24);
  color: #b7efff;
  font: 800 8px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.1em;
  cursor: pointer;
}
.river-lab-panel header button:hover,
.river-lab-panel header button[aria-expanded="true"] { border-color: #8ce7ff; box-shadow: 0 0 10px rgba(83, 204, 244, 0.2); }
.river-lab-panel header kbd { color: #6fabbf; font: inherit; }
.river-lab-panel header span { color: #8fffcf; font-size: 9px; }
.river-lab-panel header span b { color: inherit; font: inherit; }
.river-lab-panel header i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: #69ffbd;
  box-shadow: 0 0 9px #69ffbd;
  animation: river-live 1.35s ease-in-out infinite;
}

@keyframes river-live { 50% { opacity: 0.38; transform: scale(0.72); } }

.river-lab-panel.is-paused header span { color: #ffd477; }
.river-lab-panel.is-paused header i {
  animation: none;
  background: #ffd477;
  box-shadow: 0 0 7px rgba(255, 212, 119, 0.7);
}

.river-lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(75, 199, 243, 0.13);
}

.river-lab-grid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: rgba(5, 20, 29, 0.94);
}

.river-lab-grid small { color: #74a9bb; font-size: 8px; letter-spacing: 0.12em; }
.river-lab-grid b { color: #effcff; font-size: 11px; font-variant-numeric: tabular-nums; }
.river-lab-panel footer {
  padding: 7px 10px 8px;
  color: #668d9d;
  font-size: 8px;
  letter-spacing: 0.02em;
}

.water-tuning-panel {
  position: absolute;
  z-index: 4;
  top: 72px;
  right: 288px;
  bottom: 12px;
  width: 390px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: #e8f9ff;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background:
    linear-gradient(150deg, rgba(45, 181, 226, 0.13), transparent 34%),
    rgba(4, 16, 24, 0.95) !important;
  border-color: rgba(77, 203, 244, 0.48) !important;
  box-shadow: 0 0 0 1px rgba(82, 207, 249, 0.1), 0 24px 70px rgba(0, 7, 15, 0.68) !important;
  animation: water-console-in 170ms ease-out;
}

@keyframes water-console-in {
  from { opacity: 0; transform: translateX(10px) scale(0.985); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.water-tuning-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 13px 10px;
  border-bottom: 1px solid rgba(91, 207, 245, 0.2);
}
.water-tuning-panel > header small { color: #65b5cf; font-size: 8px; letter-spacing: 0.18em; }
.water-tuning-panel > header h2 { margin: 2px 0 0; color: #d9f8ff; font-size: 15px; letter-spacing: 0.05em; }
.water-tuning-panel > header button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(102, 207, 241, 0.28);
  border-radius: 5px;
  background: rgba(32, 92, 113, 0.24);
  color: #aeeaff;
  font: 20px/1 ui-monospace, monospace;
  cursor: pointer;
}

.water-tuning-scroll {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  scrollbar-color: rgba(78, 183, 219, 0.55) rgba(4, 15, 23, 0.5);
}

.water-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}
.water-presets button,
.water-tuning-panel > footer button {
  min-width: 0;
  padding: 7px 5px;
  border: 1px solid rgba(94, 193, 226, 0.25);
  border-radius: 5px;
  background: rgba(20, 62, 77, 0.5);
  color: #a9dce9;
  font: 800 8px/1.1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.water-presets button:hover,
.water-presets button.is-selected,
.water-tuning-panel > footer button:hover {
  border-color: #7bdbf8;
  background: rgba(39, 120, 149, 0.42);
  color: #effcff;
  box-shadow: 0 0 12px rgba(80, 202, 240, 0.13);
}

.water-preset-note {
  min-height: 28px;
  margin: 8px 2px 10px;
  color: #82aeba;
  font-size: 9px;
  line-height: 1.45;
}

.water-tuning-panel details {
  margin-top: 6px;
  border: 1px solid rgba(77, 181, 216, 0.18);
  border-radius: 6px;
  background: rgba(5, 24, 33, 0.68);
}
.water-tuning-panel summary {
  padding: 8px 9px;
  color: #9fe9ff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.water-tuning-panel summary::marker { color: #58b8d6; }

.water-control {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 7px 9px;
  border-top: 1px solid rgba(70, 164, 194, 0.1);
}
.water-control > span { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.water-control b { color: #d9f5fb; font-size: 10px; font-weight: 650; }
.water-control output { color: #7eddf9; font-size: 9px; font-variant-numeric: tabular-nums; text-align: right; }
.water-control input[type="range"] { width: 100%; margin: 0; accent-color: #49bfe8; }
.water-control small { color: #688b96; font-size: 8px; line-height: 1.42; }
.water-control.advanced-control { background: rgba(17, 49, 59, 0.24); }
.water-control.water-toggle > span { align-items: center; }
.water-control.water-toggle input[type="checkbox"] {
  width: 30px;
  height: 16px;
  margin: 0;
  accent-color: #58cce8;
}

.erosion-contract {
  display: grid;
  gap: 4px;
  margin: 8px;
  padding: 8px 9px;
  border-left: 2px solid #d5b56a;
  background: linear-gradient(90deg, rgba(141, 104, 48, 0.16), rgba(46, 142, 173, 0.06));
  color: #91b9c3;
  font-size: 8px;
  line-height: 1.42;
}
.erosion-contract b { color: #ead69f; font-size: 9px; letter-spacing: 0.05em; text-transform: uppercase; }
.erosion-contract small { color: #8e9f8b; font-size: 7px; letter-spacing: 0.07em; }

.water-formula {
  margin: 8px;
  padding: 7px 8px;
  border-left: 2px solid #4fc4e9;
  background: rgba(46, 142, 173, 0.1);
  color: #85bac9;
  font-size: 8px;
  line-height: 1.4;
}

.water-tuning-panel > footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
  padding: 9px 10px 10px;
  border-top: 1px solid rgba(79, 184, 219, 0.2);
  background: rgba(3, 14, 21, 0.92);
}

@media (max-width: 900px) {
  .water-tuning-panel { left: 10px; right: 10px; width: auto; }
  .river-lab-panel { width: 246px; }
}

.hud-message {
  position: absolute;
  left: 50%;
  bottom: 116px;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 16px;
  background: var(--panel);
  border: 1px solid rgba(255, 215, 106, 0.5);
  border-radius: 7px;
  color: var(--accent-hot);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  pointer-events: none !important;
  animation: hud-rise 200ms ease-out;
}

.match-end {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(5, 10, 9, 0.35) 0%, rgba(4, 8, 7, 0.8) 100%);
  pointer-events: auto;
  animation: screen-in 500ms ease-out;
}

/* ------------------------------------------------------------- studio -- */

#screen-studio {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

#screen-studio .engine-panel { z-index: 2; pointer-events: auto; }

.studio-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: 52px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) auto;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 7px 8px;
  background: linear-gradient(180deg, rgba(24, 36, 35, 0.94), rgba(9, 15, 15, 0.9));
  border: 1px solid rgba(255, 215, 106, 0.2);
  border-radius: 6px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45), inset 0 1px rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.studio-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.studio-actions { justify-content: flex-end; }

.studio-toolbar button,
.studio-toolbar select {
  height: 36px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: rgba(18, 32, 28, 0.92);
  color: var(--ink);
  border: 1px solid rgba(111, 211, 184, 0.32);
  border-radius: 6px;
  padding: 0 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-toolbar select {
  width: 124px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent-hot) 50%) calc(100% - 14px) 15px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--accent-hot) 50%, transparent 50%) calc(100% - 9px) 15px / 6px 6px no-repeat,
    rgba(18, 32, 28, 0.92);
  padding-right: 24px;
}

.studio-toolbar button:hover { border-color: var(--accent); }
#studio-status {
  min-width: 0;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-palette {
  position: absolute;
  top: 72px;
  bottom: 10px;
  left: 10px;
  width: 386px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
  background: linear-gradient(180deg, rgba(13, 22, 22, 0.96), rgba(7, 12, 13, 0.92));
  border: 1px solid rgba(111, 211, 184, 0.24);
  border-radius: 6px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.5), inset 0 1px rgba(255, 255, 255, 0.05);
  color: var(--ink);
}

.studio-drawer-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 0;
  margin-bottom: 5px;
}

.studio-palette h3 {
  flex: 0 0 auto;
  margin: 6px 0 5px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
}

.studio-drawer-header h3 { margin: 0; color: var(--ink); }

#studio-piece-count {
  color: var(--accent-hot);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

#studio-pieces {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  flex: 0 0 auto;
  gap: 4px;
  min-height: auto;
  overflow: visible;
  padding: 0;
}

#studio-pieces button {
  width: 100%;
  height: 35px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  overflow: hidden;
  background: rgba(20, 31, 30, 0.92);
  color: var(--ink);
  border: 1px solid rgba(111, 211, 184, 0.25);
  border-radius: 5px;
  padding: 4px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  contain: layout paint;
}

#studio-pieces button:hover {
  border-color: rgba(111, 211, 184, 0.65);
  background: rgba(28, 43, 40, 0.95);
}

#studio-erase.is-selected,
#studio-pieces button.is-selected,
.studio-swatch.is-selected { border-color: var(--accent-hot); box-shadow: 0 0 0 1px rgba(255, 215, 106, 0.36), 0 0 14px rgba(255, 215, 106, 0.32); }

.studio-piece-preview {
  position: relative;
  width: 25px;
  height: 25px;
  overflow: hidden;
  border-radius: 5px;
  background: radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.16), transparent 46%), rgba(9, 15, 15, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.studio-piece-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.studio-generated-preview {
  width: 100%;
  height: 100%;
  display: block;
}

.studio-piece-preview.is-fallback::before {
  content: "";
  position: absolute;
  inset: 10px 7px 8px;
  border-radius: 4px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.24) 0 4px, transparent 5px),
    radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.24) 0 4px, transparent 5px),
    linear-gradient(180deg, rgba(111, 211, 184, 0.86), rgba(39, 93, 85, 0.94));
  box-shadow: inset 0 -5px rgba(0, 0, 0, 0.2);
}

.studio-piece-preview[data-kind="brick"].is-fallback::before { background-color: #d76f4d; }
.studio-piece-preview[data-kind="plate"].is-fallback::before { background-color: #6fd3b8; }
.studio-piece-preview[data-kind="tile"].is-fallback::before { background-color: #b9bec4; }

.studio-piece-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.studio-piece-name,
.studio-piece-meta {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-piece-name {
  font-size: 10px;
  color: var(--ink);
}

.studio-piece-meta {
  font-size: 8px;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#studio-colors {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(9, 20px);
  gap: 5px;
  overflow: hidden;
}

.studio-swatch {
  width: 20px;
  height: 20px;
  box-sizing: border-box;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

.studio-surface-lab {
  position: absolute;
  top: 72px;
  right: 10px;
  width: 292px;
  box-sizing: border-box;
  padding: 12px;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(15, 27, 26, 0.97), rgba(7, 13, 14, 0.94));
  border: 1px solid rgba(255, 215, 106, 0.22);
  border-radius: 6px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.48), inset 0 1px rgba(255, 255, 255, 0.05);
  pointer-events: auto;
}

.studio-surface-lab h3 { margin: 2px 0 0; font-size: 14px; color: var(--ink); letter-spacing: 0.09em; text-transform: uppercase; }
.studio-kicker { display: block; color: var(--accent-hot); font-size: 8px; letter-spacing: 0.16em; text-transform: uppercase; }
#studio-decal-count { color: var(--accent); font-size: 9px; text-transform: uppercase; }
.studio-surface-copy { margin: 9px 0 11px; color: var(--ink-dim); font-size: 10px; line-height: 1.45; }
.studio-decal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.studio-decal-grid button {
  min-height: 58px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 7px;
  padding: 6px;
  color: var(--ink);
  background: rgba(20, 34, 31, 0.88);
  border: 1px solid rgba(111, 211, 184, 0.22);
  border-radius: 5px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.studio-decal-grid button:hover { border-color: rgba(111, 211, 184, 0.66); }
.studio-decal-grid button.is-selected { border-color: var(--accent-hot); box-shadow: 0 0 14px rgba(255, 215, 106, 0.22); }
.studio-decal-grid strong, .studio-decal-grid small { display: block; }
.studio-decal-grid strong { font-size: 10px; }
.studio-decal-grid small { margin-top: 3px; color: var(--ink-dim); font-size: 7px; line-height: 1.25; }
.studio-decal-asset {
  width: 34px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.5));
}
.studio-surface-options { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.studio-surface-options label { color: var(--ink-dim); font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.studio-surface-options select, .studio-surface-options button { width: 100%; height: 30px; margin-top: 4px; padding: 0 7px; color: var(--ink); background: #12201e; border: 1px solid rgba(111,211,184,.28); border-radius: 4px; font: inherit; font-size: 9px; }
.studio-recipe-note { display: flex; flex-direction: column; gap: 3px; margin-top: 10px; padding: 8px; border-left: 2px solid var(--accent-hot); background: rgba(255,215,106,.055); }
.studio-recipe-note strong { color: var(--accent-hot); font-size: 9px; text-transform: uppercase; }
.studio-recipe-note span { color: var(--ink-dim); font-size: 8px; line-height: 1.35; }

@media (max-width: 1060px) {
  .studio-surface-lab { width: 238px; }
  .studio-decal-grid { grid-template-columns: 1fr; max-height: 340px; overflow: auto; }
  .studio-decal-grid button { min-height: 46px; }
}

/* ------------------------------------------------------------- admin -- */

#admin-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 80;
  width: 42px;
  height: 22px;
  box-sizing: border-box;
  pointer-events: auto;
  background: rgba(38, 39, 41, 0.86);
  color: #e5e5e5;
  border: 1px solid rgba(115, 116, 118, 0.78);
  border-radius: 2px;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8), inset 1px 1px rgba(255, 255, 255, 0.08);
  font: 700 10px/1 ui-monospace, "SF Mono", Menlo, monospace;
  cursor: pointer;
}

#admin-toggle:hover,
#admin-toggle.is-active {
  border-color: #b8b8b8;
  color: #ffffff;
  background: rgba(63, 64, 66, 0.9);
}

.admin-panel {
  position: absolute;
  z-index: 79;
  top: 42px;
  left: 36px;
  width: min(900px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 54px));
  min-width: 720px;
  min-height: 320px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  resize: both;
  pointer-events: auto;
  color: #d8d8d8;
  background: rgba(31, 32, 34, 0.79);
  border: 1px solid rgba(9, 9, 10, 0.96);
  border-radius: 2px;
  outline: 1px solid rgba(112, 113, 116, 0.42);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.66), inset 1px 1px rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(3px);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.18;
}

.admin-panel::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 13px;
  height: 13px;
  pointer-events: none;
  opacity: 0.72;
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(180, 180, 180, 0.62) 46% 52%, transparent 53% 100%),
    linear-gradient(135deg, transparent 0 62%, rgba(180, 180, 180, 0.62) 63% 69%, transparent 70% 100%);
}

.admin-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 6px;
  min-height: 21px;
  padding: 2px 4px 2px 7px;
  color: #eeeeee;
  background: linear-gradient(180deg, rgba(63, 64, 67, 0.94), rgba(39, 40, 42, 0.92));
  border-bottom: 1px solid rgba(9, 9, 10, 0.96);
  cursor: move;
  user-select: none;
}

.admin-title-row {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.admin-title-row span {
  color: #f0f0f0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-title-row small {
  min-width: 0;
  overflow: hidden;
  color: #c8c8c8;
  font-size: 10px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-title-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.admin-window-button,
.admin-tabs button,
.admin-actions button {
  box-sizing: border-box;
  min-width: 0;
  color: #e2e2e2;
  background: rgba(49, 50, 52, 0.9);
  border: 1px solid rgba(10, 10, 11, 0.9);
  border-radius: 1px;
  box-shadow: inset 1px 1px rgba(255, 255, 255, 0.06);
  font: inherit;
  cursor: pointer;
}

.admin-window-button {
  flex: 0 0 auto;
  width: 18px;
  height: 17px;
  padding: 0;
  font-size: 10px;
  line-height: 1;
  text-align: center;
  cursor: pointer;
}

.admin-profile-button {
  width: auto;
  min-width: 56px;
  padding: 0 5px;
  color: #aeb0b3;
  font-size: 8px;
  letter-spacing: 0.06em;
}

.admin-profile-button.is-active {
  color: #f2f2f2;
  border-color: rgba(164, 165, 168, 0.9);
  background: rgba(76, 78, 82, 0.96);
}

.admin-tabs {
  display: flex;
  gap: 1px;
  padding: 3px 4px 0;
  overflow-x: auto;
  border-bottom: 1px solid rgba(9, 9, 10, 0.96);
  background: rgba(28, 29, 31, 0.7);
}

.admin-tabs button {
  flex: 0 0 auto;
  height: 21px;
  padding: 0 8px;
  color: #d0d0d0;
  background: rgba(45, 46, 49, 0.86);
  border-color: rgba(10, 10, 11, 0.9);
  font-size: 10px;
  white-space: nowrap;
}

.admin-tabs button:hover,
.admin-window-button:hover,
.admin-actions button:hover {
  color: #ffffff;
  background: rgba(69, 70, 73, 0.94);
}

.admin-tabs button.is-selected {
  color: #ffffff;
  background: rgba(78, 80, 84, 0.95);
  border-color: rgba(142, 143, 146, 0.8);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.15);
}

.admin-workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, 1fr) 270px;
  overflow: hidden;
}

.admin-panel.is-profiler-hidden .admin-workspace {
  grid-template-columns: minmax(0, 1fr);
}

.admin-panel.is-profiler-hidden .admin-profiler { display: none; }

.admin-body {
  min-height: 0;
  overflow: auto;
  padding: 5px;
  scrollbar-color: rgba(116, 117, 120, 0.7) rgba(24, 25, 27, 0.7);
}

.admin-profiler {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(190px, 1fr) auto;
  gap: 5px;
  padding: 6px;
  overflow: hidden;
  border-left: 1px solid rgba(9, 9, 10, 0.96);
  background: rgba(23, 24, 26, 0.78);
}

.admin-profiler > header,
.admin-profiler > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.admin-profiler > header {
  min-height: 24px;
  padding: 0 5px;
  border: 1px solid rgba(10, 10, 11, 0.88);
  background: rgba(62, 63, 66, 0.88);
  color: #efefef;
  font-size: 10px;
  font-weight: 700;
}

.admin-profiler > header small,
.admin-profiler > footer {
  color: #96989c;
  font-size: 8px;
  font-weight: 500;
}

.admin-profiler-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}

.admin-profiler-metrics > div {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 5px 6px;
  border: 1px solid rgba(10, 10, 11, 0.78);
  background: rgba(45, 46, 49, 0.58);
}

.admin-profiler-metrics span {
  overflow: hidden;
  color: #96989c;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-profiler-metrics b {
  overflow: hidden;
  color: #f2f2f2;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-profiler-graphs {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(112px, 1fr) minmax(92px, 0.78fr);
  gap: 5px;
}

.admin-graph-block {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 3px;
}

.admin-graph-label {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 1px 0 4px;
  padding: 0 2px;
  color: #c9c9c9;
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.admin-graph-label b {
  overflow: hidden;
  color: #8f9194;
  font-size: 8px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-profiler .admin-graph-label {
  margin: 0;
  color: #bfc0c2;
}

.admin-profiler .admin-graph-wrap {
  height: auto;
  min-height: 0;
  margin: 0;
}

.admin-profiler .admin-graph-wrap.compact {
  min-height: 0;
}

.admin-profiler > footer {
  padding: 1px 2px 0;
  font-variant-numeric: tabular-nums;
}

.admin-graph-wrap {
  height: 252px;
  overflow: hidden;
  margin-bottom: 5px;
  border: 1px solid rgba(10, 10, 11, 0.96);
  border-radius: 1px;
  background: rgba(20, 21, 23, 0.76);
}

.admin-graph-wrap.tall { height: 320px; }
.admin-graph-wrap.five-minute { height: 210px; }

.admin-graph {
  display: block;
  width: 100%;
  height: 100%;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 5px;
}

.admin-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.admin-metric {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px;
  min-height: 20px;
  padding: 2px 5px;
  border: 1px solid rgba(10, 10, 11, 0.76);
  border-radius: 1px;
  background: rgba(43, 44, 46, 0.56);
}

.admin-metric span {
  min-width: 0;
  overflow: hidden;
  color: #b4b4b4;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-metric b {
  min-width: 0;
  overflow: hidden;
  color: #f0f0f0;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-metric.warn b { color: #ffd76a; }
.admin-metric.bad b { color: #ff8c8c; }

.admin-section,
.admin-fold {
  margin-top: 5px;
  padding-top: 0;
  border-top: 0;
}

.admin-section h3,
.admin-fold summary {
  margin: 0 0 3px;
  padding: 2px 5px;
  color: #eeeeee;
  background: rgba(62, 63, 66, 0.88);
  border: 1px solid rgba(10, 10, 11, 0.88);
  border-radius: 1px;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}

.admin-section h3::before { content: "▾ "; color: #cfcfcf; }
.admin-fold summary { cursor: pointer; list-style: none; }
.admin-fold summary::-webkit-details-marker { display: none; }
.admin-fold summary::before { content: "▾ "; color: #cfcfcf; }
.admin-fold:not([open]) summary::before { content: "▸ "; }

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.admin-actions.sticky {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: -5px -5px 5px;
  padding: 4px 5px;
  background: rgba(35, 36, 38, 0.94);
  border-bottom: 1px solid rgba(10, 10, 11, 0.92);
}

.admin-actions button {
  min-height: 21px;
  padding: 0 7px;
  font-size: 10px;
}

.admin-actions button.primary {
  background: rgba(64, 65, 68, 0.92);
}

.admin-actions button.danger {
  background: rgba(70, 54, 56, 0.92);
  color: #ead0d0;
}

.admin-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 8px;
}

.admin-check,
.admin-range,
.admin-select {
  min-width: 0;
  display: grid;
  align-items: center;
  gap: 7px;
  color: #d8d8d8;
  font-size: 10px;
}

.admin-check {
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 20px;
}

.admin-check span,
.admin-range span,
.admin-select span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-check input,
.admin-range input {
  accent-color: #9b9b9b;
}

.admin-range {
  grid-template-columns: 88px minmax(80px, 1fr) 42px;
  margin-bottom: 3px;
}

.admin-range b {
  color: #d6d6d6;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.admin-select {
  grid-template-columns: 88px minmax(0, 1fr);
  margin-bottom: 3px;
}

.admin-select select {
  min-width: 0;
  height: 21px;
  color: #e6e6e6;
  background: rgba(42, 43, 45, 0.95);
  border: 1px solid rgba(10, 10, 11, 0.9);
  border-radius: 1px;
  font: inherit;
  font-size: 10px;
}

.admin-json,
.admin-log {
  margin: 0;
  color: #d9d9d9;
  font-size: 10px;
  line-height: 1.35;
}

.admin-json {
  overflow: auto;
  white-space: pre-wrap;
}

.admin-log {
  display: grid;
  gap: 2px;
  padding: 0;
  list-style: none;
}

.admin-log li {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 7px;
  padding: 3px 5px;
  border-left: 2px solid rgba(132, 133, 136, 0.78);
  background: rgba(43, 44, 46, 0.44);
}

.admin-log time {
  color: #b4b4b4;
  font-variant-numeric: tabular-nums;
}

.admin-log span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-log li.warn { border-left-color: #ffd76a; }
.admin-log li.bad { border-left-color: #ff8c8c; }

@media (max-width: 760px) {
  #admin-toggle {
    top: 8px;
    left: 8px;
  }

  .admin-panel {
    top: 46px;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    height: auto;
    min-width: 0;
    resize: none;
  }

  .admin-workspace { grid-template-columns: minmax(0, 1fr); }
  .admin-profiler { display: none; }
  .admin-profile-button { display: none; }

  .admin-graph-wrap { height: 210px; }
  .admin-graph-wrap.tall { height: 250px; }
  .admin-graph-wrap.five-minute { height: 190px; }
  .admin-grid,
  .admin-grid.compact,
  .admin-checks {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-range,
  .admin-select {
    grid-template-columns: 78px minmax(0, 1fr) 42px;
  }

  .admin-select { grid-template-columns: 78px minmax(0, 1fr); }

  .studio-toolbar {
    left: 8px;
    right: 8px;
    height: 48px;
    grid-template-columns: auto minmax(68px, 1fr) auto;
    gap: 6px;
    padding: 6px;
  }

  .studio-toolbar button,
  .studio-toolbar select {
    height: 34px;
    max-width: 112px;
    padding: 0 9px;
  }

  .studio-toolbar button span:last-child { display: none; }
  .studio-toolbar select { width: 104px; }
  #studio-status { font-size: 10px; }

  .studio-palette {
    top: 62px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
  }

  #studio-pieces button {
    height: 34px;
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .studio-piece-preview {
    width: 24px;
    height: 24px;
  }
}
