:root {
  --bg: #14161a;
  --panel: #1b1e24;
  --line: #2c313a;
  --ink: #e7e9ee;
  --dim: #98a0ae;
  --accent: #d99a3a;
  --danger: #d66;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header h1 { margin: 0; font-size: 22px; letter-spacing: .2px; }
header p { margin: 4px 0 0; color: var(--dim); max-width: 60ch; }

.coffee {
  background: var(--accent);
  color: #14161a;
  font-weight: 600;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 8px;
  white-space: nowrap;
}
.coffee:hover { filter: brightness(1.08); }

main { max-width: 1100px; margin: 0 auto; padding: 24px 28px 60px; }

.step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.step h2 { margin: 0 0 12px; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.num {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--line);
  color: var(--dim);
  font-size: 13px;
}

.hint { color: var(--dim); font-size: 13px; margin: 8px 0; max-width: 78ch; }
.hint code { background: #0e1013; padding: 1px 5px; border-radius: 4px; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}
.controls label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); }

button, .button, select, input[type="number"] {
  background: #262b34;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #14161a; border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }

.drop {
  display: block;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--dim);
  cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--ink); }

.readout { color: var(--dim); font-size: 13px; }

/* A preview is a window onto a canvas that is usually bigger than it: the
   canvas keeps its own resolution and a transform moves it about. */
.preview {
  position: relative;
  margin-top: 12px;
  overflow: hidden;
  height: 55vh;
  min-height: 240px;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
}
.preview.dragging { cursor: grabbing; }
.zoom-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.preview canvas { display: block; image-rendering: pixelated; }

.zoom-controls {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: rgba(10, 12, 15, .82);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: default;
}
.zoom-controls button { padding: 2px 8px; font-size: 13px; line-height: 1.2; }
.zoom-readout {
  min-width: 46px;
  text-align: center;
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.theme-labels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.label-slot b {
  display: block;
  color: var(--dim);
  font-weight: 500;
  font-size: 11px;
  margin-bottom: 3px;
}
/* How many pieces this label draws from, when it draws from more than one. */
.label-slot b small {
  display: inline-block;
  min-width: 14px;
  padding: 0 4px;
  border-radius: 7px;
  background: #1d2a1f;
  color: #4ade80;
  text-align: center;
}
.label-slot.open .asset-card { border-color: var(--accent); }

/* A label's pieces sit side by side and wrap: one is the common case, several
   is the point of the thing. */
.label-assets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.label-assets .asset-card { width: 62px; }
.label-assets .asset-art { height: 40px; font-size: 15px; }

.asset-card {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: #0e1013;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
}
.asset-card:hover { border-color: var(--accent); }
.asset-card.chosen { border-color: #4ade80; }
.asset-card.add {
  justify-content: center;
  color: var(--dim);
  font-size: 18px;
  border-style: dashed;
}
/* Takes a piece back off a label. Its own target, so the card underneath still
   opens the picker. */
.asset-drop {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  line-height: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #16181d;
  color: var(--dim);
  font-size: 12px;
}
.asset-drop:hover { color: #f87171; border-color: #f87171; }
.asset-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 58px;
  background: #16181d;
  border-radius: 4px;
  color: var(--dim);
  font-size: 20px;
  overflow: hidden;
}
.asset-art img, .asset-art canvas, .asset-art svg {
  max-width: 100%;
  max-height: 100%;
  display: block;
}
/* A window onto the game's own icon atlas: its size is set on the element, so
   nothing here may stretch or shrink it. */
.asset-art .asset-icon { flex: none; }
.asset-name {
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.picker {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #0b0d10;
}
.picker-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.picker-head b { flex: 1; font-size: 13px; }
.picker-search { flex: 1; min-width: 120px; }
.picker-group, .picker-size { max-width: 140px; }
.picker-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
  margin-top: 8px;
  max-height: 42vh;
  overflow-y: auto;
}

/* The built map, with each section's button standing on the piece of map it
   builds. A list of buttons beside the picture would say "3,1" twenty times
   and leave you counting rows to find the one you want. */
.slab-map {
  position: relative;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}
.slab-map canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.sections { position: absolute; inset: 0; }
.sections .slab {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(14, 16, 19, .82);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 12px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
}
.sections .slab:hover { border-color: var(--accent); color: var(--accent); }
.sections .slab.copied { border-color: #4ade80; color: #4ade80; }
.sections .slab.empty { opacity: .3; cursor: default; }

footer {
  border-top: 1px solid var(--line);
  padding: 18px 28px 40px;
  color: var(--dim);
  font-size: 13px;
  text-align: center;
}
footer a { color: var(--accent); }

.packs { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0; }
.packs label { display: flex; align-items: center; gap: 6px; font-size: 13px; }

details#packs-box { margin-top: 10px; }
details#packs-box summary { cursor: pointer; color: var(--dim); font-size: 13px; }

/* Inside TaleSpire the page is a panel in a game, not a site: the parts that
   exist to explain the site to a stranger only take up room there. */
body.in-talespire header p,
body.in-talespire footer { display: none; }
body.in-talespire { font-size: 14px; }

/* Only meaningful inside the game, where there is no file dialog. */
#upload-note, #upload-diagnostics { display: none; }
body.in-talespire #upload-note,
body.in-talespire #upload-diagnostics { display: block; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 11px; opacity: .7; }

.banner {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid #f87171;
  border-left-width: 4px;
  border-radius: 6px;
  background: rgba(248, 113, 113, .08);
  color: #fca5a5;
  font-size: 13px;
}
#what-talespire-said { margin: 0 0 14px; }
#what-talespire-said summary { cursor: pointer; color: var(--dim); font-size: 12px; }
#pack-dump { white-space: pre-wrap; word-break: break-all; margin-top: 6px; }
