/*! Copyright (c) 2026 BamByte (bambyte.net). All rights reserved.
 * Proprietary code: no copying, redistribution, or use to train or prompt
 * AI / machine-learning systems without written permission from BamByte. */
/* InkBuds -- drawing page (game.html).
   The page on the left, the site's sidebar on the right: HUD panel with the
   controls on top (js/sidebarLayout.js) and the tool panel (js/ui.js) under
   the logo -- the same shell, frame and sizes Solitz and Blockz use.

   Reskin points: --game-accent (keep in step with --ink-accent in menu.css)
   and --desk-* (the table round the page). */

:root {
  --game-accent: #ff4fb0;
  --game-accent-rgb: 255, 79, 176;
  --ink-blue: #29b6ff;
  --desk-light: #2a2342;
  --desk-dark: #120e22;
  --panel: #1d1830;
  --text: #f4f7fb;
  --muted: #b9b3cf;
  --ink-sidebar-w: clamp(250px, 24vw, 340px);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at 50% 40%, #241d3d, var(--desk-dark) 85%), var(--desk-dark);
  overflow: hidden;
}

/* Full-height flex + dvh, same as the rest of the site. */
.ink-shell {
  display: flex;
  gap: 16px;
  height: var(--bb-vh, 100vh);
  height: var(--bb-vh, 100dvh);
  padding: 16px;
}

.ink-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  gap: 10px;
  order: 2;
}

/* The desk the page lies on. The page itself is drawn on the canvas, so the
   board just fills the stage. */
.ink-board {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 1.5px) 0 0 / 22px 22px,
    radial-gradient(ellipse at 50% 35%, var(--desk-light), var(--desk-dark) 95%);
  border: 3px solid rgba(var(--game-accent-rgb), 0.55);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), inset 0 0 60px rgba(0, 0, 0, 0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#screen, #overlay {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#overlay { pointer-events: none; }

/* ---- Zoom bar (bottom-left of the board) ---------------------------------- */
.ink-zoombar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(20, 16, 34, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.ink-zb {
  appearance: none;
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font: 800 16px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
}
.ink-zb svg { width: 18px; height: 18px; }
.ink-zb:hover { background: rgba(255, 255, 255, 0.1); }
.ink-zb:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 1px; }
.ink-zb--pct { min-width: 58px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ink-zb--fit { font-size: 13px; }
.ink-zb-gap { width: 1px; height: 22px; margin: 0 3px; background: rgba(255, 255, 255, 0.16); }

/* ---- Tool palette beside the page (js/toolbar.js) ---------------------------
   Docked it is a flex item of the stage, so the board shrinks to make room;
   floating it sits over the stage. Sizes are whole buttons: keep --tb-btn,
   --tb-gap, the 6px body padding and the 2px frame in step with BTN / GAP /
   PAD / FRAME at the top of toolbar.js. */
.ink-board { order: 1; }
.ink-stage[data-tb-dock="top"], .ink-stage[data-tb-dock="bottom"] { flex-direction: column; }
.ink-tb {
  --tb-btn: 36px;
  --tb-gap: 3px;
  position: relative;
  order: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 2px solid rgba(var(--game-accent-rgb), 0.55);
  border-radius: 14px;
  background: rgba(20, 16, 34, 0.94);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ink-tb[hidden] { display: none; }
.ink-tb[data-dock="right"], .ink-tb[data-dock="bottom"] { order: 2; }
.ink-tb.is-horiz { flex-direction: row; }
.ink-tb[data-dock="float"] {
  position: absolute;
  z-index: 8;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.ink-tb.is-moving { opacity: 0.92; }

/* Head: the dotted grip you drag it by, and the four dock buttons. */
.ink-tb__head {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 6px 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ink-tb.is-horiz .ink-tb__head {
  flex-direction: row;
  padding: 6px 5px;
  border-bottom: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}
.ink-tb__grip {
  align-self: stretch;
  height: 10px;
  border-radius: 4px;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 1px, transparent 1.6px) 0 0 / 5px 5px;
}
.ink-tb__grip:hover { background-color: rgba(255, 255, 255, 0.06); }
.ink-tb.is-horiz .ink-tb__grip { width: 10px; height: auto; }
.ink-tb.is-moving .ink-tb__grip { cursor: grabbing; }
.ink-tb__docks { display: flex; gap: 2px; }
.ink-tb.is-horiz .ink-tb__docks { flex-direction: column; }
.ink-tb__dock {
  appearance: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  padding: 1px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.ink-tb__dock svg { width: 100%; height: 100%; }
.ink-tb__dock:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.ink-tb__dock.is-on { color: var(--game-accent); }
.ink-tb__dock:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 1px; }

/* Body: the tools, the colour squares, the tool's settings. */
.ink-tb__body {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--game-accent-rgb), 0.6) transparent;
}
.ink-tb.is-horiz .ink-tb__body { flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; }
.ink-tb__tools {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--tb-cols, 2), var(--tb-btn));
  grid-auto-rows: var(--tb-btn);
  gap: var(--tb-gap);
}
.ink-tb.is-horiz .ink-tb__tools {
  grid-template-columns: none;
  grid-template-rows: repeat(var(--tb-rows, 2), var(--tb-btn));
  grid-auto-flow: column;
  grid-auto-columns: var(--tb-btn);
}
.ink-tb .ink-tool { width: var(--tb-btn); height: var(--tb-btn); border-radius: 9px; }
.ink-tb .ink-tool:hover { transform: none; }
.ink-tb__sep { flex: 0 0 auto; align-self: stretch; height: 1px; background: rgba(255, 255, 255, 0.1); }
.ink-tb.is-horiz .ink-tb__sep { width: 1px; height: auto; }
.ink-tb__sep[hidden], .ink-tb__opts[hidden], .ink-tb__seg[hidden] { display: none; }

/* The colour squares: one, or Line in front of a shape's Fill (Photoshop's pair). */
.ink-tb__colors { position: relative; flex: 0 0 auto; align-self: center; width: 48px; height: 48px; }
.ink-tb__chip {
  appearance: none;
  position: absolute;
  inset: 8px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.ink-tb__chip[hidden] { display: none; }
.ink-tb__chip .ink-target-chip {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 0 3px rgba(0, 0, 0, 0.6);
}
.ink-tb__colors.is-pair .ink-tb__chip--line { inset: 2px 16px 16px 2px; z-index: 1; }
.ink-tb__colors.is-pair .ink-tb__chip--fill { inset: 16px 2px 2px 16px; }
.ink-tb__colors.is-pair .ink-tb__chip.is-on .ink-target-chip { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--game-accent); }
.ink-tb__chip:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 3px; }

/* The tool's settings: a column when docked on a side, two rows across on top / below. */
.ink-tb__opts { align-self: stretch; display: flex; flex-direction: column; gap: 6px; }
.ink-tb.is-horiz .ink-tb__opts {
  align-self: center;
  display: grid;
  grid-template-rows: repeat(2, auto);
  grid-auto-flow: column;
  grid-auto-columns: 132px;
  gap: 3px 12px;
}
.ink-tb .ink-slider { grid-template-columns: 1fr auto; gap: 1px 4px; font-size: 11px; }
.ink-tb .ink-slider input { grid-column: 1 / -1; height: 16px; margin: 0; }
.ink-tb .ink-slider output { font-size: 11px; }
.ink-tb .ink-seg { grid-template-columns: repeat(auto-fill, minmax(24px, 1fr)); gap: 2px; padding: 2px; }
.ink-tb .ink-seg-btn { padding: 5px 0; }
.ink-tb .ink-seg-btn span { display: none; }

/* Resize: the edge facing the page; a floating palette's corner. */
.ink-tb__size { position: absolute; z-index: 2; touch-action: none; }
.ink-tb__size::after {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: var(--game-accent);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.ink-tb__size:hover::after, .ink-tb.is-sizing .ink-tb__size::after { opacity: 0.9; }
.ink-tb[data-dock="left"] .ink-tb__size, .ink-tb[data-dock="right"] .ink-tb__size { top: 10px; bottom: 10px; width: 10px; cursor: ew-resize; }
.ink-tb[data-dock="left"] .ink-tb__size { right: -8px; }
.ink-tb[data-dock="right"] .ink-tb__size { left: -8px; }
.ink-tb[data-dock="left"] .ink-tb__size::after, .ink-tb[data-dock="right"] .ink-tb__size::after { top: 0; bottom: 0; left: 4px; width: 3px; }
.ink-tb[data-dock="top"] .ink-tb__size, .ink-tb[data-dock="bottom"] .ink-tb__size { left: 10px; right: 10px; height: 10px; cursor: ns-resize; }
.ink-tb[data-dock="top"] .ink-tb__size { bottom: -8px; }
.ink-tb[data-dock="bottom"] .ink-tb__size { top: -8px; }
.ink-tb[data-dock="top"] .ink-tb__size::after, .ink-tb[data-dock="bottom"] .ink-tb__size::after { left: 0; right: 0; top: 4px; height: 3px; }
.ink-tb[data-dock="float"] .ink-tb__size {
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 55%, rgba(255, 255, 255, 0.45) 55% 62%, transparent 62% 72%, rgba(255, 255, 255, 0.45) 72% 79%, transparent 79%);
  border-bottom-right-radius: 12px;
}
.ink-tb[data-dock="float"] .ink-tb__size::after { display: none; }

/* Where a dragged palette docks if you let go now. */
.ink-tb-zone {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  border-radius: 16px;
  border: 2px dashed var(--game-accent);
  background: rgba(var(--game-accent-rgb), 0.2);
}
.ink-tb-zone[hidden] { display: none; }
.ink-tb-zone[data-edge="left"] { left: 0; top: 0; bottom: 0; width: 96px; }
.ink-tb-zone[data-edge="right"] { right: 0; top: 0; bottom: 0; width: 96px; }
.ink-tb-zone[data-edge="top"] { left: 0; right: 0; top: 0; height: 96px; }
.ink-tb-zone[data-edge="bottom"] { left: 0; right: 0; bottom: 0; height: 96px; }

/* The colour picker, beside the palette. */
.ink-tb-pop {
  position: fixed;
  z-index: 60;
  width: 252px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(22, 20, 32, 0.97);
  border: 2px solid var(--game-accent);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}
.ink-tb-pop[hidden] { display: none; }
.ink-tb-pop .ink-sv { height: 140px; }

/* ---- Toast ---------------------------------------------------------------- */
.ink-toast {
  position: absolute;
  left: 50%;
  top: 14px;
  z-index: 6;
  transform: translate(-50%, -8px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(20, 16, 34, 0.92);
  border: 1px solid rgba(var(--game-accent-rgb), 0.7);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ink-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---- Round controls (moved into the sidebar HUD by sidebarLayout.js) ------ */
.ink-side { display: none; }
.bb-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 16px;
  background: #4a4a4a;
  border: 2px solid #6d6d6d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.45);
}
.bb-icon-btn {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.bb-toolbar .bb-icon-btn,
.bb-toolbar .bb-offline-hud-menu-btn {
  flex: 0 1 40px;
  width: auto;
  height: auto;
  min-width: 26px;
  aspect-ratio: 1;
}
.bb-icon-btn img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.bb-icon-btn:hover { transform: translateY(-1px) scale(1.08); filter: brightness(1.15); }
.bb-icon-btn:active { transform: scale(0.94); }
.bb-icon-btn:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 2px; }
.bb-icon-btn--gear { color: #111; background: #d9d9d9; width: 32px; height: 32px; padding: 5px; }
.bb-icon-btn--gear svg { width: 100%; height: 100%; display: block; }
#btn-settings { display: none; }
body.ink-no-hud-menu #btn-settings { display: grid; }

/* ---- Sidebar -------------------------------------------------------------- */
#rightPanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 var(--ink-sidebar-w);
  width: var(--ink-sidebar-w);
  max-height: 100%;
  min-width: 0;
  padding: 8px;
  overflow: hidden;
  position: relative;
  order: 4;
}
#sb-content { display: none; }

body.ink-dock-left #rightPanel { order: 1; }
body.ink-dock-left .ink-resize-handle { order: 2; }
body.ink-dock-left .ink-stage { order: 3; }

.ink-resize-handle {
  display: block;
  position: relative;
  flex: 0 0 10px;
  align-self: stretch;
  cursor: col-resize;
  background: transparent;
  order: 3;
}
.ink-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--game-accent);
  opacity: 0.35;
  border-radius: 2px;
  transition: opacity 0.18s ease, width 0.18s ease;
}
.ink-resize-handle:hover::before,
.ink-resize-handle.ink-resizing::before { opacity: 1; width: 4px; }
body.ink-resizing-cursor { cursor: col-resize; user-select: none; }

/* ---- HUD panel ------------------------------------------------------------ */
.hud-panel { display: none; }
#rightPanel > .hud-panel {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 3px solid var(--game-accent);
  border-radius: 8px;
  background-color: rgba(12, 10, 24, 0.45);
  padding: 8px;
}
.hud-panel[hidden] { display: none !important; }
.hud-panel__title {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.hud-panel__logo-card { width: 100%; padding: 0 6px; }
/* The logo art is on white: a rounded card, height capped to leave the
   tools room. */
.hud-panel__logo {
  display: block;
  width: 100%;
  max-height: 96px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}
.hud-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 2px 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--game-accent-rgb), 0.6) transparent;
}
#rightPanel .hud-collapsed > *:not(.bb-toolbar) { display: none; }
#rightPanel .hud-collapsed { padding: 0; border: 0; background: transparent; overflow: visible; }

/* ---- Tool panel (js/ui.js) ------------------------------------------------ */
.ink-sec { padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.ink-sec:first-child { padding-top: 0; }
/* SketchByte swaps the tool sections for its own (js/etch.js). */
.ink-etch { display: none; }
.is-etch > .ink-sec { display: none; }
.is-etch > .ink-etch { display: block; padding-top: 0; }
.ink-etch__tip { margin: 0 0 10px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.ink-etch__tip b { color: #fff; }
.ink-etch__tip:last-child { margin-bottom: 0; }
.ink-set-row[hidden] { display: none; }
.ink-orient { flex: 0 1 216px; min-width: 0; margin: 0; }
.ink-orient__icon { width: 13px; height: 13px; flex: none; display: flex; align-items: center; justify-content: center; }
.ink-orient__icon::before { content: ""; display: block; border: 1.5px solid currentColor; border-radius: 2px; box-sizing: border-box; }
.ink-orient__icon--landscape::before { width: 13px; height: 9px; }
.ink-orient__icon--portrait::before { width: 9px; height: 13px; }
.ink-mini-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--game-accent);
}

.ink-slider[hidden], .ink-mini[hidden] { display: none; }

/* Shapes: Outline / Filled. */
.ink-shape-opts { margin-top: 8px; }
.ink-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 10px; background: rgba(0, 0, 0, 0.28); }
.ink-seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font: 800 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif; cursor: pointer;
}
.ink-seg-btn svg { width: 15px; height: 15px; }
.ink-seg-btn.is-on { color: #fff; background: rgba(var(--game-accent-rgb), 0.32); box-shadow: inset 0 0 0 1px var(--game-accent); }
.ink-seg-btn:disabled { opacity: 0.4; cursor: default; }
.ink-seg--3 { grid-template-columns: repeat(3, 1fr); }
/* Move tools: the selection's buttons, icon over label. */
.ink-select-opts { margin-top: 8px; }
.ink-select-opts[hidden] { display: none; }
.ink-seg--5 { grid-template-columns: repeat(5, 1fr); }
.ink-seg-btn--stack { flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 10.5px; }
.ink-seg-btn--stack svg { width: 17px; height: 17px; }
.ink-select-tip { margin: 8px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.ink-select-tip b { color: #fff; }
.ink-select-tip[hidden] { display: none; }
.ink-layer-fade { flex: 0 0 auto; padding: 1px 6px; border-radius: 6px; background: rgba(255, 200, 80, 0.18); color: #ffd98a; font-size: 11px; }
/* Line / Fill: which shape colour the picker sets. */
.ink-shape-colors { display: flex; gap: 6px; margin-top: 6px; }
.ink-target[hidden] { display: none; }
.ink-target {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 5px 8px; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 9px;
  background: rgba(0, 0, 0, 0.22); color: var(--muted);
  font: 800 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif; cursor: pointer;
}
.ink-target.is-on { color: #fff; border-color: var(--game-accent); background: rgba(var(--game-accent-rgb), 0.22); }
.ink-target-chip {
  width: 16px; height: 16px; border-radius: 5px; background: var(--c, #000);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.ink-tool {
  appearance: none;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #e9e5f7;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}
.ink-tool svg { width: 62%; height: 62%; }
.ink-tool:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
.ink-tool.is-on {
  background: rgba(var(--game-accent-rgb), 0.28);
  border-color: var(--game-accent);
  color: #fff;
  box-shadow: 0 0 10px rgba(var(--game-accent-rgb), 0.45);
}
.ink-tool:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 1px; }

.ink-sliders { display: grid; gap: 2px; margin-top: 8px; }
.ink-slider {
  display: grid;
  grid-template-columns: 66px 1fr 48px;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}
.ink-slider input { width: 100%; min-width: 0; accent-color: var(--game-accent); }
.ink-slider output { text-align: right; color: #fff; font-variant-numeric: tabular-nums; font-size: 12px; }
.ink-slider.is-off { opacity: 0.4; }

.ink-color-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ink-cur {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--c, #000);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.ink-hex {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid rgba(var(--game-accent-rgb), 0.6);
  background: var(--panel);
  color: #fff;
  font: 700 14px ui-monospace, Consolas, monospace;
  text-transform: lowercase;
}
.ink-sv, .ink-hue { display: block; width: 100%; border-radius: 9px; touch-action: none; cursor: crosshair; }
.ink-sv { height: 120px; }
.ink-hue { height: 16px; margin-top: 8px; }

.ink-swatches { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-top: 8px; }
.ink-swatch {
  appearance: none;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--c);
  cursor: pointer;
}
.ink-swatch:hover { transform: scale(1.12); }
.ink-swatch.is-on { outline: 2px solid #fff; outline-offset: 1px; }
.ink-recent-wrap { margin-top: 8px; }
.ink-swatches--recent { margin-top: 4px; min-height: 18px; }
.ink-empty { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); }

.ink-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.ink-layer-btns { display: flex; gap: 2px; }
.ink-mini {
  appearance: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 4px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
}
.ink-mini svg { width: 100%; height: 100%; }
.ink-mini:hover:not(:disabled) { background: rgba(var(--game-accent-rgb), 0.3); }
.ink-mini:disabled { opacity: 0.3; cursor: default; }
.ink-mini--flat { border-color: transparent; background: transparent; color: var(--muted); }
.ink-mini--flat.is-lit { color: var(--game-accent); }

.ink-layer-list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: grid;
  gap: 3px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.ink-layer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.ink-layer:hover { background: rgba(255, 255, 255, 0.09); }
.ink-layer.is-on { border-color: var(--game-accent); background: rgba(var(--game-accent-rgb), 0.18); }
/* Online: other artists' layers -- you can hide them, not pick them. */
.ink-layer.is-theirs { cursor: default; opacity: 0.78; }
.ink-layer.is-hidden .ink-thumb, .ink-layer.is-hidden .ink-layer-name { opacity: 0.45; }
.ink-thumb {
  flex: 0 0 auto;
  width: 48px;
  height: 32px;
  border-radius: 5px;
  /* Checkers, so an empty layer reads as see-through. */
  background:
    repeating-conic-gradient(#cfd2da 0% 25%, #fff 0% 50%) 0 0 / 10px 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.ink-layer-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ink-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 10px; }
.ink-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 8px;
  border: 0;
  border-radius: 999px;
  font: 800 12.5px/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #fff;
  background: #3a3550;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.ink-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.ink-btn:hover:not(:disabled), .ink-btn:focus-visible { filter: brightness(1.2); transform: translateY(-1px); }
.ink-btn:disabled { opacity: 0.4; cursor: default; }
.ink-btn--go {
  background: #b3217a;
  box-shadow: 0 0 0 2px rgba(var(--game-accent-rgb), 0.8), 0 0 10px 2px rgba(var(--game-accent-rgb), 0.4);
}
.ink-btn--wide { width: 100%; }

/* ---- Settings popover ----------------------------------------------------- */
.settings-menu {
  position: absolute;
  right: 8px;
  top: 64px;
  z-index: 40;
  width: min(280px, calc(100% - 16px));
  max-height: calc(var(--bb-vh, 100dvh) - 120px);
  overflow-y: auto;
  padding: 12px;
  border-radius: 14px;
  background: #2b2a2a;
  border: 2px solid rgba(var(--game-accent-rgb), 0.55);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
.settings-menu[hidden] { display: none; }
#hud-panel > #settings-menu {
  top: 64px;
  bottom: 10px;
  left: 10px;
  right: 10px;
  width: auto;
  max-height: none;
  padding: 14px 16px 12px;
  background: rgba(22, 20, 32, 0.97);
  border: 2px solid var(--game-accent);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), 0 0 18px rgba(var(--game-accent-rgb), 0.22);
  text-align: left;
}
.settings-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.settings-group { margin-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 10px; }
.settings-group--first { margin-top: 0; border-top: 0; padding-top: 0; }
.settings-title { margin: 0 0 8px; font-size: 13px; color: var(--game-accent); }
.ink-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  margin: 6px 0;
}
.ink-toggle-row input { width: 18px; height: 18px; accent-color: var(--game-accent); }
.ink-select {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(var(--game-accent-rgb), 0.6);
  background: var(--panel);
  color: #fff;
  font: inherit;
}
.rules { margin: 0; }
.rules dt { margin-top: 8px; font-weight: 800; font-size: 12.5px; color: var(--game-accent); }
.rules dd { margin: 2px 0 6px; font-size: 12px; line-height: 1.45; color: #fff; }
.rules dd b { color: var(--game-accent); }

/* ---- New canvas dialog ---------------------------------------------------- */
.ink-modal {
  position: fixed;
  inset: 0;
  z-index: 4100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.6);
}
/* New canvas previews on the board, so with room to spare it sits over the
   sidebar and leaves the board undimmed. On a phone the board is on top, so it
   sits at the bottom. */
@media (max-width: 899px) {
  .ink-modal--live { align-items: flex-end; background: rgba(0, 0, 0, 0.25); }
}
@media (min-width: 900px) {
  .ink-modal--live {
    justify-content: flex-end;
    padding-inline: 24px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.6) 410px, transparent 500px);
  }
  body.ink-dock-left .ink-modal--live {
    justify-content: flex-start;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.6) 410px, transparent 500px);
  }
}
.ink-modal__card {
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  border-radius: 20px;
  background: #1f1b2e;
  border: 2px solid rgba(var(--game-accent-rgb), 0.5);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
}
.ink-modal__title {
  margin: 0 0 4px;
  text-align: center;
  font: 900 22px/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-transform: uppercase;
  color: #fff;
}
.ink-modal__label { margin: 4px 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.ink-modal__btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.ink-modal .ink-btn { padding: 12px 0; font-size: 13.5px; text-transform: uppercase; }

/* New canvas: "Start with" a blank page or a coloring page (js/pages.js). */
.ink-new-page { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ink-modal .ink-new-page .ink-btn { padding: 8px 14px; font-size: 12.5px; text-transform: none; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ink-btn--on { box-shadow: 0 0 0 2px var(--game-accent); }
.ink-new-page__x {
  width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  color: #fff; background: #3a3550; cursor: pointer; font-size: 12px;
}
.ink-new-page__x[hidden] { display: none; }

/* ---- Coloring page picker (js/pages.js) ---------------------------------- */
.ink-pages { z-index: 4200; }
.ink-pages__card { width: min(620px, 94vw); max-height: min(720px, calc(var(--bb-vh, 100dvh) * .92)); }
.ink-pages__tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ink-pages__tab {
  padding: 7px 12px; border: 0; border-radius: 999px; cursor: pointer;
  font: 800 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--muted); background: #2c2840;
}
.ink-pages__tab.is-on { color: #fff; background: #b3217a; box-shadow: 0 0 0 2px rgba(var(--game-accent-rgb), 0.8); }
.ink-pages__grid {
  flex: 1 1 auto; min-height: 140px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px;
  padding: 4px 2px;
}
.ink-pages__item { position: relative; }
.ink-pages__pick {
  width: 100%; display: flex; flex-direction: column; gap: 6px; align-items: center;
  padding: 6px; border: 0; border-radius: 12px; cursor: pointer;
  background: #2c2840; color: #fff; font: 700 11.5px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.ink-pages__pick:hover, .ink-pages__pick:focus-visible { filter: brightness(1.2); transform: translateY(-1px); box-shadow: 0 0 0 2px var(--game-accent); }
.ink-pages__pick img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; border-radius: 8px; background: #fff; }
.ink-pages__pick span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ink-pages__add b { display: grid; place-items: center; width: 100%; aspect-ratio: 3 / 4; border-radius: 8px; border: 2px dashed rgba(255, 255, 255, 0.3); font-size: 34px; color: var(--muted); }
.ink-pages__del {
  position: absolute; top: 4px; right: 4px; min-width: 24px; height: 24px; padding: 0 6px;
  border: 0; border-radius: 999px; cursor: pointer; font: 800 11px/1 system-ui, sans-serif;
  color: #fff; background: rgba(20, 16, 34, 0.85);
}
.ink-pages__del.is-armed { background: #c62f3a; }
.ink-pages__loading { grid-column: 1 / -1; margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.ink-pages__note { margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.ink-pages__note[hidden] { display: none; }
.ink-pages__btns { grid-template-columns: 1fr; }

/* ==== Phones and tablets ====================================================
   Desktop is untouched: everything below is gated on a portrait viewport no
   wider than 1024px (stacked) or a landscape one no taller than 500px. */

/* Portrait: page on top, sidebar under it. */
@media (orientation: portrait) and (max-width: 1024px) {
  html, body { height: auto; min-height: 100%; }
  body { overflow-x: hidden; overflow-y: auto; }
  .ink-shell { flex-direction: column; height: auto; min-height: var(--bb-vh, 100dvh); padding: 8px; gap: 8px; }
  .ink-stage, body.ink-dock-left .ink-stage { order: 1; flex: 0 0 auto; width: 100%; height: calc(var(--bb-vh, 100dvh) - 140px); min-height: 320px; }
  #rightPanel, body.ink-dock-left #rightPanel {
    order: 2; flex: 0 0 auto; width: 100%; max-height: none; padding: 0; overflow: visible;
  }
  #rightPanel > .hud-panel, .hud-panel__body { overflow: visible; }
  .ink-resize-handle { display: none; }
  .hud-panel__logo { max-width: 260px; margin: 0 auto; }
  .ink-stage { gap: 6px; }
  /* The sidebar's fold arrow sits between the page and the sidebar under it,
     turned to point down at it (net/sidebar_collapse.js flips it inline). */
  .ink-shell > .bb-sidebar-collapse-btn { width: 46px; height: 18px; flex: 0 0 18px; }
  .ink-shell > .bb-sidebar-collapse-btn svg { rotate: 90deg; }
  /* Folded: the page takes the screen (less the arrow). */
  body.ink-sidebar-folded .ink-stage { height: calc(var(--bb-vh, 100dvh) - 50px); }
}

/* Phones on their side: side by side, narrower sidebar. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --ink-phone-side-w: clamp(200px, 30vw, 260px); }
  .ink-shell { padding: 6px; gap: 6px; }
  #rightPanel { flex: 0 0 var(--ink-phone-side-w); width: var(--ink-phone-side-w); padding: 0; overflow-y: auto; }
  .ink-resize-handle { display: none; }
  .bb-toolbar { gap: 5px; padding: 4px 6px; }
  .hud-panel__logo { max-height: 44px; width: auto; margin: 0 auto; }
  #rightPanel > .hud-panel { padding: 6px; }
  .ink-stage { gap: 6px; }
  .ink-tb-pop .ink-sv { height: 80px; }
}

@media (orientation: portrait) and (max-width: 1024px), (orientation: landscape) and (max-height: 500px) {
  #rightPanel #settings-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(320px, calc(100vw - 24px));
    max-height: calc(var(--bb-vh, 100dvh) - 24px);
    z-index: 900;
  }
}
