:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #f59e0b;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans", sans-serif;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at top right, #1e3a8a 0%, transparent 30%),
    radial-gradient(circle at bottom left, #0f766e 0%, transparent 28%),
    var(--bg);
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

.layout-build {
  grid-template-columns: minmax(0, 1fr) clamp(280px, 28vw, 420px);
  max-width: 1700px;
}

.card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.03), transparent), var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

.title {
  margin: 0 0 0.75rem;
}

.inventory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.inventory-head .title {
  margin: 0;
}

.subtitle {
  margin: 0.25rem 0 1rem;
  color: var(--muted);
}


.stepper {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.stepper button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

.stepper button.active {
  border-color: var(--accent);
  color: #111827;
  background: linear-gradient(90deg, var(--accent), #fcd34d);
  font-weight: 600;
}

.stepper button.stepper-cog-btn {
  min-width: 2.2rem;
  padding-inline: 0.65rem;
  font-size: 1rem;
}

.file-input-hidden {
  display: none;
}

.import-export-toolbar {
  align-items: center;
}

.dndbeyond-import-guide {
  margin-top: 1rem;
  border: 1px solid rgba(245, 158, 11, 0.32);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.11), rgba(11, 18, 32, 0.92));
  overflow: hidden;
}

.dndbeyond-import-guide .title {
  margin-bottom: 0.35rem;
}

.dndbeyond-import-steps {
  margin: 0.7rem 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.5rem;
}

.dndbeyond-import-steps li {
  color: var(--text);
  line-height: 1.45;
}

.dndbeyond-import-prompt {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0.45rem 0 0;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(2, 6, 23, 0.88);
  color: #f8fafc;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.83rem;
}

.mode-toggle {
  margin-bottom: 0.9rem;
}

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

.edit-password-inline-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.edit-password-inline-row input {
  flex: 1 1 auto;
}

.edit-password-inline-row .btn {
  margin-top: 0.35rem;
  white-space: nowrap;
}

.ability-edit-grid {
  grid-template-columns: repeat(2, minmax(0, 240px));
  justify-content: start;
  gap: 0.65rem 1rem;
}

.ability-edit-field {
  width: 100%;
}

.ability-edit-field .num-input-wrap {
  max-width: 170px;
}

.ability-edit-field .num-input-wrap input {
  margin-top: 0;
}

label {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
}

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

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.35rem;
  background: #0b1220;
  color: var(--text);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  background: linear-gradient(90deg, #f59e0b, #facc15);
  color: #111827;
  font-weight: 700;
}

.btn.secondary {
  background: var(--panel-2);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

#long-rest.btn {
  border-color: rgba(245, 158, 11, 0.62);
  color: #fde68a;
  background: rgba(245, 158, 11, 0.2);
}

#long-rest.btn:hover {
  border-color: rgba(245, 158, 11, 0.75);
  background: rgba(245, 158, 11, 0.28);
}

.layout-onboarding {
  grid-template-columns: 1fr;
  max-width: 840px;
}

.onboarding-actions {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 1rem 0;
}

.onboarding-warning {
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: rgba(248, 113, 113, 0.08);
}

.title-with-history {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.8rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.app-brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  text-decoration: none;
}

.app-brand-logo {
  width: 2rem;
  height: 2rem;
  display: block;
}

.title-with-history .title {
  margin: 0;
  flex: 0 0 auto;
}

.character-history-control {
  display: grid;
  margin: 0;
  max-width: 420px;
}

.character-history-control-inline {
  width: min(420px, 52%);
  max-width: 100%;
  align-self: center;
  margin: 0;
  margin-left: auto;
}

.character-history-control-inline select {
  width: 100%;
  margin-top: 0;
}

.title-with-history .play-manual-menu,
.title-with-history .play-character-log-menu {
  margin-left: 0;
  align-self: center;
}

.title-with-history .play-manual-trigger,
.title-with-history .play-character-log-trigger {
  margin-top: 0;
}

.persistence-warning {
  margin: 0.35rem 0 0.9rem;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: rgba(251, 191, 36, 0.08);
}

.levelup-shell {
  display: grid;
  gap: 0.7rem;
}

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

.levelup-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.7rem;
  display: grid;
  gap: 0.55rem;
}

.levelup-card h4,
.levelup-card h5 {
  margin: 0;
}

.levelup-budget {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.35rem 0.5rem;
  font-size: 0.84rem;
}

.levelup-budget.is-invalid {
  border-color: rgba(248, 113, 113, 0.45);
}

.levelup-rows {
  display: grid;
  gap: 0.45rem;
}

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

.levelup-empty {
  margin: 0;
  font-size: 0.84rem;
}

.levelup-preview-block {
  display: grid;
  gap: 0.35rem;
}

.levelup-save-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.84rem;
}

.levelup-slot-list,
.levelup-contrib-list {
  display: grid;
  gap: 0.3rem;
}

.levelup-slot-change,
.levelup-contrib-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.84rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.25rem 0.45rem;
}

.levelup-contrib-row.is-total {
  font-weight: 700;
}

.levelup-hp-list {
  display: grid;
  gap: 0.45rem;
}

.levelup-hp-row {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.45rem 0.5rem;
  display: grid;
  gap: 0.45rem;
}

.levelup-hp-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.55rem;
}

.levelup-hp-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.levelup-hp-method {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
}

.levelup-hp-reroll {
  margin-top: 0;
  width: auto;
  padding-inline: 0.6rem;
}

.levelup-hp-gain {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.55rem;
  font-size: 0.82rem;
}

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

.core-stat-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.core-stat-name {
  text-align: left;
}

.core-stat-value {
  margin-left: auto;
  text-align: right;
}

.pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.82rem;
  line-height: 1.2;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: flex-start;
}

.pill-list .pill {
  display: inline-flex;
  align-items: center;
}

.pill-btn {
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.pill-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.inspiration-pill.is-active {
  border-color: rgba(245, 158, 11, 0.42);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.22), rgba(245, 158, 11, 0.08));
  color: #fef3c7;
}

button:is(
  [data-roll-initiative],
  [data-roll-death-save],
  [data-ability-roll],
  [data-save-roll-btn],
  [data-skill-roll-btn],
  [data-attack-roll],
  [data-auto-attack-roll],
  #reroll-last-roll,
  [data-levelup-hp-reroll]
) {
  border-color: rgba(56, 189, 248, 0.36);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.11), rgba(56, 189, 248, 0.04));
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.16);
}

button:is(
  [data-roll-initiative],
  [data-roll-death-save],
  [data-ability-roll],
  [data-save-roll-btn],
  [data-skill-roll-btn],
  [data-attack-roll],
  [data-auto-attack-roll],
  #reroll-last-roll,
  [data-levelup-hp-reroll]
):hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.16), rgba(56, 189, 248, 0.06));
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.24);
}

button:is(
  [data-roll-initiative],
  [data-roll-death-save],
  [data-ability-roll],
  [data-save-roll-btn],
  [data-skill-roll-btn],
  [data-attack-roll],
  [data-auto-attack-roll],
  #reroll-last-roll,
  [data-levelup-hp-reroll]
):focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.46);
  outline-offset: 1px;
}

.build-spell-pill-btn {
  margin: 0;
}

.build-spell-list {
  margin: 0.75rem 0 1rem;
  padding: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 0.55rem;
}

.build-spell-level-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  padding: 0.45rem 0.5rem 0.5rem;
}

.build-spell-level-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.build-spell-level-title {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(229, 231, 235, 0.9);
}

.build-spell-count {
  border-radius: 7px;
  padding: 0.1rem 0.4rem;
  font-size: 0.72rem;
}

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

.sticky {
  position: sticky;
  top: 0.8rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
}

.modal {
  width: min(900px, 95vw);
  max-height: 90vh;
  overflow: auto;
}

.modal.rest-modal {
  width: min(460px, 92vw);
}

#dice-overlay {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(38vw, 380px);
  height: 260px;
  display: none;
  z-index: 20;
}

body.play-mode #dice-overlay {
  display: block;
}

#dice-overlay.in-header {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  width: clamp(270px, 31.5vw, 420px);
  height: 210px;
}

#dice-tray {
  width: 100%;
  height: 210px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(circle at 18% 18%, rgba(34, 211, 238, 0.15), transparent 35%), #0b1220;
}

#dice-overlay[data-dice-style="ember"] #dice-tray {
  border-color: rgba(245, 158, 11, 0.55);
  background: radial-gradient(circle at 18% 18%, rgba(245, 158, 11, 0.25), transparent 35%), #120d05;
}

#dice-overlay[data-dice-style="arcane"] #dice-tray {
  border-color: rgba(34, 211, 238, 0.55);
  background: radial-gradient(circle at 18% 18%, rgba(34, 211, 238, 0.24), transparent 35%), #071219;
}

#dice-overlay[data-dice-style="forest"] #dice-tray {
  border-color: rgba(52, 211, 153, 0.55);
  background: radial-gradient(circle at 18% 18%, rgba(52, 211, 153, 0.24), transparent 35%), #06130f;
}

#dice-overlay[data-dice-style="ruby"] #dice-tray {
  border-color: rgba(239, 68, 68, 0.55);
  background: radial-gradient(circle at 18% 18%, rgba(239, 68, 68, 0.24), transparent 35%), #16080a;
}

#dice-tray canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#dice-overlay.in-header #dice-tray {
  height: 100%;
}

#dice-overlay.in-header #dice-result {
  display: none;
}

.dice-result {
  margin-top: 0.45rem;
  font-size: 0.82rem;
}

.dice-result.is-error {
  color: var(--danger);
}

.dice-result-total {
  display: inline-block;
  margin-left: 0.2rem;
  padding: 0.05rem 0.42rem;
  border-radius: 999px;
  font-weight: 800;
  color: #111827;
  background: linear-gradient(90deg, var(--accent), #fcd34d);
}

.dice-offscreen-panel {
  position: fixed;
  top: 0.85rem;
  right: 0.85rem;
  width: min(440px, calc(100vw - 1.7rem));
  padding: 0.65rem 0.75rem;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(11, 18, 32, 0.96);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.42);
  z-index: 45;
}

.dice-offscreen-panel-title {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.dice-offscreen-panel-message {
  font-size: 0.84rem;
  line-height: 1.28;
  color: var(--text);
}

.dice-offscreen-panel.is-error {
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(127, 29, 29, 0.9);
}

.dice-offscreen-panel.is-error .dice-offscreen-panel-message {
  color: #fecaca;
}

.long-press-roll-overlay {
  position: fixed;
  left: 50%;
  bottom: 1.3rem;
  transform: translate(-50%, 14px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  z-index: 55;
  min-width: 220px;
  padding: 0.55rem 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  background: rgba(8, 145, 178, 0.18);
  backdrop-filter: blur(3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  transition:
    opacity 120ms ease,
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.long-press-roll-overlay.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.long-press-roll-overlay.is-ready {
  pointer-events: auto;
  border-color: rgba(245, 158, 11, 0.65);
  background: rgba(245, 158, 11, 0.23);
}

.long-press-roll-overlay-hint {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-align: center;
}

.long-press-roll-overlay-actions {
  margin-top: 0.35rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.long-press-roll-overlay-btn {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 9px;
  background: rgba(11, 18, 32, 0.75);
  color: var(--text);
  padding: 0.3rem 0.45rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.long-press-roll-overlay-btn:hover {
  border-color: rgba(255, 255, 255, 0.42);
}

.option-list {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 0.5rem;
}

.slot-list {
  max-height: none;
  overflow: visible;
  padding: 0.35rem 0.45rem;
  border-color: rgba(255, 255, 255, 0.1);
}

.slot-list .option-row {
  gap: 0.75rem;
  padding: 0.3rem 0.1rem;
  align-items: flex-start;
}

.slot-list .option-row-actions {
  gap: 0.3rem;
  padding-top: 0.05rem;
}

.slot-list .btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.slot-list .auto-choice-shell {
  margin: 0.16rem 0 0.1rem;
  gap: 0.22rem;
}

.slot-list .auto-choice-card {
  padding: 0.28rem 0.4rem;
}

.slot-list .slot-row-main {
  min-width: 0;
  display: grid;
  gap: 0.14rem;
}

.slot-list .slot-row-head {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.slot-list .slot-row-head strong {
  font-size: 0.95rem;
  line-height: 1.2;
}

.slot-list .slot-row-head .muted {
  font-size: 0.8rem;
  line-height: 1.2;
}

.slot-list .auto-choice-label {
  font-size: 0.76rem;
}

.slot-list .auto-choice-selects.is-inline {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem 0.45rem;
}

.slot-list .auto-choice-select {
  gap: 0.12rem;
}

.slot-list .auto-choice-select .muted {
  font-size: 0.75rem;
}

.slot-list .auto-choice-select select {
  margin-top: 0;
  padding: 0.4rem 0.55rem;
  font-size: 0.84rem;
}

.slot-list .asi-inline-row {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: nowrap;
}

.slot-list .asi-inline-select {
  width: auto;
  min-width: 6.9rem;
  margin-top: 0;
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.14);
  padding: 0.45rem 0.2rem;
}

.option-row:last-child {
  border-bottom: 0;
}

.option-row-actions {
  display: inline-flex;
  gap: 0.4rem;
}

.auto-choice-shell {
  display: grid;
  gap: 0.45rem;
  margin: 0.15rem 0 0.4rem;
}

.auto-choice-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.45rem 0.55rem;
}

.auto-choice-card p {
  margin: 0 0 0.35rem;
}

.auto-choice-group {
  display: grid;
  gap: 0.32rem;
}

.auto-choice-label {
  margin: 0;
  font-size: 0.82rem;
}

.auto-choice-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
}

.auto-choice-option {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  color: var(--text);
  font-size: 0.86rem;
  white-space: nowrap;
}

.auto-choice-option-label {
  font-weight: 500;
}

.auto-choice-option-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.auto-choice-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.16);
  color: #dbeafe;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.14rem 0.38rem;
}

.auto-choice-option.is-disabled {
  opacity: 0.7;
}

.auto-choice-help {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
}

.auto-choice-option input[type="checkbox"] {
  margin: 0;
}

.auto-choice-selects {
  display: grid;
  gap: 0.4rem;
}

.auto-choice-select {
  display: grid;
  gap: 0.2rem;
}

.auto-choice-select select {
  width: 100%;
}

.ability-rules-note {
  margin: 0.45rem 0 0.25rem;
  font-size: 0.86rem;
}

.ability-rules-note.is-warning {
  color: #fecaca;
}

.inventory-list {
  display: grid;
  gap: 0.45rem;
}

.inventory-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.4rem 0.5rem;
}

.inventory-row-main {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex-wrap: wrap;
}

.inventory-item-name {
  font-size: 1rem;
  font-weight: 600;
}

.inventory-row-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.condition-panel {
  margin-top: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background:
    radial-gradient(circle at 10% 8%, rgba(245, 158, 11, 0.16), transparent 45%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  padding: 0.7rem;
  display: grid;
  gap: 0.6rem;
}

.condition-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.condition-count-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.79rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.15);
}

.condition-clear-btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

.condition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.45rem;
}

.condition-pill-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(155deg, rgba(15, 23, 42, 0.85), rgba(30, 41, 59, 0.7));
  color: var(--text);
  border-radius: 11px;
  padding: 0.42rem 0.58rem;
  min-height: 2.15rem;
  text-align: left;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  cursor: pointer;
  transition:
    border-color 130ms ease,
    transform 130ms ease,
    background 130ms ease,
    box-shadow 130ms ease;
}

.condition-pill-btn:hover {
  border-color: rgba(255, 255, 255, 0.42);
  transform: translateY(-1px);
}

.condition-pill-btn:focus-visible {
  outline: 2px solid rgba(103, 232, 249, 0.5);
  outline-offset: 2px;
}

.condition-pill-btn.is-active {
  border-color: rgba(52, 211, 153, 0.6);
  background: linear-gradient(155deg, rgba(16, 185, 129, 0.28), rgba(5, 46, 22, 0.85));
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.26);
}

.condition-pill-label {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.25;
}

.condition-extra-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.condition-extra-chip {
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 999px;
  background: rgba(248, 113, 113, 0.14);
  color: #fecaca;
  padding: 0.18rem 0.5rem;
  font-size: 0.77rem;
  cursor: pointer;
}

.condition-extra-chip:hover {
  border-color: rgba(248, 113, 113, 0.72);
}

.spell-picker-name-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0;
  cursor: pointer;
  font-weight: 700;
}

.spell-picker-name-btn:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

.class-info-btn {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font: inherit;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.class-info-btn:hover {
  color: #67e8f9;
}

.class-feature-list {
  margin: 0.5rem 0 0;
  padding: 0 0 0 1.1rem;
  display: grid;
  gap: 0.35rem;
}

.class-feature-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.feature-row {
  align-items: center;
}

.feature-row-feat {
  display: grid;
  grid-template-columns: 1fr;
  margin: 0.35rem 0 0;
}

.feature-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  min-width: 0;
}

.feature-name-btn {
  justify-self: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feature-name-pill {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feature-row-table-effect .feature-main {
  align-items: center;
}

.feature-mode-selected-pills {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.class-table-effect-roll-btn {
  border-color: rgba(245, 158, 11, 0.58);
  background: rgba(245, 158, 11, 0.17);
  color: #fde68a;
}

.class-table-effect-roll-btn:hover {
  border-color: rgba(245, 158, 11, 0.74);
  background: rgba(245, 158, 11, 0.25);
}

.feat-tile-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.72));
  border-radius: 0.85rem;
  padding: 0.65rem 0.75rem;
  width: 100%;
  text-align: left;
  color: var(--text);
  display: grid;
  gap: 0.28rem;
  cursor: pointer;
}

.feat-tile-btn:hover {
  border-color: rgba(103, 232, 249, 0.45);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.82));
}

.feat-tile-btn:focus-visible {
  outline: 2px solid rgba(103, 232, 249, 0.55);
  outline-offset: 2px;
}

.feat-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.feat-tile-title {
  font-size: 0.98rem;
  line-height: 1.3;
}

.feat-tile-meta {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.feat-tile-summary {
  color: rgba(229, 231, 235, 0.95);
  font-size: 0.84rem;
  line-height: 1.35;
}

.feature-mode-heading {
  margin: 0.8rem 0 0.35rem;
  font-size: 0.88rem;
  color: rgba(229, 231, 235, 0.9);
}

.feature-mode-tile {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.72));
  border-radius: 0.85rem;
  padding: 0.65rem 0.75rem;
  width: 100%;
  color: var(--text);
  display: grid;
  gap: 0.28rem;
}

.feature-mode-option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.feature-mode-option-btn {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0.24rem 0.58rem;
  font-size: 0.77rem;
}

.feature-mode-option-btn:hover {
  border-color: rgba(103, 232, 249, 0.45);
  background: rgba(103, 232, 249, 0.1);
}

.feature-mode-option-btn.is-active {
  border-color: rgba(103, 232, 249, 0.62);
  background: rgba(103, 232, 249, 0.2);
  color: #cffafe;
}

.feature-use-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  justify-self: end;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.class-feature-level {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  min-width: 3.7rem;
}

.layout-play {
  grid-template-columns: 1fr;
}

.play-header {
  display: grid;
  gap: 0.75rem;
}

.play-header-lower {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(270px, 31.5vw, 420px);
  gap: 1rem;
  align-items: start;
}

.play-header-main {
  min-width: 0;
  flex: 1 1 auto;
}

.play-header-dice-slot {
  width: 100%;
}

.play-manual-menu {
  position: relative;
  flex: 0 0 auto;
  outline: none;
}

.play-character-log-menu {
  position: relative;
  flex: 0 0 auto;
  outline: none;
}

.play-manual-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  white-space: nowrap;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.play-character-log-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  width: 2.2rem;
  min-width: 2.2rem;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

.play-manual-trigger::-webkit-details-marker {
  display: none;
}

.play-manual-trigger::marker {
  content: "";
}

.play-character-log-trigger::-webkit-details-marker {
  display: none;
}

.play-character-log-trigger::marker {
  content: "";
}

.play-manual-menu:focus,
.play-manual-menu:focus-visible,
.play-manual-menu:focus-within {
  outline: none;
}

.play-character-log-menu:focus,
.play-character-log-menu:focus-visible,
.play-character-log-menu:focus-within {
  outline: none;
}

.play-manual-trigger:focus,
.play-manual-trigger:active {
  outline: none;
  box-shadow: none;
}

.play-character-log-trigger:focus,
.play-character-log-trigger:active {
  outline: none;
  box-shadow: none;
}

.play-manual-trigger:focus-visible {
  outline: none;
  box-shadow: none;
}

.play-character-log-trigger:focus-visible {
  outline: none;
  box-shadow: none;
}

.play-manual-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.play-character-log-icon {
  font-size: 1rem;
  line-height: 1;
}

.play-manual-links {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 250px;
  display: none;
  z-index: 35;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(11, 18, 32, 0.98);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.34);
  overflow: hidden;
}

.play-manual-menu[open] .play-manual-links {
  display: block;
}

.play-manual-links a {
  display: grid;
  gap: 0.08rem;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.86rem;
}

.play-manual-link-label {
  color: var(--text);
}

.play-manual-link-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.play-manual-empty {
  display: block;
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
}

.play-manual-links a:last-child {
  border-bottom: 0;
}

.play-manual-links a:hover {
  background: rgba(99, 102, 241, 0.16);
}

.play-character-log-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  width: min(560px, 94vw);
  min-width: 290px;
  max-height: 460px;
  display: none;
  overflow: hidden;
  z-index: 35;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(8, 14, 26, 0.98);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45);
}

.play-character-log-menu[open] .play-character-log-panel {
  display: block;
}

.character-log-panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.68rem 0.78rem 0.62rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(17, 27, 44, 0.97) 0%, rgba(10, 16, 28, 0.97) 100%);
}

.character-log-panel-head strong {
  display: block;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.character-log-panel-head p {
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.character-log-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.24);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
}

.character-log-list {
  display: grid;
  gap: 0.5rem;
  max-height: 390px;
  padding: 0.58rem;
  overflow: auto;
}

.character-log-entry {
  display: grid;
  gap: 0.4rem;
  padding: 0.62rem 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-left-width: 3px;
  border-radius: 10px;
  background: rgba(14, 22, 37, 0.78);
}

.character-log-entry-tone-character {
  border-left-color: rgba(56, 189, 248, 0.72);
}

.character-log-entry-tone-play {
  border-left-color: rgba(34, 197, 94, 0.72);
}

.character-log-entry-tone-dice {
  border-left-color: rgba(250, 204, 21, 0.75);
}

.character-log-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.character-log-section {
  color: rgba(226, 232, 240, 0.92);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
}

.character-log-time {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.character-log-summary {
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.35;
}

.character-log-part {
  color: inherit;
}

.character-log-part-bold {
  font-weight: 700;
}

.character-log-part-highlight {
  font-weight: 700;
  background: rgba(250, 204, 21, 0.2);
  border-radius: 5px;
  padding: 0.03rem 0.26rem;
}

.character-log-details {
  display: grid;
  gap: 0.26rem;
  margin-top: 0.12rem;
}

.character-log-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.42fr) 1fr;
  gap: 0.48rem;
  font-size: 0.75rem;
  line-height: 1.3;
}

.character-log-row-key {
  color: var(--muted);
  text-transform: capitalize;
}

.character-log-row-value {
  color: rgba(233, 241, 255, 0.95);
  display: inline-flex;
  align-items: baseline;
  gap: 0.38rem;
  min-width: 0;
  flex-wrap: wrap;
}

.character-log-before,
.character-log-after {
  padding: 0.08rem 0.34rem;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.25;
  word-break: break-word;
}

.character-log-before {
  background: rgba(148, 163, 184, 0.2);
}

.character-log-after {
  background: rgba(99, 102, 241, 0.26);
}

.character-log-arrow {
  color: var(--muted);
}

.character-log-empty {
  display: block;
  color: var(--muted);
  padding: 0.75rem;
  font-size: 0.82rem;
  text-align: center;
}

.play-sheet-shell {
  display: grid;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.play-sheet-dice-card {
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.play-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.play-sheet-head-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.75rem;
  position: relative;
}

#dice-result-inline {
  margin-top: 0;
  text-align: left;
  white-space: nowrap;
  font-size: clamp(1.15rem, 1.8vw, 1.7rem);
  font-weight: 700;
  line-height: 1.2;
  cursor: default;
}

.dice-result-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  outline: none;
}

.dice-history-popover {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(560px, 72vw);
  max-height: 230px;
  overflow: auto;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(11, 18, 32, 0.97);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 25;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.dice-result-wrap:hover .dice-history-popover,
.dice-result-wrap:focus-within .dice-history-popover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dice-history-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.dice-history-list {
  display: grid;
  gap: 0.35rem;
}

.dice-history-entry {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem;
  align-items: baseline;
  font-size: 0.82rem;
  line-height: 1.25;
}

.dice-history-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dice-history-message {
  color: var(--text);
}

.dice-history-entry.is-error .dice-history-message {
  color: var(--danger);
}

.dice-history-empty {
  font-size: 0.82rem;
}

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

.play-list {
  display: grid;
  gap: 0.45rem;
}

.spell-slot-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.spell-slot-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.5rem 0.6rem;
  display: grid;
  gap: 0.3rem;
}

.spell-slot-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 2.2rem;
}

.spell-slot-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2rem;
}

.spell-slot-level {
  font-weight: 600;
  line-height: 1.2;
}

.spell-slot-used {
  display: inline-flex;
  align-items: center;
  color: rgba(229, 231, 235, 0.9);
  font-size: 0.87rem;
  line-height: 1.2;
  white-space: nowrap;
}

.spell-slot-used strong {
  display: inline-block;
  min-width: 2.9rem;
  text-align: right;
}

.spell-slot-controls {
  display: grid;
  grid-template-columns: minmax(84px, 120px) auto;
  gap: 0.5rem;
  align-items: end;
}

.spell-slot-max {
  margin: 0;
  display: grid;
  gap: 0.22rem;
  font-size: 0.83rem;
}

.spell-slot-max input {
  margin-top: 0;
  padding: 0.38rem 0.5rem;
}

.spell-slot-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  min-width: 0;
  flex-shrink: 0;
}

.spell-slot-actions .muted {
  white-space: nowrap;
}

.spell-slot-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 9px;
  padding: 0;
  line-height: 1;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.spell-slot-btn-reset {
  width: auto;
  min-width: 4.7rem;
  padding: 0 0.62rem;
  font-size: 0.82rem;
  line-height: 1.1;
  font-weight: 600;
}

.spell-slot-btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.spell-prep-help {
  margin: 0.45rem 0 0.65rem;
  font-size: 0.82rem;
}

.spell-visibility-toggle {
  display: inline-flex;
  gap: 0.18rem;
  padding: 0.18rem;
  margin: 0.35rem 0 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.03);
}

.spell-visibility-btn {
  border: 1px solid transparent;
  background: transparent;
  color: rgba(229, 231, 235, 0.84);
  border-radius: 999px;
  padding: 0.24rem 0.72rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.spell-visibility-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.25);
}

.spell-visibility-btn.is-active {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.55);
  color: #d1fae5;
}

.spell-cast-status {
  margin: 0 0 0.65rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.84rem;
}

.spell-cast-status.is-error {
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--danger);
  background: rgba(248, 113, 113, 0.08);
}

.spell-level-groups {
  display: grid;
  gap: 0.65rem;
}

.spell-level-group {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.45rem 0.55rem 0.55rem;
  background: rgba(255, 255, 255, 0.02);
}

.spell-level-title {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(229, 231, 235, 0.86);
}

.spell-level-list {
  display: grid;
  gap: 0.38rem;
}

.spell-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0.45rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.35rem 0.5rem;
}

.spell-row.is-prepared {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.12);
}

.spell-row.is-prepared-available {
  border-color: rgba(52, 211, 153, 0.38);
  background: rgba(52, 211, 153, 0.11);
}

.spell-row.is-prepared-unavailable {
  border-color: rgba(248, 113, 113, 0.38);
  background: rgba(248, 113, 113, 0.11);
}

.spell-row.is-unprepared {
  border-color: rgba(156, 163, 175, 0.22);
  background: rgba(156, 163, 175, 0.09);
}

.spell-prep-btn {
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.spell-prep-btn:hover {
  border-color: rgba(255, 255, 255, 0.55);
}

.spell-prep-btn.is-active {
  border-color: var(--accent);
  color: #111827;
  background: var(--accent);
}

.spell-prep-btn {
  grid-column: 1;
  grid-row: 1;
}

.spell-prep-static {
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(229, 231, 235, 0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0;
  grid-column: 1;
  grid-row: 1;
}

.spell-name-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0;
  cursor: pointer;
  font-weight: 600;
  grid-column: 2;
  grid-row: 1;
}

.spell-name-btn:hover {
  text-decoration: underline;
}

.spell-known-tag {
  font-size: 0.78rem;
  text-align: right;
  grid-column: 3;
  grid-row: 1;
}

.spell-meta {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.77rem;
}

.spell-action-group {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  align-self: end;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.spell-ritual-pill {
  min-width: 1.3rem;
  height: 1.3rem;
  border-radius: 6px;
  border: 1px solid rgba(192, 132, 252, 0.6);
  background: rgba(168, 85, 247, 0.2);
  color: rgba(233, 213, 255, 0.98);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.spell-cast-btn {
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
}

.spell-meta-grid {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
}

.spell-detail-help {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
}

.spell-description {
  display: grid;
  gap: 0.45rem;
  line-height: 1.45;
  font-size: 0.92rem;
}

.spell-description p {
  margin: 0;
}

.inline-dice-btn {
  border: 1px solid rgba(245, 158, 11, 0.65);
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  border-radius: 8px;
  padding: 0.04rem 0.36rem;
  font-size: 0.8rem;
  line-height: 1.2;
  cursor: pointer;
}

.inline-dice-btn:hover {
  background: rgba(245, 158, 11, 0.28);
}

.ability-save-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 0.75rem;
}

.play-trait-shell {
  margin-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 0.65rem;
  display: grid;
  gap: 0.6rem;
}

.play-trait-group h4 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(229, 231, 235, 0.82);
}

.play-trait-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.play-trait-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 0.24rem 0.5rem;
  font-size: 0.79rem;
  line-height: 1;
  white-space: nowrap;
}

.play-trait-chip-meta {
  display: inline-flex;
  align-items: center;
  color: rgba(229, 231, 235, 0.62);
  font-size: 0.74rem;
  line-height: 1;
  white-space: nowrap;
}

.play-trait-empty {
  margin: 0;
  font-size: 0.82rem;
}

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

.ability-save-row {
  display: grid;
  grid-template-columns: minmax(120px, auto) auto auto;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
}

.save-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(229, 231, 235, 0.92);
  min-width: 100px;
  padding: 0.2rem 0.1rem;
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
}

.save-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.save-prof-btn {
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.save-prof-btn:hover {
  border-color: rgba(255, 255, 255, 0.55);
}

.save-prof-btn.is-active {
  border-color: rgba(245, 158, 11, 0.62);
  color: #fde68a;
  background: rgba(245, 158, 11, 0.2);
}

.save-prof-btn.is-auto {
  border-color: rgba(56, 189, 248, 0.7);
  color: #e0f2fe;
  background: rgba(56, 189, 248, 0.2);
}

.save-prof-btn.is-over-limit {
  border-color: rgba(248, 113, 113, 0.72);
  color: #fecaca;
  background: rgba(248, 113, 113, 0.2);
}

.save-prof-btn.is-readonly {
  cursor: default;
  pointer-events: none;
}

.save-mod-btn {
  min-width: 3.2ch;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 0.2rem 0.45rem;
  text-align: right;
  font-weight: 700;
  cursor: pointer;
}

.save-mod-btn:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.save-mod-btn.is-active {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.12);
}


.skill-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 0.75rem;
  row-gap: 0.55rem;
}

.skill-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.skill-roll-btn {
  min-width: 3.2ch;
  text-align: right;
}

.skill-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  cursor: default;
  text-align: left;
}

.skill-btn.is-active {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.12);
}

.skill-btn.is-auto {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.08);
}

.skill-btn.is-over-limit {
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.1);
}

.skill-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.skill-prof-btn {
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.25rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.skill-prof-btn.is-half {
  min-width: 2rem;
}

.skill-prof-btn:hover {
  border-color: rgba(255, 255, 255, 0.55);
}

.skill-prof-btn.is-active {
  border-color: var(--accent);
  color: #111827;
  background: var(--accent);
}

.skill-prof-btn.is-auto {
  border-color: rgba(56, 189, 248, 0.7);
  color: #e0f2fe;
  background: rgba(56, 189, 248, 0.2);
}

.skill-prof-btn.is-over-limit {
  border-color: rgba(248, 113, 113, 0.72);
  color: #fecaca;
  background: rgba(248, 113, 113, 0.2);
}

.skill-prof-btn.is-readonly {
  cursor: default;
  pointer-events: none;
}

.ability-save-row.is-over-limit .save-name {
  color: #fecaca;
}

.ability-save-row.is-over-limit .pill {
  border-color: rgba(248, 113, 113, 0.38);
}

.proficiency-limit-warning {
  margin: 0.4rem 0 0.6rem;
  color: #fecaca;
  font-size: 0.86rem;
}

.skill-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-mod {
  min-width: 3ch;
  text-align: right;
  flex-shrink: 0;
}

.skill-btn .muted {
  color: var(--text);
  opacity: 0.7;
}

.play-inline-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.inline-field {
  min-width: 110px;
}

.hp-control {
  min-width: 0;
  width: min(180px, 100%);
}

.hp-meta {
  font-size: 0.78rem;
  margin-left: 0.25rem;
}

.inline-field input {
  margin-top: 0.2rem;
}

.num-input-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.2rem;
}

.num-input-wrap input {
  margin-top: 0;
}

.num-stepper {
  display: grid;
  gap: 0.2rem;
}

.num-step-btn {
  width: 1.55rem;
  height: 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.num-step-btn:hover {
  border-color: rgba(255, 255, 255, 0.38);
}

.num-input-wrap-inline {
  position: relative;
  grid-template-columns: 1fr;
}

.num-input-wrap-inline input {
  padding-right: 3.8rem;
}

.num-stepper-inline {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  gap: 0.25rem;
}

.num-stepper-inline .num-step-btn {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 8px;
}

.hp-quick-row {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.hp-quick-btn {
  padding: 0.28rem 0.48rem;
  border-radius: 8px;
  font-size: 0.82rem;
  min-width: 2.1rem;
  line-height: 1.1;
}

.hp-pair-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
}

.hp-pair-row .hp-control:first-child {
  justify-self: start;
}

.hp-control-right {
  justify-self: start;
}

.hp-control-right .num-input-wrap,
.hp-control-right .hp-quick-row {
  justify-content: flex-start;
}

.death-save-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: end;
}

.death-save-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding-bottom: 0.1rem;
  justify-self: start;
}

.death-save-meters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: end;
  min-width: 0;
}

.death-save-label {
  white-space: nowrap;
}

.death-save-roll-btn {
  margin: 0;
}

.dice-style-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: nowrap;
}

.dice-style-row select {
  margin-top: 0;
  min-width: 180px;
}

.custom-roll-open-btn {
  min-width: 5.25rem;
}

.custom-roll-shell {
  display: grid;
  gap: 0.75rem;
}

.custom-roll-subtitle {
  margin: 0;
}

.custom-roll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 0.55rem;
}

.custom-roll-die-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: linear-gradient(165deg, rgba(34, 211, 238, 0.15), rgba(31, 41, 55, 0.82));
  color: var(--text);
  padding: 0.55rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease, background 120ms ease;
}

.custom-roll-die-btn:hover {
  border-color: rgba(34, 211, 238, 0.65);
  background: linear-gradient(165deg, rgba(34, 211, 238, 0.3), rgba(31, 41, 55, 0.88));
  transform: translateY(-1px);
}

.custom-roll-die-label {
  letter-spacing: 0.01em;
}

.custom-roll-die-count {
  min-width: 1.5rem;
  text-align: center;
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
  background: rgba(11, 18, 32, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.78rem;
}

.custom-roll-selected {
  min-height: 2.05rem;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  padding: 0.42rem 0.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.custom-roll-selected.is-populated {
  border-style: solid;
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.07);
}

.custom-roll-selected-label {
  font-size: 0.82rem;
  margin-right: 0.1rem;
}

.custom-roll-chip {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: var(--text);
  padding: 0.16rem 0.55rem;
  cursor: pointer;
}

.custom-roll-chip:hover {
  border-color: rgba(248, 113, 113, 0.7);
  color: #fecaca;
}

.custom-roll-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.55rem;
}

.custom-roll-actions .btn {
  margin-top: 0;
}

.short-rest-shell {
  display: grid;
  gap: 0.7rem;
}

.short-rest-copy {
  margin: 0;
}

.short-rest-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: rgba(255, 255, 255, 0.03);
}

.short-rest-help {
  margin: 0;
  font-size: 0.82rem;
}

.short-rest-hitdice-list {
  display: grid;
  gap: 0.45rem;
}

.short-rest-hitdie-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: rgba(255, 255, 255, 0.02);
}

.short-rest-hitdie-row input {
  width: 58px;
  margin-top: 0;
  text-align: center;
  padding: 0.35rem 0.4rem;
}

.short-rest-hitdie-meta {
  display: grid;
  gap: 0.15rem;
}

.short-rest-hitdie-meta .muted {
  font-size: 0.8rem;
}

.short-rest-hitdie-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.short-rest-adjust-btn {
  width: 2rem;
  min-width: 2rem;
  padding: 0.35rem 0;
  font-size: 1rem;
  line-height: 1;
  margin: 0;
}

.play-grid-4 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.45rem;
}

.play-grid-4 input {
  margin-top: 0;
}

.attack-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.5rem;
  display: grid;
  gap: 0.45rem;
}

.attack-card-view {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
}

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

.attack-row-top input {
  margin-top: 0;
}

.attack-row-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.attack-row-stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
}

.attack-row-stats input {
  margin-top: 0;
}

.attack-row-stats-view {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.attack-help {
  margin: 0;
  font-size: 0.8rem;
}

.attack-mode-toolbar {
  margin: 0 0 0.55rem;
}

.attack-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.attack-title-row .title {
  margin: 0;
}

.attack-title-heading {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
}

.attack-action-indicator {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(245, 158, 11, 0.42);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.22), rgba(245, 158, 11, 0.08));
  color: #fef3c7;
  border-radius: 999px;
  padding: 0.08rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.attack-mode-btn {
  width: auto;
  padding-inline: 0.75rem;
}

.attack-title {
  font-size: 0.96rem;
}

.attack-title-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.attack-prof-pill {
  min-width: 1.3rem;
  height: 1.3rem;
  border-radius: 6px;
  border: 1px solid rgba(245, 158, 11, 0.62);
  color: #fde68a;
  background: rgba(245, 158, 11, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.attack-pill {
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  width: 100%;
  text-align: left;
}

.attack-pill.pill-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.attack-pill.pill-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.play-notes-textarea {
  min-height: 5.6rem;
  resize: vertical;
}

@media (max-width: 960px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .play-sheet-head,
  .dice-result-wrap {
    min-width: 0;
  }

  #dice-result-inline {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .layout {
    grid-template-columns: 1fr;
    max-width: 100%;
    padding: 0;
  }

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

  .levelup-grid {
    grid-template-columns: 1fr;
  }

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

  .play-grid {
    grid-template-columns: 1fr;
  }

  .title-with-history {
    align-items: center;
    gap: 0.55rem;
  }

  .character-history-control-inline {
    width: min(58vw, 380px);
    min-width: 0;
  }

  .play-header-dice-slot {
    width: 100%;
  }

  .play-header-lower {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .play-manual-links {
    width: min(92vw, 340px);
    min-width: 0;
  }

  .play-sheet-head {
    align-items: center;
  }

  .play-sheet-head-right {
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  #dice-result-inline {
    text-align: left;
    white-space: normal;
  }

  .dice-result-wrap {
    align-items: flex-start;
  }

  .dice-history-popover {
    right: auto;
    left: 0;
    width: min(92vw, 560px);
  }

  .dice-style-row {
    justify-content: flex-end;
    flex-wrap: wrap;
    min-width: 0;
  }

  .dice-style-row select {
    min-width: 0;
    width: auto;
    max-width: 100%;
    flex: 1 1 9rem;
  }

  .play-grid-4 {
    grid-template-columns: 1fr;
  }

  .attack-row-top {
    grid-template-columns: 1fr;
  }

  .attack-row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .attack-row-stats {
    grid-template-columns: 1fr;
  }

  .attack-row-stats-view {
    grid-template-columns: 1fr;
  }

  .attack-card > *,
  .attack-row-top > *,
  .attack-row-actions > *,
  .attack-row-stats > * {
    min-width: 0;
  }

  .ability-save-row,
  .save-label,
  .skill-row,
  .skill-btn,
  .skill-left,
  .attack-card,
  .attack-row-top,
  .attack-row-stats,
  .attack-row-stats-view {
    min-width: 0;
  }

  .save-label {
    white-space: normal;
  }

  .skill-name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }

  .attack-title-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .attack-title-heading {
    min-width: 0;
    flex-wrap: wrap;
  }

  .attack-pill {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .hp-pair-row {
    grid-template-columns: 1fr;
  }

  .core-stats-card .summary-grid {
    grid-template-columns: 1fr;
  }

  .hp-control-right {
    justify-self: start;
  }

  .hp-control-right .num-input-wrap,
  .hp-control-right .hp-quick-row {
    justify-content: flex-start;
  }

  .core-stats-card .death-save-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    align-items: end;
  }

  .core-stats-card .death-save-meters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .core-stats-card .death-save-row .inline-field,
  .core-stats-card .death-save-meters .inline-field {
    min-width: 0;
  }

  .core-stats-card .pill {
    font-size: 0.88rem;
  }

  .core-stats-card .inline-field {
    font-size: 0.98rem;
  }

  .core-stats-card .hp-meta {
    font-size: 0.82rem;
  }

  .core-stats-card .hp-quick-btn {
    font-size: 0.86rem;
  }

  .core-stats-card .num-step-btn {
    font-size: 0.82rem;
  }

  .skill-grid {
    grid-template-columns: 1fr;
  }

  .ability-save-grid {
    grid-template-columns: 1fr;
  }

  .feature-row-feat .feature-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    min-width: 0;
  }

  .feature-row-feat .feat-tile-btn {
    min-width: 0;
  }

  .feature-row-feat .feature-use-controls {
    justify-self: end;
    flex-wrap: wrap;
    min-width: 0;
  }

  .feat-tile-head {
    min-width: 0;
    flex-wrap: wrap;
  }

  .feat-tile-title,
  .feat-tile-meta,
  .feat-tile-summary {
    overflow-wrap: anywhere;
  }

  .spell-slot-grid {
    grid-template-columns: 1fr;
  }

  #dice-overlay {
    left: 1rem;
    right: 1rem;
    width: auto;
    height: 220px;
  }

  #dice-overlay.in-header {
    left: auto;
    right: auto;
    width: 100%;
    height: 130px;
  }

  #dice-tray {
    height: 176px;
  }

  #dice-overlay.in-header #dice-tray {
    height: 100%;
  }
}

@media (max-width: 640px) {
  .play-sheet-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .dice-result-wrap {
    width: 100%;
  }

  .dice-style-row {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .title-with-history {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  .title-with-history .title {
    flex: 0 0 100%;
  }

  .character-history-control-inline {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    margin-left: 0;
  }

  .title-with-history .play-manual-menu {
    margin-left: auto;
  }

  .feature-row-feat .feature-main {
    grid-template-columns: 1fr;
  }

  .feature-row-feat .feature-use-controls {
    justify-self: start;
  }
}
