:root {
  --bg: #10150d;
  --chassis: #171e12;
  --panel: #1d2716;
  --panel-2: #28361c;
  --line: #42562c;
  --ink: #e8f3d6;
  --dim: #93a67c;
  --hazard: #e4f25a;
  --hazard-ink: #1a2208;
  --phosphor: #b6ff62;
  --rust: #ff6a2c;
  --amber: #ffc14d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Bahnschrift, "Segoe UI", sans-serif;
}

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

button { cursor: pointer; }

button:disabled { cursor: default; opacity: 0.35; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 280px at 0% -10%, rgba(228, 242, 90, 0.08), transparent 55%),
    var(--chassis);
}

.stripe {
  height: 8px;
  flex: 0 0 auto;
  background: repeating-linear-gradient(-45deg, var(--hazard) 0 10px, #1a2208 10px 20px);
}

header.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.kicker {
  margin: 0;
  color: var(--hazard);
  letter-spacing: 0.16em;
  font-size: 11px;
}

header.top h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#shareStatus {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.04em;
}

#shareStatus[data-kind="on"] { color: var(--phosphor); }
#shareStatus[data-kind="down"],
#shareStatus[data-kind="taken"] { color: var(--rust); }

#shareButton, #groupButton, #splitToggle, #helpButton {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

#shareButton {
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 16px;
}

#groupButton {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--hazard);
  color: var(--hazard-ink);
  font-weight: 700;
}

#helpButton {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  color: var(--hazard);
  font-size: 22px;
  font-weight: 700;
}

#splitToggle {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

#splitToggle svg { width: 100%; height: 100%; display: block; }

#splitToggle rect { fill: #1a2208; }

#splitToggle.mode2 .split-three { display: none; }
#splitToggle.mode3 .split-two { display: none; }

#stage {
  flex: 1;
  min-height: 0;
  display: grid;
}

#stage[data-screens="1"] { grid-template-columns: 1fr; }
#stage[data-screens="2"] { grid-template-columns: 1fr 1fr; }
#stage[data-screens="3"] { grid-template-columns: minmax(0, 1fr) minmax(220px, 0.72fr) minmax(0, 1fr); }

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--chassis);
  overflow: hidden;
}

.stream-pane { background: #12180e; }

.pane-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px 0;
  flex: 0 0 auto;
  container-type: inline-size;
}

.pane-head h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hazard);
}

.head-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dim);
}

.head-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}

.clear-dice { margin-left: auto; }

.head-tools .clear-dice { margin-left: 0; }

@container (max-width: 230px) {
  .pane-head h2 { flex: 1 1 100%; }
  .head-tools {
    width: 100%;
    justify-content: flex-end;
    gap: 4px;
  }
  .head-tools .head-icon {
    flex: 1 1 0;
    width: auto;
    max-width: 44px;
  }
}

#stage[data-screens="3"] .extend-log,
#stage[data-screens="3"] .dice-log,
#stage[data-screens="2"][data-rolls-open="1"] .extend-log,
#stage[data-screens="2"][data-rolls-open="1"] .dice-log { display: none; }

.extend-log.on { color: var(--hazard); }

.clear-dice:hover,
.clear-dice:focus-visible { color: var(--hazard); }

.lock-dice.on { color: var(--hazard); }

.sound-dice.on { color: var(--hazard); }

.sound-dice:hover,
.sound-dice:focus-visible { color: var(--hazard); }

.sound-dice .sound-waves,
.sound-dice .sound-slash { display: none; }

.sound-dice.on .sound-waves { display: block; }

.sound-dice:not(.on) .sound-slash { display: block; }

.head-icon svg {
  width: 24px;
  height: 24px;
  display: block;
  margin: 0 auto;
}

.head-icon svg path,
.head-icon svg rect {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.filters, .mods, .die-row, .operators {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
}

.filters, .mods { padding: 6px 10px; }

.mods { container-type: inline-size; }

.filters, .die-row, .operators { flex-wrap: wrap; }

.operators { flex-wrap: nowrap; gap: 4px; }

.mods { flex-wrap: wrap; }

.chip, .nav-btn, .ghost, .step, .roster-name, #shareButton {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 10px;
}

.chip, .ghost, .roster-name, #shareButton, .roll-button, .plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.chip, .ghost, .roster-name, #shareButton { min-width: 44px; }

.flag-row {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 16px;
  min-width: 0;
}

.flag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 2px;
  color: var(--ink);
  cursor: pointer;
  flex: 0 0 auto;
}

.flag input {
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #10160c;
  display: grid;
  place-items: center;
}

.flag input:checked {
  border-color: var(--hazard);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%231a2208' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3 8.5 6.5 12 13 4'/%3E%3C/svg%3E") center / 14px 14px no-repeat,
    var(--hazard);
}

.flag input:focus-visible {
  outline: 2px solid var(--hazard);
  outline-offset: 2px;
}

.chip.on, .nav-btn.on, .step.on {
  background: var(--hazard);
  color: var(--hazard-ink);
  border-color: var(--hazard);
}

.nav-btn { border-radius: 0; }

input[type="search"], input[type="text"], select, textarea {
  background: #10160c;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 44px;
  padding: 10px 12px;
}

input[type="search"] { min-width: 120px; flex: 1; }

.operators .chip {
  flex: 1 1 0;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 8px;
  padding-right: 8px;
  user-select: none;
}

.operators input.op-edit {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  text-align: center;
  font: inherit;
}

.operators input.op-edit.on {
  background: var(--hazard);
  color: var(--hazard-ink);
  border-color: var(--hazard);
}

.step-label, .matrix label, .stack {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
}

.matrix label, .stack { flex-direction: column; align-items: stretch; white-space: normal; }

.operators, .die-row, .mods .hint, .mods .who { flex: 1 1 100%; min-width: 0; }

.stepper { display: inline-flex; align-items: center; gap: 4px; }

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 6px;
}

.step-value {
  min-width: 1.6em;
  text-align: center;
  color: var(--ink);
  font-family: Consolas, "Cascadia Mono", monospace;
}

.step-value[data-for="luck"],
.step-value[data-for="other"] {
  font-size: 22px;
  min-width: 2.2em;
}

.die-label {
  color: var(--dim);
  font-size: 16px;
  display: flex;
  align-items: center;
  height: 44px;
}

.die-pair {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 6px;
  row-gap: 6px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

.die-pair .die-row { display: contents; }

.die-row { align-items: flex-start; }

.die-row > .die-label { flex: 0 0 auto; }

.die-faces {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.die-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.die-row .die-line { flex-wrap: nowrap; }

.step-label:has([data-key="luck"]),
.step-label:has([data-key="other"]),
.step-label:has([data-key="fumbleCount"]) {
  font-size: 16px;
}

.step-label:has([data-key="other"]) { margin-left: 8px; }

.mode-tabs {
  flex: 1 1 100%;
  display: flex;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.mode-tabs .chip {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
  padding: 8px 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.mode-tabs .chip:last-child { border-right: 0; }

.caster-box {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 12px;
  min-width: 0;
  padding: 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #222e18;
}

.caster-box[data-caster="0"] {
  background: #222e18;
  border-color: #5a7340;
}

.caster-box[data-caster="1"] {
  background: #302a16;
  border-color: #74643a;
}

.caster-box[data-caster="2"] {
  background: #1a2c24;
  border-color: #3f6e5c;
}

.caster-box[data-caster="3"] {
  background: #261812;
  border-color: #9a4a32;
}

.patron-controls {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: center;
  column-gap: 20px;
  row-gap: 6px;
  min-width: 0;
}

.patron-controls .patron-line {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  min-width: 0;
}

.patron-controls .step-label:has([data-key="other"]) { margin-left: 0; }

.patron-controls .patron-line.span-center > .step-label {
  grid-column: 1 / -1;
  justify-self: center;
}

.mods > .patron-line,
.mods > .lookup-line { flex: 1 1 100%; }

.mods > .lookup-line { justify-content: center; }

.patron-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  min-width: 0;
}

.patron-line:has(> .step-label:only-child) { justify-content: center; }

.patron-line .step-label {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 2px;
  margin: 0;
  font-size: 16px;
}

.patron-line .step-name {
  flex: 0 0 auto;
  font-size: 16px;
  color: var(--dim);
  white-space: nowrap;
  text-align: left;
}

.patron-line .step-label:first-child .step-name { width: calc(3.4em - 8px); }

.patron-line:has(> .step-label:only-child) .step-name { width: auto; }

.patron-line .step-label:last-child:not(:only-child) .step-name {
  width: calc(4.4em + 8px);
  padding-right: 8px;
  text-align: right;
}

.patron-line .stepper { gap: 2px; }

.patron-line .step { font-size: 16px; }

.patron-line .step-value,
.patron-line .step-value[data-for="luck"],
.patron-line .step-value[data-for="other"] {
  width: 1.75em;
  min-width: 1.75em;
  font-size: 22px;
  text-align: center;
}

.patron-line button.step-value {
  border: 0;
  background: transparent;
  padding: 0;
  width: 44px;
  min-width: 44px;
  height: 44px;
  border-radius: 6px;
  font-family: Consolas, "Cascadia Mono", monospace;
  color: var(--ink);
}

.patron-line input.step-edit {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  text-align: center;
  font-size: 22px;
  font-family: Consolas, "Cascadia Mono", monospace;
}

/* The Level/Luck block is about 410px. A pane under that closes the
   column gap so the labels stay 2px inside. Narrower panes stack the columns. */
@container (max-width: 390px) {
  .patron-controls { column-gap: 0; }
  .patron-line .stepper { gap: 0; }
  .patron-line .step-label:first-child .step-name { width: calc(3.4em - 12px); }
  .patron-line .step-label:last-child:not(:only-child) .step-name {
    width: calc(4.4em + 2px);
    padding-right: 2px;
  }
}

@container (max-width: 366px) {
  .patron-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .patron-controls .patron-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }
}



.die-row .chip { min-width: 44px; padding-left: 10px; padding-right: 10px; }

.die-row .die-btn,
.roll-board .die-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  max-width: 44px;
  padding: 0;
  border-radius: 6px;
}

.die-row .die-line .die-btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: none;
}

.hint, .who, .eq, .matrix-title {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.35;
}

.who { padding: 0 12px 8px; }

.mods .who { padding: 2px 0 6px; }

.body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: clip;
  overflow-y: auto;
}

.entry-list { display: flex; flex-direction: column; min-width: 0; }

.entry-list > .feed-line,
.entry-list > .hint { margin-left: 12px; margin-right: 12px; }

.about-copy {
  margin: 12px 14px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

.about-copy p { margin: 0 0 12px; }

.about-copy a { color: var(--hazard); text-underline-offset: 2px; }

.entry {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px;
}

.entry:hover, .entry:focus-visible { background: var(--panel-2); }

.entry strong {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
  font-weight: 600;
}

.entry span {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--dim);
  font-size: 12px;
  white-space: nowrap;
}

.entry-row {
  display: flex;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
  border-bottom: 1px solid var(--line);
}

.entry-row .entry {
  flex: 1;
  width: auto;
  min-width: 0;
  border-bottom: 0;
}

.fav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  padding: 0;
}

.fav.on { color: var(--hazard); }

.fav svg {
  width: 22px;
  height: 22px;
  display: block;
}

.fav svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.fav.on svg path { fill: currentColor; }

.faves-chip {
  padding-left: 10px;
  padding-right: 10px;
  color: var(--dim);
}

.faves-chip svg {
  width: 18px;
  height: 18px;
  display: block;
}

.faves-chip svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.faves-chip.on svg path { fill: currentColor; }

.sheet {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 10px 0;
  background: var(--chassis);
}

.result {
  border: 1px solid var(--phosphor);
  border-radius: 10px;
  padding: 12px;
  background: #0d140b;
}

.result h2, .result h3 {
  margin: 0 0 6px;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 16px;
  color: var(--amber);
}

.result h3 {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result,
.who,
.log,
.feed,
.hint,
.dice-log {
  overflow-wrap: break-word;
}

.result p { margin: 0 0 8px; white-space: pre-wrap; line-height: 1.45; }

.sheet.computing {
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.result.computing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  text-align: center;
}

.result.computing p {
  margin: 0;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--phosphor);
}

.band-nav, .modal-card .band-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.band-nav .ghost { flex: 0 0 auto; }

.modal-card .dialog-actions { flex-wrap: nowrap; }

.modal-card .dialog-actions .ghost,
.modal-card .dialog-actions .roll-button {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 12px;
  border-width: 1px;
  border-style: solid;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  outline: none;
  min-height: 44px;
}

.modal-card .dialog-actions button.tap {
  animation: dialog-tap 220ms ease-out forwards;
}

@keyframes dialog-tap {
  0% {
    background: var(--panel);
    color: var(--ink);
    border-color: var(--line);
  }
  45%,
  100% {
    background: var(--hazard);
    color: var(--hazard-ink);
    border-color: var(--hazard);
  }
}

.roll-button {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--hazard);
  color: var(--hazard-ink);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.mods .roll-button { flex: 0 0 auto; }

.roll-board {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) auto;
  grid-template-areas:
    "diceLabel diceLine diceLine"
    "dieLabel dieLine1 dieLine1"
    ". dieLine2 roll"
    "luck luck roll";
  column-gap: 6px;
  row-gap: 6px;
  align-items: start;
  min-width: 0;
}

.roll-board .area-dice-label { grid-area: diceLabel; }
.roll-board .area-dice-line { grid-area: diceLine; }
.roll-board .area-die-label { grid-area: dieLabel; }
.roll-board .area-die-line { grid-area: dieLine1; }
.roll-board .area-die-line2 { grid-area: dieLine2; }
.roll-board .die-line { min-width: 0; }

.roll-board .roll-side {
  grid-area: luck;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  justify-content: flex-start;
  gap: 6px 14px;
  min-width: 0;
}

.roll-board .step-label:has([data-key="other"]) { margin-left: 0; }

.roll-board .roll-button {
  grid-area: roll;
  align-self: stretch;
  width: 130px;
  min-height: 88px;
  height: auto;
  font-size: 28px;
}

.roll-board.compact {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "luck roll";
}

.roll-board.compact .roll-side {
  align-items: center;
}

.roll-board.compact .roll-button {
  min-height: 44px;
  font-size: 22px;
}

.roll-board.compact input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

.plus {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--hazard);
  background: var(--panel);
  color: var(--hazard);
  font-size: 22px;
}

.log-label {
  margin: 8px 12px 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
}

.log {
  list-style: none;
  padding: 0 12px 12px;
  margin: 0;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
}

.log li { padding: 3px 0; color: var(--dim); }

.matrix-title { margin: 8px 12px 4px; }

.matrix {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 0 12px 14px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

nav.nav {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 1px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  min-width: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  background: var(--line);
  flex: 0 0 auto;
}

.nav-cell {
  display: flex;
  min-width: 0;
  min-height: 48px;
  overflow: hidden;
  background: var(--panel);
}

.nav-btn {
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 8px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 11px;
  letter-spacing: 0;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: -2px;
}

.nav-long, .nav-tiny { display: none; }

.nav-short { display: inline; }

@media (max-width: 520px) {
  .nav-btn:has(.nav-tiny) .nav-short { display: none; }
  .nav-btn:has(.nav-tiny) .nav-tiny { display: inline; }
}

@media (min-width: 1100px) {
  .nav-btn { font-size: 12px; }
  .nav-long { display: inline; }
  .nav-short, .nav-tiny { display: none; }
}

.body-felt {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dice-log {
  position: absolute;
  z-index: 4;
  left: 34%;
  width: 32%;
  top: 0;
  height: 10%;
  margin: 0;
  padding: 2px 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: pan-y;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.35;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.dice-log::-webkit-scrollbar { display: none; }

.dice-log.extended { height: 78%; }

.dice-log-line,
.dice-log-empty {
  margin: 0 0 0.35em;
}

.dice-log-line strong { color: var(--hazard); }

.dice-log-empty {
  color: var(--dim);
  font-weight: 600;
  text-shadow: none;
}

.felt {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  background:
    radial-gradient(120% 80% at 50% 40%, rgba(228, 242, 90, 0.06), transparent 62%),
    #12180e;
}

.felt-grid {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(7, minmax(0, 1fr));
  padding: 2px 0 4px;
}

/* One felt band per die row, lined up with the seven grid tracks.
   The inset on this layer matches the grid padding above.
   The band sits low in the tile: the die is packed to the bottom of the row, above its label. */
.felt-grid::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 2px 0 4px;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='64' viewBox='0 0 400 64'%3E%3Cdefs%3E%3ClinearGradient id='v' x1='0' y1='0' x2='1' y2='0'%3E%3Cstop offset='0' stop-color='%23000' stop-opacity='.42'/%3E%3Cstop offset='.1' stop-color='%23000' stop-opacity='0'/%3E%3Cstop offset='.9' stop-color='%23000' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%23000' stop-opacity='.42'/%3E%3C/linearGradient%3E%3ClinearGradient id='h' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23283816'/%3E%3Cstop offset='.5' stop-color='%2332461c'/%3E%3Cstop offset='1' stop-color='%231c2812'/%3E%3C/linearGradient%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85 .55' numOctaves='2' seed='4'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 .11 0 0 0 0 .15 0 0 0 0 .05 0 0 0 .22 0'/%3E%3C/filter%3E%3C/defs%3E%3Crect x='0' y='16' width='400' height='44' fill='url(%23h)'/%3E%3Crect x='0' y='16' width='400' height='44' filter='url(%23n)' opacity='.55'/%3E%3Cg stroke='%23b6ff62' stroke-opacity='.05' stroke-width='1'%3E%3Cline x1='0' y1='26' x2='400' y2='26'/%3E%3Cline x1='0' y1='38' x2='400' y2='38'/%3E%3Cline x1='0' y1='50' x2='400' y2='50'/%3E%3C/g%3E%3Cg stroke='%23e4f25a' stroke-opacity='.22' stroke-width='1'%3E%3Cline x1='11' y1='26' x2='11' y2='36'/%3E%3Cline x1='11' y1='44' x2='11' y2='54'/%3E%3Cline x1='389' y1='26' x2='389' y2='36'/%3E%3Cline x1='389' y1='44' x2='389' y2='54'/%3E%3C/g%3E%3Crect x='0' y='16' width='400' height='44' fill='url(%23v)'/%3E%3Cline x1='0' y1='16.5' x2='400' y2='16.5' stroke='%23e4f25a' stroke-opacity='.13'/%3E%3Cline x1='0' y1='59.5' x2='400' y2='59.5' stroke='%23000' stroke-opacity='.4'/%3E%3C/svg%3E");
  background-repeat: repeat-y;
  background-size: 100% calc(100% / 7);
  background-position: top center;
}

.die-ghost {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  min-height: 0;
  gap: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
}

.die-ghost[data-dir="right"] {
  align-items: flex-start;
  padding-left: 4px;
}

.die-ghost[data-dir="left"] {
  align-items: flex-end;
  padding-right: 4px;
}

.die-ghost svg {
  width: min(26%, 84px);
  height: auto;
  max-height: calc(100% - 16px);
  opacity: 0.42;
  pointer-events: none;
}

.die-ghost span {
  flex: 0 0 auto;
  font-size: 13px;
  letter-spacing: 0.04em;
  line-height: 1.1;
  pointer-events: none;
}

.die-ghost.trigger span { color: var(--hazard); font-weight: 700; }
.die-ghost.trigger svg { opacity: 0.92; }

.die-ghost:hover svg,
.die-ghost:focus-visible svg { opacity: 0.85; }

.die-ghost:focus-visible { outline: 2px solid var(--phosphor); outline-offset: -2px; }

.die-outline {
  fill: none;
  stroke: var(--hazard);
  stroke-width: 3;
  stroke-linejoin: round;
}

.die-inner {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.die-live {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.45));
}

.die-live.is-breaking {
  pointer-events: none;
  filter: none;
}

.die-live.is-breaking > svg,
.die-live.is-breaking > .die-face { visibility: hidden; }

.die-shard {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transform-origin: center center;
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.45));
}

.die-shard-face {
  z-index: 2;
  filter: none;
}

.die-shard-face .die-face {
  color: var(--hazard);
  text-shadow: 0 1px 0 #1a2208, 0 0 6px rgba(0, 0, 0, 0.7);
}

.die-live svg { width: 100%; height: 100%; display: block; }

.die-live .die-outline {
  fill: var(--hazard);
  stroke: var(--phosphor);
}

.die-live .die-inner { display: none; }

.die-face {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-weight: 700;
  color: var(--hazard-ink);
  pointer-events: none;
  line-height: 1;
}

.feed { padding: 4px 12px 16px; }

.feed-line {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  line-height: 1.4;
  min-width: 0;
  overflow-wrap: break-word;
}

.feed-line strong { color: var(--hazard); }

.feed-line .resultBody { display: block; }

.stream-hint { padding: 0 12px 6px; }

.error {
  margin: 16px;
  padding: 12px;
  border: 1px solid var(--rust);
  color: var(--amber);
}

#modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.modal-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--hazard);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-card h2 { margin: 0; font-size: 20px; }

.lock-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.lock-grid .chip {
  flex: 1 1 64px;
  max-width: 76px;
}

.modal-card > .chip,
.modal-card > .ghost { align-self: flex-start; }

.share-toggles {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
}

.share-toggles .chip {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  padding: 6px 10px;
}

.share-toggles [data-action="share-stream"] { flex-grow: 1.4; }

.modal-card textarea, .modal-card select { width: 100%; }

.roster { display: flex; flex-direction: column; gap: 6px; }

.roster-self { margin: 0; font-weight: 700; }

.roster-name { text-align: left; text-decoration: underline; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 12px;
  background: #10160c;
  border: 1px solid var(--amber);
  border-radius: 8px;
  z-index: 30;
  max-width: min(520px, calc(100% - 24px));
}

@media (max-width: 640px) {
  header.top { align-items: flex-start; }
  header.top h1 { font-size: 18px; }
  #shareStatus { display: none; }
}

#shareStatus[data-kind="on"] + #shareButton {
  background: var(--hazard);
  color: var(--hazard-ink);
  border-color: var(--hazard);
}
