/**
 * Portal UI chrome: settings gear + board scroll (P-UI-SETTINGS-1).
 * Prefs → CSS vars from portal_prefs.js.
 */
:root {
  --board-ui-scale: 1;
  --board-canvas-width: 560px;
  --scrollbar-thickness: 24px;
  --scrollbar-color: #c9a227;
  --settings-gear-size: 1.35rem;
  --settings-gear-color: #ffd600;
  --settings-gear-outline: #000000;
}

.board-wrap,
#board-wrap,
.portal-scroll {
  scrollbar-width: auto;
  scrollbar-color: var(--scrollbar-color) rgba(0, 0, 0, 0.25);
}
.board-wrap::-webkit-scrollbar,
#board-wrap::-webkit-scrollbar,
.portal-scroll::-webkit-scrollbar {
  height: var(--scrollbar-thickness);
  width: var(--scrollbar-thickness);
}
.board-wrap::-webkit-scrollbar-thumb,
#board-wrap::-webkit-scrollbar-thumb,
.portal-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-color);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.35);
  min-height: var(--scrollbar-thickness);
  min-width: 48px;
}
.board-wrap::-webkit-scrollbar-track,
#board-wrap::-webkit-scrollbar-track,
.portal-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Custom always-visible horizontal scroller (works in TG WebView) */
.board-scroll-slot {
  width: 100%;
  max-width: 100%;
  margin: 4px auto 8px;
  padding: 0 2px;
  box-sizing: border-box;
}
.board-scroll-slot[hidden] {
  display: none !important;
}
.board-hscroll {
  position: relative;
  width: 100%;
  height: var(--scrollbar-thickness);
  min-height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  touch-action: none;
  cursor: pointer;
  user-select: none;
}
.board-hscroll-thumb {
  position: absolute;
  top: 2px;
  left: 0;
  height: calc(100% - 4px);
  min-width: 48px;
  border-radius: 999px;
  background: var(--scrollbar-color);
  border: 2px solid rgba(0, 0, 0, 0.45);
  box-sizing: border-box;
  touch-action: none;
  cursor: grab;
}
.board-hscroll-thumb:active {
  cursor: grabbing;
}

button.settings-gear {
  flex: 0 0 auto;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--settings-gear-size) + 18px);
  height: calc(var(--settings-gear-size) + 18px);
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  color: var(--settings-gear-color);
}
button.settings-gear svg {
  width: var(--settings-gear-size);
  height: var(--settings-gear-size);
  display: block;
  filter: drop-shadow(0 0 0.5px var(--settings-gear-outline))
    drop-shadow(1px 0 0 var(--settings-gear-outline))
    drop-shadow(-1px 0 0 var(--settings-gear-outline))
    drop-shadow(0 1px 0 var(--settings-gear-outline))
    drop-shadow(0 -1px 0 var(--settings-gear-outline));
}
button.settings-gear .gear-path {
  fill: var(--settings-gear-color);
  stroke: var(--settings-gear-outline);
  stroke-width: 1.6;
}

html[data-board-scale="medium"] .board-wrap,
html[data-board-scale="large"] .board-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  justify-content: center;
  align-items: center;
  padding-bottom: 4px;
  box-sizing: border-box;
}
/* Only pin left when the board actually overflows (pan/scroll). */
html[data-board-scale="medium"] .board-wrap.board-h-overflow,
html[data-board-scale="large"] .board-wrap.board-h-overflow {
  justify-content: flex-start;
  align-items: flex-start;
}
html[data-board-scale="medium"] canvas#board,
html[data-board-scale="large"] canvas#board {
  --board-cap: min(52vh, 480px);
  /* Keep square: never let max-height squash width (was stretching labels/grid). */
  width: min(var(--board-canvas-width), var(--board-cap));
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  max-height: var(--board-cap);
}
