/* Live session / table */

.session-hero {
  margin-bottom: 20px;
}
.session-hero h2 {
  margin: 0 0 8px;
}
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.hub-tables,
.hub-create {
  margin-bottom: 16px;
}
.hub-tables-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.hub-tables-head .card-title {
  margin: 0;
}
.hub-tables-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.hub-tables .hub-claim-session {
  display: none;
}
.hub-tables.hub-take-on .hub-claim-session {
  display: inline-flex;
}
#btn-hub-take-mode.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.hub-tables .hub-delete-session {
  display: none;
}
.hub-tables.hub-delete-on .hub-delete-session {
  display: inline-flex;
}
#btn-hub-delete-mode.is-on {
  border-color: #f87171;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.35);
}
.hub-tables-scroll {
  max-height: min(42vh, 360px);
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.12);
}
.hub-tables-scroll .table-wrap {
  margin: 0;
}
.hub-tables-scroll .data-table {
  margin: 0;
}
.hub-tables-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-panel);
}
.hub-tables-empty {
  margin: 16px;
}
.hub-create-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}
.optional {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 0.85em;
}
.form-error {
  color: var(--danger);
  margin: 8px 0 0;
  font-size: 0.9rem;
}

/* badges */
.gm-badge,
.player-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.gm-badge {
  background: rgba(251, 191, 36, 0.15);
  color: var(--gold);
  border: 1px solid rgba(251, 191, 36, 0.35);
}
.player-badge {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.you-name {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.lobby-subhead {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-panel);
  flex-wrap: wrap;
}

/* join gate */
.join-gate {
  min-height: 50vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.join-gate[hidden] {
  display: none !important;
}
.join-gate-card {
  width: min(400px, 100%);
  padding: 24px;
}
.join-gate-card h2 {
  margin-top: 0;
}

/* layout */
.table-body {
  overflow-x: hidden;
}
.lobby-app {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr minmax(260px, 320px);
  gap: 0;
  min-height: calc(100vh - var(--header-h) - 48px);
  align-items: stretch;
}
.lobby-app[hidden] {
  display: none !important;
}
.lobby-left,
.lobby-side {
  background: var(--bg-panel);
  border-color: var(--border-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lobby-left {
  border-right: 1px solid var(--border-soft);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow: hidden;
}
.lobby-side {
  border-left: 1px solid var(--border-soft);
}
.lobby-main {
  padding: 12px 14px 0;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: transparent;
  --cards-bg-fade: 25;
  --cards-bg-lines: 70;
  --cards-bg-blink: 0;
  --cards-bg-chroma: 40;
}
.lobby-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.lobby-bg[hidden] {
  display: none !important;
}
.lobby-bg-image,
.lobby-bg-scan,
.lobby-bg-interlace,
.lobby-bg-chroma,
.lobby-bg-fade,
.lobby-bg-blink {
  position: absolute;
  inset: 0;
}
.lobby-bg-image {
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
  filter: contrast(1.12) saturate(1.08);
}
.lobby-bg-scan {
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.04) 0px,
    rgba(255, 255, 255, 0.04) 1px,
    rgba(0, 0, 0, 0.62) 1px,
    rgba(0, 0, 0, 0.62) 2px
  );
  opacity: calc(var(--cards-bg-lines) * 0.01);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0%, #000 78%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0%, #000 78%);
}
.lobby-bg-interlace {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.45) 0px,
    rgba(0, 0, 0, 0.45) 1px,
    rgba(180, 220, 255, 0.06) 1px,
    rgba(180, 220, 255, 0.06) 2px
  );
  background-position: 0 1px;
  mix-blend-mode: multiply;
  opacity: calc(var(--cards-bg-lines) * 0.0075);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0%, #000 80%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0%, #000 80%);
}
.lobby-main.has-bg-blink .lobby-bg-interlace {
  animation: lobby-interlace 0.14s steps(2) infinite;
}
@keyframes lobby-interlace {
  0% { transform: translateY(0); }
  100% { transform: translateY(1px); }
}
.lobby-bg-chroma {
  box-shadow:
    inset 3px 0 0 rgba(0, 255, 255, 0.22),
    inset -3px 0 0 rgba(255, 0, 128, 0.22);
  opacity: calc(var(--cards-bg-chroma) * 0.01);
}
.lobby-bg-fade {
  background:
    linear-gradient(
      to bottom,
      transparent 0%,
      color-mix(in srgb, var(--bg-deep) calc(var(--cards-bg-fade) * 0.5%), transparent) 42%,
      color-mix(in srgb, var(--bg-deep) calc(var(--cards-bg-fade) * 1%), transparent) 100%
    ),
    radial-gradient(
      ellipse at 50% 18%,
      transparent 0%,
      transparent 48%,
      color-mix(in srgb, var(--bg-deep) calc(var(--cards-bg-fade) * 0.45%), transparent) 100%
    );
}
.lobby-bg-blink {
  opacity: calc(var(--cards-bg-blink) * 0.01);
  pointer-events: none;
}
.lobby-bg-blink-pulse {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
}
.lobby-main.has-bg-blink .lobby-bg-blink-pulse {
  animation: lobby-blink 0.12s steps(2) infinite;
}
@keyframes lobby-blink {
  0% { opacity: 0; }
  100% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .lobby-main.has-bg-blink .lobby-bg-interlace,
  .lobby-main.has-bg-blink .lobby-bg-blink-pulse {
    animation: none;
  }
}
.fx-sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 8px 0 4px;
}
.fx-sliders label {
  margin-bottom: 0;
}
.fx-sliders input[type="range"] {
  width: 100%;
  margin-top: 4px;
  accent-color: var(--accent, #2dd4bf);
}
.lobby-main > .vtt-dock,
.lobby-main > .cards-stage {
  position: relative;
  z-index: 1;
}
.cards-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.table-dd {
  position: relative;
}
.table-dd-pop {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 168px;
  padding: 4px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-panel, #121820);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.table-dd-pop[hidden] {
  display: none !important;
}
.table-dd-item {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  box-sizing: border-box;
  height: var(--btn-h, 32px);
  min-height: var(--btn-h, 32px);
  padding: 0 12px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.table-dd-item:hover:not(:disabled) {
  background: var(--bg-hover, rgba(255, 255, 255, 0.06)) !important;
}
.table-dd-item:disabled {
  opacity: 0.45;
}
#btn-map-menu.is-open {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

/* Table page: hamburger is the site nav (Rules / Characters / …). */
body.table-body .btn-menu {
  display: inline-flex;
}
body.table-body .site-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 8px;
  right: auto;
  width: min(260px, calc(100vw - 16px));
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 8px;
  z-index: 120;
  background: var(--bg-panel, #121820);
  border: 1px solid var(--border);
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  box-shadow: var(--shadow);
}
body.table-body .site-nav.open {
  display: flex !important;
}
body.table-body .site-nav .site-nav-link {
  border-radius: 8px;
}
.vtt-dock {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg-deep, #0e121c) 80%, transparent);
  overflow: hidden;
}
.vtt-empty {
  margin: 0;
  padding: 16px 12px 18px;
}
.vtt-frame {
  display: block;
  width: 100%;
  height: min(52vh, 520px);
  min-height: 180px;
  border: 0;
  background: #0a0a10;
}
.vtt-resize {
  height: 12px;
  cursor: ns-resize;
  touch-action: none;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.06));
  border-top: 1px solid var(--border-soft);
  position: relative;
}
.vtt-resize::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  width: 36px;
  height: 3px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--text-muted);
  opacity: 0.55;
}
.vtt-resize:hover::after,
.vtt-dock.is-resizing .vtt-resize::after {
  opacity: 0.95;
  background: var(--accent);
}
.vtt-dock.is-resizing .vtt-frame {
  pointer-events: none;
}
.vtt-dock.is-collapsed {
  display: none;
}

.chat-msg-vtt {
  border-left: 3px solid #fbbf24;
  padding-left: 8px;
  background: rgba(251, 191, 36, 0.08);
}
.chat-vtt-text {
  color: #fbbf24;
  font-weight: 600;
}
.chat-msg-stash {
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  background: rgba(45, 212, 191, 0.08);
}
.chat-stash-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stash-modal-card {
  display: flex;
  flex-direction: column;
}
.stash-modal-hint {
  margin: 0 0 12px;
  flex: 0 0 auto;
}
.stash-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.stash-folders {
  border-right: 1px solid var(--border-soft);
  padding-right: 12px;
  overflow: auto;
  min-height: 0;
}
.stash-folder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.stash-folder-list,
.stash-item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.stash-folder-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  border-radius: 6px;
}
.stash-folder-list li.is-on,
.stash-folder-list li:hover {
  background: var(--bg-hover);
}
.stash-folder-list button.stash-folder-pick {
  flex: 1;
  text-align: left;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 2px 4px;
  min-width: 0;
}
.stash-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.stash-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}
.stash-toolbar input[type="search"] {
  flex: 1 1 180px;
  min-width: 140px;
}
.stash-item-list {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
  padding-right: 4px;
}
.stash-item {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) max-content;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-card) 70%, transparent);
}
.stash-item:hover {
  background: var(--bg-hover);
}
.stash-item-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stash-item-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stash-kind {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}
.stash-item-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}
.stash-item-actions .btn {
  flex: 0 0 auto;
}
.badge-shared {
  flex: 0 0 auto;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1a1208;
  background: #f5b942;
  border: 1px solid #d97706;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
}
.stash-view-card {
  max-width: min(640px, 94vw);
}
.stash-view-body {
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 70vh;
  overflow: auto;
}
.stash-view-body.stash-note-html,
.stash-float-body.stash-note-html {
  white-space: normal;
}
.stash-view-body img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}
.stash-folder-list li.is-drop,
.stash-item-list li.is-drop {
  outline: 1px dashed var(--accent);
}
.stash-item-list li.is-dragging {
  opacity: 0.45;
}
#stash-float-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
}
.stash-float {
  position: absolute;
  pointer-events: auto;
  min-width: 240px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.stash-float.is-min {
  display: none;
}
.stash-float-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: move;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
  user-select: none;
}
.stash-float-title {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stash-float-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
  white-space: pre-wrap;
}
.stash-note-html p,
.rte-surface p {
  margin: 0 0 0.65em;
}
.stash-note-html p:last-child,
.rte-surface p:last-child {
  margin-bottom: 0;
}
.stash-note-html h3,
.rte-surface h3 {
  margin: 0 0 0.45em;
  font-size: 1.05rem;
}
.stash-note-html ul,
.stash-note-html ol,
.rte-surface ul,
.rte-surface ol {
  margin: 0.2em 0 0.7em;
  padding-left: 1.3em;
}
.stash-note-html blockquote,
.rte-surface blockquote {
  margin: 0.4em 0 0.7em;
  padding: 4px 0 4px 10px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}
.stash-note-html a,
.rte-surface a {
  color: var(--link);
}
.stash-size-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.stash-size-row label {
  flex: 1 1 120px;
  min-width: 0;
}
.stash-size-row input[type="number"] {
  width: 100%;
}
.stash-edit-actions {
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}
.stash-edit-actions-spacer {
  flex: 1 1 auto;
}
#stash-float-layer.is-front {
  z-index: 360;
}
.stash-float.is-preview {
  outline: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
}
.stash-edit-field {
  margin-bottom: 12px;
}
.stash-edit-field[hidden] {
  display: none !important;
}
#stash-edit-body-label {
  display: block;
  margin-bottom: 6px;
}
.stash-image-preview {
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-deep);
  text-align: center;
}
.stash-image-preview[hidden] {
  display: none !important;
}
.stash-image-preview img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin: 0 auto;
  border-radius: 6px;
  object-fit: contain;
  background: #0a0a10;
}
.stash-image-preview .hint {
  margin: 6px 0 0;
}
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.rte-toolbar .btn {
  min-width: 30px;
  padding: 4px 8px;
}
.rte-surface {
  min-height: 160px;
  max-height: 42vh;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.45;
  white-space: normal;
}
.rte-surface:empty::before {
  content: "Write the handout…";
  color: var(--text-dim);
}
.rte-surface:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.stash-float-body img {
  max-width: 100%;
  height: auto;
  display: block;
}
.stash-float-resize {
  height: 12px;
  cursor: nwse-resize;
  flex: 0 0 12px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.06));
}
.min-tabs {
  position: sticky;
  bottom: 0;
  z-index: 6;
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 2px 0;
  pointer-events: none;
}
#stash-min-tray,
#note-min-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
#stash-min-tray[hidden],
#note-min-tray[hidden] {
  display: none !important;
}
.stash-min-tab {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 168px;
  max-width: 168px;
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #d9c7a6;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #fff8ec;
  color: #2a2118;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.32);
  transform: translateY(6px);
  transition: transform 0.12s ease, background 0.12s ease;
  box-sizing: border-box;
}
.stash-min-tab:hover,
.stash-min-tab:focus-visible {
  transform: translateY(0);
  background: #fffdf6;
  outline: none;
}
.stash-min-mark {
  flex: 0 0 auto;
  width: 1.2em;
  text-align: center;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.08rem;
  font-weight: 800;
  color: #1a120c;
}
.stash-min-tab[data-kind="image"] .stash-min-mark,
.stash-min-tab[data-kind="map"] .stash-min-mark {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
}
.stash-min-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-min-tab {
  background: #ffe566;
  border-color: #e3b000;
  color: #3a2a00;
}
.note-min-tab.is-glow {
  animation: note-tab-glow 1.2s ease-in-out infinite;
}
@keyframes note-tab-glow {
  0%,
  100% {
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.32), 0 0 0 0 rgba(255, 214, 0, 0.15);
  }
  50% {
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.28), 0 0 16px 4px rgba(255, 214, 0, 0.75);
    background: #fff3a0;
  }
}
.note-float {
  background: #fff3a0;
  color: #2a2110;
  border-color: #e3b000;
  overflow: visible;
}
.note-float.has-photo {
  margin-left: 8px;
}
.note-float.has-photo .stash-float-bar,
.note-float.has-photo .stash-float-body,
.note-float.has-photo .note-reply {
  padding-left: 52px;
}
.note-photo {
  position: absolute;
  top: 18px;
  left: -64px;
  width: 92px;
  z-index: 4;
  transform: rotate(-8deg);
  pointer-events: none;
}
.note-photo-frame {
  width: 92px;
  background: #fffdf6;
  padding: 5px 5px 12px;
  box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.38);
  border: 1px solid #e8dcc0;
}
.note-photo-frame img {
  display: block;
  width: 82px;
  height: 82px;
  max-width: none;
  object-fit: contain;
  background: #000;
}
.note-photo-pin {
  top: 8px;
  left: auto;
  right: 26px;
  transform: rotate(14deg);
}
.note-float .stash-float-bar {
  background: #ffe566;
  border-bottom-color: #e3b000;
  color: #2a2110;
}
.note-float .stash-float-body {
  white-space: pre-wrap;
  color: #2a2110;
  flex: 1 1 auto;
}
.note-reply {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 6px 8px;
  border-top: 1px solid #e3b000;
  background: #ffe566;
}
.note-reply-picker {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: calc(100% + 4px);
  z-index: 6;
  max-height: 180px;
}
.note-reply-clip {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  overflow: hidden;
  background: #000;
  border: 1px solid #e3b000;
}
.note-reply-clip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.note-reply-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid #e3b000;
  border-radius: 6px;
  background: #fff8c8;
  color: #2a2110;
  font: inherit;
  font-size: 0.85rem;
}
.note-reply .btn {
  height: 28px !important;
  min-height: 28px !important;
  padding: 0 10px !important;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-mail-btn {
  position: relative;
  flex: 0 0 auto;
}
.mail-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
}
.mail-dot[hidden] {
  display: none !important;
}
.secret-mail-card {
  max-width: 480px;
}
.secret-mail-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px;
}
.secret-mail-tab.is-on {
  border-color: var(--accent);
  color: var(--accent);
}
.secret-mail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 46vh;
  overflow: auto;
}
.secret-mail-list li {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-deep);
  cursor: pointer;
}
.secret-mail-list li:hover {
  border-color: var(--accent);
}
.secret-mail-list li.is-unread {
  border-color: #e3b000;
  background: color-mix(in srgb, #ffe566 12%, var(--bg-deep));
}
.secret-mail-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.secret-mail-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.secret-mail-face {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: #000;
  object-fit: contain;
}
.secret-mail-preview {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.secret-mail-compose-row {
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.secret-mail-clip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
  padding: 6px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-deep);
}
.secret-mail-clip[hidden] {
  display: none !important;
}
.secret-mail-clip img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: #000;
  object-fit: contain;
}
.secret-mail-clip-lab,
#secret-mail-clip-lab {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.85rem;
}
.tc-rail-btn.tc-stash:hover {
  border-color: #c084fc;
  color: #c084fc;
}
.side-scroll {
  overflow: auto;
  max-height: calc(100vh - var(--header-h) - 48px);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 10px;
}
.lobby-side .panel {
  margin: 0;
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.badge {
  display: inline-block;
  background: var(--bg-hover);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 0.78rem;
}

/* presence + chat */
.presence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
}
.presence-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 0.9rem;
  min-width: 0;
}
.presence-item.is-offline {
  opacity: 0.72;
}
.presence-item.is-offline .presence-name {
  color: var(--text-dim) !important;
}
.presence-item.is-self .presence-name {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.presence-name {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  font: inherit;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.presence-name:hover {
  filter: brightness(1.15);
}
.presence-mail {
  margin-left: auto;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  position: relative;
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  opacity: 0.7;
  overflow: hidden;
}
.presence-mail.has-mail {
  color: var(--text);
  opacity: 1;
}
.presence-mail.has-unread {
  color: #e8c547;
  opacity: 1;
}
.presence-mail .mail-dot {
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  box-shadow: none;
}
.presence-mail:hover {
  opacity: 1;
  color: var(--accent);
}
.presence-color-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-muted);
}
.tag-import {
  color: var(--accent);
}
.tag-gits-boom {
  color: #7dd3fc;
  border: 1px solid rgba(125, 211, 252, 0.45);
}
.die-card.die-explode {
  border-color: #7dd3fc;
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.35);
}
.presence-panel {
  position: relative;
}
.presence-panel h3.presence-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
}
.presence-head-title {
  flex: 1;
  min-width: 0;
}
/* Tiny GM control next to Connected count */
.btn-import-toggle {
  flex-shrink: 0;
  margin: 0 !important;
  padding: 2px 7px !important;
  min-height: 0 !important;
  font-size: 0.68rem !important;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  border-radius: 999px;
  opacity: 0.9;
}
.btn-import-toggle.is-open {
  color: #052e16 !important;
  background: #4ade80 !important;
  border-color: #22c55e !important;
  opacity: 1;
}
/* One green status line when open — nothing else */
.import-open-note {
  margin: 0 0 6px;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #4ade80;
  line-height: 1.25;
}
.import-open-note[hidden] {
  display: none !important;
}
.presence-panel {
  flex: 0 0 auto;
  max-height: 30%;
  overflow: auto;
  margin-bottom: 0;
}
.chat-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 0;
}
.chat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 160px;
  max-height: none;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  word-break: break-word;
}
.chat-msg {
  line-height: 1.4;
  flex: 0 0 auto;
}
.chat-msg-roll {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  padding: 2px 0;
}
.chat-roll-text {
  color: var(--text);
  font-style: italic;
  opacity: 0.92;
}
.chat-roll-label {
  font-size: 0.85em;
}
.chat-roll-replay {
  margin-left: 2px;
  vertical-align: middle;
  flex-shrink: 0;
}
.chat-time {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: var(--mono);
}
.chat-who {
  color: var(--accent);
}
.chat-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-compose {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.chat-sticker-btn {
  flex: 0 0 auto;
  min-width: 40px;
  padding: 0 10px;
  font-size: 1.15rem;
  line-height: 1;
}
.chat-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
}

.sticker-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-deep);
}
.sticker-picker[hidden] {
  display: none;
}
.sticker-pick {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: #000;
  border-radius: 8px;
  padding: 4px;
  cursor: pointer;
  line-height: 0;
}
.sticker-pick:hover,
.sticker-pick:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.sticker-pick img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.chat-msg-sticker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.chat-msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
}
.sticker-card {
  width: 112px;
  height: 112px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.sticker-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.sticker-clip {
  position: relative;
  display: flex;
  align-items: stretch;
  max-width: 100%;
  margin-top: 4px;
}
.sticker-clip .sticker-card {
  width: 80px;
  height: 80px;
  flex: 0 0 80px;
  border-radius: 8px 0 0 8px;
}
.sticker-clip-paper {
  flex: 1 1 auto;
  min-width: 0;
  background: #fff8e4;
  color: #2a2110;
  border: 1px solid #d9c7a6;
  border-left: 0;
  border-radius: 0 8px 8px 0;
  padding: 8px 10px 8px 12px;
  font-size: 0.86rem;
  line-height: 1.35;
  white-space: pre-wrap;
}
.sticker-clip-pin {
  position: absolute;
  top: -10px;
  left: 68px;
  width: 16px;
  height: 28px;
  z-index: 2;
  border: 2.5px solid #9aa3b2;
  border-radius: 10px 10px 7px 7px;
  background: transparent;
  transform: rotate(-22deg);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.sticker-clip-pin::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 8px;
  width: 6px;
  height: 14px;
  border: 2px solid #9aa3b2;
  border-top: 0;
  border-radius: 0 0 5px 5px;
}
#sticker-rain {
  position: fixed;
  inset: 0;
  z-index: 260;
  pointer-events: none;
  overflow: hidden;
}
.sticker-rain-bit {
  position: absolute;
  bottom: -12px;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
  animation: sticker-rain-up var(--dur, 2s) ease-out forwards;
  will-change: transform, opacity;
}
@keyframes sticker-rain-up {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.55) rotate(0deg);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -10vh) scale(1) rotate(calc(var(--rot, 0deg) * 0.25));
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--drift, 0px)), -76vh) scale(0.82) rotate(var(--rot, 0deg));
  }
}
@media (prefers-reduced-motion: reduce) {
  .sticker-rain-bit {
    animation-duration: 0.01s;
  }
}

/* story bar — pass points with ‹ › (totals set in Session config) */
.story-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0;
  flex: 1 1 280px;
  min-width: 0;
}
.lobby-subhead .story-bar {
  padding: 0;
  background: transparent;
  border: 0;
}
.story-pool {
  display: flex;
  align-items: center;
  gap: 6px;
}
.story-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}
.story-transfer {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.story-transfer .btn-step {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
}
.story-transfer .btn-step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.story-dots {
  display: flex;
  gap: 3px;
  min-width: 40px;
}
.story-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fde68a, var(--gold));
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.45);
}
.pool-story-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.pool-story-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.pool-story-check .muted {
  font-weight: 500;
  font-size: 0.75rem;
}
.crit-result-preview {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--bg-deep);
  font-size: 0.9rem;
}
.crit-result-preview p {
  margin: 6px 0 0;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}
.check-label input {
  width: 1rem;
  height: 1rem;
}
.btn-step {
  width: 28px;
  height: 28px;
  padding: 0 !important;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  line-height: 1;
}

/* roster cards */
.roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.tracker-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  box-shadow: var(--shadow);
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  overflow: hidden;
  min-width: 0;
}
.tc-main {
  flex: 1;
  min-width: 0;
  padding: 8px 8px 8px 10px;
}
/* Vertical action rail — frees the name row */
.tc-rail {
  flex: 0 0 36px;
  width: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-left: 1px solid var(--border-soft, #2a3142);
  background: color-mix(in srgb, var(--bg-deep, #0e121c) 55%, transparent);
}
.tc-rail-btn {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  padding: 0 !important;
  margin: 0;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem !important;
  line-height: 1 !important;
  border-radius: 6px;
  opacity: 0.88;
}
.tc-rail-btn:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}
.tc-rail-btn.tc-del:hover {
  border-color: var(--danger, #f87171);
  color: var(--danger, #f87171);
}
.tc-rail-btn.tc-dice:hover {
  border-color: #fbbf24;
  color: #fbbf24;
}
.tracker-card.side-pc {
  border-color: rgba(45, 212, 191, 0.45);
}
.tracker-card.side-ally {
  border-color: rgba(103, 232, 249, 0.4);
}
.tracker-card.side-enemy {
  border-color: rgba(248, 113, 113, 0.4);
}
.tracker-card.defeated {
  opacity: 0.55;
  filter: grayscale(0.4);
}
.tracker-add-card {
  border-style: dashed;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 120px;
  font-size: 1rem;
  font-weight: 600;
  display: grid;
  place-items: center;
  padding: 12px;
}
.tracker-add-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(45, 212, 191, 0.05);
}
.tc-head {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.tc-portrait {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  object-position: top center;
}
.tc-titles {
  flex: 1;
  min-width: 0;
}
.tc-titles strong {
  display: block;
  font-size: 0.98rem;
}
.tc-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}
.tc-unlinked {
  color: #fbbf24;
  text-transform: none;
  font-weight: 600;
}
.tc-sync {
  opacity: 0.85;
}
.tc-sync:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}
/* Legacy head-actions kept for safety if any HTML still uses them */
.tc-head-actions {
  display: none;
}
.tc-icon-btn {
  /* alias to rail size if still referenced */
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  padding: 0 !important;
}

/* GM adversary peek modal */
.adv-peek-card {
  max-width: 520px;
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
}
.adv-peek-gm-hint {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--accent);
}
.adv-peek-body {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
  font-size: 0.9rem;
}
.adv-peek-portrait {
  margin: 0 0 10px;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  max-height: 160px;
  background: var(--bg-deep, #0a0a0f);
  border: 1px solid var(--border-soft, rgba(255,255,255,0.08));
}
.adv-peek-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.adv-peek-meta {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.adv-peek-chars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.adv-peek-stat {
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  text-align: center;
  padding: 6px 2px;
}
.adv-peek-stat .val {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.adv-peek-stat .lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.adv-peek-derived {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.adv-peek-derived strong {
  color: var(--text);
}
.adv-peek-block {
  margin-bottom: 12px;
}
.adv-peek-block h4 {
  margin: 0 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.adv-peek-block p {
  margin: 0;
  line-height: 1.4;
  white-space: pre-wrap;
}
.adv-peek-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
@media (max-width: 520px) {
  .adv-peek-chars {
    grid-template-columns: repeat(3, 1fr);
  }
}
.tc-stats {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.tc-stats strong {
  color: var(--text);
}
.tc-row {
  display: grid;
  grid-template-columns: 52px 28px 1fr 28px 48px;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}
.bar {
  height: 8px;
  background: var(--bg-deep);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.bar-fill.wound {
  background: linear-gradient(90deg, #ef4444, #f87171);
  height: 100%;
}
.bar-fill.strain {
  background: linear-gradient(90deg, #6366f1, #a78bfa);
  height: 100%;
}
.tc-minion {
  font-size: 0.8rem;
  color: var(--minion);
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.tc-minion-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.tc-minion-row span {
  min-width: 4.5rem;
}
.tc-conds,
.tc-crits {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
}
.cond-chip,
.crit-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  padding: 2px 4px 2px 6px;
  border-radius: 4px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  max-width: 100%;
}
.cond-chip .chip-label,
.crit-chip .chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 11rem;
}
.crit-chip {
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}
.chip-x {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 3px;
  border-radius: 3px;
}
.chip-x:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
}
.btn-sm {
  font-size: 0.75rem !important;
  padding: 3px 8px !important;
}

/* Condition picker modal */
.cond-modal-card {
  max-width: 480px;
  max-height: min(90vh, 640px);
  display: flex;
  flex-direction: column;
}
.cond-pick-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
  margin: 4px 0 10px;
}
.cond-pick-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cond-pick {
  display: grid;
  grid-template-columns: 1.4rem 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 2px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--bg-deep);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cond-pick:hover {
  border-color: var(--accent);
}
.cond-pick.is-on {
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(45, 212, 191, 0.1);
}
.cond-pick-check {
  grid-row: 1 / span 2;
  align-self: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--bg-card);
}
.cond-pick.is-on .cond-pick-check {
  background: rgba(45, 212, 191, 0.25);
  border-color: var(--accent);
}
.cond-pick-name {
  font-weight: 700;
  font-size: 0.9rem;
}
.cond-pick-desc {
  grid-column: 2;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.cond-custom-active {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.cond-custom-active .cond-chip {
  cursor: pointer;
}
.cond-custom-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.cond-custom-row .full-input {
  flex: 1;
  min-width: 0;
}
.cond-modal-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

/* Ruleset dice isolation: never paint the other kernel's roller */
#cd-dice {
  display: none !important;
}
html[data-table-dice="d20"] #cd-dice {
  display: flex !important;
  flex-direction: column;
  gap: 10px;
}
html[data-table-dice="d20"] #story-bar,
html[data-table-dice="d20"] #pool-builder,
html[data-table-dice="d20"] .pool-action-row,
html[data-table-ruleset="cyberdark"] #story-bar,
html[data-table-ruleset="cyberdark"] #pool-builder,
html[data-table-ruleset="cyberdark"] .pool-action-row {
  display: none !important;
}
html[data-table-dice="d20"] .roll-flag-sym,
html[data-table-ruleset="cyberdark"] .roll-flag-sym {
  display: none !important;
}

#yze-dice,
#gits-dice {
  display: none !important;
}
html[data-table-dice="yze"] #yze-dice,
html[data-table-dice="gits"] #gits-dice {
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
html[data-table-dice="yze"] #story-bar,
html[data-table-dice="yze"] #pool-builder,
html[data-table-dice="yze"] .pool-action-row,
html[data-table-dice="yze"] #cd-dice,
html[data-table-dice="gits"] #story-bar,
html[data-table-dice="gits"] #pool-builder,
html[data-table-dice="gits"] #cd-dice,
html[data-table-dice="gits"] #yze-dice {
  display: none !important;
}
html[data-table-dice="yze"] .roll-flag-sym,
html[data-table-dice="gits"] .roll-flag-sym {
  display: none !important;
}

html[data-table-dice="yze"] .cd-who-row,
html[data-table-dice="gits"] .cd-who-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
html[data-table-dice="yze"] .cd-who,
html[data-table-dice="gits"] .cd-who {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  line-height: 1.3;
}
html[data-table-dice="yze"] .cd-who-clear,
html[data-table-dice="gits"] .cd-who-clear {
  flex: 0 0 auto;
}
html[data-table-dice="yze"] .cd-meters,
html[data-table-dice="gits"] .cd-meters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
html[data-table-dice="yze"] .cd-meter,
html[data-table-dice="gits"] .cd-meter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  min-width: 0;
}
html[data-table-dice="yze"] .cd-step-row,
html[data-table-dice="gits"] .cd-step-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--btn-h, 32px) 52px var(--btn-h, 32px);
  align-items: center;
  gap: 6px;
  min-width: 0;
}
html[data-table-dice="yze"] #yze-attr-name {
  cursor: pointer;
}
html[data-table-dice="gits"] .gits-extra-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
html[data-table-dice="gits"] .gits-extra-row {
  grid-template-columns: minmax(0, 1fr) var(--btn-h, 32px) 52px var(--btn-h, 32px) var(--btn-h, 32px);
}
html[data-table-dice="gits"] .gits-extra-kind {
  cursor: pointer;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}
html[data-table-dice="yze"] .cd-step-name,
html[data-table-dice="gits"] .cd-step-name {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html[data-table-dice="yze"] .cd-step-row strong,
html[data-table-dice="gits"] .cd-step-row strong {
  text-align: center;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 1.05rem;
}
html[data-table-dice="yze"] .cd-meter-hint,
html[data-table-dice="gits"] .cd-meter-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding-left: 1px;
}
html[data-table-dice="yze"] .cd-dc-presets,
html[data-table-dice="gits"] .cd-dc-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
html[data-table-dice="yze"] .cd-dc-presets .btn.is-on,
html[data-table-dice="gits"] .cd-dc-presets .btn.is-on {
  border-color: var(--accent);
  color: var(--accent);
}
html[data-table-dice="yze"] .cd-pulse,
html[data-table-dice="gits"] .cd-pulse {
  box-shadow: 0 0 0 2px var(--accent);
  border-radius: 8px;
}
html[data-table-dice="yze"] .slot-tray,
html[data-table-dice="gits"] .slot-tray {
  overflow: visible;
  position: relative;
}
html[data-table-dice="yze"] .slot-die-face,
html[data-table-dice="gits"] .slot-die-face {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 2rem;
  font-weight: 800;
}
html[data-table-dice="yze"] .cd-stage-eq,
html[data-table-dice="yze"] .cd-stage-dice,
html[data-table-dice="gits"] .cd-stage-eq,
html[data-table-dice="gits"] .cd-stage-dice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}
html[data-table-dice="yze"] .cd-stage-op,
html[data-table-dice="gits"] .cd-stage-op {
  flex: 0 0 auto;
  min-width: 1.1em;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-muted, #8fa3bd);
  text-align: center;
  user-select: none;
}
.tc-gits-locs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.tc-gits-loc {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) var(--btn-h, 32px) var(--btn-h, 32px);
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}
.tc-gits-loc strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tc-gits-gw {
  margin-top: 4px;
}
.tc-gits-loc .tc-gits-boxes {
  display: inline-flex;
  gap: 2px;
}
.tc-gits-box {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(180, 190, 200, 0.5);
  border-radius: 50%;
  background: transparent;
  display: inline-grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  color: transparent;
}
.tc-gits-box.is-slash {
  border-color: #fbbf24;
  background: #fbbf24;
  color: #111;
}
.tc-gits-box.is-slash::after {
  content: "/";
}
.tc-gits-box.is-cross {
  border-color: #ef4444;
  background: #ef4444;
  color: #fff;
}
.tc-gits-box.is-cross::after {
  content: "\00d7";
}
.tc-gits-loc.is-injured strong {
  color: #fbbf24;
}
.tc-gits-loc.is-destroyed strong {
  color: #f87171;
}

/* dice panel */
.pool-builder-root {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pool-preview {
  min-height: 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 6px;
  background: var(--bg-deep);
  border-radius: 6px;
  border: 1px solid var(--border-soft);
}
/* Clear + Copy pool sit under Roll */
.pool-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
#btn-copy-pool.is-copied {
  color: var(--ok, #4ade80);
}
.pool-chip {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  color: #0a0a0a;
}
.die-boost {
  background: #5b9bd5;
  color: #fff;
}
.die-ability {
  background: #4ade80;
}
.die-proficiency {
  background: #fbbf24;
}
.die-setback {
  background: #374151;
  color: #e5e7eb;
}
.die-difficulty {
  background: #a855f7;
  color: #fff;
}
.die-challenge {
  background: #ef4444;
  color: #fff;
}
.die-force {
  background: #e5e7eb;
  color: #111;
}
.pool-die-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pool-die-row {
  display: grid;
  grid-template-columns: 1fr 32px 32px 32px;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
}
/* After skill pick from card 🎲 — draw eyes to Difficulty */
.pool-die-row.pool-cue-pulse,
.roll-label.pool-cue-pulse,
.pool-story-block.pool-cue-pulse {
  animation: pool-cue-glow 0.45s ease-in-out 4;
  border-radius: 8px;
}
.pool-die-row.pool-cue-pulse {
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.85), 0 0 18px rgba(168, 85, 247, 0.45);
  background: rgba(168, 85, 247, 0.12);
}
.roll-label.pool-cue-pulse {
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.55);
}
@keyframes pool-cue-glow {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.35);
  }
}
.check-modal-card {
  max-width: 440px;
  max-height: min(92vh, 720px);
  display: flex;
  flex-direction: column;
}
.check-options-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
  max-height: min(60vh, 480px);
}
.check-options-group {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 8px 0 2px;
  font-weight: 700;
}
.check-opt-btn {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border-soft, #2a3142);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-deep, #0e121c) 70%, transparent);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.check-opt-btn:hover {
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.08);
}
.check-opt-btn.check-opt-unskilled {
  opacity: 0.88;
}
.check-opt-btn.check-opt-unskilled .check-opt-dice {
  color: #94a3b8;
}
.check-opt-btn strong {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.92rem;
}
.check-opt-meta {
  grid-column: 1;
  grid-row: 2;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.check-opt-dice {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 0.78rem;
  font-family: var(--mono, monospace);
  color: #fbbf24;
  white-space: nowrap;
}
/* Labels keep die-* color backgrounds (fast pick); force pure white text over chip tints */
.pool-die-row .pool-die-name {
  font-weight: 600;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  color: #ffffff !important;
}
.pool-die-row .pool-die-name.die-boost,
.pool-die-row .pool-die-name.die-ability,
.pool-die-row .pool-die-name.die-proficiency,
.pool-die-row .pool-die-name.die-setback,
.pool-die-row .pool-die-name.die-difficulty,
.pool-die-row .pool-die-name.die-challenge,
.pool-die-row .pool-die-name.die-force {
  color: #ffffff !important;
}
.pool-die-row .pool-free-name {
  font-weight: 600;
  color: #ffffff !important;
}
.pool-count {
  text-align: center;
  font-family: var(--mono);
  color: #ffffff;
}
/* Collapsed automatic symbols (talents / free results) */
.pool-free-wrap {
  margin-top: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-deep);
  padding: 0 8px 8px;
}
.pool-free-wrap > summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
}
.pool-free-wrap > summary::-webkit-details-marker {
  display: none;
}
.pool-free-wrap > summary::before {
  /* ASCII-safe escapes: ▸ / ▾ (file encoding had corrupted the glyphs) */
  content: "\25B8\00a0";
  color: var(--accent);
}
.pool-free-wrap[open] > summary::before {
  content: "\25BE\00a0";
}
.pool-free-wrap > summary:hover {
  color: var(--text);
}
.pool-free-hint {
  display: none; /* legacy; Advanced dice has no body blurb */
}
.pool-story-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 2px 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.pool-story-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.pool-story-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent, #2dd4bf);
  cursor: pointer;
}
.pool-story-check.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pool-story-check.is-disabled input {
  cursor: not-allowed;
}
.pool-free-wrap.has-story-spend > summary {
  color: var(--gold, #fbbf24);
}
.pool-free-wrap.needs-story-pay > summary {
  color: var(--gold, #fbbf24);
}
.pool-story-pay.needs-pay {
  padding: 6px 8px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.08);
}
.pool-story-pay.pool-cue-pulse {
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.9), 0 0 18px rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.14);
}
.pool-story-pay-hint {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold, #fbbf24);
}
.pool-free-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pool-free-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
}
.pool-free-icon {
  width: 16px !important;
  height: 16px !important;
}
.pool-chip-free {
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
}
.pool-chip-free .dice-icon {
  width: 14px !important;
  height: 14px !important;
}

.roll-label {
  display: block;
  margin: 8px 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.roll-label input,
.full-input {
  width: 100%;
  margin-top: 4px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
}
.btn-roll {
  width: 100%;
  margin-bottom: 6px;
  font-size: 1rem !important;
  padding: 10px !important;
}
.btn-roll-table,
#gits-clear {
  width: 100%;
  margin: 0 0 8px;
  height: auto;
  font-size: 1rem !important;
  padding: 10px !important;
}
#gits-clear {
  margin-top: 0;
}
.table-roll-opt .check-opt-name .tag {
  margin-left: 6px;
  vertical-align: middle;
}
.table-roll-mod {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.table-roll-n {
  width: 56px;
  background: var(--bg-card, #152033);
  border: 1px solid var(--border, #2a3d5c);
  color: var(--text, #e6eef8);
  border-radius: 6px;
  padding: 2px 4px;
}
.check-opt-btn.table-roll-opt {
  grid-template-columns: 1fr auto;
}
.check-opt-btn.table-roll-opt .check-opt-sub {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.table-roll-search {
  margin: 0 0 10px;
  flex: 0 0 auto;
}
.table-roll-card {
  width: min(560px, 100%);
  max-width: min(560px, 96vw);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.table-roll-card .hint {
  flex: 0 0 auto;
}
.table-roll-card .check-options-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.table-roll-card .cond-modal-foot {
  flex: 0 0 auto;
}
.table-roll-pack {
  border: 1px solid var(--border-soft, #2a3142);
  border-radius: 8px;
  margin: 0 0 8px;
  background: rgba(0, 0, 0, 0.16);
  overflow: hidden;
  flex-shrink: 0;
}
.table-roll-pack > summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.88rem;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--bg-panel, #151b28) 92%, #000);
}
.table-roll-pack > summary::-webkit-details-marker {
  display: none;
}
.table-roll-pack > summary::before {
  content: "\25B8\00a0";
  color: var(--accent);
}
.table-roll-pack[open] > summary::before {
  content: "\25BE\00a0";
}
.table-roll-pack > summary:hover {
  color: var(--accent);
}
.table-roll-pack-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 8px 8px;
  max-height: min(46vh, 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.table-roll-empty {
  margin: 8px 2px;
}
.roll-log-latest {
  margin-bottom: 8px;
}
.roll-log-latest:empty::before {
  content: "No rolls yet.";
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.roll-log-toggle {
  width: 100%;
  margin-bottom: 8px;
}
.roll-log {
  max-height: 280px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.roll-log[hidden] {
  display: none !important;
}
/* Newest first (entries are prepended; column direction keeps that order) */
.roll-entry {
  padding: 6px 8px;
  background: var(--bg-deep);
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  font-size: 0.82rem;
}
.roll-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
}
.roll-log-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.roll-icon-btn {
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  padding: 0 !important;
  font-size: 0.95rem !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  border-radius: 6px !important;
}
.roll-icon-btn:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}
.roll-icon-btn.is-flash {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.roll-reuse-btn {
  font-size: 1.05rem !important;
  font-weight: 600;
}
.roll-replay-btn {
  font-size: 0.9rem !important;
}
.roll-entry-pool {
  margin: 4px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.roll-entry-net {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.net-symbols {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.hub-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}
.hub-row-actions .btn,
.hub-row-actions .btn-sm {
  box-sizing: border-box;
  height: 32px;
  min-height: 32px;
  padding: 0 12px !important;
  font-size: 0.88rem !important;
  line-height: 1;
}
.btn-danger {
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
  background: rgba(127, 29, 29, 0.35);
}
.btn-danger:hover {
  background: rgba(185, 28, 28, 0.55);
  border-color: #f87171;
  color: #fff;
}

/* dice stage */
.dice-stage {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(4, 8, 14, 0.82);
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}
/* `display: grid` above would otherwise override the HTML hidden attribute */
.dice-stage[hidden] {
  display: none !important;
}
/* Despair: brief lightning flashes (behind UI content) */
.dice-stage.despair-thunder::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: transparent;
  animation: despair-lightning 1.15s ease-out forwards;
}
@keyframes despair-lightning {
  0% {
    background: transparent;
    opacity: 1;
  }
  4% {
    background: radial-gradient(ellipse at 70% 25%, rgba(200, 180, 255, 0.55), rgba(30, 10, 50, 0.35) 45%, transparent 70%);
  }
  8% {
    background: transparent;
  }
  14% {
    background: radial-gradient(ellipse at 30% 40%, rgba(255, 255, 255, 0.45), rgba(80, 40, 120, 0.4) 40%, transparent 65%);
  }
  20% {
    background: transparent;
  }
  32% {
    background: radial-gradient(ellipse at 55% 20%, rgba(180, 160, 255, 0.35), transparent 55%);
  }
  45%,
  100% {
    background: transparent;
    opacity: 0;
  }
}
/* Full-stage fireworks layer â€” behind tray, emote, result banner */
.roll-fireworks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.dice-stage-inner {
  position: relative;
  z-index: 1;
  width: min(900px, 96vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
/* Tray + corner emotes (machine card pop) */
.dice-tray-stage {
  position: relative;
  width: 100%;
  padding-top: 0;
  overflow: visible;
}

/*
 * Clip window sits on the tray rim (bottom of slot == top of box).
 * overflow:hidden so nothing can ever draw past the rim â€” no bottom-edge flash.
 */
.roll-emote-slot {
  position: absolute;
  bottom: 100%;
  width: min(168px, 32vw);
  max-width: 200px;
  /* Tall enough for full emote + scale peak */
  height: min(220px, 42vw);
  max-height: 240px;
  /* Above flags (1), under tray (3) — flag raise must not paint over the emote */
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  line-height: 0;
}
.roll-emote-slot-success {
  left: 6px;
}
.roll-emote-slot-failure {
  right: 6px;
}

/*
 * Triumph / Despair flags — _feedback/mockup.jpg:
 *
 *   [cloth]          hinge (base of pole) fixed on tray side
 *      |             assembly = vertical pole + rectangular cloth at top
 *      | pole        springs UP around hinge (hanging down → upright)
 *      * hinge
 *
 * z-index under tray so the hinge tucks behind the box edge.
 */
.dice-tray-wrap {
  position: relative;
  width: 100%;
  /* No elevated z-index here — a wrap stacking context would paint overflowing
     flags on top of #dice-result-banner (the Success/Failure results box below). */
  z-index: auto;
  overflow: visible;
}

/* Zero-size hinge anchors on the tray sides (mid height) */
.roll-flag {
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  /* Behind tray face (3); results banner is a sibling with higher z-index */
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  overflow: visible;
}
.roll-flag[hidden],
.roll-flag:not(.is-show) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.roll-flag.is-show {
  display: block !important;
  visibility: visible;
  opacity: 1;
}
/* Hinge anchors: a notch inward so flags spring up closer to the tray (not way out) */
.roll-flag-triumph {
  left: 22px; /* a bit to the right of the left rim */
}
.roll-flag-despair {
  right: 22px; /* a bit to the left of the right rim */
}

/* Pole + cloth; pivot = bottom of pole (the hinge) */
.roll-flag-assembly {
  position: absolute;
  width: min(118px, 24vw);
  height: min(128px, 28vw);
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.45));
  will-change: transform;
}
/* Left: assembly sits left of hinge; pivot bottom-right of assembly */
.roll-flag-triumph .roll-flag-assembly {
  right: 0;
  bottom: 0;
  transform-origin: 100% 100%;
  /* Default pose before/without animation = hanging down */
  transform: rotate(-180deg);
}
/* Right: assembly sits right of hinge; pivot bottom-left of assembly */
.roll-flag-despair .roll-flag-assembly {
  left: 0;
  bottom: 0;
  transform-origin: 0% 100%;
  transform: rotate(180deg);
}

/* Vertical pole along the tray-side edge of the assembly */
.roll-flag-pole {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  border-radius: 3px 3px 2px 2px;
  background: linear-gradient(90deg, #94a3b8 0%, #f8fafc 42%, #64748b 100%);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.3),
    inset -1px 0 0 rgba(255, 255, 255, 0.5);
}
.roll-flag-triumph .roll-flag-pole {
  right: 0;
}
.roll-flag-despair .roll-flag-pole {
  left: 0;
}

/* Rectangular cloth near the TOP of the pole, flying outward */
.roll-flag-cloth {
  position: absolute;
  top: 2px;
  height: 46%;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.roll-flag-triumph .roll-flag-cloth {
  right: 6px;
  left: 0;
  border-radius: 5px 2px 2px 5px;
  background: linear-gradient(160deg, #fde68a 0%, #fbbf24 42%, #d97706 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.roll-flag-despair .roll-flag-cloth {
  left: 6px;
  right: 0;
  border-radius: 2px 5px 5px 2px;
  background: linear-gradient(200deg, #d8b4fe 0%, #9333ea 45%, #5b21b6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.roll-flag-sym {
  display: block;
  width: min(34px, 7.5vw);
  height: auto;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transform: scale(0.4);
}

/*
 * Spring UP around the hinge.
 * Start 180° from rest, finish at 70° lean (signs flipped so each side rises outward).
 * Left (Triumph):  -180° → -70°
 * Right (Despair):  180° →  70°
 * (Positive CSS rotate = clockwise.)
 */
.roll-flag-triumph.is-show .roll-flag-assembly {
  animation: roll-flag-spring-up-left 0.8s cubic-bezier(0.18, 1.35, 0.32, 1) both;
}
.roll-flag-despair.is-show .roll-flag-assembly {
  animation: roll-flag-spring-up-right 0.8s cubic-bezier(0.18, 1.35, 0.32, 1) both;
}
.roll-flag.is-show .roll-flag-sym {
  animation: roll-flag-sym-pop 0.35s cubic-bezier(0.25, 0.9, 0.35, 1) 0.45s both;
}

@keyframes roll-flag-spring-up-left {
  0% {
    opacity: 0.85;
    transform: rotate(-180deg);
  }
  58% {
    opacity: 1;
    /* overshoot past the rest angle */
    transform: rotate(-55deg);
  }
  80% {
    transform: rotate(-78deg);
  }
  100% {
    opacity: 1;
    transform: rotate(-70deg);
  }
}
@keyframes roll-flag-spring-up-right {
  0% {
    opacity: 0.85;
    transform: rotate(180deg);
  }
  58% {
    opacity: 1;
    transform: rotate(55deg);
  }
  80% {
    transform: rotate(78deg);
  }
  100% {
    opacity: 1;
    transform: rotate(70deg);
  }
}
@keyframes roll-flag-sym-pop {
  0% {
    opacity: 0;
    transform: scale(0.35);
  }
  70% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Image anchored to bottom of the clip window (= tray top) */
.roll-emote {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  opacity: 0;
  transform: translateY(100%) scale(0.82);
  transform-origin: bottom center;
  filter: brightness(0.85);
  will-change: transform, opacity;
  line-height: 0;
}
.roll-emote img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
  user-select: none;
  -webkit-user-drag: none;
}
.roll-emote.is-show {
  opacity: 1;
  filter: brightness(1);
  animation: roll-emote-pop 0.5s cubic-bezier(0.25, 0.85, 0.35, 1) both;
}

/*
 * Slide up from behind the box, then a scale pulse (grows up from the rim).
 * Never translateY < 0 â€” no overshoot above, rim always clips.
 */
@keyframes roll-emote-pop {
  0% {
    opacity: 0.2;
    transform: translateY(100%) scale(0.82);
    filter: brightness(0.6);
  }
  55% {
    opacity: 1;
    transform: translateY(0) scale(1.12);
    filter: brightness(1.06);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

/* â”€â”€ Slot-machine dice tray â”€â”€ */
.slot-tray {
  position: relative;
  z-index: 3; /* above emotes + flags so mast/cloth tuck under the box face */
  width: 100%;
  min-height: 140px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: stretch;
  align-content: center;
  padding: 18px 14px;
  background: #0a1018;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 0 40px rgba(45, 212, 191, 0.12);
  /* smooth reflow when dice collapse out of the row */
  transition: gap 0.2s ease;
}
.slot-tray[hidden] {
  display: none !important;
}
@media (max-width: 640px) {
  .roll-emote-slot {
    width: min(120px, 36vw);
    height: min(160px, 48vw);
  }
}
.slot-die {
  --die-color: #4ade80;
  --die-ink: #111;
  width: 92px;
  flex: 0 0 92px;
  max-width: 92px;
  border-radius: 12px;
  background: linear-gradient(160deg, #1a2434 0%, #0e1520 100%);
  border: 2px solid color-mix(in srgb, var(--die-color) 65%, #2a3d5c);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease,
    filter 0.15s ease,
    width 0.28s ease,
    max-width 0.28s ease,
    flex-basis 0.28s ease,
    margin 0.28s ease,
    padding 0.28s ease,
    border-width 0.28s ease;
}
.slot-die-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 5px 4px 3px;
  color: var(--die-color);
  border-bottom: 1px solid var(--border-soft);
}
.slot-die-window {
  padding: 8px;
  background: #070b12;
}
.slot-die-face {
  min-height: 64px;
  border-radius: 8px;
  background: var(--die-color);
  color: var(--die-ink);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.slot-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  text-align: center;
  transition: opacity 0.15s ease, filter 0.15s ease, transform 0.15s ease;
}
/* Official Genesys result symbols on the colored die face (dice roller) */
.slot-glyph .slot-sym {
  width: 30px;
  height: 30px;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
  /* keep art crisp on solid die colors */
  image-rendering: auto;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.12));
}
.slot-glyph-multi .slot-sym {
  width: 24px;
  height: 24px;
}
.slot-glyph-fallback {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}
/* Cancelled symbol still visible but clearly spent */
.slot-glyph-cancelled {
  opacity: 0.28;
  filter: grayscale(1);
  transform: scale(0.88);
}
.slot-glyph-cancelled .slot-sym {
  /* keep master art readable while looking spent */
  filter: none;
}
.slot-die.slot-partial {
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.45), 0 4px 14px rgba(0, 0, 0, 0.45);
}
.slot-die-face.slot-face-update {
  animation: slot-face-nudge 0.18s ease-out;
}
@keyframes slot-face-nudge {
  0% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}
.slot-blank {
  opacity: 0.35;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--die-ink) 22%, transparent);
  display: inline-block;
}
.slot-die.spinning .slot-die-face {
  filter: brightness(1.08);
}
.slot-die-face.slot-tick {
  animation: slot-tick 0.06s ease-out;
}
.slot-die-face.slot-land {
  animation: slot-land 0.22s ease-out;
}
.slot-die.landed {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--die-color) 50%, transparent),
    0 6px 16px rgba(0, 0, 0, 0.4);
}
/* Story Point pre-roll: tremble → explode → reborn die (no caption) */
.slot-tray.story-fx-active {
  position: relative;
  overflow: visible !important;
}
/* Let fireworks paint outside the tray box during Story Point FX */
.dice-tray-wrap:has(.slot-tray.story-fx-active),
.dice-tray-stage:has(.slot-tray.story-fx-active) {
  overflow: visible;
}
.slot-tray.story-tray-pulse {
  animation: story-tray-pulse 0.45s ease-in-out;
}
.slot-die.story-stage-die {
  opacity: 0.95;
}
.slot-die.story-tremble {
  z-index: 4;
  animation: story-tremble 0.62s ease-in-out;
  filter: brightness(1.25) saturate(1.35);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35), 0 0 28px color-mix(in srgb, var(--die-color) 70%, transparent);
}
/* Upgrade flash — same size, color swap (no shrink/grow) */
.slot-die.story-spark-flash {
  z-index: 5;
  filter: brightness(2.1) saturate(1.6);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.65), 0 0 36px color-mix(in srgb, var(--die-color) 85%, #fff);
}
.slot-die.story-recolor {
  z-index: 4;
  animation: story-recolor 0.55s ease-out;
}
/* Only brand-new dice (no green/purple left) grow in */
.slot-die.story-die-reborn {
  animation: story-die-reborn 0.7s cubic-bezier(0.22, 1.4, 0.36, 1);
  z-index: 4;
}
.story-add-epicenter {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  pointer-events: none;
  opacity: 0;
}
.story-burst {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 12;
  pointer-events: none;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--burst-color, #fbbf24) 70%, #fff));
}
/* Central white-hot flash */
.story-burst-core {
  position: absolute;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #fff 0%,
    color-mix(in srgb, var(--burst-color, #fbbf24) 80%, #fff) 38%,
    transparent 72%
  );
  animation: story-core-flash 0.55s ease-out forwards;
  box-shadow: 0 0 40px 12px color-mix(in srgb, var(--burst-color, #fbbf24) 75%, #fff);
}
.story-burst-particle {
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 3px;
  background: var(--burst-color, #fbbf24);
  box-shadow:
    0 0 10px 2px color-mix(in srgb, var(--burst-color, #fbbf24) 90%, #fff),
    0 0 18px color-mix(in srgb, var(--burst-color, #fbbf24) 60%, transparent);
  animation: story-particle-fly 0.95s cubic-bezier(0.12, 0.7, 0.25, 1) forwards;
  animation-delay: var(--delay, 0s);
  will-change: transform, opacity;
}
/* Big confetti squares */
.story-burst-particle.is-chunk {
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 4px;
  box-shadow:
    0 0 14px 3px color-mix(in srgb, var(--burst-color, #fbbf24) 85%, #fff),
    0 0 28px rgba(255, 255, 255, 0.45);
}
/* Long festive ribbons */
.story-burst-particle.is-ribbon {
  width: 8px;
  height: 28px;
  margin: -14px 0 0 -4px;
  border-radius: 3px;
  box-shadow:
    0 0 12px 2px #fff,
    0 0 22px color-mix(in srgb, var(--burst-color, #fbbf24) 80%, transparent);
}
/* Streak sparks */
.story-burst-particle.is-spark {
  width: 5px;
  height: 22px;
  margin: -11px 0 0 -2px;
  border-radius: 2px;
  box-shadow: 0 0 14px 2px #fff, 0 0 24px var(--burst-color, #fbbf24);
}
/* Star-ish diamond flecks (still readable size) */
.story-burst-particle.is-star {
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 2px;
  transform: rotate(45deg);
  box-shadow: 0 0 12px 2px #fff;
}
.story-burst-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 3px solid var(--burst-color, #fbbf24);
  box-shadow: 0 0 18px color-mix(in srgb, var(--burst-color, #fbbf24) 70%, #fff);
  animation: story-ring-pop 0.7s ease-out forwards;
}
.story-burst-ring.is-mid {
  animation-delay: 0.05s;
  border-color: #fff;
  border-width: 2px;
}
.story-burst-ring.is-late {
  animation-delay: 0.12s;
  border-color: color-mix(in srgb, var(--burst-color, #fbbf24) 50%, #fff);
  border-width: 2px;
  opacity: 0.9;
}
@keyframes story-tremble {
  0%,
  100% {
    transform: translate(0, 0) rotate(0) scale(1);
  }
  10% {
    transform: translate(-3px, 2px) rotate(-4deg) scale(1.04);
  }
  20% {
    transform: translate(4px, -2px) rotate(5deg) scale(1.06);
  }
  30% {
    transform: translate(-4px, -3px) rotate(-6deg) scale(1.08);
  }
  40% {
    transform: translate(5px, 2px) rotate(7deg) scale(1.1);
  }
  50% {
    transform: translate(-5px, 3px) rotate(-8deg) scale(1.12);
  }
  60% {
    transform: translate(4px, -4px) rotate(6deg) scale(1.14);
  }
  70% {
    transform: translate(-3px, 2px) rotate(-5deg) scale(1.16);
  }
  80% {
    transform: translate(3px, -2px) rotate(4deg) scale(1.18);
  }
  90% {
    transform: translate(-2px, 1px) rotate(-3deg) scale(1.2);
  }
}
/* Same-size color change after sparks (upgrade only) */
@keyframes story-recolor {
  0% {
    filter: brightness(2.4) saturate(1.8);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 40px color-mix(in srgb, var(--die-color) 90%, #fff);
    transform: scale(1.04);
  }
  55% {
    filter: brightness(1.25) saturate(1.25);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--die-color) 55%, transparent),
      0 0 22px color-mix(in srgb, var(--die-color) 50%, transparent);
    transform: scale(1.02);
  }
  100% {
    filter: brightness(1) saturate(1);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--die-color) 50%, transparent),
      0 6px 16px rgba(0, 0, 0, 0.4);
    transform: scale(1);
  }
}
/* New die only (add path) — grow from small */
@keyframes story-die-reborn {
  0% {
    opacity: 0;
    transform: scale(0.15) translateY(20px) rotate(-20deg);
    filter: brightness(2);
  }
  55% {
    opacity: 1;
    transform: scale(1.18) translateY(-6px) rotate(4deg);
    filter: brightness(1.35);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0) rotate(0);
    filter: brightness(1);
  }
}
@keyframes story-core-flash {
  0% {
    opacity: 1;
    transform: scale(0.35);
  }
  35% {
    opacity: 1;
    transform: scale(1.35);
  }
  100% {
    opacity: 0;
    transform: scale(2.4);
  }
}
@keyframes story-particle-fly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(var(--scale0, 1)) rotate(0deg);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.35) rotate(var(--rot));
  }
}
@keyframes story-ring-pop {
  0% {
    opacity: 0.95;
    transform: scale(0.35);
  }
  100% {
    opacity: 0;
    transform: scale(12);
  }
}
@keyframes story-tray-pulse {
  0%,
  100% {
    box-shadow: 0 0 40px rgba(45, 212, 191, 0.12);
  }
  50% {
    box-shadow: 0 0 50px rgba(251, 191, 36, 0.45), 0 0 20px rgba(255, 255, 255, 0.15);
  }
}
/* Story Point tags in roll log / result banner */
.tag-story {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 999px;
  vertical-align: middle;
}
.tag-story-pc {
  color: #052e16;
  background: #4ade80;
  border: 1px solid #22c55e;
}
.tag-story-gm {
  color: #faf5ff;
  background: #a855f7;
  border: 1px solid #7c3aed;
}
.banner-story-tag {
  display: inline-block;
  margin: 0 auto 8px;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.dice-result-banner .banner-story-tag {
  display: block;
  width: fit-content;
}
.slot-die.slot-cancel-flash {
  transform: scale(1.08);
  filter: brightness(1.35);
}
.slot-die.gits-die-fling {
  margin: 0 !important;
  pointer-events: none;
  will-change: transform;
  overflow: visible;
  /* rAF sets transform every frame — easing here makes the shot wind up */
  transition: none !important;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.45));
}
.gits-bullet-hole {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  animation: gits-hole-punch 0.14s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.gits-bullet-hole svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}
.gits-hole-rim {
  fill: #0b0c10;
  stroke: #d4cfc4;
  stroke-width: 1.6;
  stroke-linejoin: miter;
  stroke-miterlimit: 8;
}
.gits-hole-core {
  fill: #050508;
}
.gits-hole-glint {
  fill: #fff;
  opacity: 0.28;
}
.gits-hole-cracks {
  fill: none;
  stroke: #1a1a1c;
  stroke-width: 1.15;
  stroke-linecap: round;
}
@keyframes gits-hole-punch {
  from {
    transform: scale(0.12);
    opacity: 0;
  }
  55% {
    transform: scale(1.18);
    opacity: 1;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.gits-die-spacer {
  flex: 0 0 auto;
  box-sizing: border-box;
  pointer-events: none;
  visibility: hidden;
}
.gits-die-spacer.is-gone {
  width: 0 !important;
  min-width: 0 !important;
  height: 0 !important;
  margin: 0 -6px;
  overflow: hidden;
  transition:
    width 0.28s ease,
    min-width 0.28s ease,
    height 0.28s ease,
    margin 0.28s ease;
}
.slot-die.slot-pop {
  animation: slot-pop 0.18s ease-in forwards;
  pointer-events: none;
}
/* Collapse out of flex flow so remaining dice re-center */
.slot-die.slot-gone {
  opacity: 0;
  transform: scale(0.15);
  pointer-events: none;
  filter: blur(2px);
  width: 0 !important;
  max-width: 0 !important;
  flex-basis: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border-width: 0 !important;
  overflow: hidden;
}
@keyframes slot-tick {
  0% {
    transform: translateY(10px);
    opacity: 0.55;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes slot-land {
  0% {
    transform: scale(1.12);
  }
  60% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes slot-pop {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  40% {
    transform: scale(1.2);
    filter: brightness(1.5);
  }
  100% {
    transform: scale(0.15);
    opacity: 0;
  }
}
.slot-die.die-boost {
  --die-color: #5b9bd5;
  --die-ink: #fff;
}
.slot-die.die-ability {
  --die-color: #4ade80;
  --die-ink: #111;
}
.slot-die.die-proficiency {
  --die-color: #fbbf24;
  --die-ink: #111;
}
.slot-die.die-setback {
  --die-color: #374151;
  --die-ink: #fff;
}
.slot-die.die-difficulty {
  --die-color: #a855f7;
  --die-ink: #fff;
}
.slot-die.die-challenge {
  --die-color: #ef4444;
  --die-ink: #fff;
}
.slot-die.die-force {
  --die-color: #e5e7eb;
  --die-ink: #111;
}
.slot-die.die-auto {
  --die-color: #e8eaef;
  --die-ink: #111;
  /* solid face â€” same chrome as other dice, just pale */
  border: 2px solid color-mix(in srgb, #c8ced8 80%, #2a3d5c);
  background: linear-gradient(160deg, #f7f8fa 0%, #e4e7ee 100%);
}
.slot-die.die-auto .slot-die-label {
  color: #52525b;
}
.die-auto {
  background: #e8eaef;
  color: #18181b;
}
.dice-result-banner {
  position: relative;
  /* Above tray wrap overflow (flag spring) so the results box is never crossed */
  z-index: 5;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.35);
  max-height: min(42vh, 360px);
  overflow: auto;
}
.dice-result-banner.is-success {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
}
.dice-result-banner.is-failure {
  border-color: #f87171;
  box-shadow: 0 0 28px rgba(248, 113, 113, 0.4);
}
.dice-result-banner.is-failure .banner-summary {
  color: #fca5a5;
}
.dice-result-banner.is-neutral {
  border-color: var(--border);
}
.dice-result-banner[hidden] {
  display: none !important;
}
.dice-stage-actions[hidden] {
  display: none !important;
}
/* Success/Failure text + net symbols on one announce row */
.banner-announce {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  margin-bottom: 4px;
  text-align: center;
}
.banner-summary {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  line-height: 1.2;
}
.banner-net {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 22px;
}
.banner-net .dice-icon {
  width: 22px !important;
  height: 22px !important;
}
.result-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  text-align: center;
}
.result-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
}
.result-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.die-card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: stretch;
}
.die-card.is-editable {
  cursor: pointer;
  position: relative;
}
.die-card.is-editable:hover,
.die-card.is-editable:focus-visible {
  box-shadow: 0 0 0 2px var(--accent, #2dd4bf);
}
.die-card.is-dropped {
  opacity: 0.42;
}
.die-card.die-numeric .die-card-face {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  min-height: 28px;
}
.die-card.die-numeric {
  border-color: #d4d4d8;
  min-width: 64px;
}
.die-card.die-numeric .die-card-type {
  color: #e4e4e7;
}
.die-edit-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0 0;
}
.die-face-picker {
  position: fixed;
  /* Above #dice-stage (400). Appending to body at 80 put the menu behind the overlay. */
  z-index: 520;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: min(280px, calc(100vw - 16px));
  padding: 8px;
  background: #0a1018;
  border: 1px solid var(--border, #2a3d5c);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}
.die-face-picker.is-numeric {
  display: grid;
  grid-template-columns: repeat(5, minmax(32px, 1fr));
  max-width: 220px;
}
.die-face-opt {
  min-width: 36px;
  min-height: 36px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #2a3d5c;
  background: #12161f;
  color: #f0f4f8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
}
.die-face-opt:hover,
.die-face-opt:focus-visible {
  border-color: var(--accent, #2dd4bf);
}
.die-face-opt.is-on {
  border-color: var(--accent, #2dd4bf);
  box-shadow: 0 0 0 1px var(--accent, #2dd4bf);
}
.die-face-opt .dice-icon {
  width: 18px !important;
  height: 18px !important;
}
.die-face-opt .face-blank {
  font-size: 0.68rem;
}
/*
 * Result / log die cards: dark face so white symbol masters stay readable.
 * Die type is shown via colored border + label (not a full flood fill).
 */
.die-card {
  min-width: 80px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 2px solid #2a3d5c;
  background: #0a1018;
  text-align: center;
  color: #f0f4f8;
}
.die-card.die-boost {
  border-color: #5b9bd5;
}
.die-card.die-boost .die-card-type {
  color: #7eb6e0;
}
.die-card.die-ability {
  border-color: #4ade80;
}
.die-card.die-ability .die-card-type {
  color: #4ade80;
}
.die-card.die-proficiency {
  border-color: #fbbf24;
}
.die-card.die-proficiency .die-card-type {
  color: #fbbf24;
}
.die-card.die-setback {
  border-color: #6b7280;
}
.die-card.die-setback .die-card-type {
  color: #9ca3af;
}
.die-card.die-difficulty {
  border-color: #a855f7;
}
.die-card.die-difficulty .die-card-type {
  color: #c084fc;
}
.die-card.die-challenge {
  border-color: #ef4444;
}
.die-card.die-challenge .die-card-type {
  color: #f87171;
}
.die-card.die-auto {
  border-color: #d4d4d8;
  background: #12161f;
}
.die-card.die-auto .die-card-type {
  color: #e4e4e7;
}
.die-card .dice-icon {
  width: 26px !important;
  height: 26px !important;
}
.die-card-type {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
  opacity: 0.95;
}
.die-card-face {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
  min-height: 28px;
}
.die-card-face .dice-icon {
  /* white masters on dark card */
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.35));
}
.face-blank {
  font-size: 0.75rem;
  color: #94a3b8;
}
.sym-wrap {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.sym-glyph {
  font-size: 1.25em;
  font-weight: 700;
  line-height: 1;
  padding: 0 2px;
  color: #f0f4f8;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.35);
}
.banner-net .dice-icon,
.result-net .dice-icon {
  width: 26px !important;
  height: 26px !important;
}
.roll-entry-dice {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}
.roll-entry-dice .die-card {
  min-width: 56px;
  padding: 4px 6px;
}
/* Share invite modal */
.share-modal-card {
  max-width: 520px;
}
.share-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.share-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
}
.share-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.share-row .full-input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.share-gm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.dice-stage-actions {
  position: relative;
  z-index: 5; /* same layer as results banner — above flag overflow */
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}
#btn-close-stage,
#btn-reroll-stage,
#btn-share-roll {
  min-width: 120px;
  font-size: 1rem !important;
  padding: 10px 20px !important;
}
#btn-reroll-stage:disabled,
#btn-close-stage:disabled,
#btn-share-roll:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.share-roll-box {
  width: 100%;
  max-width: 640px;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.share-roll-box[hidden] {
  display: none !important;
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal[hidden] {
  display: none !important;
}
.modal-card {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 16px;
}
#stash-modal .stash-modal-card {
  width: min(1180px, 98vw);
  max-width: min(1180px, 98vw);
  height: auto;
  min-height: min(520px, 86vh);
  max-height: 86vh;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.modal-head h3 {
  margin: 0;
}
.add-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.add-tab.active {
  border-color: var(--accent);
  color: var(--accent);
}
.inline-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}
.adv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
  margin-top: 8px;
}
.adv-pick {
  text-align: left;
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}
.adv-pick:hover:not(:disabled) {
  border-color: var(--accent);
}
.adv-pick:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Tablet: stack columns (phones get tabbed UI below) */
@media (max-width: 960px) {
  .lobby-app {
    grid-template-columns: 1fr;
  }
  .lobby-left,
  .lobby-side {
    border: none;
    border-bottom: 1px solid var(--border-soft);
    max-height: none;
  }
  .lobby-left {
    max-height: 50vh;
  }
  .side-scroll {
    max-height: none;
  }
  .chat-list {
    min-height: 120px;
  }
}

/* Phone table layout: html[data-table-layout="phone"] (set before paint + layout switch).
 * Same PHP/markup as desktop — hard layout fork via attribute, not a second page.
 */
.mobile-table-tabs {
  display: none;
}
.mobile-table-tabs[hidden] {
  display: none !important;
}
.layout-switch {
  display: none;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.layout-switch .layout-switch-btn {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem !important;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 10px !important;
  line-height: 1.2;
  cursor: pointer;
}
.layout-switch .layout-switch-btn.active {
  background: rgba(45, 212, 191, 0.18);
  color: var(--accent);
}
html[data-table-layout="phone"] .layout-switch,
html[data-table-layout="desktop"] .layout-switch {
  display: inline-flex;
}

/* Lock width so desktop 3-col min-width cannot force page zoom */
html[data-table-layout="phone"] {
  --mobile-tab-h: 56px;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  height: 100%;
}
html[data-table-layout="phone"] body.table-body {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overflow-x: clip;
  box-sizing: border-box;
}
html[data-table-layout="phone"] .site-topbar,
html[data-table-layout="phone"] .lobby-subhead {
  flex-shrink: 0;
  max-width: 100%;
  box-sizing: border-box;
}
html[data-table-layout="phone"] .site-topbar {
  flex-wrap: wrap;
  height: auto;
  min-height: var(--header-h);
  padding: 6px 10px;
  gap: 6px 10px;
  row-gap: 4px;
}
html[data-table-layout="phone"] .brand h1 {
  font-size: 0.85rem;
}
html[data-table-layout="phone"] .brand h1 span {
  display: none;
}
html[data-table-layout="phone"] .site-nav {
  display: none;
}
html[data-table-layout="phone"] .site-nav.open {
  display: flex !important;
}
html[data-table-layout="phone"] .topbar-actions {
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  max-width: 100%;
}
html[data-table-layout="phone"] .nav-user-name {
  display: none;
}
html[data-table-layout="phone"] .lobby-subhead {
  gap: 8px;
  padding: 6px 10px;
}
html[data-table-layout="phone"] .layout-switch {
  margin-left: auto;
}

/* Full-bleed single-panel shell — never a 280px grid track */
html[data-table-layout="phone"] .lobby-app:not([hidden]) {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow: hidden;
  padding-bottom: calc(var(--mobile-tab-h) + env(safe-area-inset-bottom, 0px));
}
html[data-table-layout="phone"] .lobby-app > [data-mtab-panel] {
  display: none !important;
  flex: 1 1 auto !important;
  align-self: stretch !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  border: none;
  grid-column: 1 / -1 !important;
  grid-row: 1 !important;
  box-sizing: border-box;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="chat"] > [data-mtab-panel="chat"],
html[data-table-layout="phone"] .lobby-app[data-mtab="dice"] > [data-mtab-panel="dice"],
html[data-table-layout="phone"] .lobby-app[data-mtab="cards"] > [data-mtab-panel="cards"] {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  max-width: none !important;
}

/* â”€â”€ Chat tab â”€â”€ */
html[data-table-layout="phone"] .lobby-app[data-mtab="chat"] .lobby-left {
  margin: 0;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="chat"] .presence-panel {
  flex: 0 0 auto;
  max-height: 28%;
  margin: 8px 8px 0;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="chat"] .chat-panel {
  flex: 1 1 auto;
  min-height: 0;
  margin: 8px;
  display: flex;
  flex-direction: column;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="chat"] .chat-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

/* â”€â”€ Cards tab â”€â”€ */
html[data-table-layout="phone"] .lobby-app[data-mtab="cards"] .lobby-main {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 0;
  width: 100%;
  box-sizing: border-box;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="cards"] .roster {
  grid-template-columns: 1fr;
}
html[data-table-layout="phone"] .vtt-frame {
  height: 58vh;
  min-height: 240px;
}
html[data-table-layout="phone"] .lobby-subhead .story-bar {
  flex: 1 1 100%;
  order: 5;
}
html[data-table-layout="phone"] .table-tools {
  margin-left: 0;
}
html[data-table-layout="phone"] .stash-modal-card {
  width: 100%;
  height: min(92vh, 100%);
}
html[data-table-layout="phone"] .stash-layout {
  grid-template-columns: 1fr;
  max-height: none;
}
html[data-table-layout="phone"] .stash-folders {
  border-right: 0;
  border-bottom: 1px solid var(--border-soft);
  padding-right: 0;
  padding-bottom: 8px;
  max-height: 28vh;
}
html[data-table-layout="phone"] .stash-item {
  grid-template-columns: 4.2rem minmax(0, 1fr);
}
html[data-table-layout="phone"] .stash-item-actions {
  grid-column: 1 / -1;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* â”€â”€ Dice tab: centered roller, full-width column â”€â”€ */
html[data-table-layout="phone"] .lobby-app[data-mtab="dice"] .lobby-side {
  overflow: hidden;
  width: 100%;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="dice"] .side-scroll {
  flex: 1 1 auto;
  max-height: none;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="dice"] .dice-panel {
  width: 100%;
  max-width: 420px;
  margin: 0;
  flex: 0 0 auto;
  flex-shrink: 0;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="dice"] .roll-log-panel {
  width: 100%;
  max-width: 420px;
  margin: 0;
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="dice"] .roll-log {
  flex: 1 1 auto;
  max-height: 36vh;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="dice"] .pool-die-row {
  grid-template-columns: 1fr 40px 36px 40px;
  min-height: 40px;
  font-size: 0.9rem;
}
html[data-table-layout="phone"] .lobby-app[data-mtab="dice"] .btn-roll {
  height: var(--btn-h, 32px) !important;
  min-height: var(--btn-h, 32px) !important;
  padding: 0 14px !important;
  font-size: 0.95rem !important;
}

/* Bottom tab bar â€” only when JS enables phone mode + table is open */
html[data-table-layout="phone"] .mobile-table-tabs:not([hidden]) {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  height: calc(var(--mobile-tab-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 4px env(safe-area-inset-bottom, 0px);
  background: linear-gradient(180deg, #0f1826 0%, #0a101a 100%);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
}
html[data-table-layout="phone"] .mobile-tab {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--mobile-tab-h);
  margin: 0;
  padding: 6px 4px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
html[data-table-layout="phone"] .mobile-tab .mtab-icon {
  font-size: 1.15rem;
  line-height: 1;
}
html[data-table-layout="phone"] .mobile-tab .mtab-label {
  line-height: 1.1;
}
html[data-table-layout="phone"] .mobile-tab:hover,
html[data-table-layout="phone"] .mobile-tab:focus-visible {
  color: var(--text);
  outline: none;
}
html[data-table-layout="phone"] .mobile-tab.active {
  color: var(--accent);
}
html[data-table-layout="phone"] .mobile-tab.active::after {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* New-message blink on Chat tab */
html[data-table-layout="phone"] .mtab-dot {
  position: absolute;
  top: 8px;
  right: calc(50% - 22px);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f87171;
  box-shadow: 0 0 0 2px #0a101a, 0 0 8px rgba(248, 113, 113, 0.7);
  pointer-events: none;
}
html[data-table-layout="phone"] .mtab-dot[hidden] {
  display: none !important;
}
html[data-table-layout="phone"] .mobile-tab.has-unread .mtab-dot {
  display: block !important;
  animation: mtab-dot-blink 1s ease-in-out infinite;
}
@keyframes mtab-dot-blink {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.25;
    transform: scale(0.85);
  }
}

/*
 * Dice stage on phone:
 * Emotes sit above the tray. Never overflow-clip .dice-stage-inner.
 */
html[data-table-layout="phone"] .dice-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0 20px;
  place-items: unset;
}
html[data-table-layout="phone"] .dice-stage-inner {
  width: min(900px, 100%);
  max-width: 100%;
  padding: 0 10px;
  margin-top: auto;
  margin-bottom: auto;
  overflow: visible;
  max-height: none;
  flex: 0 0 auto;
}
html[data-table-layout="phone"] .dice-tray-stage {
  --emote-band: min(128px, 34vw);
  padding-top: var(--emote-band);
  overflow: visible;
}
html[data-table-layout="phone"] .roll-emote-slot {
  top: 0;
  bottom: auto;
  width: min(108px, 30vw);
  height: var(--emote-band);
  max-height: none;
  max-width: none;
}
html[data-table-layout="phone"] .roll-emote-slot-success {
  left: 4px;
}
html[data-table-layout="phone"] .roll-emote-slot-failure {
  right: 4px;
}
html[data-table-layout="phone"] .roll-flag {
  top: 50%;
  z-index: 1;
}
html[data-table-layout="phone"] .roll-flag-assembly {
  width: min(88px, 26vw);
  height: min(96px, 26vw);
}
html[data-table-layout="phone"] .roll-flag-sym {
  width: min(26px, 7vw);
}
html[data-table-layout="phone"] .slot-tray {
  min-height: 110px;
  gap: 8px;
  padding: 12px 8px;
}
html[data-table-layout="phone"] .dice-result-banner {
  max-height: min(38vh, 280px);
}

/* Table color themes — only this page (html[data-table-theme]). Dice stay official. */
.theme-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.theme-swatch {
  min-width: 56px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--swatch, var(--accent)) 55%, #fff);
  background: color-mix(in srgb, var(--swatch, var(--accent)) 22%, #0c121c);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.theme-swatch.is-on {
  background: var(--swatch, var(--accent));
  color: #111;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--swatch, var(--accent)) 70%, #fff);
}

/* Primary = same dark chip as other buttons, accent ink only (no fat filled pills). */
body.table-body .btn-primary {
  background: var(--bg-panel);
  border-color: var(--accent);
  color: var(--accent);
}
body.table-body .btn-primary:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: #fff;
}

html[data-table-theme="amber"] {
  --accent: #f5b942;
  --accent-soft: #d97706;
  --accent-glow: rgba(245, 185, 66, 0.32);
  --link: #ffe08a;
  --magenta: #fb7185;
  --theme-ink: #1a1208;
  --bg-deep: #120d08;
  --bg: #1a140c;
  --bg-panel: #24180d;
  --bg-card: #2c1d10;
  --bg-hover: #3a2714;
  --border: #7a5420;
  --border-soft: #4a3214;
}
html[data-table-theme="ice"] {
  --accent: #7dd3fc;
  --accent-soft: #38bdf8;
  --accent-glow: rgba(125, 211, 252, 0.32);
  --link: #bae6fd;
  --magenta: #a5b4fc;
  --theme-ink: #06202c;
  --bg-deep: #071018;
  --bg: #0b1620;
  --bg-panel: #10202c;
  --bg-card: #142834;
  --bg-hover: #1a3344;
  --border: #2a5a72;
  --border-soft: #1a3848;
}
html[data-table-theme="neon"] {
  --accent: #e879f9;
  --accent-soft: #c026d3;
  --accent-glow: rgba(232, 121, 249, 0.34);
  --link: #f0abfc;
  --magenta: #fb7185;
  --theme-ink: #1a0818;
  --bg-deep: #120814;
  --bg: #180b1c;
  --bg-panel: #241028;
  --bg-card: #2c1432;
  --bg-hover: #3a1a42;
  --border: #7a3a86;
  --border-soft: #4a2254;
}
html[data-table-theme="rust"] {
  --accent: #fb923c;
  --accent-soft: #ea580c;
  --accent-glow: rgba(251, 146, 60, 0.32);
  --link: #fdba74;
  --magenta: #f43f5e;
  --theme-ink: #1c0c06;
  --bg-deep: #140a07;
  --bg: #1c100a;
  --bg-panel: #28160c;
  --bg-card: #321c10;
  --bg-hover: #422616;
  --border: #8a4a22;
  --border-soft: #4e2a14;
}
html[data-table-theme="toxin"] {
  --accent: #86efac;
  --accent-soft: #22c55e;
  --accent-glow: rgba(134, 239, 172, 0.32);
  --link: #bbf7d0;
  --magenta: #a3e635;
  --theme-ink: #06140c;
  --bg-deep: #07120b;
  --bg: #0c1810;
  --bg-panel: #122418;
  --bg-card: #162c1c;
  --bg-hover: #1c3a24;
  --border: #2e6a42;
  --border-soft: #1c4030;
}
html[data-table-theme="amber"] body.table-body {
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(245, 185, 66, 0.22), transparent),
    radial-gradient(ellipse 50% 40% at 95% 10%, rgba(251, 113, 133, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(180, 83, 9, 0.16), transparent);
}
html[data-table-theme="ice"] body.table-body {
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(125, 211, 252, 0.22), transparent),
    radial-gradient(ellipse 50% 40% at 95% 10%, rgba(165, 180, 252, 0.14), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(56, 189, 248, 0.14), transparent);
}
html[data-table-theme="neon"] body.table-body {
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(232, 121, 249, 0.24), transparent),
    radial-gradient(ellipse 50% 40% at 95% 10%, rgba(251, 113, 133, 0.14), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(192, 38, 211, 0.16), transparent);
}
html[data-table-theme="rust"] body.table-body {
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(251, 146, 60, 0.22), transparent),
    radial-gradient(ellipse 50% 40% at 95% 10%, rgba(244, 63, 94, 0.14), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(180, 83, 9, 0.16), transparent);
}
html[data-table-theme="toxin"] body.table-body {
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(134, 239, 172, 0.22), transparent),
    radial-gradient(ellipse 50% 40% at 95% 10%, rgba(163, 230, 53, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(34, 197, 94, 0.14), transparent);
}

/* One button height on the table. Width may vary; height does not. */
body.table-body {
  --btn-h: 32px;
}
body.table-body .btn {
  box-sizing: border-box;
  height: var(--btn-h);
  min-height: var(--btn-h);
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1;
  border-width: 1px;
  border-style: solid;
}
body.table-body .btn-sm {
  height: var(--btn-h) !important;
  min-height: var(--btn-h) !important;
  padding: 0 10px !important;
  font-size: 0.8rem !important;
}
body.table-body .btn-roll {
  height: var(--btn-h) !important;
  min-height: var(--btn-h) !important;
  padding: 0 14px !important;
  font-size: 0.92rem !important;
}
body.table-body .note-reply .chat-sticker-btn {
  width: 28px !important;
  min-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  font-size: 1rem;
}
body.table-body .btn-step,
body.table-body .tc-rail-btn,
body.table-body .roll-icon-btn,
body.table-body .modal-head > .btn,
body.table-body .chat-sticker-btn {
  width: var(--btn-h) !important;
  min-width: var(--btn-h) !important;
  height: var(--btn-h) !important;
  min-height: var(--btn-h) !important;
  padding: 0 !important;
}
body.table-body .btn-import-toggle {
  height: var(--btn-h) !important;
  min-height: var(--btn-h) !important;
  padding: 0 10px !important;
  font-size: 0.75rem !important;
}
body.table-body .layout-switch .layout-switch-btn {
  height: var(--btn-h);
  padding: 0 12px !important;
}
body.table-body .tc-rail {
  flex-basis: 36px;
  width: 36px;
}
body.table-body .rte-toolbar .btn {
  height: var(--btn-h) !important;
  min-height: var(--btn-h) !important;
  min-width: var(--btn-h);
  padding: 0 8px !important;
}
body.table-body .chat-compose,
body.table-body .lobby-subhead,
body.table-body .topbar-actions,
body.table-body .story-bar,
body.table-body .table-tools,
body.table-body .stash-item-actions,
body.table-body .stash-toolbar {
  align-items: center;
}
