:root {
  /* Verdigris and brass: the patina of old fortifications. The chrome is a deep green-teal ink so
     the paper-coloured board reads as a map laid on a table; brass marks what you can act on. */
  --bg: #0e2224; --panel: #143033; --panel-2: #1c3e41; --border: #2b5356;
  --text: #e8f0ec; --muted: #8fada8; --accent: #d9a23f; --accent-2: #e8b85a; --danger: #c8372d;
  /* the one accent, tinted: toggled-on buttons, the selected chat channel, focus rings */
  --accent-soft: rgba(217,162,63,0.15); --accent-line: rgba(217,162,63,0.5); --accent-text: #f3d595;
  --on-accent: #1d1607;
  --gold: #f0c869;
  /* the unpainted board: a warm off-white a step down from paper, so the dark chrome frames it */
  --board: #ecebe6;
  /* the board's selection and hover rings (canvas.js reads these) */
  --select: #0f6f69;
  --header-h: 48px; --sidebar-w: 320px;
  --font: "Barlow", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-cond: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  /* Overlay colours: the legend and the canvas/store (which read these at start-up) share them. */
  --weather-0: rgba(0,114,178,0.9); --weather-1: rgba(240,228,66,0.9); --weather-2: rgba(230,159,0,0.9); --weather-3: rgba(204,121,167,0.9);
  --worth-0: #52525b; --worth-1: #2563eb; --worth-2: #06b6d4; --worth-3: #22c55e; --worth-4: #facc15; --worth-5: #ef4444;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.4 var(--font); background: var(--bg); color: var(--text); }
body.board-page { overflow: hidden; }
button { font: inherit; color: inherit; }
/* Every text field is dark; rules below only adjust padding, size or layout. (:where keeps this at zero specificity.) */
input:where(:not([type=checkbox]):not([type=range])), textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; }
code { font-family: var(--mono); font-size: 12px; }
a { color: var(--accent-2); }

.app { height: 100vh; display: flex; flex-direction: column; }
.header { position: relative; height: var(--header-h); display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); z-index: 5; min-width: 0; }
/* the header is the wall the board sits under: a row of merlons hangs off its bottom edge */
.header::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 6px; pointer-events: none; background: linear-gradient(90deg, var(--panel) 0 20px, transparent 20px 32px) 0 0 / 32px 6px repeat-x; }
.header > * { flex: none; }
.header .spacer { flex: 1; min-width: 0; }
.header-user { display: flex; align-items: center; gap: 8px; }
/* the tool buttons: one shape (icon + label in a row, same height); labels drop on narrow screens */
.toolbar { display: flex; align-items: center; gap: 4px; }
.btn.tool { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; font-family: var(--font-cond); font-weight: 500; font-size: 15px; background: transparent; border-color: transparent; color: var(--muted); }
.btn.tool:hover:not(:disabled) { filter: none; background: var(--panel-2); color: var(--text); }
.btn.tool .ico { width: 16px; height: 16px; margin: 0; vertical-align: 0; flex: none; }
.btn.tool.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.btn.tool[aria-expanded=true]:not(.active) { background: var(--panel-2); color: var(--text); }
.header-user .btn { height: 32px; }
/* the More menu */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--panel); border: 1px solid var(--border); border-radius: 5px; padding: 4px; box-shadow: 0 12px 32px rgba(0,0,0,0.45); z-index: 8; display: flex; flex-direction: column; }
.menu [role=menuitem] { display: flex; align-items: center; gap: 8px; text-align: left; background: none; border: 0; border-radius: 4px; padding: 7px 10px; cursor: pointer; color: var(--text); text-decoration: none; font-size: 13px; }
.menu [role=menuitem]:hover, .menu [role=menuitem]:focus-visible { background: var(--panel-2); outline: none; }
.menu [role=menuitem].checked::after { content: '✓'; margin-left: auto; color: var(--accent-text); }
.menu [role=menuitem] .unread-count { margin-left: auto; }
/* unread notifications, counted on the corner of the More button so the header keeps its width */
.btn.tool { position: relative; }
.btn.tool > .unread-count { position: absolute; top: -2px; right: -2px; min-width: 15px; height: 15px; padding: 0 4px; font-size: 10px; line-height: 15px; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
/* brand lockup (templates/_brand.html): the header button, and the big version on full pages */
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-cond); font-weight: 700; letter-spacing: 0.01em; text-transform: capitalize; color: var(--text); text-decoration: none; }
.brand.big { display: flex; gap: 12px; font-size: 26px; }
.brand.big .logo-mark { width: 26px; height: 26px; border-width: 4px; background-size: 8px 8px; }
.logo { background: none; border: 0; cursor: pointer; font-size: 21px; padding: 6px 8px; border-radius: 4px; margin-right: 4px; }
.logo:hover { background: var(--panel-2); }
/* the mark is an enclave: a closed brass ring with one pixel held inside it */
.logo-mark { width: 19px; height: 19px; border: 3px solid var(--accent); border-radius: 1px; background: linear-gradient(var(--text), var(--text)) center / 5px 5px no-repeat; flex: none; }
/* cursor coordinates: a small badge on the board, bottom right, visible while hovering it */
.coords { position: absolute; right: 12px; bottom: 48px; z-index: 2; pointer-events: none; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; padding: 4px 9px; border-radius: 3px; background: rgba(14,34,36,0.86); border: 1px solid var(--border); backdrop-filter: blur(6px); transition: opacity 150ms; }
.coords span { color: var(--muted); margin-right: 2px; }
.coords.idle { opacity: 0; }
.goto { display: flex; align-items: center; }
.goto-input { width: 116px; height: 32px; font: 13px var(--mono); padding: 5px 9px; background: var(--bg); }
.goto-input::placeholder { color: var(--muted); }
.goto-input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.goto-input.invalid { border-color: var(--danger); outline-color: var(--danger); }
.header-color { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 0; cursor: pointer; }
.header-color:hover, .header-color.active { border-color: var(--accent-2); }
.header-color .swatch { width: 20px; height: 20px; border-radius: 4px; cursor: pointer; box-shadow: 0 0 0 1px rgba(255,255,255,0.12); }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; margin: 0 2px; }
.dot.on { background: #22c55e; }
.dot.off { background: #f59e0b; }
/* pills: tags, status badges and the credit counter share the rounded outline */
.tag, .pill, .credits { background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; }
.tag, .pill { display: inline-block; padding: 1px 8px; font-size: 12px; }
.credits { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.credits { height: 32px; color: var(--gold); border-color: rgba(240,200,105,0.3); background: rgba(240,200,105,0.07); font-family: var(--font-cond); font-size: 16px; }
.coin { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fbe3a2, #b9842a); box-shadow: inset 0 0 0 1.5px rgba(29,22,7,0.35); }

.btn { border: 1px solid var(--border); background: var(--panel-2); padding: 6px 12px; border-radius: 4px; cursor: pointer; }
.btn:hover:not(:disabled) { filter: brightness(1.15); }
a.btn { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); border-color: var(--accent-2); color: var(--on-accent); font-weight: 600; }
.btn.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.btn.danger { background: var(--danger); border-color: #e0574c; color: #fff; }
.btn .ico { width: 15px; height: 15px; vertical-align: -3px; margin-right: 5px; }
.btn.icon { padding: 2px 8px; font-size: 18px; line-height: 1; background: transparent; border-color: transparent; }
.btn.wide { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; }
.link { background: none; border: 0; color: var(--accent-2); cursor: pointer; padding: 0; text-decoration: underline; }

.main { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

.palette { position: absolute; left: 132px; top: 6px; z-index: 3; background: var(--panel); border: 1px solid var(--border); border-radius: 5px; padding: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.palette-current { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.palette-label { font-size: 12px; color: var(--muted); }
/* with the Stats drawer open the palette moves clear of it */
.main:has(.drawer.left.open) .palette { left: calc(var(--sidebar-w) + 12px); }
.palette-grid { display: grid; grid-template-columns: repeat(16, 16px); gap: 1px; }
.swatch { width: 16px; height: 16px; border-radius: 1px; border: 1px solid rgba(0,0,0,0.35); padding: 0; cursor: pointer; display: inline-block; }
.swatch.selected { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.swatch.big { width: 28px; height: 28px; border-radius: 4px; }
.swatch.huge { width: 56px; height: 56px; border-radius: 4px; border: 1px solid var(--border); background-image: linear-gradient(45deg, #333 25%, transparent 25%, transparent 75%, #333 75%), linear-gradient(45deg, #333 25%, transparent 25%, transparent 75%, #333 75%); background-size: 12px 12px; background-position: 0 0, 6px 6px; background-color: #444; }
.swatch.inline { width: 14px; height: 14px; }

/* side drawers: the cell panel slides in from the right, the leaderboards from the left */
.drawer { position: absolute; top: 0; bottom: 0; width: var(--sidebar-w); max-width: 100%; background: var(--panel); transform: translateX(100%); transition: transform 180ms ease; z-index: 4; display: flex; flex-direction: column; overflow: auto; }
.drawer.right { right: 0; border-left: 1px solid var(--border); }
.drawer.left { left: 0; border-right: 1px solid var(--border); transform: translateX(-100%); }
.drawer.open { transform: translateX(0); }
.sidebar-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.sidebar-head h2 { margin: 0; font-family: var(--font-cond); font-size: 18px; font-weight: 600; }
.sidebar-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.cell-preview { display: flex; gap: 12px; align-items: center; }
.rect-line { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; font-size: 13px; }
.notice { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; font-size: 13px; margin-top: 8px; }
.notice.locked { border-color: #7f1d1d; background: #3b1212; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; width: 100%; max-width: 380px; max-height: calc(100vh - 32px); overflow: auto; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-family: var(--font-cond); font-size: 22px; font-weight: 600; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.error { color: #fca5a5; font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.account-credits { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.big-number { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 8px; color: var(--gold); }
.big-number .coin { width: 18px; height: 18px; }
.buy { display: flex; gap: 6px; flex-wrap: wrap; }
/* modal sections: a divider and a small uppercase title each */
.modal-section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.modal-section.first { border-top: 0; padding-top: 0; margin-top: 0; }
.modal-section > p:last-child { margin-bottom: 0; }
/* the rules modal: short plain-language sections, with a price ladder and a perimeter drawn in pixels */
.rules-modal { font-size: 14px; line-height: 1.5; }
.rules-modal p { margin: 0; }
.rules-modal .rules-lead { margin-bottom: 10px; color: var(--muted); }
.rules-controls { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 12px; margin-bottom: 14px; border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: 5px; font-size: 13px; }
.rules-controls b { color: var(--accent-text); }
kbd { font: 12px var(--mono); padding: 0 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 3px; background: var(--bg); }
.rules-note { margin: 6px 0 0; }
/* first visit: the rules modal opens with a welcome */
.welcome { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.rules-modal .welcome-lead { margin: 0 0 14px; font-size: 16px; }
.welcome-steps { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.welcome-steps li { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--panel-2); font-size: 13px; }
.welcome-steps b { font-family: var(--font-cond); font-size: 16px; color: var(--accent-text); }
.welcome-steps span:not(.step-n) { color: var(--muted); }
.step-n { width: 20px; height: 20px; display: grid; place-items: center; border: 2px solid var(--accent); border-radius: 1px; font: 600 11px var(--mono); color: var(--accent-text); margin-bottom: 2px; }
.welcome-invite { margin: 0 0 14px; padding: 8px 12px; border-left: 3px solid var(--gold); background: var(--accent-soft); font-size: 14px; }
.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
@media (max-width: 640px) {
  .welcome-steps { grid-template-columns: 1fr; gap: 6px; }
  .welcome-steps li { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; padding: 8px 10px; }
  .welcome-steps .step-n { grid-row: span 2; align-self: center; margin: 0; }
}
/* the bare stage is hatched as well as colored, so it does not rely on hue alone */
.legend .sw.bare { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.55) 0 1.5px, transparent 1.5px 4px) !important; }
.rules-modal ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.rules-modal a { color: var(--accent-2); }
.rules-fig { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
.rules-fig .sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 6px; }
.rules-fig .sw.empty { background: var(--board); }
.rules-fig .sw.a, .rules-fig .sw.w, .px-grid .w { background: var(--accent-2); }
.rules-fig .sw.b { background: color-mix(in srgb, var(--worth-1) 33%, var(--worth-2)); }
.rules-fig .sw.c { background: color-mix(in srgb, var(--worth-2) 94%, var(--worth-3)); }
.price-steps .sw.a { background: var(--worth-1); }
.rules-fig .sw.i, .px-grid .i { background: #bfd4f7; }
.price-steps { color: var(--muted); }
.price-steps span { color: var(--text); white-space: nowrap; }
.price-steps b { color: var(--gold); }
.px-grid { display: grid; grid-template-columns: repeat(7, 12px); gap: 1px; padding: 6px; background: var(--board); border-radius: 4px; flex: none; }
.px-grid i { width: 12px; height: 12px; }
.rules-key { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; }
.section-title { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; display: flex; align-items: baseline; gap: 8px; }
.section-title .count { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.section-title a.count { color: var(--accent-2); }
.section-note { margin: -4px 0 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row label { min-width: 0; }
.form-row select, .form-row input { width: 100%; }
.staff-links { display: flex; gap: 6px; margin: -2px 0 14px; padding: 8px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border); }
.account-foot { margin-top: 12px; }
.profile-summary { gap: 10px; }
.profile-who { min-width: 0; }
.profile-name { font-weight: 600; overflow-wrap: anywhere; }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 20; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--border); padding: 8px 14px; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.toast.error { border-color: #7f1d1d; background: #3b1212; }
.toast.alert { pointer-events: auto; cursor: pointer; max-width: 420px; }
/* sticky toasts (demo narration): a step badge, the text, and a × that dismisses them */
.toast.sticky { pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; max-width: 480px; }
.toast-label { flex: none; font-size: 11px; line-height: 18px; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-text); white-space: nowrap; }
.toast.sticky .toast-text { flex: 1; }
.toast-close { flex: none; margin: -2px -6px -2px 0; color: var(--muted); }
.toast-close:hover { color: var(--text); }

/* narrower windows: tool labels go first (tooltips keep the names), then the go-to box */
@media (max-width: 1200px) {
  #help-btn .lbl { display: none; }
}
@media (max-width: 1000px) {
  .btn.tool .lbl { display: none; }
  .btn.tool { padding: 0 8px; }
}
@media (max-width: 640px) {
  .header { gap: 4px; padding: 0 8px; }
  .toolbar { gap: 0; }
  .btn.tool { padding: 0 6px; }
  .header .dot { display: none; }
  .header-user { gap: 4px; }
  .header-user .btn { padding: 4px 8px; font-size: 14px; }
  .credits { padding: 4px 8px; }
  .logo .brand-name, .brand .brand-name { display: none; }
  .coords { display: none; }
  .goto { display: none; }
  .header-user .with-avatar .user-name { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .chatbar { max-height: 80vh; }
  .palette-grid { grid-template-columns: repeat(16, 14px); }
  .swatch { width: 14px; height: 14px; }
  .drawer.right { width: 100%; }
  .palette { left: 8px; }
}

/* floating panels pinned to the top centre of the board (timeline, overlays, share, report) */
.float-panel { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 4; max-width: calc(100% - 24px); background: var(--panel); border: 1px solid var(--border); border-radius: 5px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.timeline { z-index: 3; flex-direction: row; align-items: center; padding: 6px 10px; top: auto; bottom: 48px; }
.timeline input[type=range] { width: 320px; max-width: 40vw; accent-color: var(--accent); }
.tl-label { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.timelapse-panel { width: 420px; font-size: 13px; }
.timelapse-panel label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.timelapse-panel input { width: 100%; padding: 5px 8px; }
.timelapse-panel .form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.referral-link { margin-top: 6px; }
body.history .board { cursor: default; }
body.history .palette, body.history #header-color { display: none; }

/* ---- left panel ---- */
/* seven totals on an even 4×2 grid: the pixel count is the hero tile and spans two columns */
.lb-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lb-totals div { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 1px; min-width: 0; }
.lb-totals b { font-size: 16px; font-variant-numeric: tabular-nums; }
.lb-totals span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-totals .lb-hero { grid-column: span 2; background: var(--accent-soft); border-color: var(--accent-line); }
.lb-totals .lb-hero b { font-size: 20px; color: var(--accent-text); }
/* small uppercase section headings */
.lb-section h3, .groups-panel h4, .keys h4, .chan-head { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.lb-section h3 { margin: 0 0 6px; }
.lb-section ol { margin: 0; padding-left: 22px; }
.lb-section li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.lb-section li b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- tags & inline forms ---- */
.tag { margin: 2px 2px 0 0; }
.tag.ally { border-color: #1d4ed8; color: #93c5fd; }
.tag.mine { border-color: #15803d; color: #86efac; }
.tag.open { border-color: #0f766e; color: #5eead4; }
.ring-group select { padding: 3px 6px; font-size: 12px; }
.inline-form { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.inline-form input[type=number] { width: 72px; }
.inline-form input { padding: 5px 8px; }
.small-btn { padding: 4px 10px; font-size: 13px; }
.siege-forms { margin-top: 4px; }
.rect-line.broken { border-color: #7f1d1d; }
.rect-line.besieged { border-color: #b45309; }
.contested { color: #fca5a5; }
.siege-line { color: #fbbf24; }
.tag.besieged { border-color: #b45309; color: #fcd34d; }
.tag.weathering { border-color: #57534e; color: #d6d3d1; }
.tag.scorched { border-color: #c2410c; color: #fdba74; }
.rect-line.mine { border-color: #b91c1c; }
.rect-line.mine.detected { border-color: #ca8a04; background: #2a2208; }
.tag.mine-detect { border-color: #ca8a04; color: #fde68a; }
.tag.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.overlay-panel { width: 360px; gap: 10px; font-size: 13px; }
.overlay-section { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.tier-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; }
.tier { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; border-radius: 4px; border: 1px solid var(--border); background: var(--panel-2); font-size: 12px; cursor: pointer; }
.tier span { color: var(--muted); font-size: 11px; }
button.tier:hover { border-color: var(--accent-2); }
.tier.owned { cursor: default; background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.tier.owned span { color: var(--accent-text); opacity: 0.8; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.mine-arm { margin-top: 8px; }
.mine-arm summary { cursor: pointer; list-style: none; }
.mine-arm form { margin-top: 6px; }
.mine-arm select { flex: 1; min-width: 0; background: var(--panel-2); padding: 4px 6px; font-size: 12px; }
.swatch.scorched { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.35) 0 4px, transparent 4px 8px) !important; }

/* ---- chat bar ---- */
.chatbar { --chat-h: 280px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--panel); border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(0,0,0,0.25); transform: translateY(calc(100% - 36px)); transition: transform 180ms ease; height: var(--chat-h); max-height: 70vh; display: flex; flex-direction: column; }
.chatbar.open { transform: translateY(0); }
.chatbar.resizing { transition: none; user-select: none; }
/* the grab strip on the top edge (only does anything while the panel is open) */
.chat-resize { position: absolute; left: 0; right: 0; top: -4px; height: 8px; z-index: 1; }
.chatbar.open .chat-resize { cursor: ns-resize; }
.chatbar.open .chat-resize::after { content: ''; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border); }
.chatbar-toggle { height: 36px; flex: none; background: transparent; border: 0; cursor: pointer; text-align: left; padding: 0 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.chatbar-toggle:hover, .chatbar.open .chatbar-toggle { color: var(--text); }
.chatbar-toggle .ico { width: 16px; height: 16px; }
.chatbar-chevron { width: 8px; height: 8px; border: solid currentColor; border-width: 2px 2px 0 0; transform: rotate(-45deg); margin: 3px 0 0 2px; opacity: 0.6; transition: transform 180ms; }
.chatbar.open .chatbar-chevron { transform: rotate(135deg); margin-top: -4px; }
.unread-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.chatbar-body { flex: 1; min-height: 0; }
.chat-layout { display: flex; height: 100%; }
.chat-channels { width: 200px; flex: none; border-right: 1px solid var(--border); overflow: auto; padding: 8px 6px; display: flex; flex-direction: column; gap: 2px; background: rgba(0,0,0,0.12); }
.chan { text-align: left; background: transparent; border: 0; padding: 6px 10px; border-radius: 4px; cursor: pointer; position: relative; color: var(--muted); }
.chan:hover { background: var(--panel-2); color: var(--text); }
.chan.active { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 2px 0 0 var(--accent-2); }
.chan.chan-add { color: var(--accent-2); font-size: 13px; }
.chan-action { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); font: inherit; text-transform: none; letter-spacing: 0; }
.chan-action:hover { color: var(--text); }
.chan.unread::after { content: ''; position: absolute; right: 8px; top: 50%; width: 7px; height: 7px; margin-top: -3px; border-radius: 50%; background: #ef4444; }
.chan-head { font-size: 11px; padding: 10px 10px 4px; display: flex; justify-content: space-between; align-items: center; }
.chan-empty { padding: 2px 10px 4px; }
.chan-new input { width: 100%; font-size: 12px; padding: 6px 9px; margin-top: 8px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 9px 14px; border-bottom: 1px solid var(--border); }
.chat-messages { flex: 1; overflow: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.msg { display: flex; gap: 8px; align-items: baseline; font-size: 13px; padding: 4px 6px; margin: 0 -6px; border-radius: 4px; }
.msg:hover { background: rgba(255,255,255,0.03); }
.msg-name { font-weight: 600; white-space: nowrap; }
.msg-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.msg-held { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-text); border: 1px solid var(--accent-line); border-radius: 3px; padding: 0 4px; white-space: nowrap; }
.chat-form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; }
.groups-panel h4 { margin: 12px 0 6px; }
.group-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; }
.group-row { padding: 4px 0; }
.members { margin-top: 4px; }
.check { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; color: var(--muted); }
.check.small { align-items: flex-start; gap: 6px; }  /* sentence-long labels: box beside the first line */
.check.small > input { margin-top: 2px; flex: none; }
.form label.check { flex-direction: row; }  /* a checkbox label inside a form keeps its box beside the text */
@media (max-width: 640px) {
  .chat-channels { width: 130px; }
  .lb-totals { grid-template-columns: repeat(2, 1fr); }
}

.keys h4 { margin: 14px 0 6px; }
.keys > .section-title { margin-top: 0; }
.key-row { padding: 4px 0; }
.key-value { display: block; margin-top: 6px; word-break: break-all; user-select: all; }

.msg-flag { background: none; border: 0; color: var(--muted); cursor: pointer; opacity: 0; font-size: 12px; padding: 0 4px; }
.msg:hover .msg-flag { opacity: 1; }
.board.selecting { cursor: crosshair; }
.board.picking { cursor: copy; }
.report-panel { width: 420px; border-color: #7f1d1d; }
.report-panel textarea { resize: vertical; }

/* worth overlay legend: bare grey, then the price ramp */
.worth-legend { display: flex; flex-direction: column; gap: 3px; padding: 0 10px; }
.worth-ticks { position: relative; height: 14px; }
.worth-ticks span { position: absolute; transform: translateX(-50%); color: var(--muted); }
.worth-legend .worth-bar { display: block; height: 10px; border-radius: 3px; background: linear-gradient(90deg, var(--worth-0) 0 8%, var(--worth-1) 8%, var(--worth-2), var(--worth-3), var(--worth-4), var(--worth-5)); }
/* demo panel (superusers only) and the notifications panel sit at the right, clear of the board's centre */
.demo-panel, .notif-panel { left: auto; right: 12px; transform: none; width: 380px; }
.demo-scenes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.demo-scenes .demo-scene { text-align: left; }
/* notifications panel: the toasts the server sent, newest first; ones about a place are buttons */
.notif-list { display: flex; flex-direction: column; gap: 2px; max-height: min(60vh, 440px); overflow: auto; margin: 0 -6px; }
.notif { display: flex; align-items: baseline; gap: 8px; padding: 5px 6px; border: 0; border-radius: 4px; background: none; text-align: left; }
button.notif { cursor: pointer; }
button.notif:hover, button.notif:focus-visible { background: var(--panel-2); outline: none; }
.notif-time { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.notif-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notif.error .notif-text { color: #fca5a5; }
.notif-empty { padding: 5px 6px; }
/* beside the cell drawer when that is open, not under it; on phones the drawer is the full width, so over it */
.main:has(#sidebar.open) .notif-panel { right: calc(var(--sidebar-w) + 12px); }
@media (max-width: 640px) {
  .main:has(#sidebar.open) .notif-panel { right: 12px; z-index: 5; }
}

/* tickets */
.form textarea { resize: vertical; }
.btn.icon-only { padding: 6px 8px; }
.modal-wide { max-width: 560px; }
.ticket-list { display: flex; flex-direction: column; gap: 8px; }
.ticket-item { border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; }
.ticket-item summary { cursor: pointer; }
.ticket-item .ticket-body { white-space: pre-wrap; margin: 8px 0; font-size: 13px; }
.ticket-item .note { border-left: 3px solid var(--border); padding: 4px 8px; margin: 6px 0; font-size: 13px; }
.ticket-item .note.own { border-left-color: var(--accent); }
.ticket-item .form { margin-top: 6px; }
.pill.st-open { border-color: #f59e0b; color: #fcd34d; }
.pill.st-triaged { border-color: #3b82f6; color: #93c5fd; }
.pill.st-in_progress { border-color: #a855f7; color: #d8b4fe; }
.pill.st-resolved { border-color: #22c55e; color: #86efac; }
.pill.st-closed { border-color: #57534e; color: #a8a29e; }

/* achievements */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.badge { background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; padding: 10px 8px; text-align: center; font-size: 12px; }
.badge img { width: 56px; height: 56px; object-fit: contain; display: block; margin: 0 auto 6px; border-radius: 50%; background: var(--panel); }
.badge.locked img { filter: grayscale(1); opacity: .35; }
.badge.locked .badge-name { color: var(--muted, #888); }
.badge-name { font-weight: 600; }
.badge.hard { border-color: #7f1d1d; }
.badge.medium { border-color: #78350f; }
.badge-strip { display: inline-flex; gap: 2px; vertical-align: middle; margin-left: 4px; }
.badge-strip img { width: 16px; height: 16px; object-fit: contain; }

/* avatars */
.avatar { image-rendering: pixelated; background: var(--panel-2); border-radius: 4px; vertical-align: middle; }
.avatar-xs { width: 16px; height: 16px; border-radius: 3px; flex: none; align-self: center; }
.avatar-sm { width: 22px; height: 22px; }
.avatar-lg { width: 64px; height: 64px; border-radius: 4px; }
.with-avatar { display: inline-flex; align-items: center; gap: 6px; }
.avatar-summary { gap: 10px; }
.avatar-editor { display: flex; gap: 14px; align-items: flex-start; margin-top: 6px; flex-wrap: wrap; }
.avatar-grid { display: grid; grid-template-columns: repeat(8, 22px); grid-template-rows: repeat(8, 22px); gap: 1px; background: var(--border); border: 1px solid var(--border); touch-action: none; user-select: none; width: max-content; }
.avatar-cell { background: transparent; cursor: crosshair; }
.avatar-cell.empty { background-image: linear-gradient(45deg, var(--panel-2) 25%, transparent 25%, transparent 75%, var(--panel-2) 75%), linear-gradient(45deg, var(--panel-2) 25%, var(--panel) 25%, var(--panel) 75%, var(--panel-2) 75%); background-size: 8px 8px; background-position: 0 0, 4px 4px; }
.avatar-previews { margin-top: 8px; gap: 8px; }
.avatar-right { flex: 1; min-width: 200px; }
.avatar-palette { display: grid; grid-template-columns: repeat(auto-fill, 14px); gap: 2px; max-height: 150px; overflow: auto; padding: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; margin-bottom: 8px; }
.avatar-swatch { width: 14px; height: 14px; padding: 0; border: 1px solid transparent; border-radius: 2px; cursor: pointer; font-size: 9px; line-height: 1; }
.avatar-swatch.eraser { background: var(--panel); color: var(--muted); }
.avatar-swatch.active { border-color: #fff; outline: 1px solid #fff; }

/* share panel */
.share-link input { flex: 1; min-width: 0; font-size: 12px; font-family: var(--mono); padding: 6px 8px; }
.share-sites { display: flex; flex-wrap: wrap; gap: 6px; }
.share-sites a { text-decoration: none; }
.share-mastodon input { flex: 1; min-width: 0; font-size: 12px; }
.share-preview { display: flex; flex-direction: column; gap: 4px; }
.share-preview img { width: 100%; aspect-ratio: 1200 / 630; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); image-rendering: pixelated; }

/* maintenance */
.maintenance-banner { background: #3b1212; border-bottom: 1px solid #7f1d1d; color: #fecaca; padding: 6px 14px; font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.maintenance-banner a { color: #fca5a5; }
.maintenance-curtain { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; text-align: center; padding: 24px 16px; background: rgba(14, 34, 36, 0.92); }
.maintenance-curtain h2 { margin: 0 0 10px; font-size: 26px; }
.maintenance-curtain p { max-width: 34em; margin: 0 auto 6px; }
/* the smallest phones: tighten the header so Log in / Sign up stay on screen */
@media (max-width: 380px) {
  .btn.tool { padding: 0 4px; }
  .header { gap: 2px; padding: 0 6px; }
}
