:root {
  --bg: #0e1418;
  --panel: #162027;
  --line: #2a3a44;
  --text: #e6e0d4;
  --dim: #8fa0a8;
  --accent: #c8a85a;
  --danger: #d0574f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 Oswald, system-ui, sans-serif; }
button, select, input, textarea { font: inherit; color: inherit; }
button, select, .file {
  background: #1f2c34; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
button:hover, .file:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #1b1408; border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
.file input { display: none; }
a.file { color: inherit; text-decoration: none; }

.top { padding: 14px 20px 6px; display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.top h1 { font: 800 26px Cinzel, serif; margin: 0; letter-spacing: .06em; color: var(--accent); }
.top h1 a.logo { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; }
.top h1 a.logo svg { width: 28px; height: 28px; flex: none; }
.top h1 span { font: 400 14px Oswald, sans-serif; color: var(--dim); letter-spacing: .2em; text-transform: uppercase; margin-left: 8px; }
.hint { margin: 0; color: var(--dim); }
.top .site-nav { order: 2; margin-left: auto; }
.top .site-nav a { color: var(--accent); }
.share-gallery { margin-top: 10px; }
/* links to the site's own pages: hidden in the file version */
.site-only { display: none; }
body.on-site .site-only { display: inline; }

main { display: grid; grid-template-columns: 360px 1fr; gap: 16px; padding: 16px 20px; align-items: start; }


.side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; }
.row select { flex: 1; min-width: 0; }
textarea { width: 100%; height: 200px; resize: vertical; background: #0c1216; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: 12px/1.4 ui-monospace, monospace; }
.summary { margin: 0; color: var(--dim); min-height: 1.4em; }
.summary b { color: var(--text); }

.units { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow: auto; }
.units li { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.units li:hover { border-color: var(--line); background: #1a262e; }
.units li.sel { border-color: var(--accent); }
.units li.off { opacity: .45; }
.units .th { width: 44px; height: 44px; border-radius: 4px; background: #0c1216 center/contain no-repeat; display: grid; place-items: center; color: var(--dim); font-size: 18px; }
.units .nm { min-width: 0; }
.units .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.units .nm span { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.units .st { font-size: 12px; color: var(--dim); }
.units .st.miss { color: var(--danger); }
.units .eye { background: none; border: 0; padding: 2px 4px; color: var(--dim); }

.settings summary { cursor: pointer; color: var(--dim); }
.settings label { display: block; margin-top: 8px; }
.settings input { width: 100%; background: #0c1216; border: 1px solid var(--line); border-radius: 6px; padding: 6px; font: 12px ui-monospace, monospace; }
.small { font-size: 12px; color: var(--dim); }

.stage { min-width: 0; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { background: var(--accent); color: #1b1408; border-color: var(--accent); }
.tog { display: inline-flex; gap: 4px; align-items: center; color: var(--dim); }
#shuffle { margin-left: auto; }
#bgColor { width: 36px; height: 32px; padding: 2px; background: #1f2c34; border: 1px solid var(--line); border-radius: 6px; }
#bgDim { width: 90px; }
.canvas-wrap { position: relative; background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
/* a finger on the board scrolls the page, unless a miniature is selected: then it moves it */
#board { display: block; width: 100%; height: auto; touch-action: pan-y pinch-zoom; }
#board.held { touch-action: none; }
#board.grab { cursor: grab; }
#board.drag { cursor: grabbing; }
/* one line of text in the middle (its words in one span: a grid would make each bold word its own row) */
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-size: 16px; pointer-events: none; text-align: center; padding: 16px; }
.selbar { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.selbar b { margin-right: 6px; }
.selbar button.danger { color: var(--danger); }
.undobar { display: flex; gap: 10px; align-items: center; margin-top: 8px; padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; width: fit-content; }
.units .del { background: none; border: 0; padding: 2px 6px; color: var(--dim); font-size: 15px; line-height: 1; }
.units .del:hover { color: var(--danger); }
.units .acts { display: inline-flex; align-items: center; }
.foot { margin-top: 8px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; width: min(760px, calc(100vw - 32px)); padding: 14px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.pick-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 18px; }
.pick-head button { padding: 2px 10px; }
.pick-search, .pick-own { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.pick-white { margin-top: 10px; display: flex; }
.pick-pieces { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-pieces button { padding: 4px; background: #0c1216; border: 2px solid var(--accent); display: grid; place-items: center; min-width: 70px; min-height: 70px; }
.pick-pieces button.off { border-color: var(--line); opacity: .35; }
.pick-pieces canvas { display: block; max-width: 110px; max-height: 110px; }
.pick-search input, .pick-own input[type=url] { flex: 1; min-width: 160px; background: #0c1216; border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.pick-kits, .pick-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.pick-kits button, .pick-pics button { padding: 4px; display: flex; flex-direction: column; gap: 4px; align-items: center; background: #f4f4f2; color: #222; border: 2px solid transparent; }
.pick-kits button.on, .pick-pics button.on { border-color: var(--accent); }
.pick-kits img, .pick-pics img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.pick-kits span { font-size: 11px; line-height: 1.2; text-align: center; }
h4 { margin: 12px 0 6px; color: var(--dim); font-weight: 400; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }

/* phones and touch screens: last, so these win over the rules above */
/* one column; minmax(0, ...) so a long unit name never makes the page wider than a phone */
@media (max-width: 900px) {
  main { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  /* the picture right under the Build button, the unit list after it */
  .side { display: contents; }
  .side > * { order: 0; }
  .side > #summary, .side > #units, .side > .settings { order: 2; }
  .stage { order: 1; }
  .units { max-height: none; }
}
/* touch screens: a finger needs about 40 px */
@media (pointer: coarse) {
  button, select, .file, .tog { min-height: 40px; }
  .tog input { width: 20px; height: 20px; }
  .units .eye { padding: 10px 12px; }
  .units .del { padding: 10px 10px; }
  .units li { padding: 6px; }
  .top .site-nav a { display: inline-block; padding: 10px 0; }
}
