@font-face {
  font-family: BoldPixels;
  src: url('./assets/boldpixels.woff2') format('woff2');
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #17131f;
  color: #f3e9dc;
  --line: #4b3e55;
  --surface: #231c2d;
  --muted: #bfafc5;
  --gold: #ffca87;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse at 72% 0, #352338, #17131f 800px); }
button, select { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
a { color: var(--gold); }
button, select {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #2d2439;
  min-height: 38px;
  padding: 6px 10px;
}
button:disabled { opacity: .5; cursor: default; }
button:hover:not(:disabled) { border-color: #a4839c; }
button[aria-pressed='true']:not(.tile) { color: var(--gold); background: #413044; border-color: #b48b78; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1, h2 { font-family: BoldPixels, monospace; font-weight: 400; }
h1 { margin-top: 9px; font-size: clamp(38px, 7vw, 64px); line-height: .98; color: #ffe1b7; }
h2 { font-size: 24px; }

.editor { max-width: 1120px; padding: 28px clamp(12px, 3vw, 34px) 28px; margin-inline: auto; }
.masthead, .panel-heading, .selection { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.masthead { flex-wrap: wrap; align-items: end; }
.back { font-size: 14px; text-underline-offset: 4px; }
.file-actions, .zoom-controls, #tile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.primary { border-color: #ffc784; color: #2b1c2e; background: var(--gold); font-weight: 650; }
.primary:hover:not(:disabled) { background: #ffdfa9; }
dialog {
  width: min(34rem, calc(100% - 24px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  background: var(--surface);
}
dialog::backdrop { background: #12101acc; }
dialog form, dialog fieldset { display: grid; gap: 8px; }
dialog form { margin-top: 12px; }
dialog fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
dialog label { font-size: 14px; }
dialog textarea {
  width: 100%;
  min-height: 5em;
  padding: 8px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #17131f;
  color: inherit;
  font: 14px monospace;
}
dialog .status { margin: 0; }

.workspace { display: grid; grid-template-columns: 245px minmax(0, 1fr); gap: 12px; align-items: start; }
.tools, .map-panel { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.tools { display: grid; gap: 10px; }
.brushes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.brushes button { display: flex; align-items: center; gap: 6px; justify-content: start; font-size: 13px; padding-inline: 7px; text-align: left; }
.brushes i { display: inline-grid; place-items: center; flex: 0 0 13px; height: 13px; font-size: 11px; line-height: 1; color: var(--gold); font-style: normal; }
.inspect-mark { border: 1px dashed currentColor; }
.wall-mark { background: #14121d; border: 1px solid #66576b; }
.floor-mark { background: #77617c; }
.gate-mark { background: repeating-linear-gradient(90deg, #b78d6c 0 2px, #342732 2px 4px); }
.candle-mark::before { content: ''; width: 5px; height: 10px; background: #ff8297; box-shadow: 0 -2px #ffde9a; }
.brush-option { display: grid; gap: 5px; font-size: 14px; }
.brush-option select { width: 100%; }
#brush-help, .draft-actions, .extra-tools, .dimensions { color: var(--muted); font-size: 13px; }
.extra-tools .brushes { margin-top: 7px; }
.draft-actions button { margin-top: 7px; }
.draft-actions > label { margin-top: 8px; }
.resize-map { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; margin-top: 8px; }
.resize-map input { width: 100%; min-width: 0; min-height: 38px; padding: 4px 6px; font: inherit; color: inherit; background: #2d2439; border: 1px solid var(--line); border-radius: 5px; }
.resize-map button { grid-column: 1 / -1; }

.map-panel { min-width: 0; }
.map-panel .panel-heading { padding-bottom: 9px; }
.map-panel .panel-heading > div:first-child { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.zoom-controls { flex: none; }
.zoom-controls button { min-width: 38px; }
.map-viewport {
  height: min(67svh, var(--plan-height, 600px));
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #47394e;
  background: #12101a;
}
.map-viewport.is-fit { height: var(--plan-height); overflow: hidden; overscroll-behavior: auto; }
.is-fit .floor-plan { margin-inline: auto; }
.floor-plan {
  display: grid;
  width: max-content;
  grid-template-columns: repeat(var(--columns), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
  user-select: none;
  -webkit-user-select: none;
}
.tile {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: inset -1px -1px #0f0d1940;
  background: #1d1827;
  color: var(--marker, #f7e9cd);
  font-size: max(5px, calc(var(--cell) * .68));
  font-weight: 750;
  line-height: 1;
}
.tile[data-region='0'] { background: #78604f; }
.tile[data-region='1'] { background: #465874; }
.tile[data-region='2'] { background: #426660; }
.tile[data-region='3'] { background: #655075; }
.tile[data-region='4'] { background: #77505d; }
.tile[data-gate] { background: repeating-linear-gradient(90deg, var(--marker) 0 2px, #292032 2px 5px); }
.tile[data-gate] span { padding: 0 min(2px, calc(var(--cell) * .1)); background: #1d1525; }
.tile:hover { box-shadow: inset 0 0 0 1px #fce5bc; }
.tile[aria-pressed='true'], .tile:focus-visible { z-index: 1; outline: 2px solid #fff4d8; outline-offset: -2px; }
.tile span { pointer-events: none; text-shadow: 0 1px #1b1423, 1px 0 #1b1423, -1px 0 #1b1423, 0 -1px #1b1423; }
.selection { min-height: 60px; flex-wrap: wrap; padding-top: 8px; }
#tile-location { font-weight: 650; font-variant-numeric: tabular-nums; }
#tile-contents { font-size: 13px; color: var(--muted); }
#tile-actions button { font-size: 13px; }
.map-issues { margin-top: 8px; color: #ffd19c; font-size: 13px; }
.status { margin-block: 6px 11px; min-height: 1.3em; font-size: 13px; color: var(--muted); }
.status[data-error] { color: #ffb0b7; }

@media (max-width: 700px) {
  .editor { padding-top: 16px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .tools, .map-panel { padding: 8px; }
  .brushes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tools { gap: 6px; }
}
@media (pointer: coarse) {
  button:not(.tile), select { min-height: 44px; }
}
