/* Colours sampled from the in-game pause menu; Kollektif is the game's UI font (gui/fonts). */
@font-face {
  font-family: "Kollektif";
  src: url("fonts/Kollektif.ttf") format("truetype");
  font-display: swap;
}
:root {
  --bg: #171523;
  --surface-1: #201735;
  --surface-2: #15121a;
  --border-outer: #3f2142;
  --border: #805878;
  --border-hi: #ac7b85;
  --border-glow: #f7d4be;
  --title: #7c55a8;
  --ink: #f0e9e6;
  --ink-2: #c9bcc4;
  --ink-muted: #8e7f8c;
  --accent: #ac7b85;
  --ruler-bg: #131021;
  --ruler-tick: #5a4458;
  --ruler-hl: rgba(172, 123, 133, 0.32);
  --viewport-bg: #11121b;
  --font: "Kollektif", "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 var(--font);
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* bevelled double frame like the game's buttons */
.frame {
  border: 2px solid var(--border);
  box-shadow: 0 0 0 2px var(--border-outer), inset 0 0 0 1px #0d0a12;
  border-radius: 2px;
}

.sidebar {
  width: 360px; flex: none; overflow-y: auto;
  background: var(--surface-1); border-right: 2px solid var(--border-outer);
}
.side-section { padding: 12px 16px; border-bottom: 2px solid var(--border-outer); }
.side-section h3 {
  margin: 12px 0 8px; font-size: 14px; font-weight: 700; color: var(--title);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.side-section h3:first-child { margin-top: 0; }
.form { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; }
.form .ctl { display: contents; }
.form select { width: 100%; }
.view-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand-box { display: flex; flex-direction: column; }
.version { color: var(--ink-muted); font-size: 11px; font-family: var(--mono); }
.sample-label {
  position: absolute; left: 10px; bottom: 10px; pointer-events: none;
  color: var(--ink-muted); font-size: 12px; font-family: var(--mono);
}
button:disabled { opacity: 0.4; cursor: default; }
.brand {
  font-size: 20px; font-weight: 700; color: var(--title);
  letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  text-shadow: 0 2px 0 #0d0a12;
}
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctl { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.ctl > span { font-size: 13px; }
.ctl[hidden], .form .ctl[hidden] { display: none; }
#ctl-nest { margin-top: 10px; }
.sep { width: 2px; height: 24px; background: var(--border-outer); }

select, button {
  appearance: none;
  background: var(--surface-2);
  color: var(--ink);
  border: 2px solid var(--border);
  box-shadow: 0 0 0 2px var(--border-outer);
  border-radius: 2px;
  padding: 3px 10px;
  font: inherit;
  cursor: pointer;
}
select {
  padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--border-hi) 50%), linear-gradient(135deg, var(--border-hi) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 8px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
select:hover, button:hover { border-color: var(--border-hi); }
select:focus-visible, button:focus-visible, input:focus-visible {
  outline: none;
  border-color: var(--border-glow);
  box-shadow: 0 0 0 2px var(--border-hi);
}
option { background: var(--surface-2); color: var(--ink); }
input[type=range] { width: 76px; accent-color: var(--border-hi); }
.toggle input { accent-color: var(--border-hi); }

.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 8px 3px 4px; font-size: 14px; color: var(--ink-muted); min-height: 36px;
  text-align: left;
  border-color: var(--border-outer);
  box-shadow: 0 0 0 2px #1a1226;
  user-select: none;
}
.chip .ico { flex: none; width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; opacity: 0.45; filter: saturate(0.4); }
.chip .ico-blank { width: 28px; height: 28px; flex: none; }
.chip .sw { width: 8px; height: 8px; opacity: 0.3; margin-left: auto; flex: none; }
.chip[aria-pressed=true] .ico { opacity: 1; filter: none; }
.chip[aria-pressed=true] { color: var(--ink); border-color: var(--border-hi); box-shadow: 0 0 0 2px var(--border-outer), inset 0 0 0 1px rgba(247, 212, 190, 0.25); }
.chip[aria-pressed=true] .sw { opacity: 1; }

.viewer {
  position: relative; flex: 1; min-width: 0;
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: 26px 1fr;
}
.ruler { background: var(--ruler-bg); display: block; }
.ruler.top { grid-column: 2; grid-row: 1; width: 100%; height: 26px; border-bottom: 2px solid var(--border-outer); }
.ruler.left { grid-column: 1; grid-row: 2; width: 44px; height: 100%; border-right: 2px solid var(--border-outer); }
.corner {
  grid-column: 1; grid-row: 1; background: var(--ruler-bg);
  border-right: 2px solid var(--border-outer); border-bottom: 2px solid var(--border-outer);
  color: var(--ink-muted); font-size: 11px; display: flex; align-items: center; justify-content: center;
}
.viewport {
  grid-column: 2; grid-row: 2; position: relative; overflow: hidden;
  cursor: grab; touch-action: none; background: var(--viewport-bg);
}
.viewport.dragging { cursor: grabbing; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage img, .stage canvas { position: absolute; left: 0; top: 0; display: block; }
.stage img { image-rendering: pixelated; }
.stage img.hidden { visibility: hidden; }
.hover-tile {
  position: absolute; pointer-events: none;
  box-shadow: 0 0 0 1.5px var(--border-glow), 0 0 0 3px rgba(13, 10, 18, 0.7);
  display: none;
}

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(32, 23, 53, 0.97);
  border: 2px solid var(--border);
  box-shadow: 0 0 0 2px var(--border-outer), 0 8px 18px rgba(0, 0, 0, 0.5);
  border-radius: 2px; padding: 8px 10px; min-width: 190px;
}
.tooltip .tt-head { font-size: 14px; color: var(--ink); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.tooltip .tt-row .sw { width: 8px; height: 8px; flex: none; }
.tooltip .tt-row .v { margin-left: auto; color: var(--ink); font-family: var(--mono); font-size: 12px; }
.loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-2); background: rgba(17, 18, 27, 0.6); font-size: 16px;
}
.loading[hidden] { display: none; }

.zoom-ctl { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 8px; }
.zoom-ctl button { min-width: 34px; height: 30px; }

.note { color: var(--ink-2); }
.note strong { color: var(--ink); }
.legend-item { margin-bottom: 10px; }
.legend-item .lbl { display: flex; align-items: center; gap: 6px; color: var(--ink); margin-bottom: 4px; }
.legend-item .lbl .sw { width: 10px; height: 10px; }
.legend-item .ramp { height: 8px; border: 1px solid var(--border-outer); }
.legend-item .scale { display: flex; justify-content: space-between; color: var(--ink-muted); font-size: 12px; margin-top: 2px; }
.legend-item .scale span:first-child, .legend-item .scale span:last-child { font-family: var(--mono); font-size: 11px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.stats-table th, .stats-table td { white-space: nowrap; }
.stats-table th { text-align: right; color: var(--ink-muted); font-weight: 400; padding: 2px 4px; font-size: 13px; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table td { text-align: right; padding: 3px 4px; font-family: var(--mono); color: var(--ink); border-top: 1px solid var(--border-outer); }
.stats-block { margin-bottom: 12px; }
.stats-block .t { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.stats-block .t .sw { width: 10px; height: 10px; }
.about { color: var(--ink-muted); font-size: 13px; }
.about b { color: var(--ink-2); font-weight: 600; }

@media (max-width: 820px) {
  body { flex-direction: column; overflow: auto; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 2px solid var(--border-outer); overflow: visible; }
  .viewer { height: 75vh; flex: none; }
}
