:root {
  --bg: var(--theme-bg, #eadcc1);
  --bg2: var(--theme-raised, #efdfc3);
  --panel: var(--theme-panel, #fff5de);
  --panel2: var(--theme-raised, #f1e3c8);
  --line: var(--theme-border, #ccb693);
  --text: var(--theme-text, #372817);
  --muted: var(--theme-muted, #6e5c46);
  --gold: var(--theme-accent, #a26221);
  --pink: var(--theme-danger, #a23c2e);
  --red: var(--theme-danger, #a23c2e);
  --green: var(--theme-action, #496641);
  --font: var(--theme-ui-font, "DM Sans", system-ui, sans-serif);
  --display: var(--theme-heading-font, "Spectral", Georgia, serif);
  --radius: var(--theme-radius, 9px);
  --shadow: var(--theme-shadow, 0 12px 32px #30231524);
  --sea: var(--board-ocean-far, #236479);
  --accent-ink: var(--theme-accent-ink, #fff8e9);
  --action-ink: var(--theme-action-ink, #fff9ec);
  --control-icon-size: 20px;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgb(96 68 37 / calc(var(--theme-grain, .22) * .36)) .55px, transparent .75px);
  background-size: 5px 5px;
  color: var(--text);
  font-family: var(--font);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme-style]) body {
    background-color: #11161d;
    color: #f7f1e7;
  }
}
button, input, select, textarea { font-family: inherit; }
h1, h2, h3 { color: var(--text); letter-spacing: 0; }
a { color: var(--gold); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
select option { color: var(--text); background: var(--panel); }

.btn, .chip, .cap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel2);
  color: var(--text);
  box-shadow: none;
  font-weight: 700;
  text-shadow: none;
}
.btn { min-height: 38px; }
.btn.sm { min-height: 32px; }
.btn:hover:not(:disabled), .chip:hover, .cap:hover {
  background: color-mix(in srgb, var(--panel2), var(--gold) 14%);
}
.btn.primary, .chip.on, .cap.on {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--accent-ink);
}
.btn.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--gold), var(--text) 16%);
}
.btn.green, .btn.green:hover:not(:disabled) {
  background: var(--green);
  border-color: var(--green);
  color: var(--action-ink);
}
.btn.pink, .btn.pink:hover:not(:disabled) {
  background: var(--red);
  border-color: var(--red);
  color: var(--theme-danger-ink, #fff4e5);
}
.btn.active { border-color: var(--text); }
.btn.active:not(.green, .pink),
.btn.active:not(.green, .pink):hover:not(:disabled) {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--accent-ink);
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .48; }
input[type=text], select, textarea {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
input[type=text]::placeholder { color: var(--muted); }
input[type=range] { accent-color: var(--gold); }
.card, .modal, .offer {
  border: 0;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.overlay { background: #13211eb8; backdrop-filter: blur(2px); }
.modal { max-height: calc(100dvh - 28px); }
.game-dialog { margin: auto; width: min(560px, calc(100% - 32px)); color: var(--text); }
.game-dialog.flag-modal { width: min(760px, calc(100% - 28px)); }
.game-dialog:has(.building-costs) { width: min(410px, calc(100% - 24px)); }
.building-costs { text-align: center; }
.building-costs > h2 { margin: 0 0 14px; }
.building-cost-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}
.building-cost-list li { display: flex; flex-direction: column; gap: 4px; }
.building-cost-list h3 {
  order: 1;
  margin: 0;
  padding: 4px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--panel2), var(--building-cost-color) 23%);
  font-size: 1.02rem;
}
.building-cost-resources { display: flex; gap: 6px; justify-content: center; align-items: center; }
.building-cost-resources img {
  width: clamp(34px, 10.5vw, 48px);
  height: clamp(34px, 10.5vw, 48px);
  object-fit: contain;
}
.game-dialog::backdrop { background: #13211eb8; backdrop-filter: blur(2px); }
.modal h2 { overflow-wrap: anywhere; }
.modal h2:focus { outline: none; }
.modal .btn { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.modal .tabs { flex-wrap: wrap; }
.steppers { grid-template-columns: repeat(auto-fit, minmax(min(78px, 100%), 1fr)); }
.stepper { background: var(--panel2); border-radius: var(--radius); }
.stepper .ctl .btn { width: 30px; min-height: 34px; padding: 0; }
.respick {
  --control-icon-size: 28px;
  grid-template-columns: repeat(auto-fit, minmax(min(78px, 100%), 1fr));
}
.score-scroll { overflow-x: auto; }
.help-body li { color: var(--text); }
.help-body ul { padding-inline-start: 1.35em; }
.save-status { position: absolute; z-index: 3; inset: auto 8px 8px; width: fit-content; max-width: calc(100% - 16px); padding: 4px 9px; border-radius: 4px; color: #fff; background: #8a241c; pointer-events: none; }
.pill, .tag {
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
}
.section-label { color: var(--muted); letter-spacing: .04em; }
.toast, .toast.error, .toast.good {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  box-shadow: var(--shadow);
}
.toast.error { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }

#app:has(> :is(.menu, .lobby, .online-hub, .editor)) {
  isolation: isolate;
  --menu-wood-tint: light-dark(rgb(246 223 187 / .52), rgb(20 15 12 / .62));
}
#app:has(> :is(.menu, .lobby, .online-hub, .editor))::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.editor-side {
  background: color-mix(in srgb, var(--panel) 75%, transparent);
}
:is(.menu-dialog, .flag-modal, .game-dialog:has(.settings-options)) {
  --menu-wood-tint: color-mix(in srgb, var(--panel) 84%, transparent);
}
#app:has(> :is(.menu, .lobby, .online-hub, .editor))::before,
:is(.menu-dialog, .flag-modal, .game-dialog:has(.settings-options)) {
  background: linear-gradient(var(--menu-wood-tint), var(--menu-wood-tint)),
    #b38758 url("../assets/home-wood-table.webp") center / cover no-repeat;
}

.menu {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  justify-content: stretch;
  align-items: stretch;
  gap: clamp(18px, 4vw, 44px);
  margin: auto;
  max-width: 1500px;
  padding: clamp(18px, 4vw, 52px);
}
.menu-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.menu-top .brand-mark { width: 28px; height: 28px; background-color: var(--text); }
.menu-top-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.menu-top-actions .btn { min-height: 42px; padding: 8px 11px; }
.menu .btn.ghost { background: var(--panel); }
.menu .btn.ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--panel), var(--gold) 14%); }
.lang-pick { display: flex; align-items: center; gap: 7px; }
.lang-pick .control-icon { color: var(--text); }
.lang-pick select { min-height: 42px; max-inline-size: min(146px, 42vw); padding: 6px 8px; }
.lang-status { max-inline-size: 240px; margin: 6px 0 0; font-size: 0.85rem; }
.menu-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: clamp(24px, 6vw, 90px);
  align-items: center;
  padding-bottom: clamp(10px, 5vh, 64px);
}
.menu .logo { text-align: left; margin: 0 0 26px; }
.menu .logo .t1 {
  color: var(--text);
  background: none;
  filter: none;
  font-family: var(--display);
  font-size: clamp(46px, 5.4vw, 84px);
  letter-spacing: -.035em;
  line-height: 1;
}
.menu-buttons { width: 100%; gap: 9px; }
.menu-buttons .btn { margin: 0; font-size: 14px; padding: 10px 12px; white-space: normal; }
.menu-buttons .menu-play { justify-content: flex-start; min-height: 54px; font-size: 15px; padding-inline: 14px; }
.menu-tools, .menu-resume { display: flex; flex-wrap: wrap; gap: 7px; }
.menu-tools { margin-top: 5px; }
.menu-tools .btn { flex: 1 1 120px; }
.menu-resume .btn:first-child { flex: 1; }
.menu-kingdom {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 22px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel);
}
.menu-kingdom .mk-flag { min-height: 48px; padding: 6px 8px; gap: 8px; }
.mk-flag .flag-img { border-radius: 2px; box-shadow: none; }
.mk-info { display: grid; gap: 5px; }
.mk-info .section-label { margin: 0; line-height: 1.2; }
.mk-info input { min-height: 42px; padding: 7px 9px; font-size: 16px; }
.menu-foot { text-align: left; margin-top: 12px; font-size: 11px; color: var(--text); }
.menu-foot a { color: inherit; }
.menu-preview {
  display: grid;
  place-items: stretch;
  aspect-ratio: 1.25;
  max-height: 72dvh;
  border: 0;
  border-radius: calc(var(--radius) * 2);
  overflow: hidden;
  background: var(--sea);
  box-shadow: var(--shadow);
}
.menu-preview .board-svg { display: block; width: 100%; height: 100%; }
.menu-dialog { margin: auto; color: var(--text); padding: 18px; width: min(540px, calc(100% - 24px)); }
.menu-dialog::backdrop { background: #162b28ad; }
.menu-dialog > .row { justify-content: space-between; align-items: center; }
.menu-dialog h2 { margin: 0; }

.lobby, .hub-inner { padding-top: clamp(20px, 3vw, 44px); }
.hub-head h2 { text-shadow: none; color: var(--text); }
.hub-sub, .hub-status { text-shadow: none; }
.room-code { color: var(--text); background: var(--panel2); border-color: var(--line); text-shadow: none; }
.lobby .preview { background: var(--sea); }
.start-bar {
  background: var(--panel);
  box-shadow: 0 -3px 20px #211f1b15;
}
.map-card, .mode { background: var(--panel2); border-color: var(--line); }
.swatch { border: 1px solid var(--line); }
.map-card.on, .mode.on { background: color-mix(in srgb, var(--panel), var(--gold) 12%); border-color: var(--gold); }
.editor .board-wrap, .preview { background: var(--sea); }

/* Shared live HUD. Each theme sets its own material, rail, and resource treatment. */
.game {
  --hud-rail-size: 24%;
  --hud-rail-pad: clamp(8px, 1vw, 17px);
  --hud-card-gap: 7px;
  --hud-frame: var(--line);
  --hud-frame-radius: 0px;
  --hud-header: var(--panel);
  --hud-footer: var(--panel);
  --hud-rail: var(--panel);
  --hud-paper: none;
  --hud-paper-size: 384px 384px;
  --hud-paper-blend: soft-light;
  --hud-panel-font: var(--font);
  --hud-command-font: var(--font);
  --hud-card-ink: var(--text);
  --hud-card-surface: var(--panel2);
  --hud-card-radius: var(--radius);
  --hud-hand-width: clamp(65px, 8.6vw, 148px);
  --hud-hand-height: clamp(61px, 9.9vh, 99px);
  --hud-hand-background: #fae9c6;
  --hud-hand-ink: #30261b;
  --hud-hand-border: #af9b76;
  --hud-hand-inner: #fff7e1;
  --hud-button-surface: var(--panel2);
  --hud-button-edge: var(--line);
  --hud-button-ink: var(--text);
  --hud-icon-button-size: 38px;
  --hud-end-surface: var(--green);
  --hud-end-ink: var(--action-ink);
  --hud-accent: var(--gold);
  --hud-title-size: clamp(22px, 2.32vw, 41px);
  --hud-title-color: var(--text);
  --hud-emblem: var(--gold);
  --hud-vp-color: color-mix(in srgb, var(--text) 75%, var(--gold));
  border-radius: var(--hud-frame-radius);
  overflow: clip;
}

.topbar, .actionbar, .game .side {
  background-image: var(--hud-paper);
  background-size: var(--hud-paper-size);
  background-blend-mode: var(--hud-paper-blend);
  color: var(--text);
}

.topbar {
  min-height: clamp(43px, 5.8vh, 60px);
  padding: 3px clamp(7px, 1.25vw, 22px);
  gap: clamp(8px, 1.25vw, 22px);
  background-color: var(--hud-header);
  border-bottom: 0;
  flex-wrap: nowrap;
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 22px; }
.brand-mark {
  display: inline-block;
  flex: none;
  width: 23px;
  height: 23px;
  background: var(--gold);
  mask: url("../assets/openhexes-mark.svg") center / contain no-repeat;
}
.game .brand {
  color: var(--hud-title-color);
  font-family: var(--display);
  font-size: var(--hud-title-size);
  font-weight: 800;
  letter-spacing: -.025em;
  font-synthesis: weight;
  line-height: 1;
  text-shadow: none;
  white-space: nowrap;
}

.game .brand-mark { background: var(--hud-emblem); width: 1.08em; height: 1.08em; }

.match-status {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.15vw, 18px);
  min-width: 0;
}
.match-event:empty { display: none; }
.game .turn-info {
  min-width: 0;
  gap: clamp(7px, .79vw, 13px);
  flex: 0 1 auto;
  font: 600 clamp(12px, 1.05vw, 16px)/1.2 var(--hud-panel-font);
}
.turn-dot { width: 11px; height: 11px; flex: none; box-shadow: 0 0 0 1px var(--line); }
.turn-label { flex: none; color: var(--muted); }
.turn-name { display: inline-flex; align-items: center; gap: 5px; max-width: 19ch; min-width: 0; font-weight: 800; }
.turn-player, .game .phase-tag { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game .phase-tag { display: block; border-inline-start: 1px solid var(--hud-frame); padding-inline-start: clamp(6px, .8vw, 12px); font: inherit; color: var(--muted); }
.round-tag {
  flex: none;
  border-inline-start: 1px solid var(--hud-frame);
  padding-inline-start: clamp(8px, 1vw, 16px);
  white-space: nowrap;
}
.dice-group, .dice { display: flex; align-items: center; gap: 5px; }
.dice-group { flex: none; font: 600 clamp(11px, 1.05vw, 15px)/1.2 var(--hud-panel-font); }
.dice-group .dice-label { white-space: nowrap; }
.die { width: 26px; height: 26px; border-radius: 4px; padding: 4px; }
.die i { width: 4px; height: 4px; }
.die.red-die { background: #f9dcc8; }
.dice-sum { font-size: 17px; min-width: 16px; }
.event-badge { color: var(--text); background: var(--panel2); border-color: var(--line); }
.top-actions { flex: none; gap: 6px; margin-inline-start: auto; }
.game .top-actions .btn, .zoom-ctrl .btn, .roll-log > summary {
  width: var(--hud-icon-button-size);
  height: var(--hud-icon-button-size);
  min-height: 0;
  padding: 0;
}
.game .top-actions .btn {
  border-color: transparent;
  background: transparent;
  border-radius: min(var(--radius), 6px);
  box-shadow: none;
  font-size: clamp(12px, 1.23vw, 20px);
  font-weight: 800;
}
.game .top-actions .btn:hover {
  background: color-mix(in srgb, var(--hud-header), var(--text) 10%);
}
.turn-timer {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel2);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.turn-timer.urgent { color: var(--red); border-color: var(--red); }

.game-main { grid-template-columns: minmax(0, 1fr) clamp(225px, var(--hud-rail-size), 490px); }
.game-main .board-wrap { background: var(--sea); }
.game-main .board-svg { position: absolute; inset: 0; }
.board-tools { display: contents; }
.game .side {
  background-color: var(--hud-rail);
  border-inline-start: 0;
  min-width: 0;
  padding: var(--hud-rail-pad);
  gap: 5px;
  font-family: var(--hud-panel-font);
}
.game .side-heading {
  padding: 0 1px 3px;
  font: 750 clamp(15px, 1.8vw, 31px)/1.1 var(--hud-panel-font);
  color: var(--text);
  text-transform: none;
  letter-spacing: -.015em;
}
.players-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 4px; flex-shrink: 0; max-height: 60%; min-height: 0; }
.activity-panel { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.players {
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  padding: 0;
  gap: var(--hud-card-gap);
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.pcard {
  --seat-avatar-size: clamp(23px, 2vw, 31px);
  --seat-stat-icon: 19px;
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: var(--hud-card-radius);
  padding: 7px 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 4px;
  background: var(--hud-card-surface);
  color: var(--hud-card-ink);
  box-shadow: none;
}
.pcard.current, .pcard.winner {
  background: color-mix(in srgb, var(--hud-card-surface), var(--pc) 13%);
}
.pcard .top { gap: 7px; }
.pcard .avatar {
  width: var(--seat-avatar-size);
  height: var(--seat-avatar-size);
  color: var(--pc);
  background: transparent;
  box-shadow: none;
  position: relative;
  font-size: 12px;
}
.pcard .avatar:not(.has-flag, :has(img.flag-img)) {
  color: transparent;
  background: var(--pc);
  border-radius: 0;
  clip-path: polygon(11% 90%, 11% 69%, 23% 54%, 39% 46%, 29% 37%, 28% 21%, 38% 8%, 53% 5%, 67% 10%, 75% 23%, 74% 37%, 63% 48%, 78% 55%, 89% 69%, 89% 90%);
}
.pcard .avatar.has-flag { inline-size: auto; }
.pcard .seat-bot {
  display: inline-grid;
  flex: none;
  width: var(--seat-avatar-size);
  height: var(--seat-avatar-size);
  place-items: center;
  color: color-mix(in srgb, var(--hud-card-ink) 80%, var(--pc));
}
.pcard .seat-bot .control-icon {
  width: min(var(--control-icon-size), var(--seat-avatar-size));
  height: min(var(--control-icon-size), var(--seat-avatar-size));
}
.pcard .avatar .flag-img {
  width: calc(var(--seat-avatar-size) * 1.36);
  height: var(--seat-avatar-size);
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
  object-fit: contain;
}
.pcard .name {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-weight: 750;
  font-size: clamp(13px, 1.13vw, 18px);
}
.pcard .name > * { overflow: hidden; text-overflow: ellipsis; }
.pcard .name small { flex: none; margin: 0; max-width: 43%; font-size: .77em; color: var(--muted); }
.pcard :is(.vp, .acting-dot, .conn) { flex: none; }
.pcard .vp { display: flex; align-items: center; gap: 4px; color: var(--hud-vp-color); white-space: nowrap; font: 750 clamp(14px, 1.18vw, 20px)/1.1 var(--hud-panel-font); }
.vp-symbol { display: inline-grid; flex: none; place-items: center; width: 1.1em; height: 1.1em; font-size: .9em; vertical-align: middle; }
.vp-symbol img { width: 1em; height: 1em; }
[data-theme-style="tabletop"][data-theme-custom="false"] .vp-symbol {
  border-radius: 50%;
  background: url("../assets/themes/tabletop/victory-point.png") center / cover;
}
[data-theme-style="tabletop"][data-theme-custom="false"] .vp-symbol > span { visibility: hidden; }
.pcard :is(.stats, .longest-road-award) {
  margin: 0;
  color: var(--hud-card-ink);
  font-size: clamp(11px, .9vw, 14px);
  line-height: 1.2;
}
.pcard .stats { gap: 4px clamp(6px, .85vw, 14px); font-variant-numeric: tabular-nums; }
.pcard .longest-road-award { display: flex; align-items: center; gap: 6px; font-weight: 750; }
.longest-road-award .control-icon { flex: none; width: max(16px, 1.35em); height: max(16px, 1.35em); }
.pcard .stats > span { display: inline-flex; gap: 3px; align-items: center; white-space: nowrap; }
.pcard .stats img { width: var(--seat-stat-icon); height: var(--seat-stat-icon); object-fit: contain; }
.pcard .stats .award { color: var(--hud-accent); }

.bank-info {
  --bank-icon-size: clamp(15px, 1.4vw, 20px);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 44px));
  align-items: center;
  justify-content: center;
  justify-items: center;
  column-gap: 2px;
  padding: 5px 0;
  font-size: clamp(11px, .98vw, 14px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.bank-info > span { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.bank-info img { width: var(--bank-icon-size); height: var(--bank-icon-size); }
.game .log {
  min-height: 42px;
  padding: 3px 1px;
  border-top: 0;
  color: var(--text);
  font-size: clamp(11px, 1.04vw, 17px);
  line-height: 1.5;
  scrollbar-width: thin;
}
.game .log div { padding: 2px 3px; border-bottom: 0; }
.pname { color: color-mix(in srgb, var(--pc), var(--text) 72%); filter: none; }

.roll-log, .zoom-ctrl { z-index: 2; }
.zoom-ctrl { bottom: 10px; right: 10px; gap: 4px; }
.zoom-ctrl .btn { background: var(--panel); }
.roll-log {
  position: absolute;
  z-index: 6;
  top: 10px;
  right: 10px;
  color: var(--text);
}
.roll-log > summary {
  display: grid;
  place-items: center;
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--hud-frame);
  border-radius: var(--radius);
  background: var(--panel);
}
.roll-log > summary::-webkit-details-marker { display: none; }
.roll-log-values {
  position: absolute;
  inset: 100% 0 auto auto;
  display: grid;
  justify-items: center;
  gap: 5px;
  max-height: min(43dvh, 290px);
  overflow: auto;
  padding: 7px;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.offer-slot {
  flex: 0 1 clamp(225px, 31vw, 400px);
  min-inline-size: 0;
}
.offer-slot:empty { display: none; }
.offer {
  max-block-size: min(45dvh, 340px);
  overflow: auto;
  overflow-wrap: anywhere;
  color: var(--text);
}
.offer .btn { max-inline-size: 100%; white-space: normal; }

.actionbar {
  z-index: 7;
  min-height: clamp(69px, 12vh, 118px);
  padding: clamp(5px, .6vw, 10px) clamp(6px, 1.4vw, 24px) max(6px, env(safe-area-inset-bottom));
  gap: 6px clamp(5px, .9vw, 15px);
  background-color: var(--hud-footer);
  border-top: 0;
  box-shadow: 0 -3px 14px #1b251018;
}
.actionbar-content {
  display: flex;
  flex: 1 1 0;
  flex-wrap: wrap;
  align-items: center;
  gap: inherit;
  min-inline-size: 0;
}
.handtray, .hand, .devcards { display: flex; align-items: center; flex-wrap: nowrap; gap: clamp(4px, .7vw, 12px); }
.handtray { flex: none; }
.rcard {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  clip-path: none;
  width: var(--hud-hand-width);
  height: var(--hud-hand-height);
  margin: 0;
  gap: 2px;
  padding: 3px;
  background: var(--hud-hand-background);
  border: 0;
  border-radius: var(--hud-card-radius);
  color: var(--hud-hand-ink);
  box-shadow: none;
}

.rcard[data-resource="wood"] { --card-art: var(--card-wood); --card-color: var(--board-wood); }
.rcard[data-resource="brick"] { --card-art: var(--card-brick); --card-color: var(--board-brick); }
.rcard[data-resource="sheep"] { --card-art: var(--card-sheep); --card-color: var(--board-sheep); }
.rcard[data-resource="wheat"] { --card-art: var(--card-wheat); --card-color: var(--board-wheat); }
.rcard[data-resource="ore"] { --card-art: var(--card-ore); --card-color: var(--board-ore); }
.rcard.zero { opacity: .82; }
.rcard.zero .resource-art { filter: saturate(.77); }
.rcard .resource-art {
  display: grid;
  place-items: center;
  line-height: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  border-radius: max(2px, calc(var(--hud-card-radius) - 2px));
  background-color: var(--card-color, var(--resource-color));
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.rcard .resource-art::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: var(--card-art, none) center / cover no-repeat;
  opacity: var(--hud-hand-art-opacity, .46);
}
.rcard .resource-item[data-card-art] { display: none; }
.rcard .resource-art .resource-item {
  width: 76%;
  height: 96%;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px #23170864);
  image-rendering: auto;
}
[data-theme-style="tabletop"][data-theme-custom="false"] .rcard .resource-item[data-card-art] {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: none;
}
[data-theme-style="tabletop"][data-theme-custom="false"] .rcard .resource-item:not([data-card-art]),
[data-theme-style="tabletop"][data-theme-custom="false"] .rcard .resource-art::before { display: none; }
.resource-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
  color: var(--hud-hand-ink);
  font: 750 clamp(9px, .93vw, 15px)/1 var(--hud-panel-font);
}
.rcard b {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  place-items: center;
  min-width: 1.3em;
  min-height: 1.3em;
  margin: 0;
  padding: 0 3px;
  color: var(--hud-hand-ink);
  background: var(--hud-hand-inner);
  border: 0;
  border-radius: 100%;
  font: 800 clamp(12px, 1.12vw, 19px)/1.1 var(--hud-panel-font);
}
.dcard {
  height: var(--hud-hand-height);
  width: clamp(32px, 4vw, 55px);
  border: 0;
  border-radius: var(--hud-card-radius);
  background: var(--panel2);
  color: var(--text);
}
.dcard.playable { box-shadow: none; background: var(--gold); color: var(--accent-ink); }
.actions { gap: clamp(5px, .85vw, 14px); }
.actions .btn, .actions .act-build { padding: 5px 9px; }
.actionbar .act-trade, .actionbar .act-build, .actionbar .act-end {
  justify-content: center;
  min-width: clamp(92px, 11.75vw, 205px);
  min-height: clamp(34px, 6vh, 57px);
  border: 1px solid var(--hud-button-edge);
  border-radius: var(--hud-card-radius);
  background: var(--hud-button-surface);
  color: var(--hud-button-ink);
  font: 750 clamp(13px, 1.36vw, 23px)/1 var(--hud-command-font);
  list-style: none;
}
.actionbar .act-build::-webkit-details-marker { display: none; }
.actionbar .act-end, .actionbar .act-end:hover:not(:disabled) {
  color: var(--hud-end-ink);
  background: var(--hud-end-surface);
  border-color: color-mix(in srgb, var(--hud-end-surface), #2e231d 28%);
}
.actionbar .act-trade:hover:not(:disabled), .actionbar .act-build:hover {
  background: color-mix(in srgb, var(--hud-button-surface), var(--hud-accent) 15%);
}
.control-icon, .btn > img.ui-icon {
  display: inline-block;
  width: var(--control-icon-size);
  height: var(--control-icon-size);
  flex: none;
  vertical-align: middle;
}
.roll-caption { display: inline-flex; align-items: center; gap: 7px; }
.build-menu { position: relative; }
.actionbar:has(.build-menu[open]) { z-index: 9; }
.build-options {
  position: absolute;
  z-index: 8;
  inset: auto 0 calc(100% + 8px) auto;
  display: grid;
  gap: 5px;
  min-width: max(100%, 174px);
  padding: 7px;
  color: var(--text);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.build-menu:not([open]) > .build-options { display: none; }
.build-options > .btn { justify-content: flex-start; }
.build-options > .btn { --control-icon-size: 24px; }

.waiting { padding: 4px 0; }
.build-instruction { flex: 0 0 100%; justify-content: flex-end; font-size: .9em; }
.settings-options { display: grid; gap: 12px; }
.timer-setting { display: grid; gap: 5px; min-width: 0; }
.timer-setting label { display: flex; justify-content: space-between; gap: 8px; }
.timer-setting input { width: 100%; }
.settings-options .section-label { margin-top: 0; }

@media (min-width: 861px) and (max-width: 1090px) {
  .game { --hud-hand-width: clamp(52px, 7.15vw, 78px); }
  .actionbar { gap: 6px; }
  .actions .btn { font-size: 12px; padding: 5px 6px; }
}
@media (min-width: 861px) {
  .players-panel:has(.players > .pcard:nth-child(6)) { max-height: 72%; }
  .players:has(> .pcard:nth-child(6)) { gap: 5px; }
  .players:has(> .pcard:nth-child(6)) .pcard {
    --seat-avatar-size: 24px;
    padding-block: 5px;
  }
}
@media (max-width: 860px) {
  .game { --hud-hand-width: 48px; --hud-hand-height: 51px; overflow: visible; }
  .game-main { grid-template-columns: minmax(0, 1fr); }
  .game-main .board-wrap { min-height: 320px; height: 55dvh; grid-row: 2; }
  .game :is(.side, .players-panel, .activity-panel) { display: contents; }
  .game .side-heading { display: none; }
  .players {
    grid-row: 1;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 142px), 1fr));
    gap: 6px;
    overflow: visible;
    padding: 6px;
    background: var(--panel);
  }
  .pcard {
    --seat-avatar-size: 21px;
    --seat-stat-icon: 15px;
    padding: 5px 6px;
  }
  .pcard .top { gap: 5px; }
  .pcard .stats { gap: 4px; }
  .pcard .name small { display: none; }
  .pcard .vp { font-size: 16px; }
  .bank-info, .game .log { background: var(--hud-rail); padding-inline: 8px; }
  .game .log { min-height: 0; max-height: 88px; }
  .game:has(.offer) {
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .game:has(.offer) .game-main { overflow: auto; overscroll-behavior-y: contain; }
  .actionbar {
    position: sticky;
    inset-block-end: 0;
    min-height: 0;
  }
  .actionbar:has(.offer) { position: relative; }
  .actionbar .actions { margin: 0 0 0 auto; }
  .game .brand { font-size: 19px; }
  .topbar { min-height: 44px; gap: 6px; flex-wrap: wrap; }
}
@media (max-width: 860px) and (max-height: 520px) {
  .offer { max-block-size: 36dvh; }
}
@media (max-width: 620px) {
  .menu { padding: 15px; gap: 16px; }
  .menu-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; padding-bottom: 0; }
  .menu-preview { grid-row: 1; inline-size: 100%; aspect-ratio: 1.8; min-height: 180px; }
  .menu .logo { margin: 0 0 14px; }
  .menu .logo .t1 { font-size: clamp(39px, 12vw, 64px); }
  .menu-kingdom { margin-top: 14px; }
  .menu-top-actions { gap: 8px; }
  .game { --hud-hand-width: 43px; --hud-hand-height: 46px; --hud-icon-button-size: 36px; }
  .brand, .game .brand { gap: 5px; font-size: clamp(13px, 3.7vw, 17px); }
  .brand-mark { width: 18px; height: 18px; }
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: 'brand dice actions' 'status status status';
    padding: 5px 8px;
    gap: 5px 8px;
  }
  .topbar .brand { grid-area: brand; }
  .topbar .dice-group { grid-area: dice; }
  .topbar .top-actions { grid-area: actions; }
  .match-status {
    grid-area: status;
    flex-wrap: wrap;
    gap: 4px 9px;
    padding-block-start: 5px;
  }
  .top-actions { gap: 4px; }
  .game .turn-info { font-size: 12px; gap: 6px; }
  .game .round-tag { padding-inline-start: 7px; font-size: 12px; }
  .dice-group .dice-label { display: none; }
  .turn-timer { font-size: 11px; }
  .die { width: 22px; height: 22px; padding: 3px; }
  .die i { width: 4px; height: 4px; }
  .dice { gap: 3px; }
  .dice-sum { min-width: 14px; font-size: 15px; }
  .event-badge { max-width: 132px; overflow: hidden; padding: 2px 5px; font-size: 11px; }
  .actionbar { padding-inline: 7px; }
  .actionbar > .offer-slot { flex-basis: 100%; }
  .actions .btn { font-size: 12px; padding: 4px 6px; min-height: 32px; }
  .rcard { padding: 2px; }
  .actionbar :is(.act-trade, .act-build, .act-end) { padding: 4px 6px; min-width: 63px; min-height: 33px; font-size: 12px; }
  .build-options { inset-inline-end: -10px; }
  .resource-name { font-size: 9px; }
  .dcard { width: 32px; height: 44px; }
  .game-main .board-svg { height: calc(100% - 44px); }
  .board-tools {
    display: flex;
    position: absolute;
    inset: auto 0 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: 44px;
    padding-inline: 6px;
    background: var(--hud-rail);
  }
  .board-tools .zoom-ctrl { position: static; flex: none; flex-direction: row; margin-inline-start: auto; }
  .board-tools .roll-log {
    position: relative;
    inset: auto;
  }
  .board-tools .roll-log-values {
    inset: auto auto 100% 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    width: 162px;
  }
  .board-wrap .save-status { bottom: 48px; }
}
@media (min-width: 550px) and (max-width: 860px) and (max-height: 520px) and (orientation: landscape) {
  .game {
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: clip;
  }
  .game-main { grid-template-columns: minmax(0, 1fr) minmax(160px, 27%); }
  .game-main .board-wrap { grid-row: auto; min-height: 0; height: auto; }
  .game .side { display: flex; overflow-y: auto; overscroll-behavior: contain; }
  .game :is(.players-panel, .activity-panel) { display: block; flex: none; max-height: none; }
  .game .players { grid-template-columns: minmax(0, 1fr); }
  .game .actionbar { position: relative; }
}
@media (prefers-reduced-motion: reduce) {
  .game *, .game *::before, .game *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
