:root {
  color-scheme: dark;
  --bg: #101215;
  --panel: #181b20;
  --panel-2: #1e2228;
  --line: #30353e;
  --line-soft: #262b32;
  --ink: #f2efe8;
  --muted: #969da8;
  --gold: #d0a44a;
  --gold-2: #f0c765;
  --red: #bb3339;
  --green: #4f9562;
  --tile: 240px;
  --zoom: 0.85;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

button,
input,
select,
.button {
  font: inherit;
}

button,
.button {
  color: inherit;
}

.topbar {
  height: 74px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #15181c;
  box-shadow: 0 2px 14px #0008;
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #8e713b;
  background: radial-gradient(circle at 50% 35%, #423720, #171714 70%);
  color: var(--gold-2);
  font-family: Georgia, serif;
  font-weight: 900;
  font-size: 25px;
  transform: rotate(-3deg);
}

h1,
h2,
p {
  margin: 0;
}

.eyebrow,
.kicker {
  font-size: 9px;
  letter-spacing: 0.2em;
  font-weight: 800;
  color: var(--gold);
}

h1 {
  font:
    700 20px/1.1 Georgia,
    serif;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 14px;
}

.mvp-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 4px 6px;
  border-radius: 3px;
  background: #483a1e;
  color: var(--gold-2);
  margin-left: 4px;
}

.document-actions {
  display: flex;
  gap: 7px;
}

.help-button {
  width: 34px;
  padding-inline: 0;
  border-radius: 50%;
  color: var(--gold-2);
  font-size: 14px;
}

.tutorial-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.tutorial-backdrop {
  position: absolute;
  inset: 0;
  background: #08090bca;
  backdrop-filter: blur(3px);
}

.tutorial-dialog {
  position: relative;
  width: min(480px, 100%);
  min-height: 410px;
  padding: 28px;
  border: 1px solid #5a503a;
  border-radius: 8px;
  background: linear-gradient(145deg, #22262c, #171a1f 72%);
  box-shadow: 0 24px 70px #000c, inset 0 1px #ffffff12;
}

.tutorial-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.tutorial-steps {
  display: flex;
  gap: 6px;
  margin: 14px 42px 20px 0;
}

.tutorial-step {
  height: 3px;
  flex: 1;
  border-radius: 4px;
  background: #3a4049;
}

.tutorial-step.active,
.tutorial-step.done {
  background: var(--gold);
}

.tutorial-visual {
  aspect-ratio: 3 / 1;
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid #353b44;
  border-radius: 6px;
  background: #111419;
}

.tutorial-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tutorial-counter {
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
}

.tutorial-dialog h2 {
  margin-bottom: 9px;
  font: 700 23px/1.2 Georgia, serif;
}

.tutorial-copy {
  min-height: 66px;
  color: #b7bdc6;
  font-size: 13px;
  line-height: 1.6;
}

.tutorial-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
}

#tutorial-previous[hidden] + #tutorial-next {
  margin-left: auto;
}

.button,
button {
  border: 1px solid #3d444e;
  background: #252a31;
  border-radius: 4px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.button:hover,
button:hover {
  border-color: #68717d;
  background: #2a3038;
}

.primary {
  background: linear-gradient(#c44349, #a92d34);
  border-color: #db6267;
  box-shadow: inset 0 1px #ffffff25;
}

.primary:hover {
  background: #c43c43;
}

.ghost {
  background: #20242a;
}

.danger {
  color: #f0a2a5;
  border-color: #623438;
  background: #302024;
}

.wide-button {
  width: 100%;
  margin-top: 10px;
}

.warning-bar {
  min-height: 36px;
  padding: 9px 18px;
  background: #4b3516;
  border-bottom: 1px solid #816023;
  color: #f4d48e;
  font-size: 12px;
}

.app-shell {
  height: calc(100vh - 74px);
  display: grid;
  grid-template-columns: 320px minmax(520px, 1fr) 248px;
}

.sidebar {
  background: var(--panel);
  min-height: 0;
  overflow: auto;
}

.left-sidebar {
  border-right: 1px solid var(--line);
}

.inspector {
  border-left: 1px solid var(--line);
  padding: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 3;
}

.tab {
  border: 0;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 14px 4px;
  color: var(--muted);
  font-size: 11px;
}

.tab.active {
  color: var(--gold-2);
  border-bottom-color: var(--gold);
}

.tab-panel {
  display: none;
  padding: 17px;
}

.tab-panel.active {
  display: block;
}

.panel-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-title .kicker {
  margin-bottom: 3px;
}

.panel-title.compact {
  margin-top: 0;
}

.count {
  font-size: 10px;
  color: var(--muted);
  padding: 3px 6px;
  background: #242931;
  border-radius: 10px;
}

.panel-help {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  margin-bottom: 13px;
}

.search-wrap {
  height: 35px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid #3b424c;
  border-radius: 4px;
  background: #111419;
  margin-bottom: 9px;
  color: var(--muted);
}

.search-wrap input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  width: 100%;
  font-size: 11px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  margin: 9px 0;
}

.check-row input,
.product-choice input {
  accent-color: var(--gold);
}

.tile-library {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.tile-card {
  position: relative;
  min-width: 0;
  border: 1px solid #343a43;
  border-radius: 5px;
  background: #20242a;
  overflow: hidden;
  cursor: grab;
}

.tile-card:hover {
  border-color: #8a7447;
  transform: translateY(-1px);
}

.tile-card.unavailable {
  opacity: 0.5;
  filter: grayscale(0.8);
  cursor: not-allowed;
}

.tile-preview,
.mini-tile {
  aspect-ratio: 1;
  background-color: #65604e;
  background-image:
    linear-gradient(
      145deg,
      #baad88 0 20%,
      #4c554f 20% 47%,
      #89816a 47% 67%,
      #292e2c 67%
    ),
    repeating-linear-gradient(35deg, transparent 0 17px, #0003 18px 19px);
  background-blend-mode: multiply;
  background-size: cover;
  background-position: center;
}

.tile-card:nth-child(3n + 2) .tile-preview {
  background-image: linear-gradient(
    35deg,
    #383c38,
    #9e9474 48%,
    #2d302d 50%,
    #74694e
  );
}

.tile-card:nth-child(3n) .tile-preview {
  background-image: linear-gradient(
    145deg,
    #8f8060,
    #333a38 35%,
    #c4b999 36% 57%,
    #5a5546 58%
  );
}

.tile-meta {
  padding: 7px;
}

.tile-title {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
}

.tile-product {
  display: block;
  color: var(--muted);
  font-size: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.availability-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-top: 3px;
  flex: 0 0 auto;
}

.unavailable .availability-dot {
  background: #8a4b4e;
}

.tile-exception {
  width: 100%;
  border: 0;
  border-top: 1px solid #303640;
  background: #171a1f;
  color: var(--muted);
  padding: 4px;
  font-size: 9px;
}

.import-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px dashed #505966;
  padding: 14px 8px;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
}

.import-tile > span {
  font-size: 22px;
}

.import-tile strong {
  font-size: 11px;
  color: #d8dbe0;
}

.import-tile small {
  font-size: 9px;
  margin-top: 2px;
}

.marker-library {
  display: grid;
  gap: 14px;
}

.marker-product-group {
  display: grid;
  gap: 9px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.marker-product-group:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.marker-product-group.unavailable {
  opacity: 0.72;
}

.marker-product-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #f0c765;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.marker-product-title span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0;
  text-transform: none;
}

.marker-group {
  display: grid;
  gap: 6px;
}

.marker-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #d9dde3;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.marker-group-title span {
  color: var(--muted);
  letter-spacing: 0;
}

.marker-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.marker-choice {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 8px;
  background: #20242a;
}

.marker-choice:disabled {
  cursor: not-allowed;
}

.marker-choice.unavailable {
  opacity: 0.45;
  filter: grayscale(0.35);
}

.marker-swatch,
.marker-node {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #eee;
  color: white;
  font-weight: 800;
  font-size: 11px;
  box-shadow: 0 2px 5px #0007;
}

.marker-choice > span:not(.marker-swatch) {
  font-size: 10px;
  min-width: 0;
}

.marker-choice small {
  grid-column: 2;
  color: var(--muted);
  font-size: 9px;
  margin-top: -5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-invasion,
.marker-exit,
.marker-gate,
.marker-crypt,
.marker-crypt-yellow {
  border-radius: 4px;
}

.marker-door {
  border-radius: 1px;
  transform: rotate(45deg);
  width: 25px;
  height: 25px;
  margin: 2px;
}

.marker-door > span {
  transform: rotate(-45deg);
}

.marker-swatch.has-image,
.marker-node.has-image,
.marker-node.marker-door.has-image {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: translate(-50%, -50%);
}

.marker-swatch.has-image {
  width: 30px;
  height: 30px;
  transform: none;
}

.marker-node.has-image,
.marker-node.marker-door.has-image {
  width: var(--marker-width, 42px);
  height: var(--marker-height, 42px);
}

.marker-swatch.has-image img,
.marker-node.has-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
}

.type-start {
  background: #2d6eb6;
}

.type-objective {
  background: #bd343b;
}

.type-invasion {
  background: #a62d32;
}

.type-exit {
  background: #318053;
}

.type-door {
  background: #666c72;
}

.type-spawn {
  background: #7f3f98;
}

.type-vault {
  background: #a77b27;
}

.type-crypt {
  background: #4d4568;
}

.type-crypt-yellow {
  background: #d7b33f;
}

.type-noise {
  background: #217d86;
}

.type-gate {
  background: #a77b27;
}

.type-rubble {
  background: #b87416;
}

.type-guard {
  background: #24798a;
}

.type-statue {
  background: #727981;
}

.type-chi {
  background: #55a6b4;
  color: #102125;
}

.tip,
.priority-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border-left: 2px solid var(--gold);
  background: #242116;
  margin-top: 16px;
  font-size: 10px;
}

.tip span,
.priority-note span {
  color: var(--muted);
  line-height: 1.45;
}

.profile-row {
  display: grid;
  grid-template-columns: 1fr 34px 34px;
  gap: 5px;
  margin-bottom: 12px;
}

.profile-row select,
.inspector select,
.inspector input,
.mission-toolbar select,
.mission-toolbar input {
  border: 1px solid #3e4651;
  border-radius: 4px;
  background: #111419;
  color: var(--ink);
  padding: 7px;
  font-size: 11px;
}

.product-list {
  display: grid;
  gap: 5px;
}

.product-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid #2f353d;
  border-radius: 4px;
  background: #1e2228;
  font-size: 11px;
}

.product-choice span {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
}

.collection-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 14px;
}

.collection-actions > * {
  text-align: center;
  font-size: 10px;
}

.collection-actions > :first-child {
  grid-column: 1/-1;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0e1013;
}

.mission-toolbar {
  height: 54px;
  flex: 0 0 54px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  background: #171a1e;
}

.mission-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.mission-name {
  flex: 1;
  max-width: 260px;
}

.mission-name span {
  font-size: 8px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.14em;
}

.mission-name input {
  width: 100%;
}

.toolbar-divider {
  height: 25px;
  border-left: 1px solid var(--line);
}

.tool-button.active {
  border-color: var(--gold);
  color: var(--gold-2);
  background: #382f1b;
}

.icon-button {
  padding: 5px 9px;
}

.mission-toolbar #zoom-label {
  font-size: 10px;
  color: var(--muted);
  min-width: 30px;
  text-align: center;
}

.canvas-scroller {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 42px;
  background-color: #111419;
  background-image: radial-gradient(#ffffff0e 1px, transparent 1px);
  background-size: 18px 18px;
}

.board-wrap {
  transform: scale(var(--zoom));
  transform-origin: center;
  transition: transform 0.15s;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tile));
  grid-template-rows: repeat(var(--rows), var(--tile));
  width: calc(var(--cols) * var(--tile));
  height: calc(var(--rows) * var(--tile));
  background: #272b30;
  box-shadow:
    0 16px 60px #000c,
    0 0 0 8px #171a1e,
    0 0 0 9px #3d4249;
}

.grid-cell {
  position: relative;
  border: 1px dashed #4b5058;
  display: grid;
  place-items: center;
  color: #656b74;
  font:
    700 11px Georgia,
    serif;
}

.grid-cell.dragover {
  background: #d0a44a22;
  outline: 2px solid var(--gold);
  outline-offset: -3px;
}

.placed-tile {
  position: absolute;
  width: var(--tile);
  height: var(--tile);
  border: 0;
  padding: 0;
  border-radius: 0;
  background: #59584f;
  cursor: move;
  transform-origin: center;
  box-shadow: inset 0 0 35px #0008;
}

.placed-tile .tile-art {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(
      145deg,
      #aa9e7c 0 18%,
      #46504a 18% 45%,
      #b5a989 45% 63%,
      #343936 63%
    ),
    repeating-linear-gradient(40deg, transparent 0 24px, #0002 25px 26px);
  background-blend-mode: multiply;
  background-size: cover;
  background-position: center;
}

.placed-tile:nth-of-type(even) .tile-art {
  filter: hue-rotate(12deg) brightness(0.9);
}

.placed-tile.selected {
  outline: 4px solid var(--gold-2);
  outline-offset: -4px;
  z-index: 3;
}

.placed-tile.unavailable {
  outline: 4px solid #d6444a;
  outline-offset: -5px;
}

.tile-ref {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  padding: 4px 7px;
  background: #111d;
  border: 1px solid #eee;
  border-radius: 3px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.door-anchor {
  position: absolute;
  z-index: 6;
  width: 12px;
  height: 12px;
  border: 2px solid var(--gold-2);
  background: #1b1c18;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.door-anchor.custom {
  box-shadow: 0 0 0 3px #d0a44a44;
}

.marker-node {
  position: absolute;
  z-index: 8;
  width: 38px;
  height: 38px;
  font-size: 13px;
  margin: 0;
  cursor: move;
  transform: translate(-50%, -50%);
}

.marker-node.selected {
  outline: 3px solid var(--gold-2);
  outline-offset: 3px;
}

.marker-node.unavailable {
  opacity: 0.5;
  filter: grayscale(0.5);
}

.marker-node.marker-door {
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.statusbar {
  height: 26px;
  flex: 0 0 26px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #777f89;
  font-size: 9px;
  background: #15181c;
}

.statusbar span:first-child {
  color: #aeb4bc;
}

.inspector label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin: 12px 0;
}

.inspector label input,
.inspector label select {
  display: block;
  width: 100%;
  margin-top: 5px;
}

.empty-inspector {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--muted);
  padding: 35px 8px;
}

.empty-inspector div {
  font-size: 34px;
  color: #555c65;
}

.empty-inspector strong {
  font-size: 12px;
  color: #c9cdd2;
  margin: 8px;
}

.empty-inspector span {
  font-size: 10px;
  line-height: 1.5;
}

.selection-card {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 8px;
  background: #20242a;
  border: 1px solid #303640;
}

.mini-tile {
  width: 48px;
  flex: 0 0 auto;
}

.selection-card div:last-child {
  min-width: 0;
}

.selection-card strong,
.selection-card > div:last-child > span {
  display: block;
}

.selection-card strong {
  font-size: 11px;
}

.selection-card > div:last-child > span {
  font-size: 9px;
  color: var(--muted);
  margin-top: 3px;
}

.marker-selection > span:first-child {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 0;
}

.marker-selection .marker-swatch > span {
  margin: 0;
  color: inherit;
  font-size: inherit;
  line-height: 1;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.field-note {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 7px;
}

.legend-section {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 18px;
}

.legend {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  color: #c9cdd2;
}

.legend-row .marker-swatch {
  width: 20px;
  height: 20px;
  font-size: 8px;
  border-width: 1px;
}

.legend-row span:last-child {
  color: var(--muted);
}

.legend-empty {
  color: var(--muted);
  font-size: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  z-index: 20;
  transform: translateX(-50%);
  padding: 9px 14px;
  border: 1px solid #5f6874;
  background: #20252c;
  box-shadow: 0 8px 30px #000b;
  border-radius: 4px;
  font-size: 11px;
}

.toast.error {
  border-color: #a63f45;
  color: #f3a7aa;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 240px minmax(480px, 1fr) 220px;
  }

  .left-sidebar .tab-panel {
    padding: 13px;
  }

  .document-actions .ghost {
    display: none;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .topbar {
    height: auto;
    min-height: 66px;
  }

  .app-shell {
    height: auto;
    display: block;
  }

  .sidebar {
    overflow: visible;
  }

  .left-sidebar,
  .inspector {
    border: 0;
  }

  .workspace {
    height: 70vh;
  }

  .document-actions {
    flex-wrap: wrap;
  }

  .tile-library {
    grid-template-columns: repeat(3, 1fr);
  }
}

.type-npc {
  background: #7f3f98;
}

.placed-tile {
  overflow: hidden;
}

.placed-tile .tile-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}
