:root {
  --ink: #111714;
  --paper: #f3ecd7;
  --paper-strong: #fff9e9;
  --pine: #143f35;
  --moss: #51684f;
  --ice: #cbe6df;
  --rust: #bd4d35;
  --amber: #f2bc57;
  --shadow: rgba(16, 23, 20, 0.24);
  --panel: rgba(255, 249, 233, 0.9);
  --line: rgba(17, 23, 20, 0.16);
  --glass-dark: rgba(13, 26, 22, 0.76);
  --control-surface: rgba(255, 252, 241, 0.76);
  --control-surface-strong: rgba(255, 252, 241, 0.94);
  --control-muted: rgba(17, 23, 20, 0.62);
  --control-focus: rgba(189, 77, 53, 0.58);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Bricolage Grotesque", Georgia, serif;
  background: #17231f;
  overflow: hidden;
}

body.lobby-body {
  min-height: 100%;
  overflow: auto;
  background:
    linear-gradient(rgba(13, 26, 22, 0.66), rgba(13, 26, 22, 0.86)),
    url("/static/img/ground/frozen-cobblestone.png") center / 24rem repeat,
    #17231f;
}

body.auth-body {
  display: grid;
  place-items: center;
}

button,
select,
input,
textarea {
  font: inherit;
}

button,
select,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea {
  border: 1px solid rgba(17, 23, 20, 0.22);
  border-radius: 14px;
}

button {
  cursor: pointer;
  color: var(--paper-strong);
  background: var(--pine);
  padding: 0.8rem 0.9rem;
  box-shadow: 0 12px 24px rgba(20, 63, 53, 0.16);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

button:hover,
button.active {
  background: var(--rust);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(189, 77, 53, 0.2);
}

button:disabled {
  cursor: progress;
  opacity: 0.7;
}

a.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(17, 23, 20, 0.22);
  border-radius: 14px;
  background: var(--pine);
  box-shadow: 0 12px 24px rgba(20, 63, 53, 0.16);
  color: var(--paper-strong);
  padding: 0.8rem 0.9rem;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

a.button-link:hover {
  background: var(--rust);
  box-shadow: 0 14px 28px rgba(189, 77, 53, 0.2);
  transform: translateY(-1px);
}

a.secondary-link {
  width: 100%;
  margin-top: 0.5rem;
  background: rgba(20, 63, 53, 0.86);
}

.auth-shell {
  width: min(24rem, calc(100vw - 2rem));
  padding: 1rem;
}

.auth-panel {
  border: 1px solid rgba(255, 249, 233, 0.28);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.28);
  padding: 1.25rem;
}

.auth-panel h1 {
  margin: 0.12rem 0 0.9rem;
  font-size: clamp(2rem, 11vw, 3.6rem);
}

.auth-form {
  display: grid;
  gap: 0.72rem;
}

.auth-form button {
  margin-top: 0.35rem;
}

.auth-error {
  color: #8f2d21;
  font-weight: 700;
}

.auth-link {
  color: var(--paper-strong);
  font-size: 0.78rem;
  text-align: center;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.45rem;
  border: 1px solid rgba(17, 23, 20, 0.14);
  border-radius: 8px;
  background: rgba(255, 252, 241, 0.74);
  color: rgba(17, 23, 20, 0.76);
  padding: 0.55rem 0.72rem;
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  font-weight: 700;
}

.logout-form {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.logout-form button {
  min-height: 2.45rem;
  border-radius: 8px;
  padding: 0.56rem 0.7rem;
}

.drawer-session {
  margin-left: auto;
}

.admin-shell {
  max-width: 1180px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.admin-panel {
  margin-top: 1rem;
}

.admin-panel h2 {
  margin: 0 0 0.7rem;
  color: var(--ink);
  font-size: 1.15rem;
}

.admin-panel-head,
.inline-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.admin-panel-head {
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

.inline-form input,
.inline-form select {
  min-height: 2.35rem;
  border-radius: 8px;
  padding: 0.48rem 0.58rem;
}

.inline-form input[type="number"] {
  width: 5.2rem;
}

.inline-form button,
.admin-table button {
  min-height: 2.35rem;
  border-radius: 8px;
  padding: 0.48rem 0.65rem;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid rgba(17, 23, 20, 0.1);
  padding: 0.56rem 0.42rem;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: rgba(17, 23, 20, 0.62);
  font-family: "Space Mono", monospace;
  font-size: 0.64rem;
  text-transform: uppercase;
}

.admin-table code,
.code-grid code {
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
}

.code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.45rem;
}

select {
  width: 100%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  padding: 0.72rem 0.8rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="color"],
textarea {
  width: 100%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  padding: 0.72rem 0.8rem;
}

textarea {
  resize: vertical;
}

select:focus-visible,
input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
input[type="number"]:focus-visible,
input[type="search"]:focus-visible,
input[type="color"]:focus-visible,
textarea:focus-visible,
button:focus-visible,
a.button-link:focus-visible {
  outline: 2px solid var(--control-focus);
  outline-offset: 2px;
}

input[type="file"] {
  width: 100%;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.shell,
.viewport-card,
.tabletop {
  width: 100vw;
  height: 100vh;
}

.shell {
  position: relative;
  overflow: hidden;
}

.lobby-shell {
  width: 100%;
  min-height: 100vh;
  padding: clamp(0.75rem, 2vw, 1.5rem);
}

.lobby-panel {
  display: grid;
  width: min(82rem, 100%);
  gap: 0.85rem;
  margin: 0 auto;
}

.lobby-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(255, 249, 233, 0.92);
  box-shadow: 0 24px 70px var(--shadow);
  padding: clamp(0.85rem, 2vw, 1.15rem);
}

.lobby-title-block {
  max-width: 42rem;
}

.lobby-head h1 {
  margin-bottom: 0.4rem;
  font-size: 3rem;
  line-height: 0.95;
  letter-spacing: 0;
}

.lobby-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.lobby-head .button-link {
  border-radius: 8px;
  box-shadow: none;
}

.lobby-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.lobby-stat {
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(13, 26, 22, 0.74);
  color: var(--paper-strong);
  padding: 0.62rem 0.76rem;
  backdrop-filter: blur(12px);
}

.lobby-stat strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1;
}

.lobby-stat span {
  display: block;
  margin-top: 0.24rem;
  color: rgba(255, 249, 233, 0.72);
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
}

.lobby-tabbed-workspace {
  display: grid;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(255, 249, 233, 0.9);
  box-shadow: 0 24px 70px var(--shadow);
  overflow: hidden;
}

.lobby-tabs {
  display: flex;
  gap: 0.35rem;
  border-bottom: 1px solid rgba(17, 23, 20, 0.13);
  background: rgba(13, 26, 22, 0.08);
  padding: 0.5rem;
}

.lobby-tab {
  min-width: 8rem;
  border-color: transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: rgba(17, 23, 20, 0.76);
  padding: 0.62rem 0.8rem;
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.lobby-tab:hover,
.lobby-tab.active,
.lobby-tab[aria-selected="true"] {
  background: var(--pine);
  color: var(--paper-strong);
  transform: none;
  box-shadow: none;
}

.lobby-tab-panel {
  padding: 0.85rem;
}

.lobby-tab-panel[hidden] {
  display: none;
}

.lobby-workspace {
  display: grid;
  grid-template-columns: minmax(24rem, 0.95fr) minmax(28rem, 1.2fr);
  align-items: start;
  gap: 0.85rem;
}

.lobby-campaign-workspace,
.lobby-warband-workspace {
  display: grid;
  grid-template-columns: minmax(24rem, 0.95fr) minmax(28rem, 1.2fr);
  align-items: start;
  gap: 0.85rem;
}

.lobby-create-card,
.lobby-games-card,
.lobby-campaign-card,
.lobby-campaigns-card,
.lobby-warband-editor-card,
.lobby-warband-list-card {
  display: grid;
  gap: 0.85rem;
  background: rgba(255, 252, 241, 0.72);
  box-shadow: none;
}

.tool-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.8rem;
  border-bottom: 1px solid rgba(17, 23, 20, 0.11);
  margin: -0.1rem -0.1rem 0;
  padding: 0 0.1rem 0.72rem;
}

.tool-card .tool-card-head h2 {
  display: block;
  border: 0;
  margin: 0;
  padding: 0;
}

.tool-card-head p {
  margin: 0.22rem 0 0;
  color: rgba(17, 23, 20, 0.66);
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.38;
}

.lobby-badge,
.game-open-label,
.game-chip-row span {
  border: 1px solid rgba(17, 23, 20, 0.13);
  border-radius: 999px;
  background: rgba(203, 230, 223, 0.32);
  color: rgba(17, 23, 20, 0.72);
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
}

.lobby-badge {
  padding: 0.24rem 0.46rem;
  text-transform: uppercase;
}

.lobby-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(9rem, 0.6fr);
  gap: 0.65rem;
}

.lobby-form-grid .field {
  margin-top: 0;
}

.lobby-player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
  gap: 0.65rem;
}

.player-card {
  display: grid;
  gap: 0.62rem;
  min-width: 0;
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 252, 241, 0.74), rgba(203, 230, 223, 0.18)),
    rgba(255, 252, 241, 0.46);
  padding: 0.72rem;
}

.player-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.48rem;
}

.player-card-head > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.48rem;
}

.player-card-head > div > span {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  border-radius: 999px;
  background: var(--pine);
  color: var(--paper-strong);
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
}

.player-card-head strong {
  overflow: hidden;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-ai-toggle {
  flex: 0 0 auto;
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 999px;
  background: rgba(255, 252, 241, 0.62);
  color: rgba(17, 23, 20, 0.68);
  margin: 0;
  padding: 0.24rem 0.46rem;
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.check-field.player-ai-toggle input {
  width: 0.92rem;
  height: 0.92rem;
}

.lobby-terrain-field {
  margin-top: 0;
}

.lobby-create-actions {
  display: grid;
  grid-template-columns: minmax(10rem, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  border-top: 1px solid rgba(17, 23, 20, 0.11);
  padding-top: 0.85rem;
}

.lobby-create-actions .microcopy,
.lobby-list-status {
  margin: 0;
}

.lobby-games-card {
  min-height: 30rem;
}

.lobby-games-card .tool-card-head {
  align-items: center;
}

.lobby-games-card .tool-card-head button {
  min-width: 6.4rem;
}

.lobby-search-field {
  margin-top: 0;
}

.lobby-game-list {
  max-height: min(38rem, calc(100vh - 22rem));
  overflow: auto;
  padding-right: 0.15rem;
  scrollbar-color: rgba(20, 63, 53, 0.52) rgba(17, 23, 20, 0.08);
  scrollbar-width: thin;
}

.lobby-campaign-list {
  max-height: 28rem;
  overflow: auto;
  padding-right: 0.15rem;
  scrollbar-color: rgba(20, 63, 53, 0.52) rgba(17, 23, 20, 0.08);
  scrollbar-width: thin;
}

.lobby-game-link {
  display: grid;
  gap: 0.32rem;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.lobby-campaign-item {
  display: grid;
  gap: 0.42rem;
}

.campaign-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.18rem;
}

.warband-editor-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 0.55rem;
}

.warband-quantity-field {
  width: 5.5rem;
}

.warband-editor-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.warband-editor-summary span,
.warband-unit-stat {
  border: 1px solid rgba(17, 23, 20, 0.14);
  border-radius: 999px;
  background: rgba(20, 63, 53, 0.08);
  padding: 0.24rem 0.48rem;
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
}

.warband-unit-list,
.warband-roster-list {
  display: grid;
  gap: 0.55rem;
  max-height: 35rem;
  overflow: auto;
  padding-right: 0.15rem;
  scrollbar-color: rgba(20, 63, 53, 0.52) rgba(17, 23, 20, 0.08);
  scrollbar-width: thin;
}

.warband-unit-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 241, 0.68);
  padding: 0.66rem;
}

.warband-unit-card header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
}

.warband-unit-card header strong,
.warband-unit-card header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warband-unit-card header button {
  padding: 0.48rem 0.62rem;
}

.warband-unit-card input {
  width: 100%;
  border: 1px solid rgba(17, 23, 20, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  padding: 0.58rem 0.62rem;
}

.warband-unit-fields {
  display: grid;
  grid-template-columns: minmax(9rem, 1.1fr) minmax(6.5rem, 0.75fr) repeat(6, minmax(4.2rem, 0.5fr));
  gap: 0.45rem;
  margin-top: 0.58rem;
}

.warband-unit-fields .field span,
.warband-unit-detail-fields .field span {
  font-size: 0.56rem;
}

.warband-unit-detail-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.warband-unit-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.warband-roster-item {
  cursor: pointer;
}

.warband-roster-item:hover {
  background: rgba(255, 249, 233, 0.96);
}

.warband-library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.danger-action {
  background: rgba(115, 28, 28, 0.9);
}

.warband-editor-body {
  overflow: auto;
}

.warband-page-shell {
  display: grid;
  gap: 0.85rem;
  width: min(94rem, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.5rem);
}

.warband-page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(255, 249, 233, 0.94);
  box-shadow: 0 24px 70px var(--shadow);
  padding: clamp(0.85rem, 2vw, 1.15rem);
}

.warband-page-head h1 {
  margin: 0.1rem 0 0.35rem;
  font-size: clamp(2.15rem, 4vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.warband-editor-grid {
  display: grid;
  grid-template-columns: minmax(15rem, 0.58fr) minmax(32rem, 1.34fr) minmax(20rem, 0.9fr);
  align-items: start;
  gap: 0.85rem;
}

.warband-library-panel,
.warband-main-panel,
.warband-inspector-panel {
  display: grid;
  gap: 0.75rem;
  background: rgba(255, 252, 241, 0.78);
  box-shadow: none;
}

.warband-editor-title-row,
.warband-management-row,
.editor-fields-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8rem, 0.28fr);
  gap: 0.55rem;
  align-items: end;
}

.warband-management-row {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.warband-total-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.warband-total-strip span {
  border: 1px solid rgba(17, 23, 20, 0.14);
  border-radius: 8px;
  background: rgba(20, 63, 53, 0.08);
  padding: 0.56rem 0.62rem;
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.warband-total-strip strong {
  display: block;
  color: var(--pine);
  font-family: "Bricolage Grotesque", Georgia, serif;
  font-size: 1.45rem;
  line-height: 1;
  text-transform: none;
}

.editor-unit-list {
  display: grid;
  gap: 0.55rem;
  max-height: calc(100vh - 29rem);
  min-height: 14rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.editor-unit-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 241, 0.66);
  color: var(--ink);
  padding: 0.66rem;
  text-align: left;
  box-shadow: none;
}

.editor-unit-card:hover,
.editor-unit-card.active {
  border-color: rgba(189, 77, 53, 0.46);
  background: rgba(255, 249, 233, 0.96);
  transform: translateY(-1px);
}

.editor-unit-main {
  min-width: 0;
}

.editor-unit-main strong,
.editor-unit-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-unit-main span {
  margin-top: 0.16rem;
  color: rgba(17, 23, 20, 0.62);
  font-size: 0.72rem;
}

.editor-unit-cost {
  color: var(--pine);
  font-family: "Space Mono", monospace;
  font-size: 0.75rem;
}

.editor-inspector {
  display: grid;
  gap: 0.7rem;
}

.editor-inspector select,
.editor-inspector input,
.editor-inspector textarea {
  width: 100%;
  border: 1px solid rgba(17, 23, 20, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  padding: 0.58rem 0.62rem;
}

.editor-inspector select,
.editor-inspector input {
  min-height: 2.72rem;
}

.editor-portrait-preview {
  position: relative;
  display: grid;
  min-height: 11rem;
  border: 1px solid rgba(17, 23, 20, 0.13);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(20, 63, 53, 0.08), rgba(189, 77, 53, 0.08)),
    rgba(255, 252, 241, 0.72);
  overflow: hidden;
}

.editor-portrait-preview img {
  display: none;
  max-width: min(9rem, 70%);
  max-height: 10rem;
  object-fit: contain;
}

.editor-standee-scene {
  width: 100%;
  min-height: 14rem;
  cursor: grab;
}

.editor-standee-scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.editor-standee-scene:active {
  cursor: grabbing;
}

.editor-procedural-preview {
  display: grid;
  place-items: center;
  width: 5.4rem;
  aspect-ratio: 0.58;
  border: 0.55rem solid #49c6e5;
  border-radius: 8px;
  background: rgba(255, 249, 233, 0.94);
  color: var(--ink);
  font-family: "Space Mono", monospace;
  font-size: 2rem;
  font-weight: 700;
}

.editor-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.editor-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.42rem;
  margin-bottom: 0.42rem;
}

.editor-picker-row button {
  padding: 0.62rem 0.72rem;
}

.editor-section-block {
  display: grid;
  gap: 0.55rem;
  border-top: 1px solid rgba(17, 23, 20, 0.12);
  padding-top: 0.7rem;
}

.editor-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8rem, 0.72fr);
  align-items: end;
  gap: 0.55rem;
}

.editor-section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.standee-gallery,
.spell-browser {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  max-height: 18rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.standee-option,
.spell-option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 241, 0.64);
  color: var(--ink);
  padding: 0.5rem;
  text-align: left;
  box-shadow: none;
}

.standee-option.active,
.spell-option.active {
  border-color: rgba(189, 77, 53, 0.5);
  background: rgba(255, 249, 233, 0.96);
}

.standee-option img {
  display: block;
  width: 100%;
  height: 5.8rem;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(13, 26, 22, 0.08);
}

.standee-option strong,
.spell-option strong {
  display: block;
  margin-top: 0.34rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.spell-option span,
.spell-option p,
.standee-option span {
  display: block;
  margin: 0.16rem 0 0;
  color: rgba(17, 23, 20, 0.62);
  font-size: 0.68rem;
}

.selected-spell-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.selected-spell-row button {
  border-radius: 999px;
  background: rgba(20, 63, 53, 0.88);
  padding: 0.35rem 0.52rem;
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
}

.warband-action-bar {
  position: sticky;
  bottom: 0.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(255, 249, 233, 0.96);
  box-shadow: 0 14px 42px rgba(16, 23, 20, 0.24);
  padding: 0.66rem;
  z-index: 5;
}

.campaign-action-row button,
.campaign-action-row .button-link {
  min-width: 7rem;
  border-radius: 8px;
  box-shadow: none;
  padding: 0.58rem 0.72rem;
  font-size: 0.78rem;
}

.game-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.game-card-top .item-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-open-label {
  padding: 0.18rem 0.42rem;
}

.game-terrain {
  color: rgba(17, 23, 20, 0.82);
  font-weight: 700;
}

.game-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.12rem;
}

.game-chip-row span {
  display: inline-flex;
  padding: 0.16rem 0.42rem;
}

.viewport-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 12%, rgba(242, 188, 87, 0.25), transparent 24rem),
    linear-gradient(rgba(8, 31, 28, 0.12), rgba(8, 31, 28, 0.04)),
    #19251f;
}

.tabletop canvas {
  display: block;
}

.top-bar,
.selected-float,
.hud,
.camera-widget,
.rule-dialog-card,
.control-drawer {
  backdrop-filter: blur(18px);
}

.top-bar {
  position: absolute;
  z-index: 5;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.icon-button {
  display: grid;
  gap: 0.22rem;
  width: 3.1rem;
  height: 3.1rem;
  place-content: center;
  flex: 0 0 auto;
  border-color: rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: var(--glass-dark);
  padding: 0;
}

.icon-button span:not(.sr-only) {
  display: block;
  width: 1.2rem;
  height: 2px;
  border-radius: 999px;
  background: var(--paper-strong);
}

.tools-toggle,
.table-title,
.quick-modes,
.phase-help-toggle,
.top-end-phase,
.selected-float,
.hud {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: var(--glass-dark);
  color: var(--paper-strong);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
}

.tools-toggle {
  flex: 0 0 auto;
  border-radius: 18px;
  padding: 0.84rem 1rem;
  font-family: "Space Mono", monospace;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tools-toggle.active,
.tools-toggle:hover {
  background: var(--rust);
}

.table-title {
  display: grid;
  min-width: 0;
  max-width: 32rem;
  border-radius: 20px;
  padding: 0.62rem 0.9rem;
}

.table-title strong {
  line-height: 1;
  letter-spacing: -0.03em;
}

.table-title span {
  overflow: hidden;
  color: rgba(255, 249, 233, 0.72);
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phase-help-toggle {
  display: grid;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 18px;
  padding: 0;
  font-family: "Space Mono", monospace;
  font-size: 0.9rem;
  font-weight: 700;
}

.phase-help-toggle.active,
.phase-help-toggle:hover {
  background: var(--rust);
}

.quick-modes {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
  border-radius: 20px;
  padding: 0.35rem;
}

.xr-toggle {
  flex: 0 0 auto;
  border-color: rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: var(--glass-dark);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
  padding: 0.76rem 0.82rem;
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
}

.xr-toggle.active,
.xr-toggle:hover {
  background: var(--rust);
}

.top-end-phase {
  flex: 0 0 auto;
  border-radius: 18px;
  padding: 0.76rem 0.92rem;
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.top-end-phase:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(167, 201, 87, 0.28), rgba(242, 188, 87, 0.16)),
    var(--glass-dark);
  border-color: rgba(167, 201, 87, 0.55);
}

.top-end-phase:hover {
  background: var(--rust);
}

.quick-modes button {
  border-color: transparent;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
  padding: 0.62rem 0.78rem;
}

.quick-modes button:hover,
.quick-modes button.active {
  background: var(--rust);
}

.mode-chip {
  top: 5.2rem;
  left: 1rem;
}

.phase-banner {
  position: absolute;
  z-index: 7;
  top: 46%;
  left: 50%;
  display: grid;
  width: min(32rem, calc(100vw - 2rem));
  gap: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(13, 26, 22, 0.82);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.36);
  color: var(--paper-strong);
  padding: clamp(1rem, 3vw, 1.35rem);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(18px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.phase-banner.visible {
  opacity: 1;
  transform: translate(-50%, -54%);
}

.phase-banner[hidden] {
  display: none;
}

.phase-banner strong {
  font-size: clamp(1.35rem, 4vw, 2.15rem);
  line-height: 1.05;
}

.phase-banner span {
  color: rgba(255, 249, 233, 0.76);
  font-family: "Space Mono", monospace;
  font-size: clamp(0.72rem, 2vw, 0.86rem);
  line-height: 1.45;
}

.phase-help-panel {
  position: absolute;
  z-index: 10;
  top: 4.85rem;
  left: 5.1rem;
  display: grid;
  width: min(24rem, calc(100vw - 2rem));
  gap: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 249, 233, 0.94);
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.24);
  color: var(--ink);
  padding: 0.82rem;
  backdrop-filter: blur(18px);
}

.phase-help-panel[hidden] {
  display: none;
}

.phase-help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.phase-help-head strong {
  font-size: 0.96rem;
}

.phase-help-head button,
.phase-help-mini {
  border-radius: 8px;
  box-shadow: none;
  font-family: "Space Mono", monospace;
  font-size: 0.66rem;
}

.phase-help-head button {
  padding: 0.46rem 0.58rem;
}

.phase-cycle-list {
  display: grid;
  gap: 0.42rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase-cycle-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem;
  align-items: start;
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.44);
  padding: 0.52rem 0.58rem;
}

.phase-cycle-list li.active {
  border-color: rgba(189, 77, 53, 0.45);
  background: rgba(242, 188, 87, 0.26);
}

.phase-cycle-list i {
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  border-radius: 999px;
  background: var(--pine);
  color: var(--paper-strong);
  font-family: "Space Mono", monospace;
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 700;
}

.phase-cycle-list li.active i {
  background: var(--rust);
}

.phase-cycle-list strong {
  display: block;
  font-size: 0.82rem;
}

.phase-cycle-list span {
  display: block;
  margin-top: 0.14rem;
  color: rgba(17, 23, 20, 0.66);
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  line-height: 1.35;
}

.xr-overlay {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  color: var(--paper-strong);
  pointer-events: none;
}

.xr-overlay[hidden] {
  display: none;
}

.xr-overlay-half {
  position: relative;
  min-width: 0;
}

.xr-eye-hud {
  position: absolute;
  top: 1rem;
  left: 50%;
  display: grid;
  width: min(25rem, calc(100% - 2rem));
  gap: 0.28rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: rgba(13, 26, 22, 0.78);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
  padding: 0.66rem 0.74rem;
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.xr-eye-hud strong {
  line-height: 1;
}

.xr-eye-hud span {
  overflow-wrap: anywhere;
  color: rgba(255, 249, 233, 0.74);
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  line-height: 1.35;
}

.xr-eye-hud .xr-overlay-mode {
  color: var(--paper-strong);
  font-weight: 700;
}

.xr-eye-hud button {
  width: max-content;
  margin-top: 0.18rem;
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--rust);
  box-shadow: none;
  padding: 0.46rem 0.62rem;
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  pointer-events: auto;
}

body.xr-glasses-active .top-bar,
body.xr-glasses-active .mode-chip,
body.xr-glasses-active .camera-widget,
body.xr-glasses-active .selected-float,
body.xr-glasses-active .bottom-left,
body.xr-glasses-active .action-menu {
  display: none;
}

.camera-widget {
  position: absolute;
  z-index: 4;
  top: 5.6rem;
  right: 1rem;
  display: grid;
  width: 12.5rem;
  gap: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 24px;
  background: rgba(13, 26, 22, 0.78);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
  color: var(--paper-strong);
  padding: 0.65rem;
}

.camera-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-left: 0.2rem;
}

.camera-widget-head strong {
  letter-spacing: -0.025em;
}

.camera-widget-head button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 249, 233, 0.1);
  box-shadow: none;
  padding: 0.42rem 0.55rem;
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
}

.camera-map {
  width: 100%;
  aspect-ratio: 1;
  overflow: visible;
  cursor: grab;
  touch-action: none;
}

.camera-map:active {
  cursor: grabbing;
}

.camera-bounds {
  fill: rgba(255, 249, 233, 0.06);
  stroke: rgba(255, 249, 233, 0.16);
  stroke-width: 1;
}

.camera-board {
  fill: rgba(91, 126, 58, 0.7);
  stroke: rgba(255, 249, 233, 0.34);
  stroke-width: 0.8;
}

.camera-terrain {
  fill: rgba(92, 91, 78, 0.82);
  stroke: rgba(255, 249, 233, 0.22);
  stroke-width: 0.55;
}

.camera-sight {
  stroke: rgba(242, 188, 87, 0.9);
  stroke-linecap: round;
  stroke-width: 1.3;
}

.camera-target-dot {
  fill: var(--amber);
  stroke: rgba(13, 26, 22, 0.92);
  stroke-width: 1;
}

.camera-position-dot {
  fill: var(--ice);
  stroke: rgba(13, 26, 22, 0.92);
  stroke-width: 1.2;
}

.selected-float {
  position: absolute;
  z-index: 4;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  width: min(24rem, calc(100vw - 2rem));
  max-height: min(82vh, 42rem);
  overflow-y: auto;
  gap: 0.65rem;
  border-radius: 24px;
  padding: 0.9rem;
}

.selected-float span,
.selected-stats,
.distance-readout,
.microcopy,
.stat-row,
.rules-card p,
.hud,
.item-meta {
  font-family: "Space Mono", monospace;
}

.selected-float > div:first-child {
  display: grid;
  gap: 0.15rem;
}

.selected-float > div:first-child span {
  color: rgba(255, 249, 233, 0.66);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.selected-float strong {
  color: var(--paper-strong);
  font-size: 1.35rem;
  letter-spacing: -0.035em;
}

.selected-stats {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: rgba(255, 249, 233, 0.76);
  font-size: 0.76rem;
}

.meter-wrap {
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 249, 233, 0.16);
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--rust));
  transition: width 180ms ease;
}

.distance-readout {
  margin: 0;
  color: rgba(255, 249, 233, 0.74);
  font-size: 0.78rem;
  line-height: 1.45;
}

.selected-end-activation {
  justify-self: start;
  border-color: rgba(242, 188, 87, 0.46);
  background: rgba(242, 188, 87, 0.14);
  color: var(--paper-strong);
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.selected-end-activation:hover {
  background: rgba(242, 188, 87, 0.28);
}

.selected-end-activation[hidden] {
  display: none;
}

.character-sheet {
  display: grid;
  gap: 0.55rem;
  border: 1px solid rgba(255, 249, 233, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 249, 233, 0.1), rgba(13, 26, 22, 0.46)),
    rgba(13, 26, 22, 0.36);
  padding: 0.65rem;
}

.character-sheet[hidden] {
  display: none;
}

.sheet-head {
  display: grid;
  gap: 0.45rem;
}

.sheet-head > span {
  color: rgba(255, 249, 233, 0.7);
  font-family: "Space Mono", monospace;
  font-size: 0.66rem;
  line-height: 1.25;
  text-transform: uppercase;
}

.sheet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.sheet-tags i {
  border: 1px solid rgba(203, 230, 223, 0.18);
  border-radius: 999px;
  background: rgba(203, 230, 223, 0.1);
  color: rgba(255, 249, 233, 0.78);
  font-family: "Space Mono", monospace;
  font-size: 0.58rem;
  font-style: normal;
  padding: 0.12rem 0.36rem;
}

.sheet-stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.32rem;
}

.sheet-stat-grid div {
  min-width: 0;
  border: 1px solid rgba(255, 249, 233, 0.12);
  border-radius: 12px;
  background: rgba(255, 249, 233, 0.08);
  padding: 0.32rem 0.22rem;
  text-align: center;
}

.sheet-stat-grid span {
  display: block;
  color: rgba(255, 249, 233, 0.58);
  font-family: "Space Mono", monospace;
  font-size: 0.48rem;
  line-height: 1;
  text-transform: uppercase;
}

.sheet-stat-grid strong {
  display: block;
  margin-top: 0.14rem;
  color: var(--paper-strong);
  font-size: 0.82rem;
  letter-spacing: -0.03em;
}

.sheet-extra-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.sheet-extra-stats span {
  border-radius: 999px;
  background: rgba(255, 249, 233, 0.08);
  color: rgba(255, 249, 233, 0.68);
  font-family: "Space Mono", monospace;
  font-size: 0.58rem;
  padding: 0.16rem 0.38rem;
}

.sheet-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
}

.sheet-conditions span {
  border: 1px solid rgba(188, 199, 255, 0.28);
  border-radius: 999px;
  background: rgba(188, 199, 255, 0.13);
  color: rgba(255, 249, 233, 0.9);
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  padding: 0.18rem 0.42rem;
}

.sheet-details {
  border-top: 1px solid rgba(255, 249, 233, 0.1);
  padding-top: 0.42rem;
}

.sheet-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: rgba(255, 249, 233, 0.82);
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  font-weight: 800;
  list-style: none;
  text-transform: uppercase;
}

.sheet-details summary::-webkit-details-marker {
  display: none;
}

.sheet-details summary::after {
  content: "+";
  color: var(--amber);
  font-size: 0.82rem;
}

.sheet-details[open] summary::after {
  content: "-";
}

.sheet-details summary span {
  margin-left: auto;
  margin-right: 0.45rem;
  color: rgba(255, 249, 233, 0.52);
  font-size: 0.58rem;
}

.sheet-details ul {
  display: grid;
  gap: 0.38rem;
  max-height: 7.5rem;
  overflow-y: auto;
  margin: 0.45rem 0 0;
  padding: 0;
  list-style: none;
}

.sheet-details li {
  display: grid;
  gap: 0.12rem;
  border-radius: 10px;
  background: rgba(255, 249, 233, 0.07);
  padding: 0.36rem 0.42rem;
}

.sheet-details li strong {
  color: var(--paper-strong);
  font-size: 0.74rem;
  line-height: 1.2;
}

.sheet-details li span,
.sheet-details p {
  margin: 0.42rem 0 0;
  color: rgba(255, 249, 233, 0.68);
  font-family: "Space Mono", monospace;
  font-size: 0.64rem;
  line-height: 1.35;
}

.attack-result {
  display: grid;
  gap: 0.45rem;
  border: 1px solid rgba(242, 188, 87, 0.32);
  border-radius: 16px;
  background: rgba(13, 26, 22, 0.72);
  color: var(--paper-strong);
  padding: 0.65rem;
}

.attack-result[hidden] {
  display: none;
}

.dice-tray {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 7;
  width: min(25rem, calc(100vw - 2rem));
  border: 1px solid rgba(242, 188, 87, 0.3);
  border-radius: 22px;
  background:
    radial-gradient(circle at 22% 12%, rgba(242, 188, 87, 0.22), transparent 34%),
    linear-gradient(145deg, rgba(18, 24, 21, 0.9), rgba(38, 50, 41, 0.84));
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  color: var(--paper-strong);
  padding: 0.75rem;
  backdrop-filter: blur(20px);
  transform: translateY(0);
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease;
}

.dice-tray[aria-hidden="true"] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.8rem);
}

.dice-tray[hidden] {
  display: none;
}

.dice-tray-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.dice-tray-head span,
.dice-tray-head label {
  color: rgba(255, 249, 233, 0.62);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dice-tray-head label {
  display: grid;
  gap: 0.22rem;
}

.dice-tray-head select {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 249, 233, 0.1);
  color: var(--paper-strong);
  padding: 0.32rem 0.55rem;
}

.dice-roll-actors {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.35rem;
  margin: 0;
  min-width: 0;
}

.dice-roll-actors span {
  display: inline-flex;
  gap: 0.28rem;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 249, 233, 0.08);
  padding: 0.32rem 0.5rem;
  overflow: hidden;
  letter-spacing: 0;
  text-transform: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dice-roll-actors b {
  color: var(--paper-strong);
}

.dice-box-canvas {
  position: relative;
  width: 100%;
  height: 11.5rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 30%, rgba(131, 215, 200, 0.16), transparent 42%),
    rgba(6, 9, 8, 0.42);
  cursor: grab;
  touch-action: none;
}

.dice-box-canvas:active {
  cursor: grabbing;
}

.dice-box-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.dice-grab-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.dice-grab-layer p {
  position: absolute;
  bottom: 0.65rem;
  left: 0.75rem;
  right: 0.75rem;
  margin: 0;
  color: rgba(255, 249, 233, 0.72);
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  text-align: center;
}

.dice-grab-token {
  position: relative;
  display: grid;
  width: 5.2rem;
  height: 5.2rem;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--die-color, #f2bc57);
  cursor: grab;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.38));
  pointer-events: auto;
  transform-style: preserve-3d;
  touch-action: none;
  user-select: none;
  transition: filter 140ms ease, scale 140ms ease;
}

.dice-grab-token.grabbing {
  cursor: grabbing;
  scale: 1.05;
  filter: drop-shadow(0 26px 32px rgba(0, 0, 0, 0.46));
}

.dice-grab-d20 {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dice-grab-shell {
  fill: currentColor;
  stroke: rgba(255, 249, 233, 0.82);
  stroke-width: 2.2;
  stroke-linejoin: round;
}

.dice-grab-face {
  stroke: rgba(17, 23, 20, 0.38);
  stroke-width: 1;
  stroke-linejoin: round;
}

.dice-grab-face-light {
  fill: #fff9e9;
  opacity: 0.28;
}

.dice-grab-face-mid {
  fill: #07100d;
  opacity: 0.16;
}

.dice-grab-face-dark {
  fill: #07100d;
  opacity: 0.3;
}

.dice-grab-ridge {
  fill: none;
  stroke: rgba(255, 249, 233, 0.58);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.dice-grab-number {
  fill: var(--paper-strong);
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 1.65rem;
  font-weight: 900;
  paint-order: stroke;
  stroke: rgba(17, 23, 20, 0.74);
  stroke-width: 0.22rem;
  text-anchor: middle;
  dominant-baseline: middle;
}

.dice-grab-token span {
  position: absolute;
  bottom: -0.85rem;
  color: var(--paper-strong);
  font-family: "Space Mono", monospace;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.42);
  text-transform: uppercase;
}

.dice-tray-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.dice-tray-actions button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 249, 233, 0.1);
  color: var(--paper-strong);
  cursor: pointer;
  font-size: 0.64rem;
  font-weight: 900;
  padding: 0.38rem 0.58rem;
}

.dice-tray-actions button.active {
  border-color: rgba(242, 188, 87, 0.62);
  background: rgba(242, 188, 87, 0.22);
}

.dice-tray .microcopy {
  margin: 0.5rem 0 0;
}

.attack-result-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  font-weight: 800;
}

.dice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.die-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background:
    radial-gradient(circle at 22% 12%, rgba(242, 188, 87, 0.16), transparent 34%),
    rgba(255, 249, 233, 0.09);
  padding: 0.5rem;
  overflow: hidden;
  position: relative;
}

.die-card.winner {
  border-color: rgba(242, 188, 87, 0.55);
  box-shadow: inset 0 0 0 1px rgba(242, 188, 87, 0.18), 0 0 22px rgba(242, 188, 87, 0.14);
}

.d20-shell {
  width: 3.85rem;
  height: 3.85rem;
  display: grid;
  place-items: center;
  perspective: 220px;
}

.d20-result-token {
  width: 3.2rem;
  height: 3.2rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(242, 188, 87, 0.48);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(242, 188, 87, 0.26), rgba(189, 77, 53, 0.18)),
    rgba(17, 23, 20, 0.86);
  box-shadow: inset 0 0 0 1px rgba(255, 249, 233, 0.08), 0 8px 16px rgba(0, 0, 0, 0.22);
  transform: rotate(45deg);
}

.d20-result-token span,
.d20-result-token strong {
  transform: rotate(-45deg);
}

.d20-result-token span {
  color: rgba(255, 249, 233, 0.6);
  font-size: 0.46rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.d20-result-token strong {
  color: var(--paper-strong);
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 1.3rem;
  line-height: 1;
}

.d20 {
  --roll-spin: 180deg;
  width: 3.45rem;
  height: 3.72rem;
  position: relative;
  display: grid;
  place-items: center;
  color: #fff9e9;
  isolation: isolate;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.28));
  animation: d20-roll 820ms cubic-bezier(0.16, 0.86, 0.2, 1.08) both;
}

.d20-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.d20 > strong {
  position: relative;
  z-index: 2;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 1.42rem;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(17, 23, 20, 0.82), 0 0 10px rgba(17, 23, 20, 0.38);
}

.d20-shadow {
  fill: #3c1e18;
  stroke: rgba(255, 249, 233, 0.82);
  stroke-width: 2.2;
  stroke-linejoin: round;
}

.d20-face {
  stroke: rgba(60, 30, 24, 0.82);
  stroke-width: 1.35;
  stroke-linejoin: round;
}

.d20-face-1 { fill: #f4c46a; }
.d20-face-2 { fill: #e99f4d; }
.d20-face-3 { fill: #9c3f32; }
.d20-face-4 { fill: #c9583d; }
.d20-face-5 { fill: #d86d3f; }
.d20-face-6 { fill: #7e302b; }
.d20-face-7 { fill: #5f2a28; }
.d20-face-8 { fill: #6f3028; }
.d20-face-9 { fill: #8e3b2e; }
.d20-face-10 { fill: #a84731; }
.d20-face-11 { fill: #bd4d35; }
.d20-face-12 { fill: #f2bc57; }

.d20-ridge {
  fill: none;
  stroke: rgba(255, 249, 233, 0.36);
  stroke-width: 0.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.d20-face-number {
  fill: rgba(255, 249, 233, 0.68);
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(17, 23, 20, 0.55);
  stroke-width: 1.2;
}

.die-total {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.die-total > span {
  color: rgba(255, 249, 233, 0.6);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.die-total strong {
  display: block;
  font-size: 1.1rem;
}

.die-card > span,
.attack-result p {
  margin: 0;
  color: rgba(255, 249, 233, 0.68);
  font-size: 0.68rem;
  line-height: 1.35;
}

.die-card > span {
  grid-column: 1 / -1;
}

@keyframes d20-roll {
  0% {
    transform: rotate(-34deg) rotateY(-58deg) rotateX(36deg) scale(0.72);
    opacity: 0.25;
  }
  46% {
    transform: rotate(calc(var(--roll-spin) - 90deg)) rotateY(210deg) rotateX(-24deg) scale(1.12);
    opacity: 1;
  }
  72% {
    transform: rotate(calc(var(--roll-spin) + 18deg)) rotateY(-18deg) rotateX(8deg) scale(0.96);
  }
  100% {
    transform: rotate(var(--roll-spin)) rotateY(0deg) rotateX(0deg) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .d20 {
    animation: none;
  }
}

@media (max-width: 520px) {
  .dice-row {
    grid-template-columns: 1fr;
  }
}

.hud {
  position: absolute;
  z-index: 4;
  display: flex;
  gap: 0.55rem;
  border-radius: 999px;
  padding: 0.55rem 0.75rem;
  font-size: 0.74rem;
  pointer-events: none;
}

.action-menu {
  position: absolute;
  z-index: 7;
  display: grid;
  width: 12.5rem;
  max-height: min(22rem, calc(100vh - 2rem));
  overflow-y: auto;
  overscroll-behavior: contain;
  gap: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: rgba(13, 26, 22, 0.9);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.32);
  padding: 0.48rem;
  transform: none;
  backdrop-filter: blur(18px);
  scrollbar-color: rgba(242, 188, 87, 0.72) rgba(255, 249, 233, 0.08);
  scrollbar-width: thin;
}

.action-menu[hidden] {
  display: none;
}

.action-menu::after {
  display: none;
}

.action-menu strong {
  overflow: hidden;
  color: var(--paper-strong);
  padding: 0.14rem 0.3rem 0.22rem;
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-menu-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.3rem;
}

.action-menu button {
  position: relative;
  z-index: 1;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 249, 233, 0.1);
  box-shadow: none;
  min-width: 0;
  padding: 0.42rem 0.5rem;
  font-size: 0.74rem;
  line-height: 1.18;
  text-align: left;
}

.action-menu button:hover {
  background: var(--rust);
}

.action-menu-rules {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin-top: 0.15rem;
  padding-top: 0.38rem;
}

.action-menu-rules:empty {
  display: none;
}

.action-menu-meta {
  color: rgba(255, 249, 233, 0.68);
  font-family: "Space Mono", monospace;
  font-size: 0.58rem;
  line-height: 1.25;
}

.action-menu .rule-action {
  border-color: rgba(203, 230, 223, 0.28);
  background:
    linear-gradient(135deg, rgba(203, 230, 223, 0.18), rgba(242, 188, 87, 0.1)),
    rgba(255, 249, 233, 0.08);
}

.action-menu .rule-action small {
  display: block;
  margin-top: 0.12rem;
  color: rgba(255, 249, 233, 0.62);
  font-family: "Space Mono", monospace;
  font-size: 0.56rem;
  line-height: 1.25;
}

.rule-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(4, 9, 7, 0.48);
  padding: 1rem;
}

.rule-dialog[hidden] {
  display: none;
}

.victory-banner {
  position: fixed;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(242, 188, 87, 0.24), transparent 28rem),
    rgba(10, 17, 15, 0.58);
  opacity: 0;
  padding: 1rem;
  backdrop-filter: blur(12px);
  transition: opacity 160ms ease;
}

.victory-banner.visible {
  opacity: 1;
}

.victory-banner[hidden] {
  display: none;
}

.story-prompt {
  position: fixed;
  z-index: 13;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 11, 10, 0.62);
  opacity: 0;
  padding: 1rem;
  backdrop-filter: blur(12px);
  transition: opacity 160ms ease;
}

.story-prompt.visible {
  opacity: 1;
}

.story-prompt[hidden] {
  display: none;
}

.victory-card {
  display: grid;
  width: min(48rem, calc(100vw - 2rem));
  max-height: min(88vh, 46rem);
  overflow: auto;
  gap: 0.9rem;
  border: 1px solid rgba(242, 188, 87, 0.42);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 249, 233, 0.96), rgba(230, 215, 174, 0.92)),
    var(--paper-strong);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.42);
  padding: clamp(1rem, 3vw, 1.35rem);
}

.story-card {
  display: grid;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(88vh, 42rem);
  overflow: auto;
  gap: 0.85rem;
  border: 1px solid rgba(203, 230, 223, 0.4);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 249, 233, 0.97), rgba(203, 230, 223, 0.92)),
    var(--paper-strong);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.42);
  padding: clamp(1rem, 3vw, 1.35rem);
}

.victory-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(17, 23, 20, 0.14);
  padding-bottom: 0.85rem;
}

.story-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(17, 23, 20, 0.14);
  padding-bottom: 0.78rem;
}

.victory-head strong {
  display: block;
  color: var(--ink);
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.story-head strong {
  display: block;
  color: var(--ink);
  font-size: clamp(1.4rem, 4vw, 2.35rem);
  line-height: 1;
  letter-spacing: 0;
}

.victory-head button,
.victory-actions button,
.story-head button,
.story-actions button,
.story-audio-controls button {
  border-radius: 9px;
  box-shadow: none;
}

.story-content {
  display: grid;
  gap: 0.65rem;
  color: rgba(17, 23, 20, 0.78);
  font-family: "Space Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.55;
}

.story-content h2,
.story-content h3,
.story-content h4,
.story-content p,
.story-content ul {
  margin: 0;
}

.story-content h2,
.story-content h3,
.story-content h4 {
  color: var(--ink);
  font-family: "Bricolage Grotesque", Georgia, serif;
  line-height: 1.05;
}

.story-content ul {
  padding-left: 1.2rem;
}

.story-content code {
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 5px;
  background: rgba(255, 252, 241, 0.72);
  padding: 0.02rem 0.22rem;
}

.story-audio-controls,
.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.story-actions {
  justify-content: flex-end;
}

.victory-summary {
  margin: 0;
  color: rgba(17, 23, 20, 0.78);
  font-size: 1rem;
  line-height: 1.4;
}

.victory-player-list {
  display: grid;
  gap: 0.65rem;
}

.victory-player-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  border: 1px solid rgba(17, 23, 20, 0.13);
  border-radius: 12px;
  background: rgba(255, 252, 241, 0.68);
  padding: 0.75rem;
}

.victory-player-card.winner {
  border-color: rgba(189, 77, 53, 0.36);
  background: linear-gradient(135deg, rgba(242, 188, 87, 0.32), rgba(255, 252, 241, 0.82));
}

.victory-rank {
  display: grid;
  width: 2.1rem;
  height: 2.1rem;
  place-items: center;
  border-radius: 999px;
  background: var(--pine);
  color: var(--paper-strong);
  font-family: "Space Mono", monospace;
  font-weight: 700;
}

.victory-player-card strong {
  display: block;
  color: var(--ink);
  font-size: 1.02rem;
}

.victory-player-card span,
.victory-player-card p,
.victory-player-card dl,
.victory-summary {
  font-family: "Space Mono", monospace;
}

.victory-player-card span {
  color: rgba(17, 23, 20, 0.62);
  font-size: 0.72rem;
}

.victory-player-card p {
  margin: 0.3rem 0 0;
  color: rgba(17, 23, 20, 0.68);
  font-size: 0.7rem;
  line-height: 1.35;
}

.victory-player-card dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.16rem 0.55rem;
  margin: 0;
  color: rgba(17, 23, 20, 0.72);
  font-size: 0.66rem;
  text-align: right;
}

.victory-player-card dt {
  font-weight: 700;
  text-transform: uppercase;
}

.victory-player-card dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.victory-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.65rem;
}

.victory-actions button:first-child {
  background: rgba(20, 63, 53, 0.82);
}

.rule-dialog-card {
  display: grid;
  width: min(24rem, calc(100vw - 2rem));
  gap: 0.75rem;
  border: 1px solid rgba(242, 188, 87, 0.38);
  border-radius: 22px;
  background: rgba(13, 26, 22, 0.9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  color: var(--paper-strong);
  padding: 1rem;
}

.rule-dialog-card strong {
  font-size: 1.05rem;
}

.rule-dialog-card p {
  margin: 0;
  color: rgba(255, 249, 233, 0.74);
  font-family: "Space Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

.rule-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 0.5rem;
}

.rule-dialog-actions button:first-child {
  background: rgba(255, 249, 233, 0.14);
}

.terrain-quick-actions {
  position: absolute;
  z-index: 6;
  display: flex;
  gap: 0.35rem;
  max-width: min(18rem, calc(100% - 2rem));
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  background: rgba(13, 26, 22, 0.88);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.3);
  padding: 0.4rem;
  transform: translate(-50%, -100%);
  backdrop-filter: blur(18px);
}

.terrain-quick-actions[hidden] {
  display: none;
}

.terrain-quick-actions button {
  border-color: rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: none;
  padding: 0.46rem 0.58rem;
  font-size: 0.72rem;
  line-height: 1;
}

.bottom-left {
  bottom: 1rem;
  left: 1rem;
  max-width: calc(100vw - 28rem);
  flex-wrap: wrap;
  border-radius: 18px;
}

.drawer-backdrop {
  position: fixed;
  z-index: 8;
  inset: 0;
  display: none;
  border: 0;
  border-radius: 0;
  background: rgba(10, 17, 15, 0.44);
  box-shadow: none;
}

.drawer-open .drawer-backdrop {
  display: none;
}

.panel,
.control-drawer {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: var(--panel);
  box-shadow: 0 24px 70px var(--shadow);
}

.control-drawer {
  position: fixed;
  z-index: 9;
  top: 5.25rem;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  width: min(30rem, calc(100vw - 2rem));
  flex-direction: column;
  gap: 0.55rem;
  overflow: hidden;
  border-radius: 14px;
  padding: 0.72rem;
  transform: translateX(calc(-100% - 1.5rem));
  transition: transform 220ms ease;
  scrollbar-color: rgba(20, 63, 53, 0.52) rgba(17, 23, 20, 0.08);
  scrollbar-width: thin;
}

.drawer-open .control-drawer {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  margin: -0.1rem 0 0.1rem;
  padding: 0.05rem 0.1rem 0.48rem;
}

.close-button {
  flex: 0 0 auto;
  background: var(--rust);
  padding: 0.62rem 0.75rem;
}

.tool-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.25rem;
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 10px;
  background: rgba(17, 23, 20, 0.07);
  padding: 0.25rem;
}

.tool-tab {
  min-width: 0;
  border-color: transparent;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  color: rgba(17, 23, 20, 0.76);
  padding: 0.45rem 0.25rem;
  font-family: "Space Mono", monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.tool-tab:hover,
.tool-tab.active,
.tool-tab[aria-selected="true"] {
  background: var(--pine);
  color: var(--paper-strong);
  transform: none;
}

.tool-panels {
  min-height: 0;
  overflow: auto;
  padding-right: 0.2rem;
  scrollbar-color: rgba(20, 63, 53, 0.52) rgba(17, 23, 20, 0.08);
  scrollbar-width: thin;
}

.tool-tab-panel {
  display: grid;
  gap: 0.62rem;
}

.tool-tab-panel[hidden] {
  display: none;
}

.priority-card {
  background:
    linear-gradient(135deg, rgba(255, 252, 241, 0.92), rgba(242, 188, 87, 0.18)),
    var(--control-surface);
  border-color: rgba(242, 188, 87, 0.34);
}

.brand-block {
  padding: 0;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--rust);
  font-family: "Space Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.45rem;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.85;
  letter-spacing: -0.075em;
}

.control-drawer h1,
.builder-panel h1 {
  margin-bottom: 0.28rem;
  font-size: clamp(1.6rem, 2.6vw, 2.35rem);
  line-height: 0.9;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
  letter-spacing: -0.025em;
}

.lede {
  margin-bottom: 0;
  color: rgba(17, 23, 20, 0.72);
  line-height: 1.35;
}

.control-drawer .lede {
  font-size: 0.8rem;
  line-height: 1.25;
}

.tool-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 10px 28px rgba(16, 23, 20, 0.07);
  padding: 0.68rem;
}

.tool-card h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(17, 23, 20, 0.11);
  margin: -0.06rem -0.06rem 0.54rem;
  padding: 0 0.06rem 0.42rem;
  color: rgba(17, 23, 20, 0.92);
  font-size: 0.86rem;
}

.tool-card button,
.tool-card .button-link {
  border-radius: 8px;
  padding: 0.56rem 0.64rem;
  box-shadow: none;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid var(--line);
  padding: 0.65rem 0;
  font-size: 0.8rem;
}

.microcopy,
.rules-card p {
  margin: 0.55rem 0 0;
  color: rgba(17, 23, 20, 0.72);
  font-size: 0.72rem;
  line-height: 1.35;
}

.rules-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.rules-pill-row span {
  border: 1px solid rgba(17, 23, 20, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.34);
  color: rgba(17, 23, 20, 0.7);
  padding: 0.35rem 0.55rem;
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.turn-tracker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 10px;
  background: rgba(255, 252, 241, 0.62);
  margin-bottom: 0.55rem;
  padding: 0.46rem;
}

.turn-tracker div {
  display: grid;
  gap: 0.16rem;
}

.turn-tracker span {
  color: rgba(17, 23, 20, 0.6);
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.turn-tracker strong {
  color: rgba(17, 23, 20, 0.9);
  font-size: 0.86rem;
}

.turn-tracker button {
  flex: 0 0 auto;
  padding: 0.44rem 0.54rem;
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
}

.turn-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.phase-help-mini {
  display: grid;
  width: 1.8rem;
  height: 1.8rem;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
}

.phase-help-mini.active {
  background: var(--rust);
}

.turn-tracker.phase-complete {
  border-color: rgba(167, 201, 87, 0.44);
  background:
    linear-gradient(135deg, rgba(167, 201, 87, 0.15), transparent 52%),
    rgba(255, 252, 241, 0.7);
}

.turn-tracker.phase-complete #nextTurn {
  border-color: rgba(167, 201, 87, 0.62);
  background: rgba(167, 201, 87, 0.24);
  color: rgba(17, 23, 20, 0.92);
}

.turn-guidance {
  display: grid;
  gap: 0.34rem;
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 12px;
  background:
    radial-gradient(circle at 12% 18%, rgba(242, 188, 87, 0.14), transparent 38%),
    rgba(255, 252, 241, 0.58);
  margin: -0.12rem 0 0.55rem;
  padding: 0.5rem;
}

.turn-guidance strong {
  color: rgba(17, 23, 20, 0.9);
  font-size: 0.82rem;
}

.turn-guidance p {
  margin: 0;
  color: rgba(17, 23, 20, 0.64);
  font-family: "Space Mono", monospace;
  font-size: 0.64rem;
  line-height: 1.38;
}

.turn-guidance-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.turn-guidance-actions button {
  min-width: 0;
  padding: 0.46rem 0.42rem;
  font-size: 0.62rem;
}

.turn-guidance-actions button[hidden],
.turn-guidance[hidden] {
  display: none;
}

.group-activation-panel {
  border: 1px solid rgba(17, 23, 20, 0.14);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(73, 198, 229, 0.13), transparent 46%),
    rgba(255, 252, 241, 0.68);
  margin: 0 0 0.55rem;
  padding: 0.5rem;
}

.group-activation-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.6rem;
}

.group-activation-head div {
  display: grid;
  gap: 0.15rem;
}

.group-activation-head span,
.group-activation-head em {
  color: rgba(17, 23, 20, 0.58);
  font-family: "Space Mono", monospace;
  font-size: 0.61rem;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
}

.group-activation-head strong {
  color: rgba(17, 23, 20, 0.9);
  font-size: 0.82rem;
}

.group-soldier-list {
  display: grid;
  gap: 0.35rem;
  max-height: 8.5rem;
  margin-top: 0.55rem;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.group-soldier-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(17, 23, 20, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.42);
  color: rgba(17, 23, 20, 0.82);
  padding: 0.42rem 0.48rem;
}

.group-soldier-option input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--teal);
}

.group-soldier-option span {
  min-width: 0;
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-soldier-option small {
  color: rgba(17, 23, 20, 0.58);
  font-family: "Space Mono", monospace;
  font-size: 0.59rem;
  font-weight: 700;
}

.group-soldier-empty {
  border: 1px dashed rgba(17, 23, 20, 0.18);
  border-radius: 9px;
  color: rgba(17, 23, 20, 0.6);
  font-size: 0.72rem;
  padding: 0.55rem;
}

.compact-actions {
  margin-top: 0.58rem;
}

.encounter-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0.75rem;
}

.encounter-actions button {
  min-width: 0;
  padding-inline: 0.45rem;
}

.encounter-log {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.7rem;
}

.encounter-log span {
  border: 1px solid rgba(17, 23, 20, 0.1);
  border-radius: 8px;
  background: rgba(255, 252, 241, 0.52);
  color: rgba(17, 23, 20, 0.68);
  padding: 0.42rem 0.5rem;
  font-family: "Space Mono", monospace;
  font-size: 0.66rem;
  line-height: 1.35;
}

.button-grid button {
  padding-inline: 0.4rem;
}

.field {
  display: grid;
  gap: 0.26rem;
  margin-top: 0.52rem;
  color: var(--control-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.field > span {
  font-family: "Space Mono", monospace;
  line-height: 1.1;
  text-transform: uppercase;
}

.tool-inline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.45rem;
}

.inline-check {
  min-height: 2.36rem;
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 8px;
  background: rgba(255, 252, 241, 0.48);
  margin-top: 0.52rem;
  padding: 0 0.55rem;
}

.tool-card select,
.tool-card input[type="text"],
.tool-card input[type="number"],
.tool-card input[type="search"],
.tool-card input[type="color"] {
  border-color: rgba(17, 23, 20, 0.18);
  border-radius: 8px;
  background: var(--control-surface-strong);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
  min-height: 2.36rem;
}

.tool-card input[type="color"] {
  padding: 0.22rem;
}

.tool-card select:disabled,
.tool-card input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.check-field input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--rust);
}

.ai-control-field {
  border: 1px solid rgba(17, 23, 20, 0.12);
  border-radius: 8px;
  background: rgba(255, 252, 241, 0.44);
  min-height: 2.36rem;
  padding: 0 0.55rem;
}

.xr-control-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.38rem;
  margin-top: 0.55rem;
}

.xr-control-row button {
  min-width: 0;
  padding: 0.56rem 0.48rem;
}

.xr-control-row button.active {
  background: var(--rust);
}

.xr-diagnostics {
  word-break: break-word;
}

.split-action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.38rem;
  margin-top: 0.58rem;
}

.editor-actions,
.invite-tools,
.stat-edit-grid {
  display: grid;
  gap: 0.38rem;
}

.editor-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0.45rem;
}

.invite-tools {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 0.52rem;
}

.stat-edit-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.model-editor,
.player-editor {
  display: grid;
  gap: 0.1rem;
}

.danger-button {
  background: #7e2d24;
}

.danger-button:hover {
  background: #bd4d35;
}

.terrain-project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.55rem;
}

.compact-field {
  margin-top: 0;
}

.terrain-subpanel {
  display: grid;
  gap: 0.65rem;
  border-top: 1px solid rgba(17, 23, 20, 0.11);
  margin-top: 0.85rem;
  padding-top: 0.85rem;
}

.terrain-subpanel h3 {
  margin: 0;
  color: rgba(17, 23, 20, 0.76);
  font-size: 0.86rem;
  letter-spacing: -0.01em;
}

.terrain-settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.terrain-color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.material-variant-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.material-variant-preview span {
  min-height: 0.7rem;
  border: 1px solid rgba(17, 23, 20, 0.16);
  border-radius: 999px;
  background: var(--control-surface-strong);
}

.compact-upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.55rem;
}

.compact-upload button,
.terrain-project-row button {
  min-width: max-content;
  padding: 0.68rem 0.82rem;
}

.small-drop {
  min-height: 3rem;
  padding: 0.65rem;
}

.terrain-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.terrain-primary-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.terrain-apply-row {
  grid-template-columns: 1fr;
}

.terrain-primary-actions button.active {
  border-color: rgba(189, 77, 53, 0.5);
  background: var(--rust);
  box-shadow: 0 0 0 2px rgba(189, 77, 53, 0.16);
}

.secondary-action {
  background: #2f5a4d;
}

.secondary-action.active {
  background: var(--rust);
}

.secondary-danger {
  background: #65332d;
}

.secondary-danger:hover {
  background: var(--rust);
}

.selected-terrain-editor[aria-disabled="true"] {
  opacity: 0.72;
}

.builder-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(29rem, 36vw);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #17231f;
}

.library-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(34rem, 40vw);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #17231f;
}

.builder-viewport {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(8, 31, 28, 0.12), rgba(8, 31, 28, 0.04)),
    #19251f;
}

.library-viewport {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(8, 31, 28, 0.16), rgba(8, 31, 28, 0.05)),
    #19251f;
}

.builder-viewport .tabletop {
  width: 100%;
  height: 100%;
}

.library-viewport .tabletop {
  width: 100%;
  height: 100%;
}

.builder-toolbar {
  position: absolute;
  z-index: 5;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  pointer-events: none;
}

.builder-toolbar > * {
  pointer-events: auto;
}

.builder-toolbar .button-link {
  border-color: rgba(255, 255, 255, 0.24);
  background: var(--glass-dark);
}

.builder-toolbar .button-link:first-of-type {
  margin-left: auto;
}

.builder-panel {
  position: relative;
  z-index: 2;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.78rem;
  overflow: auto;
  border-width: 0 0 0 1px;
  border-radius: 0;
  padding: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 249, 233, 0.95), rgba(243, 236, 215, 0.9)),
    var(--panel);
  scrollbar-color: rgba(20, 63, 53, 0.52) rgba(17, 23, 20, 0.08);
  scrollbar-width: thin;
}

.builder-panel .tool-card {
  flex: 0 0 auto;
}

.library-panel {
  gap: 0.7rem;
}

.library-asset-list {
  max-height: 18rem;
  overflow: auto;
  padding-right: 0.15rem;
  scrollbar-color: rgba(20, 63, 53, 0.52) rgba(17, 23, 20, 0.08);
  scrollbar-width: thin;
}

.builder-selection {
  right: 1rem;
  bottom: 1rem;
  width: min(24rem, calc(100% - 2rem));
}

.import-form {
  display: grid;
  gap: 0.65rem;
}

.file-drop {
  display: grid;
  place-items: center;
  min-height: 5.5rem;
  border: 1px dashed rgba(20, 63, 53, 0.36);
  border-radius: 8px;
  background: rgba(203, 230, 223, 0.28);
  color: var(--control-muted);
  padding: 0.85rem;
  text-align: center;
  cursor: pointer;
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.35;
}

.file-drop:hover {
  border-color: rgba(189, 77, 53, 0.5);
  background: rgba(242, 188, 87, 0.16);
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.list-stack {
  display: grid;
  gap: 0.42rem;
}

.compact-list {
  margin-top: 0.45rem;
}

.list-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 241, 0.62);
  color: var(--ink);
  padding: 0.66rem 0.7rem;
  text-align: left;
  box-shadow: none;
}

a.list-item {
  display: block;
  text-decoration: none;
}

.list-empty {
  cursor: default;
}

.lobby-game-link:hover {
  background: rgba(255, 249, 233, 0.96);
  transform: translateY(-1px);
}

.list-item.active {
  border-color: rgba(189, 77, 53, 0.48);
  background: rgba(255, 249, 233, 0.96);
  outline: 2px solid rgba(189, 77, 53, 0.16);
  outline-offset: 0;
}

.list-item.moved {
  border-color: rgba(242, 188, 87, 0.52);
  background: rgba(255, 247, 219, 0.9);
}

.moved-badge {
  border: 1px solid rgba(189, 77, 53, 0.28);
  border-radius: 999px;
  background: rgba(242, 188, 87, 0.2);
  color: rgba(82, 51, 19, 0.88);
  padding: 0.08rem 0.32rem;
  font-family: "Space Mono", monospace;
  font-size: 0.55rem;
  text-transform: uppercase;
}

.list-summary {
  cursor: default;
  background: rgba(20, 63, 53, 0.72);
  color: var(--paper-strong);
}

.list-summary:hover {
  transform: none;
  background: rgba(20, 63, 53, 0.72);
}

.item-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 700;
}

.swatch {
  width: 0.85rem;
  height: 0.85rem;
  flex: 0 0 auto;
  border: 1px solid rgba(17, 23, 20, 0.32);
  border-radius: 999px;
}

.item-meta {
  display: block;
  margin-top: 0.35rem;
  color: rgba(17, 23, 20, 0.66);
  font-size: 0.72rem;
}

.uuid-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .lobby-workspace,
  .lobby-campaign-workspace,
  .lobby-warband-workspace {
    grid-template-columns: 1fr;
  }

  .warband-editor-grid {
    grid-template-columns: 1fr;
  }

  .editor-unit-list {
    max-height: 24rem;
  }

  .lobby-game-list,
  .lobby-campaign-list,
  .warband-unit-list,
  .warband-roster-list {
    max-height: 28rem;
  }

  .warband-unit-fields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .top-bar {
    align-items: flex-start;
  }

  .quick-modes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .xr-toggle {
    margin-left: auto;
  }

  .bottom-left {
    display: none;
  }

  .mode-chip {
    top: 7.4rem;
  }

  .camera-widget {
    top: 9.5rem;
    width: 10.5rem;
  }
}

@media (max-width: 640px) {
  .lobby-shell {
    padding: 0.75rem;
  }

  .lobby-head {
    grid-template-columns: 1fr;
  }

  .warband-page-head,
  .warband-editor-title-row,
  .warband-management-row,
  .warband-total-strip,
  .editor-fields-two,
  .editor-stat-grid,
  .editor-section-head,
  .warband-action-bar {
    grid-template-columns: 1fr;
  }

  .standee-gallery,
  .spell-browser {
    grid-template-columns: 1fr;
  }

  .lobby-head h1 {
    font-size: 2.55rem;
  }

  .lobby-nav,
  .lobby-nav .button-link {
    width: 100%;
  }

  .lobby-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .lobby-tab {
    min-width: 0;
  }

  .lobby-stats,
  .lobby-form-grid,
  .lobby-player-grid,
  .lobby-create-actions,
  .warband-editor-toolbar,
  .warband-unit-fields,
  .warband-unit-detail-fields,
  .tool-card-head {
    grid-template-columns: 1fr;
  }

  .lobby-stats {
    gap: 0.5rem;
  }

  .lobby-stat {
    padding: 0.66rem 0.72rem;
  }

  .lobby-badge {
    width: max-content;
  }

  .top-bar {
    right: 0.5rem;
    left: 0.5rem;
    top: 0.5rem;
  }

  .table-title {
    display: none;
  }

  .quick-modes {
    flex: 1;
  }

  .phase-help-toggle {
    width: 2.65rem;
    height: 2.65rem;
  }

  .phase-help-panel {
    top: 5.35rem;
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
  }

  .xr-toggle {
    width: 2.65rem;
    height: 2.65rem;
    padding: 0;
  }

  .top-end-phase {
    height: 2.65rem;
    padding: 0 0.68rem;
    font-size: 0.62rem;
  }

  .selected-float {
    right: 0.5rem;
    bottom: 0.5rem;
    width: calc(100vw - 1rem);
  }

  .camera-widget {
    top: 6.2rem;
    right: 0.5rem;
    width: 8.75rem;
  }

  .control-drawer {
    inset: 0.5rem;
    width: auto;
    border-radius: 20px;
  }

  .drawer-open .drawer-backdrop {
    display: block;
  }

  .tool-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tool-inline-grid {
    grid-template-columns: 1fr;
  }

  .victory-player-card {
    grid-template-columns: 1fr;
  }

  .victory-player-card dl {
    grid-template-columns: 1fr 1fr;
    text-align: left;
  }

  .victory-actions {
    grid-template-columns: 1fr;
  }

  .button-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .xr-control-row {
    grid-template-columns: 1fr;
  }

  .split-action-row,
  .editor-actions,
  .invite-tools,
  .stat-edit-grid,
  .terrain-project-row,
  .terrain-settings-grid,
  .terrain-color-grid,
  .compact-upload,
  .terrain-action-row {
    grid-template-columns: 1fr;
  }

  .builder-shell {
    grid-template-columns: 1fr;
  }

  .library-shell {
    grid-template-columns: 1fr;
  }

  .builder-panel {
    position: fixed;
    z-index: 8;
    top: auto;
    right: 0.5rem;
    bottom: 0.5rem;
    left: 0.5rem;
    max-height: 48vh;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 20px;
  }

  .builder-selection {
    display: none;
  }

  .xr-eye-hud {
    top: 0.5rem;
    width: calc(100% - 1rem);
    padding: 0.54rem;
  }

  .xr-eye-hud span {
    font-size: 0.58rem;
  }
}
