@font-face {
  font-family: "IM Fell English";
  src: url("fonts/IMFellEnglish.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Jost";
  src: url("fonts/Jost-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* The painting sets the colour of the world; the chrome only has to sit on it and read.
   Light = vellum and iron-gall ink. Dark = a lamp-lit war tent. */
:root {
  --page: #d9cdb4;
  --panel: rgba(249, 244, 233, 0.95);
  --panel-edge: rgba(74, 52, 30, 0.28);
  --ink: #241a12;
  --ink-soft: #57452f;
  --chip: rgba(250, 245, 233, 0.9);
  --chip-ink: #241a12;
  --accent: #9a3a12;
  --accent-ink: #fff8ee;
  --focus: #1d5f9e;
  --teal: #11615b;
  --teal-deep: #0b3f3b;
  --gold: #7d5600;
  --target: #a8261b;
  --scout: #1f5d96;
  --danger: #b45f06;
  --note: #3d3227;
  --shadow: 0 6px 22px rgba(36, 22, 8, 0.24);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #1b1714;
    --panel: rgba(27, 23, 19, 0.95);
    --panel-edge: rgba(240, 214, 170, 0.18);
    --ink: #f1e8d8;
    --ink-soft: #cdbda4;
    --chip: rgba(27, 22, 17, 0.86);
    --chip-ink: #f6eedf;
    --accent: #e0864f;
    --accent-ink: #1b1209;
    --focus: #8cc4ff;
    --teal: #5cc0b5;
    --teal-deep: #0e4a45;
    --gold: #e2b24d;
    --target: #ff7a6b;
    --scout: #7db8f0;
    --danger: #f2a54a;
    --note: #e9dcc6;
    --shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page: #1b1714;
  --panel: rgba(27, 23, 19, 0.95);
  --panel-edge: rgba(240, 214, 170, 0.18);
  --ink: #f1e8d8;
  --ink-soft: #cdbda4;
  --chip: rgba(27, 22, 17, 0.86);
  --chip-ink: #f6eedf;
  --accent: #e0864f;
  --accent-ink: #1b1209;
  --focus: #8cc4ff;
  --teal: #5cc0b5;
  --teal-deep: #0e4a45;
  --gold: #e2b24d;
  --target: #ff7a6b;
  --scout: #7db8f0;
  --danger: #f2a54a;
  --note: #e9dcc6;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 400 15px/1.45 "Jost", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#map.placing { cursor: crosshair; }
#overlay { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- masthead & toolbar -------------------------------------------------- */
.masthead {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 16px;
  padding: 10px 16px 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--panel-edge); box-shadow: var(--shadow);
  pointer-events: none; max-width: calc(100vw - 32px);
}
.kicker { margin: 0; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-soft); }
h1 { margin: 2px 0 0; font: 400 26px/1.05 "IM Fell English", Georgia, serif; }
h1 span { font-style: italic; color: var(--accent); }

.toolbar {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: 16px;
  display: flex; gap: 6px; padding: 6px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--panel-edge); box-shadow: var(--shadow);
}
.tool {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 9px; background: transparent; cursor: pointer;
  color: var(--ink); white-space: nowrap;
}
.tool svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.tool:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.tool[aria-pressed="true"], .tool[aria-expanded="true"] { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.tool.primary { background: var(--accent); color: var(--accent-ink); }
/* Hide war / Show war: the icon names what a tap does */
#btnWar .eye-open, #btnWar[aria-pressed="true"] .eye-shut { display: none; }
#btnWar[aria-pressed="true"] .eye-open { display: inline; }
.tool.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.tool.primary[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; background: var(--accent); }
.link { border: 0; background: none; padding: 8px 6px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.icon-btn { border: 0; background: none; font-size: 26px; line-height: 1; width: 40px; height: 40px; cursor: pointer; color: var(--ink-soft); border-radius: 8px; }

/* ---- panels --------------------------------------------------------------- */
.panel {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--panel-edge); border-radius: var(--radius); box-shadow: var(--shadow);
}
h2 { margin: 0 0 8px; font: 400 21px/1.15 "IM Fell English", Georgia, serif; }
h3 { margin: 14px 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); font-weight: 400; }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--ink-soft); }

.layers { position: fixed; top: calc(max(14px, env(safe-area-inset-top)) + 64px); right: 16px; width: 270px; padding: 14px 16px; }
.looks { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--panel-edge); }
.layers label { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.layers input { width: 18px; height: 18px; accent-color: var(--accent); }
.dm-row { margin-top: 6px; border-top: 1px solid var(--panel-edge); padding-top: 4px; }

.board {
  position: fixed; top: calc(max(14px, env(safe-area-inset-top)) + 64px); right: 16px; bottom: 56px;
  width: 330px; padding: 12px 16px 16px; overflow: auto;
}
.board-head { display: flex; align-items: center; justify-content: space-between; }
.board-head h2 { margin: 0; }
.board-list { list-style: none; margin: 0; padding: 0; }
.board-list li button {
  width: 100%; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  text-align: left; padding: 7px 6px; border: 0; border-radius: 8px; background: none; cursor: pointer;
}
.board-list li button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.board-list .glyph { width: 24px; height: 24px; }
.board-list .who { font-size: 14px; }
.board-list .sub { display: block; font-size: 12px; color: var(--ink-soft); }
.tag { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; border: 1px solid currentColor; color: var(--ink-soft); }
.tag.standing { color: var(--teal); }
.tag.struck { color: var(--target); }
.tag.confirmed { color: var(--gold); }

.card {
  position: fixed; left: 16px; bottom: 56px; width: 340px; max-width: calc(100vw - 32px);
  padding: 14px 16px 12px;
}
.card .row { display: flex; gap: 10px; align-items: flex-start; }
.card .glyph { width: 30px; height: 30px; flex: none; }
.card h2 { margin: 0; }
.card .meta { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }
.card .body { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.card dl { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 14px; }
.card dt { color: var(--ink-soft); }
.card dd { margin: 0; }
.card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.card .actions button {
  min-height: 36px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--panel-edge); background: color-mix(in srgb, var(--ink) 5%, transparent);
}
.card .actions button.danger { color: var(--target); }
.card .close { position: absolute; top: 4px; right: 4px; }

.banner {
  position: fixed; left: 50%; top: calc(max(14px, env(safe-area-inset-top)) + 70px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; border-radius: 99px;
  background: var(--ink); color: var(--page); box-shadow: var(--shadow); white-space: nowrap;
}
.banner .link { color: var(--page); }

.status {
  position: fixed; left: 16px; bottom: max(12px, env(safe-area-inset-bottom)); margin: 0;
  padding: 5px 11px; border-radius: 99px; font-size: 13px;
  background: var(--panel); border: 1px solid var(--panel-edge); color: var(--ink-soft);
}
.status::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--ink-soft); vertical-align: 1px; }
.status.live::before { background: #2f9e54; }
.status.off::before { background: var(--danger); }

/* ---- dialogs -------------------------------------------------------------- */
.dialog { width: min(420px, calc(100vw - 32px)); padding: 18px 20px; }
.dialog::backdrop { background: rgba(20, 12, 4, 0.42); }
.field { display: grid; gap: 4px; margin-top: 12px; }
.field > span { font-size: 13px; color: var(--ink-soft); }
.field input, .field textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--panel-edge);
  background: color-mix(in srgb, var(--page) 35%, var(--panel)); color: var(--ink);
}
.field input::placeholder { color: var(--ink-soft); opacity: .8; }
.types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; border: 0; margin: 4px 0 0; padding: 0; }
.types legend { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; padding: 0; }
.type { position: relative; display: grid; place-items: center; gap: 2px; padding: 34px 4px 7px; border-radius: 9px; border: 1px solid var(--panel-edge); cursor: pointer; font-size: 13px; }
.type input { position: absolute; opacity: 0; pointer-events: none; }
.type::before { content: ""; position: absolute; top: 8px; left: 50%; width: 22px; height: 22px; transform: translateX(-50%); background: currentColor; -webkit-mask: var(--glyph) center / contain no-repeat; mask: var(--glyph) center / contain no-repeat; }
.type:has(input:checked) { background: color-mix(in srgb, currentColor 14%, transparent); border-color: currentColor; }
.type:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.t-target { color: var(--target); --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 2h2v3.1A7 7 0 0 1 18.9 11H22v2h-3.1A7 7 0 0 1 13 18.9V22h-2v-3.1A7 7 0 0 1 5.1 13H2v-2h3.1A7 7 0 0 1 11 5.1V2Zm1 5a5 5 0 1 0 0 10 5 5 0 0 0 0-10Zm0 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4Z'/%3E%3C/svg%3E"); }
.t-scout { color: var(--scout); --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5c5 0 9 4.5 10 7-1 2.5-5 7-10 7S3 14.5 2 12c1-2.5 5-7 10-7Zm0 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm0 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4Z'/%3E%3C/svg%3E"); }
.t-danger { color: var(--danger); --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 23 21H1L12 2Zm-1 7v6h2V9h-2Zm0 8v2h2v-2h-2Z'/%3E%3C/svg%3E"); }
.t-note { color: var(--note); --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.7 3.3c-4.6.2-9.4 3-12.2 7.7L6 16.2l-2.4 4.4 1.8.9 2-3.7c3.3-.2 6.1-1.9 7.6-4.4h-3.6l4.5-2.2c1.4-1.6 2.6-4 4.8-7.9Z'/%3E%3C/svg%3E"); }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 16px; }
.error { margin: 10px 0 0; color: var(--target); font-size: 14px; }

/* ---- things on the map ----------------------------------------------------- */
.lbl {
  position: absolute; left: 0; top: 0; will-change: transform, opacity;
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
  transition: opacity .25s;
}
.lbl .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chip-ink); border: 1.5px solid var(--chip); flex: none; }
.lbl .txt {
  font-family: "IM Fell English", Georgia, serif; color: var(--chip-ink);
  background: var(--chip); padding: 1px 7px 2px; border-radius: 5px; line-height: 1.15;
}
.lbl.t1 .txt { font-size: 18px; }
.lbl.t2 .txt { font-size: 16px; }
.lbl.t3 .txt { font-size: 14.5px; }
.lbl.region .dot { display: none; }
.lbl.region .txt { font-size: 14px; letter-spacing: .22em; text-transform: uppercase; font-style: italic; background: color-mix(in srgb, var(--chip) 78%, transparent); }

/* On a game ground the names are lettered onto the map itself: cream letters on a dark halo, the
   same in light and dark because they belong to the map, not to the page. The halo is the
   backplate the contrast check measures. */
:root { --letter: #f7eedb; --halo: rgba(18, 12, 6, 0.96); }
body.towns .lbl .dot { display: none; }
body.towns .lbl .txt {
  background: none; padding: 0 2px; color: var(--letter);
  /* a solid ~2.5 px outline (offsets at 1 and 2 px), then a glow so the letters own their patch of map.
     tools/contrast.py measures the band 1-3 px outside each glyph: this is what covers it */
  text-shadow: 1px 0 0 var(--halo), -1px 0 0 var(--halo), 0 1px 0 var(--halo), 0 -1px 0 var(--halo),
    1px 1px 0 var(--halo), -1px 1px 0 var(--halo), 1px -1px 0 var(--halo), -1px -1px 0 var(--halo),
    2px 0 1px var(--halo), -2px 0 1px var(--halo), 0 2px 1px var(--halo), 0 -2px 1px var(--halo),
    1.5px 1.5px 1px var(--halo), -1.5px 1.5px 1px var(--halo), 1.5px -1.5px 1px var(--halo), -1.5px -1.5px 1px var(--halo),
    0 0 3px var(--halo), 0 0 4px var(--halo), 0 0 5px var(--halo), 0 0 6px var(--halo), 0 1px 7px var(--halo), 0 0 12px rgba(18, 12, 6, 0.6);
}
/* and a soft pool of shadow under the word (no edge, no shape): the counters of small serif letters
   are 1-2 px, too narrow for an outline, and showed bright grass through them */
body.towns .lbl .txt { position: relative; z-index: 0; }
body.towns .lbl .txt::before {
  content: ""; position: absolute; inset: -2px -9px; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(18, 12, 6, 0.66), rgba(18, 12, 6, 0.5) 62%, rgba(18, 12, 6, 0) 100%);
  filter: blur(2px);
}
body.towns .lbl.t1 .txt { font-size: 20px; font-variant: small-caps; letter-spacing: .04em; }
body.towns .lbl.t2 .txt { font-size: 16.5px; }
body.towns .lbl.t3 .txt { font-size: 15px; }
.regions { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.rtxt {
  font-family: "IM Fell English", Georgia, serif; font-style: italic; font-size: 15px; letter-spacing: .26em;
  /* 7.5 px of halo (3.75 px beyond the glyph): on the Bright Continent's snow the old 5.5 px let white reach 2-3 px
     from the letters between the wide-spaced glyphs (Ansied Mountains measured 1.5:1 on the front view) */
  fill: var(--letter); stroke: var(--halo); stroke-width: 7.5px; stroke-linejoin: round; paint-order: stroke fill;
  filter: drop-shadow(0 0 3px rgba(18, 12, 6, 0.95));
  visibility: hidden; transition: opacity .25s;
}
.rtxt.measure { visibility: hidden; }

.pin {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  display: grid; justify-items: center; gap: 2px; padding: 0; border: 0; background: none; color: inherit;
  will-change: transform;
}
.pin .glyph { width: 34px; height: 34px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); }
.pin .name {
  font: 400 13px/1.15 "Jost", system-ui, sans-serif; color: var(--chip-ink); background: var(--chip);
  padding: 2px 7px 3px; border-radius: 5px; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
.pin.selected .glyph { transform: scale(1.18); }
.pin.noname .name { visibility: hidden; }
.pin.noname:hover .name, .pin.noname:focus-visible .name { visibility: visible; position: relative; z-index: 2; }
.pin.selected .name { outline: 2px solid var(--accent); }
.pin.piece .name { font-family: "IM Fell English", Georgia, serif; font-size: 14.5px; }
.pin.struck .name { text-decoration: line-through; text-decoration-thickness: 2px; }
.pin.struck .glyph { filter: grayscale(.9) drop-shadow(0 2px 3px rgba(0,0,0,.45)); opacity: .82; }
.pin.facedown .name { font-style: italic; }
.pin.camp .glyph { width: 40px; height: 40px; }

/* ---- the war set (Layers → War pieces): chunky tokens and name plates that belong to the map,
   so they are the same in light and dark. Plates are solid: their text never sits on the ground. */
.pin .glyph.tok { width: var(--gw); height: var(--gh); filter: drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
.pin.struck .glyph.tok { filter: drop-shadow(0 3px 3px rgba(0,0,0,.5)); opacity: 1; }
.pin .glyph.tok { transition: transform .12s ease-out; transform-origin: 50% 92%; }
.pin:hover .glyph.tok, .pin:focus-visible .glyph.tok { transform: translateY(-3px) scale(1.06); }
.pin.selected .glyph.tok { transform: translateY(-3px) scale(1.14); }
.board-list .glyph.tok { width: 26px; height: 34px; }
.board-list li button { grid-template-columns: 28px 1fr auto; }
.card .glyph.tok { width: 40px; height: 48px; }
.card .camp-img { width: 64px; height: 46px; object-fit: contain; flex: none; }
body[data-set] .pin.piece .name, body[data-set] .pin.camp .name { max-width: 220px; }
body[data-set="warhost"] .pin.piece .name, body[data-set="warhost"] .pin.camp .name {
  font: 400 15px/1.15 "IM Fell English", Georgia, serif; font-variant: small-caps; letter-spacing: .03em;
  color: #f8ebc9; background: linear-gradient(#33281c, #171009); border: 1.5px solid #c9a24a; border-radius: 3px;
  padding: 2px 10px 4px; box-shadow: 0 2px 6px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,235,190,.16);
}
body[data-set="warhost"] .pin.camp .name { color: #2a1a06; background: linear-gradient(#f3d78c, #c99a3e); border-color: #4a2e0c; box-shadow: 0 2px 6px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,250,225,.6); }
body[data-set="table"] .pin.piece .name, body[data-set="table"] .pin.camp .name {
  font: 400 12px/1.25 "Jost", system-ui, sans-serif; text-transform: uppercase; letter-spacing: .14em;
  color: #f7e4b8; background: linear-gradient(#55361d, #2b190b); border: 2px solid #c39443; border-radius: 99px;
  padding: 3px 12px; box-shadow: 0 2px 6px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,225,160,.18);
}
body[data-set="table"] .pin.camp .name { background: linear-gradient(#8a3d06, #552502); }   /* Rolan = Sunspire orange */
body[data-set="glory"] .pin.piece .name, body[data-set="glory"] .pin.camp .name {
  font: 400 12.5px/1.2 "Jost", system-ui, sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: #ffffff; background: #0a5c53; border: 2px solid #ffffff; border-radius: 6px;
  padding: 2px 9px 3px; box-shadow: 0 0 0 1.5px #04201c, 0 3px 8px rgba(0,0,0,.5);
}
body[data-set="glory"] .pin.camp .name { color: #2a1a02; background: #f2c23e; box-shadow: 0 0 0 1.5px #2a1a02, 0 3px 8px rgba(0,0,0,.5); }
body[data-set] .pin.facedown .name { font-style: italic; }
body[data-set] .pin.struck .name { color: #d9d2c6; text-decoration-color: #e2442f; }
body[data-set="glory"] .pin.struck .name, body[data-set="table"] .pin.struck .name { background: #4d4943; }
body[data-set] .pin.selected .name { outline: 2px solid #fff3cf; outline-offset: 1px; }

/* ---- the DM's hand: right-click menu, tray, dragging ----------------------------- */
.ctx { position: fixed; z-index: 30; min-width: 210px; padding: 6px; display: grid; gap: 2px; }
.ctx-title { margin: 2px 8px 6px; font: 400 15px/1.2 "IM Fell English", Georgia, serif; color: var(--ink-soft); }
.ctx-item { text-align: left; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); cursor: pointer; font: inherit; font-size: 14px; }
.ctx-item:hover, .ctx-item:focus-visible { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.ctx-item.danger { color: var(--target); }
.tray { margin: 4px 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--panel-edge); }
.tray-hint { margin: 0 0 8px; font-size: 12.5px; }
.tray-tokens { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.tray-tok { display: grid; justify-items: center; gap: 2px; padding: 6px 2px 5px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ink); cursor: grab; font-size: 10.5px; line-height: 1.15; text-align: center; touch-action: none; }
.tray-tok:hover, .tray-tok:focus-visible { border-color: var(--panel-edge); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tray-tok .glyph.tok { width: calc(var(--gw) * .62); height: calc(var(--gh) * .62); pointer-events: none; }
.tray-ghost { position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; margin: -40px 0 0 -26px; filter: drop-shadow(0 6px 8px rgba(0,0,0,.45)); }
.tray-ghost .glyph.tok { width: var(--gw); height: var(--gh); }
body.dm .pin.piece, body.dm .pin.camp { cursor: grab; touch-action: none; }
.pin.dragging { cursor: grabbing; z-index: 20; opacity: .9; }
body.placing .pin, body.placing .lbl { pointer-events: none; }
.pin.dragging .glyph.tok { transform: translateY(-6px) scale(1.12); filter: drop-shadow(0 10px 8px rgba(0,0,0,.5)); }
.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.field select { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--panel-edge); background: color-mix(in srgb, var(--page) 35%, var(--panel)); color: var(--ink); font: inherit; }
.toast { top: auto; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 44px); }

/* ---- phones ------------------------------------------------------------------ */
@media (max-width: 640px) {
  .masthead { top: max(10px, env(safe-area-inset-top)); left: 12px; padding: 7px 12px 9px; }
  h1 { font-size: 20px; }
  .kicker { font-size: 10px; }
  .toolbar {
    top: auto; bottom: max(10px, env(safe-area-inset-bottom)); left: 12px; right: 12px;
    justify-content: space-between;
  }
  .toolbar .tool { flex: 1; justify-content: center; padding: 0 6px; flex-direction: column; gap: 1px; min-height: 50px; font-size: 12px; }
  .status { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 72px); left: 12px; font-size: 12px; }
  .layers, .board {
    top: auto; left: 12px; right: 12px; width: auto;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 108px); max-height: 58vh; overflow: auto;
  }
  .card { left: 12px; right: 12px; width: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 108px); }
  .banner { top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 112px); }
  .lbl.t1 .txt { font-size: 15px; }
  .lbl.t2 .txt { font-size: 14px; }
  .lbl.t3 .txt { font-size: 13px; }
  .lbl.region .txt { font-size: 12px; }
  .rtxt { font-size: 13px; letter-spacing: .2em; }
  body.towns .lbl.t1 .txt { font-size: 18px; }
  .pin .glyph { width: 30px; height: 30px; }
  .pin .glyph.tok { width: calc(var(--gw) * .82); height: calc(var(--gh) * .82); }
}

@media (prefers-reduced-motion: reduce) {
  .lbl { transition: none; }
}
