/* This file is for your main application CSS */

/* Character sheet: computed stats and option pickers (creation form and character page) */
.computed-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0 0.5em;
}
.computed-field-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.computed-field-formula {
  grid-column: 1 / -1;
  opacity: 0.7;
}
.option-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}
.option-picker-items {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}
.option-picker-scroll {
  max-height: 28em;
  overflow-y: auto;
  padding-right: 0.5em;
}
.option-picker-item {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
}
.option-picker-item input {
  flex-shrink: 0;
}
.option-picker-item select {
  width: 4em;
  flex-shrink: 0;
}
.option-picker-summary {
  display: block;
  opacity: 0.7;
}

/* Tag skill checkbox beside a skill's label, as on the printed sheet */
.tag-skill {
  flex-shrink: 0;
  margin: 0 0.35em 0 0;
  vertical-align: middle;
  cursor: pointer;
}
.cap-warning {
  display: block;
  font-size: 0.85em;
  color: var(--warning);
}
.cap-warning:empty {
  display: none;
}

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

/* ── Fallout character sheet (RPJesusWeb.FalloutSheet) ────────────────────────
   Modeled on the official sheet: a paper page, slanted colored banners, black
   table headers and gear-shaped number boxes. */
.fallout-sheet {
  --paper: #eeece8;
  --ink: #1f1d1b;
  --ink-soft: #5b5650;
  --rule: #b9b4ad;
  --peach: #f7dcc4;
  --peach-light: #fbeadb;
  --panel: #dcdad6;
  --str: #7f9f88;
  --per: #8a7856;
  --end: #43b1c6;
  --cha: #e38b4a;
  --int: #b3ad90;
  --agi: #e7a08f;
  --lck: #a9a4c6;
  --skills: #e8955a;
  --combat: #8fb39b;
  --weapons: #b3ad90;
  --caps: #e7a08f;
  --perks: #47b6c9;
  --gear-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='91.0,50.0 97.9,53.8 96.4,62.4 88.6,63.7 85.5,70.5 89.6,77.2 83.9,83.9 76.6,81.2 70.5,85.5 70.7,93.3 62.4,96.4 57.5,90.3 50.0,91.0 46.2,97.9 37.6,96.4 36.3,88.6 29.5,85.5 22.8,89.6 16.1,83.9 18.8,76.6 14.5,70.5 6.7,70.7 3.6,62.4 9.7,57.5 9.0,50.0 2.1,46.2 3.6,37.6 11.4,36.3 14.5,29.5 10.4,22.8 16.1,16.1 23.4,18.8 29.5,14.5 29.3,6.7 37.6,3.6 42.5,9.7 50.0,9.0 53.8,2.1 62.4,3.6 63.7,11.4 70.5,14.5 77.2,10.4 83.9,16.1 81.2,23.4 85.5,29.5 93.3,29.3 96.4,37.6 90.3,42.5' fill='%23ffffff' stroke='%231f1d1b' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E");
  color: var(--ink);
  margin-top: 1em;
}
.fallout-sheet .sheet-panel {
  background: var(--paper);
  border-radius: 0 0.4em 0.4em 0.4em;
  padding: 1.25em;
  /* Oat fades tab panels in; switching sheet tabs should be instant. */
  animation: none;
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}
.fallout-sheet input,
.fallout-sheet select,
.fallout-sheet textarea {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 0.2em;
}
.fallout-sheet a,
.fallout-sheet button {
  color: var(--ink);
}
.fallout-sheet .field-value:hover,
.fallout-sheet .field-value:focus-visible {
  background: #fff;
  outline: 1px solid var(--ink);
}
.fallout-sheet .error,
.fallout-sheet .field-error {
  color: #a3271f;
}
/* In-place inputs and their floating notes, in the sheet's ink (see
   character_live.html.heex for the shared rules). */
.fallout-sheet {
  --sheet-focus: var(--ink);
  --sheet-danger: #a3271f;
  --sheet-note: #fff;
}
.fallout-sheet .field-saving {
  color: var(--ink-soft);
}
.fallout-sheet .sheet-header-fields .character-field,
.fallout-sheet .sheet-labeled-value .character-field {
  padding: 0.1em 0;
}
.fallout-sheet .sheet-health .sheet-labeled-value {
  min-width: 3em;
  text-align: right;
}
.fallout-sheet .sheet-rank-cell .inline-input {
  width: 3em !important;
}
.fallout-sheet .sheet-name-value .character-field h1 {
  margin: 0.15em 0 0;
}
.fallout-sheet .sheet-more-value textarea.inline-input {
  min-height: 3.5em;
}
.fallout-sheet .field-saved {
  color: #2f6b2a;
}
.fallout-sheet .field-warning,
.fallout-sheet .cap-warning {
  color: #8a5a00;
}

/* Tabs: radio buttons, so they work without JavaScript */
.sheet-tabs {
  display: flex;
  gap: 0.25em;
}
.sheet-tab-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.sheet-tab {
  padding: 0.5em 1.5em;
  background: var(--panel);
  color: var(--ink-soft);
  border-radius: 0.4em 0.4em 0 0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.sheet-tab-radio:checked + .sheet-tab {
  background: var(--paper);
  color: var(--ink);
}
.sheet-tab-radio:focus-visible + .sheet-tab {
  outline: 2px solid var(--end);
}
.sheet-tab-error {
  color: #a3271f;
}
.fallout-sheet .sheet-panel-gear,
.fallout-sheet:has(.sheet-tab-radio-gear:checked) .sheet-panel-attributes {
  display: none;
}
.fallout-sheet:has(.sheet-tab-radio-gear:checked) .sheet-panel-gear {
  display: flex;
}

/* Banners and label bars */
.fallout-sheet .sheet-banner {
  display: inline-block;
  margin: 0 0 0.5em;
  padding: 0.15em 2.5em 0.15em 0.6em;
  background: var(--banner, var(--weapons));
  color: #fff;
  font-size: 1rem;
  font-style: italic;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  clip-path: polygon(0 0, 88% 0, 100% 100%, 0 100%);
}
.sheet-banner-skills,
.sheet-banner-ammo {
  --banner: var(--skills);
}
.sheet-banner-combat,
.sheet-banner-gear {
  --banner: var(--combat);
}
.sheet-banner-weapons,
.sheet-banner-more {
  --banner: var(--weapons);
}
.sheet-banner-caps {
  --banner: var(--caps);
}
.sheet-banner-perks {
  --banner: var(--perks);
}
.fallout-sheet .sheet-label-bar,
.fallout-sheet .sheet-table thead th,
.fallout-sheet .sheet-part-title {
  display: block;
  background: var(--ink);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.3em 0.5em;
}
.fallout-sheet .sheet-table thead th {
  display: table-cell;
}

/* Gear-shaped number boxes */
.fallout-sheet .sheet-gear {
  display: grid;
  place-items: center;
  width: 6.5em;
  aspect-ratio: 1;
  background: var(--gear-shape) center / contain no-repeat;
  font-size: 1.1rem;
  font-weight: 700;
}
.fallout-sheet .sheet-gear input,
.fallout-sheet .sheet-gear .field-value {
  width: 3em;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  background: transparent;
  border: none;
}
.fallout-sheet .sheet-gear .character-field {
  display: grid;
  justify-items: center;
}

/* Header */
.sheet-header {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr auto;
  gap: 1em;
  align-items: start;
}
.sheet-name-value input,
.sheet-name-value .field-value {
  width: 100%;
  font-size: 1.4rem;
}
.sheet-name-value h1 {
  margin: 0;
  font-size: 1.4rem;
}
.sheet-header-fields {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
}
.sheet-header-fields .sheet-labeled {
  display: grid;
  grid-template-columns: 11em 1fr;
  align-items: center;
  background: #fff;
}
.sheet-header-fields .sheet-labeled-value {
  padding: 0 0.5em;
}
.sheet-header-fields input,
.sheet-header-fields select {
  width: 100%;
  border: none;
}
.sheet-gear-box {
  display: grid;
  justify-items: center;
}
.sheet-gear-label {
  font-weight: 800;
  text-transform: uppercase;
}

/* S.P.E.C.I.A.L. */
.sheet-specials {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.75em 0.5em;
  padding-bottom: 2.5em;
}
.sheet-special,
.sheet-luck-points {
  display: grid;
  justify-items: center;
}
.sheet-special .sheet-banner,
.sheet-luck-points .sheet-banner {
  width: 100%;
  padding-right: 0.6em;
  text-align: center;
  font-size: 0.9rem;
  clip-path: polygon(0 0, 100% 0, 92% 100%, 6% 100%);
}
/* Tucked under Luck, overlapping the next row, as on the paper sheet */
.sheet-luck-points {
  position: absolute;
  right: 0;
  bottom: -3.5em;
  width: calc((100% - 3em) / 7);
}
.sheet-luck-points .sheet-gear {
  width: 4.5em;
}
.sheet-special-strength .sheet-banner { --banner: var(--str); }
.sheet-special-perception .sheet-banner { --banner: var(--per); }
.sheet-special-endurance .sheet-banner { --banner: var(--end); }
.sheet-special-charisma .sheet-banner { --banner: var(--cha); }
.sheet-special-intelligence .sheet-banner { --banner: var(--int); }
.sheet-special-agility .sheet-banner { --banner: var(--agi); }
.sheet-special-luck .sheet-banner,
.sheet-luck-points .sheet-banner { --banner: var(--lck); }

/* Two-column body */
.sheet-columns {
  display: grid;
  grid-template-columns: minmax(18em, 1fr) 2fr;
  gap: 1.5em;
  align-items: start;
}
.sheet-columns-gear {
  grid-template-columns: minmax(18em, 1fr) 2fr;
}

/* Tables */
.fallout-sheet .sheet-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.9rem;
}
.fallout-sheet .sheet-table td,
.fallout-sheet .sheet-table tbody th {
  color: var(--ink);
  padding: 0.2em 0.4em;
  border-bottom: 1px dotted var(--rule);
  text-align: left;
  font-weight: 400;
}
.fallout-sheet .sheet-table input,
.fallout-sheet .sheet-table select {
  width: 100%;
  min-width: 3em;
  padding: 0.15em 0.3em;
}
.fallout-sheet input[type="checkbox"] {
  width: 1.1em !important;
  min-width: 0 !important;
  height: 1.1em;
  padding: 0;
  accent-color: var(--ink);
}
.sheet-skills-table tbody tr:nth-child(odd) th,
.sheet-skills-table tbody tr:nth-child(odd) .sheet-tag-cell {
  background: var(--peach);
}
.sheet-skills-table tbody tr:nth-child(even) th,
.sheet-skills-table tbody tr:nth-child(even) .sheet-tag-cell {
  background: var(--peach-light);
}
.sheet-attribute {
  color: var(--skills);
  font-size: 0.8em;
}
.sheet-tag-cell {
  width: 3em;
  text-align: center !important;
}
.sheet-rank-cell {
  width: 6em;
}
.sheet-rank-cell input {
  width: 4em !important;
}
.sheet-skills-rules {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5em;
  margin-bottom: 0.5em;
  font-size: 0.85rem;
}
.sheet-skill-points {
  display: flex;
  gap: 0.5em;
  font-weight: 700;
}
.sheet-cell-option {
  display: inline-flex;
  gap: 0.2em;
  margin-right: 0.5em;
  white-space: nowrap;
  font-size: 0.85em;
}
.sheet-cell-option input {
  width: auto !important;
  min-width: 0 !important;
}
.sheet-cell-computed {
  text-align: center !important;
  font-weight: 700;
}
.sheet-remove {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
}
.sheet-list-form {
  overflow-x: auto;
}
.sheet-weapons .sheet-control,
.sheet-weapons .character-field {
  overflow-x: auto;
}

/* Combat */
.sheet-combat-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5em;
  margin-bottom: 0.75em;
}
.sheet-combat-stats .sheet-labeled {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  background: var(--ink);
}
.sheet-combat-stats .sheet-labeled-value {
  min-width: 3.5em;
  padding: 0.3em;
  background: #fff;
  text-align: center;
  font-weight: 700;
}
.sheet-body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas:
    "poison head health"
    "larm . rarm"
    ". torso ."
    "lleg . rleg";
  gap: 0.75em;
  padding: 0.75em;
  background: var(--panel);
}
.sheet-poison { grid-area: poison; align-self: start; display: grid; grid-template-columns: auto 1fr; background: #fff; }
.sheet-poison .sheet-labeled-value { padding: 0.3em; text-align: center; font-weight: 700; }
.sheet-health { grid-area: health; background: #fff; }
.sheet-health .sheet-labeled { display: flex; justify-content: space-between; padding: 0.2em 0.5em; }
.sheet-health .sheet-labeled .sheet-label-bar { background: none; color: var(--ink); text-transform: none; font-weight: 400; padding: 0; font-size: 0.9rem; }
.sheet-part-head { grid-area: head; }
.sheet-part-left_arm { grid-area: larm; }
.sheet-part-right_arm { grid-area: rarm; }
.sheet-part-torso { grid-area: torso; }
.sheet-part-left_leg { grid-area: lleg; }
.sheet-part-right_leg { grid-area: rleg; }
.sheet-part {
  background: #fff;
  text-align: center;
}
.sheet-part dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
}
.sheet-part dl > div {
  display: flex;
  justify-content: space-between;
  gap: 0.3em;
  padding: 0.15em 0.4em;
  border: 1px solid var(--rule);
  font-size: 0.85rem;
}
.sheet-part dd,
.sheet-part dt {
  margin: 0;
}
.sheet-part dd {
  font-weight: 700;
}

/* Gear tab */
.sheet-gear-column {
  display: flex;
  flex-direction: column;
  gap: 1.25em;
}
.sheet-caps {
  display: flex;
  align-items: center;
}
.sheet-caps .sheet-banner {
  margin: 0;
  padding: 0.4em 3em 0.4em 1em;
  font-size: 1.3rem;
}
.sheet-carry {
  margin: 0;
  background: var(--ink);
  color: #fff;
}
.sheet-carry > div {
  display: grid;
  grid-template-columns: 1fr 6em;
  border-top: 1px dotted var(--ink-soft);
}
.sheet-carry dt {
  padding: 0.4em 0.6em;
  text-align: right;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
}
.sheet-carry dd {
  margin: 0;
  padding: 0.4em;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.sheet-perks .sheet-choices h3 {
  margin: 0.5em 0 0.25em;
  font-size: 0.95rem;
  text-transform: uppercase;
}
.sheet-perks .option-picker-scroll {
  max-height: 40em;
}
.sheet-choices-table td:last-child {
  font-size: 0.85rem;
}
.fallout-sheet .option-picker-effect {
  border: none;
  padding: 0;
  margin: 0;
  background: none;
  font-size: 0.85em;
}
.fallout-sheet .option-picker-effect summary {
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}
.sheet-more-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14em, 1fr));
  gap: 1em;
}
.sheet-more-field.sheet-wide {
  grid-column: 1 / -1;
}
.sheet-more-value textarea {
  width: 100%;
}
.sheet-hint {
  color: var(--ink-soft);
}

/* Narrow windows: one column */
@media (max-width: 900px) {
  .sheet-header,
  .sheet-columns,
  .sheet-columns-gear {
    grid-template-columns: 1fr;
  }
  .sheet-specials {
    grid-template-columns: repeat(4, 1fr);
  }
  .sheet-specials {
    padding-bottom: 0;
  }
  .sheet-luck-points {
    position: static;
    width: auto;
  }
  .sheet-body {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "poison health"
      "head torso"
      "larm rarm"
      "lleg rleg";
  }
  .sheet-combat-stats {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 520px) {
  .sheet-specials {
    grid-template-columns: repeat(2, 1fr);
  }
  .sheet-body {
    grid-template-columns: 1fr;
    grid-template-areas: "poison" "health" "head" "torso" "larm" "rarm" "lleg" "rleg";
  }
  .fallout-sheet .sheet-panel {
    padding: 0.75em;
  }
}

/* App top bar, holding the sidebar toggle */
[data-topnav] .app-title {
  color: var(--foreground);
  font-weight: 700;
  text-decoration: none;
}
[data-topnav] [data-sidebar-toggle] {
  font-size: 1.25rem;
  line-height: 1.4;
  color: var(--foreground);
  cursor: pointer;
}

/* Always-on inputs (character page and Fallout creation form) look like the
   value they hold; focus only adds an underline, so nothing moves. */
:is(input, select, textarea).inline-input {
  appearance: none;
  -moz-appearance: textfield;
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: inherit;
  font-variant-numeric: tabular-nums;
}
:is(input, select, textarea).inline-input::-webkit-inner-spin-button,
:is(input, select, textarea).inline-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
:is(input, select, textarea).inline-input::placeholder {
  color: inherit;
  opacity: 0.6;
}
textarea.inline-input {
  resize: vertical;
  white-space: pre-wrap;
}
select.inline-input {
  cursor: pointer;
}
:is(input, select, textarea).inline-input:hover {
  box-shadow: inset 0 -1px 0 color-mix(in srgb, currentColor 40%, transparent);
}
:is(input, select, textarea).inline-input:focus,
:is(input, select, textarea).inline-input:focus-visible {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--sheet-focus, var(--ring));
}
.sheet-control[aria-invalid="true"] :is(input, select, textarea).inline-input {
  box-shadow: inset 0 0 0 2px var(--sheet-danger, var(--danger));
}
/* Notes in the rank column open leftward, staying over the skills table. */
.fallout-sheet .sheet-rank-cell .character-field :is(.field-saving, .field-saved, .field-warning, .field-error) {
  left: auto;
  right: 0;
}
.fallout-sheet .sheet-health .sheet-label-bar {
  white-space: nowrap;
}

/* Perk search: an autocomplete listbox under the search box */
.perk-search {
  position: relative;
  margin: 0.35em 0 0.5em;
}
.catalog-search {
  position: relative;
}
.catalog-search input[aria-invalid="true"] {
  box-shadow: inset 0 0 0 2px var(--sheet-danger, var(--danger));
}
.catalog-unknown {
  display: block;
  font-size: 0.8em;
  color: #a3271f;
}
.fallout-sheet .perk-search input {
  width: 100%;
  padding: 0.35em 0.5em;
}
/* Placed by the script with position: fixed, so scrolling tables can't clip it */
:is(.perk-search, .catalog-search) [role="listbox"] {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 4;
  max-height: 18em;
  overflow-y: auto;
  margin: 2px 0 0;
  padding: 0.25em 0;
  list-style: none;
  background: #fff;
  color: var(--ink, #1f1d1b);
  border: 1px solid var(--ink, #1f1d1b);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.25);
}
:is(.perk-search, .catalog-search) :is([role="option"], .perk-search-empty) {
  padding: 0.3em 0.6em;
  cursor: pointer;
}
:is(.perk-search, .catalog-search) [role="option"][aria-selected="true"] {
  background: var(--ink, #1f1d1b);
  color: #fff;
}
:is(.perk-search, .catalog-search) [role="option"][aria-disabled="true"] {
  cursor: default;
  color: #77706a;
}
:is(.perk-search, .catalog-search) [role="option"] small {
  font-size: 0.8em;
  color: #8a3b2f;
}
:is(.perk-search, .catalog-search) .perk-search-empty {
  color: #77706a;
  cursor: default;
}

/* Attribute points left to spend, under the S.P.E.C.I.A.L. row at creation */
.sheet-attribute-points {
  grid-column: 1 / span 4;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  align-items: baseline;
  font-weight: 700;
}
.sheet-attribute-points .sheet-control {
  display: flex;
  gap: 0.5em;
  align-items: baseline;
}

/* Live Tag skill count beside the skills hint, at creation */
.sheet-tag-count {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  align-items: baseline;
  font-weight: 700;
}

/* Compact traits: one line each, effect behind a toggle */
.trait-picker .trait-group {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  margin-bottom: 0.4em;
}
.trait-picker .trait-group-name {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft, inherit);
}
.trait-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.75em;
  padding: 0.1em 0;
}
.trait-line > label {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  flex: 1 1 20em;
  min-width: 0;
  margin: 0;
  cursor: pointer;
}
.trait-line input:disabled + .trait-name {
  opacity: 0.5;
}
.trait-name {
  font-weight: 700;
  white-space: nowrap;
}
.trait-summary {
  color: var(--ink-soft, inherit);
  font-size: 0.85em;
  font-weight: 400;
}
.fallout-sheet .trait-effect {
  flex: 0 0 auto;
}
.fallout-sheet .trait-effect[open] {
  flex-basis: 100%;
}
.trait-table .trait-summary {
  display: block;
}
/* `display` above would otherwise override the hidden attribute */
.trait-line[hidden],
.trait-picker .trait-group[hidden] {
  display: none;
}

/* Trait groups as cards: a black header bar per origin, as on the sheet's tables */
.fallout-sheet .trait-picker .trait-group {
  gap: 0;
  margin-bottom: 0.75em;
  background: #fff;
  border: 1px solid var(--rule);
}
.fallout-sheet .trait-picker .trait-group-name {
  display: block;
  padding: 0.25em 0.6em;
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
}
.fallout-sheet .trait-picker .trait-line {
  padding: 0.3em 0.6em;
}
.fallout-sheet .trait-picker .trait-line + .trait-line {
  border-top: 1px dotted var(--rule);
}

/* Effect toggles: no dark bar when open (Oat styles open summaries) */
.fallout-sheet details.option-picker-effect > summary,
.fallout-sheet details.option-picker-effect[open] > summary {
  background: none;
  border: none;
  color: var(--ink);
  padding: 0;
}
.fallout-sheet details.option-picker-effect[open] {
  background: none;
  color: var(--ink);
}

/* Checkboxes: an ink outline, with a dark tick when checked */
.fallout-sheet input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  width: 1.1em !important;
  height: 1.1em;
  margin: 0;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
}
.fallout-sheet input[type="checkbox"]:checked {
  background: #fff;
  border-color: var(--ink);
}
.fallout-sheet input[type="checkbox"]::before {
  content: "";
  width: 0.3em;
  height: 0.6em;
  margin-top: -0.15em;
  border: solid var(--ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  visibility: hidden;
}
.fallout-sheet input[type="checkbox"]:checked::before {
  visibility: visible;
}
.fallout-sheet input[type="checkbox"]:disabled {
  opacity: 0.45;
  cursor: default;
}
.fallout-sheet input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--end);
  outline-offset: 1px;
}
.fallout-sheet details.option-picker-effect > summary::after {
  display: none;
}
.fallout-sheet details.option-picker-effect > summary::before {
  content: "▸ ";
}
.fallout-sheet details.option-picker-effect[open] > summary::before {
  content: "▾ ";
}
.fallout-sheet details.option-picker-effect > summary {
  display: inline-flex;
  justify-content: flex-start;
  gap: 0.2em;
  width: auto;
}

/* "Choose an origin first" above the traits, while no origin is picked */
.sheet-prerequisite {
  margin: 0.25em 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #8a5a00;
}
.sheet-prerequisite[hidden] {
  display: none;
}

/* Active effects and the Use button */
.active-effects {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #fff;
  border: 1px solid var(--rule);
}
.active-effects li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25em 0.75em;
  padding: 0.35em 0.6em;
}
.active-effects li + li {
  border-top: 1px dotted var(--rule);
}
.active-effect-name {
  font-weight: 700;
}
.active-effect-applied {
  font-weight: 700;
  color: #2f6b2a;
}
.active-effect-actions {
  margin-left: auto;
  display: flex;
  gap: 0.35em;
}
.fallout-sheet .active-effect-actions button,
.fallout-sheet .sheet-use {
  padding: 0.1em 0.6em;
  font-size: 0.85rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0.2em;
  cursor: pointer;
}
.sheet-row-actions {
  white-space: nowrap;
}

/* Gear spans the Gear tab's width; Active Effects get their own banner */
.sheet-banner-effects {
  --banner: var(--perks);
  margin-top: 1em !important;
}
.sheet-gear-list .sheet-carry {
  max-width: 28em;
  margin-left: auto;
}
.fallout-sheet .sheet-list input[name$="[quantity]"] {
  width: 4.5em;
  min-width: 0;
}

.fallout-sheet .sheet-add-row {
  margin-top: 0.35em;
  padding: 0.15em 0.75em;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0.2em;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Delete buttons are red, and ask before deleting */
.fallout-sheet .sheet-remove {
  color: #a3271f;
  font-weight: 700;
  border-radius: 0.2em;
}
.fallout-sheet .sheet-remove:hover,
.fallout-sheet .sheet-remove:focus-visible {
  background: #f6dcd8;
  color: #7d1c15;
}

.sheet-perk-points {
  margin-left: 0.5em;
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: none;
}
.sheet-perk-points,
.sheet-perk-points * {
  display: inline;
}

/* Mods: a compact summary that opens to one picker per slot */
.sheet-mods summary {
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.85rem;
  text-decoration: underline dotted;
}
.sheet-mods[open] summary {
  margin-bottom: 0.3em;
}
.sheet-mods-slots {
  display: grid;
  gap: 0.25em;
  min-width: 19em;
}
.sheet-mods-slots label {
  display: grid;
  grid-template-columns: 6em 1fr;
  align-items: center;
  gap: 0.4em;
  font-size: 0.8rem;
}
.fallout-sheet .sheet-mods-slots select {
  min-width: 0;
  width: 100%;
  background: #fff;
  color: var(--ink);
  font-size: 0.8rem;
}
.sheet-mods-none {
  color: var(--ink-soft);
}
/* Mods picker: plain summary, light pop-over (overrides Oat's details card) */
.fallout-sheet details.sheet-mods,
.fallout-sheet details.sheet-mods[open] {
  position: relative;
  background: none;
  border: none;
  color: var(--ink);
  padding: 0;
  margin: 0;
}
.fallout-sheet details.sheet-mods > summary,
.fallout-sheet details.sheet-mods[open] > summary {
  display: inline-flex;
  gap: 0.2em;
  width: auto;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  color: var(--ink);
}
.fallout-sheet details.sheet-mods > summary::after {
  display: none;
}
.fallout-sheet details.sheet-mods > summary::before {
  content: "▸";
}
.fallout-sheet details.sheet-mods[open] > summary::before {
  content: "▾";
}
/* Inline, not a pop-over: the table's scroll wrapper would clip one. */
.fallout-sheet details.sheet-mods[open] > .sheet-mods-slots {
  margin-top: 0.25em;
  padding: 0.4em;
  background: #fff;
  border: 1px solid var(--rule);
}
.fallout-sheet .sheet-mods-slots span {
  color: var(--ink-soft);
}
.fallout-sheet .sheet-mods-slots select {
  border: 1px solid var(--ink-soft);
}
.fallout-sheet details.sheet-mods > .sheet-mods-slots {
  animation: none;
  opacity: 1;
}
.fallout-sheet .sheet-cell-catalog input {
  min-width: 9em;
}

/* Equipment pack picker (creation form) */
.sheet-pack {
  margin-bottom: 1.25em;
}
.sheet-banner-pack {
  --banner: var(--combat);
}
.sheet-pack-body {
  display: grid;
  grid-template-columns: minmax(14em, 1fr) minmax(14em, 1.4fr) minmax(14em, 1.4fr);
  gap: 0.75em 1.5em;
  align-items: start;
}
.sheet-pack-pick {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  align-items: flex-start;
}
.sheet-pack-choices {
  display: grid;
  gap: 0.4em;
}
.sheet-pack-choices label {
  display: grid;
  gap: 0.15em;
  font-size: 0.85rem;
}
.fallout-sheet .sheet-pack-choices select,
.fallout-sheet .sheet-pack-pick select {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--ink-soft);
}
.sheet-pack-rolls {
  margin: 0;
  padding-left: 1.1em;
  font-size: 0.85rem;
  color: var(--ink);
}
@media (max-width: 900px) {
  .sheet-pack-body {
    grid-template-columns: 1fr;
  }
}
.fallout-sheet .sheet-list select[name$="[worn]"] {
  min-width: 6.5em;
}

/* Bestiary (rulebook): filters, entry list and stat blocks. */
.bestiary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0 0.5rem;
}
.bestiary-filters input[type="search"] {
  flex: 1 1 18rem;
}
.bestiary-filters select {
  flex: 0 1 14rem;
}
.bestiary-level {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}
.bestiary-level input {
  width: 5rem;
}
.bestiary-count {
  font-size: 0.85rem;
  opacity: 0.75;
}
.bestiary .adversary {
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
}
.bestiary .adversary summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
}
.adversary-meta {
  font-size: 0.85rem;
  opacity: 0.75;
}
.stat-block {
  margin-top: 0.75rem;
  max-width: 75ch;
}
.stat-block h3 {
  font-size: 1rem;
  margin: 1rem 0 0.4rem;
}
.stat-block .stat-table {
  width: 100%;
  table-layout: fixed;
  margin-bottom: 0.5rem;
}
.stat-block .stat-table th,
.stat-block .stat-table td {
  text-align: center;
  padding: 0.25rem;
  font-size: 0.85rem;
  overflow-wrap: break-word;
}
.adversary-skills {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.15rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}
.adversary-skills .tag-mark {
  font-size: 0.7rem;
  border: 1px solid currentColor;
  border-radius: 0.2rem;
  padding: 0 0.25rem;
  margin-left: 0.25rem;
}
.adversary-attacks {
  padding-left: 1.25rem;
}
.adversary-abilities dt {
  font-weight: 600;
}
.adversary-abilities dd {
  margin: 0 0 0.5rem;
}
.adversary-notes {
  font-style: italic;
}

/* Combat encounters */
.encounter-new {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

/* ── Encounter screens (setup, battle, aftermath) ─────────────────────────── */
.enc {
  --enc-ground: #f4f3ee;
  --enc-surface: #ffffff;
  --enc-ink: #1c1b19;
  --enc-muted: #5e5b54;
  --enc-line: #dedbd2;
  --enc-line-strong: #c9c5ba;
  --enc-party: #1f5fbf;
  --enc-party-soft: #f3f7fd;
  --enc-party-line: #c8d6ee;
  --enc-enemy: #a8430e;
  --enc-enemy-soft: #fdf6f1;
  --enc-enemy-line: #ebc9b5;
  --enc-warn-bg: #fbede4;
  --enc-warn-ink: #7a2f08;
  background: var(--enc-ground);
  color: var(--enc-ink);
  font-family: Inter, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  border-radius: 14px;
  overflow: hidden;
  margin: -0.5rem 0 1rem;
}
.enc h2, .enc h3 { margin: 0; color: inherit; }
.enc button { font: inherit; cursor: pointer; }
.enc button:disabled { cursor: not-allowed; opacity: .45; }
.enc input, .enc select, .enc textarea {
  font: inherit;
  color: var(--enc-ink);
  background: var(--enc-surface);
  border: 1px solid var(--enc-line-strong);
  border-radius: 8px;
  padding: 0 10px;
  min-height: 40px;
  margin: 0;
}
.enc textarea { padding: 8px 10px; resize: vertical; }
.enc a { color: var(--enc-party); }

.enc-bar {
  background: var(--enc-ink);
  color: var(--enc-ground);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}
.enc-bar-title { display: flex; flex-direction: column; gap: 2px; flex: 1 1 260px; min-width: 0; }
.enc .enc-back { color: #c9c5ba; font-size: 13px; text-decoration: none; }
.enc .enc-back:hover { color: #ffffff; }
.enc-eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #c9c5ba; }
.enc-name-form { margin: 0; }
.enc .enc-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: 22px;
  font-weight: 600;
  background: transparent;
  border: 0;
  border-bottom: 1px dashed #6b6860;
  border-radius: 0;
  color: var(--enc-ground);
  padding: 2px 0;
  width: 100%;
  max-width: 420px;
}
.enc-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; font-size: 13px; flex-wrap: wrap; }
.enc-step { padding: 6px 12px; border-radius: 16px; border: 1px solid #4a4842; color: #c9c5ba; }
.enc-step.is-current { background: var(--enc-ground); color: var(--enc-ink); font-weight: 600; border-color: var(--enc-ground); }
.enc .enc-bar-button {
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--enc-ground);
  background: transparent;
  color: var(--enc-ground);
  font-weight: 600;
}

.enc-setup {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 20px 24px 32px;
  align-items: flex-start;
}
.enc-card {
  background: var(--enc-surface);
  border: 1px solid var(--enc-line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.enc-party { flex: 1 1 380px; }
.enc-opposition { flex: 1 1 460px; }
.enc-initiative { flex: 2 1 520px; }
.enc-start { flex: 1 1 320px; }
.enc-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.enc-card-title { font-family: "Space Grotesk", sans-serif; font-size: 17px; }
.enc-side-title { font-family: "Space Grotesk", sans-serif; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.enc-side-title.side-party { color: var(--enc-party); }
.enc-side-title.side-enemy { color: var(--enc-enemy); }
.enc-subtitle { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--enc-muted); }
.enc-subsection { border-top: 1px solid var(--enc-line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.enc-muted { font-size: 13px; color: var(--enc-muted); margin: 0; }
.enc-hint { font-size: 13px; color: var(--enc-muted); margin: 0; }
.enc-empty { font-size: 14px; color: var(--enc-muted); padding: 12px; border: 1px dashed var(--enc-line-strong); border-radius: 10px; margin: 0; }
.enc-warning { font-size: 14px; background: var(--enc-warn-bg); color: var(--enc-warn-ink); border-radius: 8px; padding: 8px 12px; margin: 0; }

.enc-list, .enc-results, .enc-order { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.enc-pick { border-radius: 10px; border: 1px solid var(--enc-line); background: var(--enc-surface); }
.enc-pick.is-on { border-color: var(--enc-party-line); background: var(--enc-party-soft); }
.enc-pick label { display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; margin: 0; }
.enc .enc-pick input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--enc-party); padding: 0; }
.enc-pick-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.enc-pick-name small { font-size: 12px; color: var(--enc-muted); }

.enc-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  flex-wrap: wrap;
}
.enc-group.side-enemy { border: 1px solid var(--enc-enemy-line); background: var(--enc-enemy-soft); color: var(--enc-ink); }
.enc-group.side-ally { border: 1px solid var(--enc-party-line); background: var(--enc-party-soft); color: var(--enc-ink); }
.enc-group .enc-pick-name { flex: 1 1 160px; }
.enc-group-controls { display: flex; align-items: center; gap: 8px; }
.enc-count { min-width: 28px; text-align: center; font-weight: 700; }

.enc .enc-button {
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--enc-line-strong);
  background: var(--enc-surface);
  color: var(--enc-ink);
  font-size: 13px;
}
.enc .enc-button-party { border-color: var(--enc-party); color: var(--enc-party); font-weight: 600; }
.enc .enc-button-dark { border: 0; background: var(--enc-ink); color: #ffffff; font-weight: 600; }
.enc .enc-button-primary { border: 0; background: var(--enc-party); color: #ffffff; font-weight: 600; }
.enc .enc-button-wide { width: 100%; height: 48px; font-size: 15px; border-radius: 10px; }
.enc .enc-icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--enc-line-strong);
  background: var(--enc-surface);
  color: var(--enc-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.enc-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--enc-muted); margin: 0; }
#bestiary-search { margin: 0; }
.enc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.enc .enc-chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  font-size: 13px;
  border: 1px solid var(--enc-line);
  background: var(--enc-surface);
  color: var(--enc-ink);
}
.enc .enc-chip.is-on { border-color: var(--enc-ink); background: var(--enc-ink); color: #ffffff; }
.enc-results { max-height: 300px; overflow-y: auto; gap: 0; }
.enc-results li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid #efede6; }

.enc-order { gap: 6px; }
.enc-order-row { display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: 8px; flex-wrap: wrap; }
.enc-order-row.side-enemy { background: var(--enc-enemy-soft); }
.enc-order-row.side-player, .enc-order-row.side-ally { background: var(--enc-party-soft); }
.enc-order-pos { width: 22px; text-align: right; color: var(--enc-muted); font-size: 13px; }
.enc-order-name { flex: 1 1 140px; font-weight: 500; }
.enc-order-note { font-size: 12px; color: var(--enc-warn-ink); font-weight: 600; }
.enc-order-move { display: flex; gap: 4px; width: 76px; justify-content: flex-end; }
.enc-order-init { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--enc-muted); margin: 0; }
.enc .enc-order-init input { width: 68px; min-height: 34px; height: 34px; }

.enc-stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.enc-stepper-controls { display: flex; align-items: center; gap: 8px; }
#details-notes, .enc-start-form { margin: 0; display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 640px) {
  .enc-bar { padding: 12px 16px; }
  .enc-setup { padding: 16px; gap: 16px; }
  .enc-order-move { width: auto; }
}

/* Battle screen */
.enc-battle { position: relative; }
.enc .enc-title { font-family: "Space Grotesk", sans-serif; font-size: 22px; font-weight: 600; margin: 0; color: var(--enc-ground); }
.enc-round { font-size: 14px; color: #e4e0d5; }
.enc-pool { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #c9c5ba; }
.enc-pool strong { min-width: 20px; text-align: center; font-size: 18px; color: var(--enc-ground); }
.enc .enc-bar-icon { width: 32px; height: 32px; padding: 0; border-radius: 6px; border: 1px solid #4a4842; background: transparent; color: var(--enc-ground); }
.enc .enc-bar-button-light { background: var(--enc-ground); color: var(--enc-ink); border-color: var(--enc-ground); }

.enc-ribbon { background: var(--enc-surface); border-bottom: 1px solid var(--enc-line); padding: 10px 24px; display: flex; gap: 8px; overflow-x: auto; align-items: center; }
.enc-ribbon-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--enc-muted); white-space: nowrap; }
.enc-chip-init { white-space: nowrap; font-size: 13px; padding: 6px 10px; border-radius: 16px; background: #e6eef9; }
.enc-chip-init.side-enemy { background: var(--enc-warn-bg); }
.enc-chip-init.is-current { background: var(--enc-party); color: #ffffff; font-weight: 600; }
.enc-chip-init.is-defeated { text-decoration: line-through; opacity: .6; }

.enc-board { display: flex; flex-wrap: wrap; gap: 20px; padding: 20px 24px 96px; align-items: flex-start; }
.enc-col { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.enc-col-party, .enc-col-enemies { flex: 1 1 260px; }
.enc-col-turn { flex: 2 1 480px; gap: 16px; }

.enc-unit { background: var(--enc-surface); border: 1px solid var(--enc-line); border-radius: 12px; overflow: hidden; }
.enc-unit.is-current { box-shadow: 0 0 0 3px var(--enc-party); }
.enc-unit.is-target { box-shadow: 0 0 0 3px #e0a100; }
.enc-unit.is-defeated { opacity: .55; }
.enc .enc-unit-main { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 14px 14px 10px; color: var(--enc-ink); border-radius: 0; height: auto; }
.enc-unit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.enc-unit-head strong { font-size: 16px; }
.enc-hp { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.enc-hp-bar { flex: 1; height: 8px; background: #e9e6de; border-radius: 4px; overflow: hidden; display: block; }
.enc-hp-fill { display: block; height: 100%; background: #2f6f4e; }
.enc-hp-fill.is-low { background: #c77700; }
.enc-hp-fill.is-out { background: var(--enc-enemy); }
.enc .combatant-hp { font-size: 13px; font-weight: 600; white-space: nowrap; }
.enc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.enc .combatant-flag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #e9e6de; color: var(--enc-ink); font-weight: 500; }
.enc .combatant-flag.condition { background: #f1e6c8; }
.enc .combatant-flag.injury { background: var(--enc-warn-bg); color: var(--enc-warn-ink); }
.enc .combatant-flag.enc-tag-target { background: #e0a100; }
.enc-unit-foot { display: flex; justify-content: space-between; align-items: center; padding: 0 14px 12px; gap: 8px; }

.enc-turn { border: 2px solid var(--enc-party); }
.enc-turn-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.enc-turn-eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--enc-party); font-weight: 600; }
.enc .enc-turn-name { font-family: "Space Grotesk", sans-serif; font-size: 24px; font-weight: 600; margin: 0; }
.enc-alert { background: var(--enc-warn-bg); border: 1px solid #e8b79a; border-radius: 10px; padding: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; }
.enc-alert > span { flex: 1 1 240px; }
.enc .enc-tabs { background: transparent; }
.enc-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--enc-line); padding-bottom: 10px; }
.enc .enc-tab { height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--enc-line); background: var(--enc-surface); color: var(--enc-ink); font-weight: 600; }
.enc .enc-tab.is-on { background: var(--enc-ink); border-color: var(--enc-ink); color: #ffffff; }
.enc-pane { display: flex; flex-direction: column; gap: 12px; }
.enc-pane[hidden] { display: none; }
.enc-step-label { font-size: 13px; font-weight: 600; color: var(--enc-muted); }
.enc-weapons { display: flex; flex-wrap: wrap; gap: 8px; }
.enc .enc-weapon { min-height: 48px; height: auto; padding: 6px 14px; text-align: left; border-radius: 10px; border: 1px solid var(--enc-line-strong); background: var(--enc-surface); color: var(--enc-ink); display: flex; flex-direction: column; }
.enc .enc-weapon small { font-size: 12px; opacity: .8; }
.enc .enc-weapon.is-on { background: var(--enc-party); border-color: var(--enc-party); color: #ffffff; }
.enc .enc-target { align-self: flex-start; min-height: 44px; padding: 8px 14px; border-radius: 8px; font-size: 14px; background: var(--enc-ground); color: var(--enc-muted); border: 1px dashed #a8a498; }
.enc .enc-target.is-on { background: #e0a100; color: var(--enc-ink); border: 0; font-weight: 600; }
.enc-tn { margin: 0; font-size: 14px; background: #e6eef9; border-radius: 8px; padding: 8px 12px; }
.enc-hit-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 0; }
.enc-row { display: flex; gap: 8px; align-items: center; }
.enc-wrap { flex-wrap: wrap; }
.enc-grow { flex: 1 1 200px; }
.enc .enc-small { width: 88px; }
.enc-hit-details { flex: 1 1 100%; font-size: 14px; }
.enc-hit-details summary { cursor: pointer; color: var(--enc-muted); }
.enc-hit-details > div { margin-top: 10px; align-items: flex-end; }
.enc-check { display: flex; gap: 6px; align-items: center; font-size: 14px; margin: 0; }
.enc .enc-check input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; }
.enc-apply { flex: 1 1 100%; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; background: var(--enc-ground); border-radius: 10px; padding: 12px; }
.enc-apply .enc-muted { flex: 1 1 240px; }
.enc .enc-button-big { height: 44px; padding: 0 22px; font-size: 15px; }
.enc .enc-button-danger { border-color: var(--enc-enemy); color: var(--enc-enemy); }
.enc-turn-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--enc-line); padding-top: 12px; }
.enc-inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.enc-label-inline { display: flex; align-items: center; gap: 6px; font-size: 14px; margin: 0; flex-wrap: wrap; }
.enc-spend { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.enc-spend-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.enc-due { border-color: #e8b79a; background: var(--enc-warn-bg); }
.enc-due-unit { display: flex; flex-direction: column; gap: 6px; }
.enc-due .pending { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.enc-log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.enc-log-list li { display: flex; gap: 10px; font-size: 14px; padding: 6px 0; border-bottom: 1px solid #efede6; }
.enc-log-list .log-round { color: var(--enc-muted); font-size: 12px; padding-top: 2px; white-space: nowrap; }
.enc .enc-dashed { height: 40px; border-radius: 10px; border: 1px dashed #a8a498; background: transparent; color: var(--enc-muted); }
.enc .enc-pill { height: 36px; padding: 0 12px; border-radius: 18px; border: 0; background: #f1e6c8; color: var(--enc-ink); }
.enc .enc-pill-add { background: var(--enc-surface); border: 1px dashed #a8a498; }
.enc .loot ul { margin: 6px 0; padding-left: 18px; }
.enc .roll-result .die { display: inline-block; min-width: 28px; text-align: center; padding: 2px 6px; margin: 2px; border-radius: 6px; background: var(--enc-ground); border: 1px solid var(--enc-line); }

.enc .enc-fab { position: fixed; right: 20px; bottom: 20px; width: 56px; height: 56px; padding: 0; border-radius: 28px; border: 0; background: var(--enc-ink); color: var(--enc-ground); display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(28, 27, 25, .3); z-index: 20; }
.enc-overlay { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; }
.enc .enc-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; background: rgba(28, 27, 25, .35); border: 0; border-radius: 0; }
.enc-drawer { position: relative; width: 400px; max-width: 100%; height: 100%; background: var(--enc-surface); padding: 20px; box-sizing: border-box; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.enc-drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.enc-drawer-body { display: flex; flex-direction: column; gap: 12px; }
.enc-drawer-foot { margin-top: 8px; border-top: 1px solid var(--enc-line); padding-top: 12px; }
.enc-target-group { display: flex; flex-direction: column; gap: 6px; }
.enc .enc-target-option { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--enc-line); background: var(--enc-surface); color: var(--enc-ink); text-align: left; }
.enc-tabbar { display: none; }

/* On a phone the battle is four tabs, with drawers as bottom sheets. */
@media (max-width: 760px) {
  .enc-bar { padding: 10px 14px; gap: 8px 12px; }
  .enc .enc-title { font-size: 18px; }
  .enc-ribbon { padding: 8px 14px; }
  .enc-board { padding: 12px 14px 140px; gap: 12px; }
  .enc-col { flex: 1 1 100%; }
  .enc-battle[data-view="turn"] .enc-col-party,
  .enc-battle[data-view="turn"] .enc-col-enemies,
  .enc-battle[data-view="turn"] .enc-log,
  .enc-battle[data-view="party"] .enc-col-turn,
  .enc-battle[data-view="party"] .enc-col-enemies,
  .enc-battle[data-view="enemies"] .enc-col-turn,
  .enc-battle[data-view="enemies"] .enc-col-party,
  .enc-battle[data-view="log"] .enc-col-party,
  .enc-battle[data-view="log"] .enc-col-enemies,
  .enc-battle[data-view="log"] .enc-turn-only { display: none; }
  .enc-tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--enc-surface); border-top: 1px solid var(--enc-line); }
  .enc .enc-tabbar-item { height: 58px; border: 0; border-radius: 0; background: transparent; color: var(--enc-muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 13px; font-weight: 500; box-shadow: inset 0 3px 0 transparent; }
  .enc .enc-tabbar-item small { font-size: 11px; opacity: .8; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .enc .enc-tabbar-item.is-on { color: var(--enc-party); font-weight: 700; box-shadow: inset 0 3px 0 var(--enc-party); }
  .enc .enc-fab { bottom: 72px; right: 14px; width: 48px; height: 48px; }
  .enc-overlay { align-items: flex-end; }
  .enc-drawer { width: 100%; height: auto; max-height: 75vh; border-radius: 16px 16px 0 0; }
  .enc-turn-foot { position: sticky; bottom: 62px; background: var(--enc-surface); padding-bottom: 4px; }
}

/* Aftermath screen */
.enc-after { display: flex; flex-direction: column; gap: 20px; padding: 20px 24px 32px; }
.enc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.enc-tile { background: var(--enc-surface); border: 1px solid var(--enc-line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.enc-tile-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--enc-muted); }
.enc-tile strong { font-family: "Space Grotesk", sans-serif; font-size: 22px; font-weight: 600; }
.enc-after-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.enc-xp { flex: 1 1 380px; }
.enc-loot { flex: 2 1 520px; }
.enc-big { font-family: "Space Grotesk", sans-serif; font-size: 22px; }
.enc-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.enc-lines li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 4px 0; border-bottom: 1px solid #efede6; }
.enc-lines li.enc-line-party { border: 0; padding: 8px 10px; border-radius: 8px; background: var(--enc-party-soft); }
.enc-done { margin: 0; font-weight: 600; color: #1f5136; background: #e7f2ec; border-radius: 8px; padding: 8px 12px; }
.enc-loot-group { display: flex; flex-direction: column; gap: 6px; }
.enc-loot-item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--enc-ground); }
.enc-loot-item.is-taken { background: #e7f2ec; }
.enc-loot-text { flex: 1 1 160px; font-weight: 500; }
.enc-loot-item .enc-done { padding: 0; background: transparent; }
.enc .enc-loot-name { width: 180px; }
.enc-table-wrap { overflow-x: auto; }
.enc-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.enc-table th { text-align: left; color: var(--enc-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 8px; border-bottom: 1px solid var(--enc-line); }
.enc-table td { padding: 10px 8px; border-bottom: 1px solid #efede6; vertical-align: top; }
#full-log summary { cursor: pointer; }
#full-log .enc-log-list { max-height: none; margin-top: 12px; }
.enc-after-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.enc .enc-link-button { display: inline-flex; align-items: center; text-decoration: none; color: #ffffff; }
@media (max-width: 760px) {
  .enc-after { padding: 16px; gap: 16px; }
}
.enc .enc-inline-form select, .enc .enc-inline-form input:not(.enc-small):not(.enc-loot-name) { width: auto; max-width: 100%; }
.enc .enc-inline-form input[type="text"]:not(.enc-loot-name) { flex: 1 1 160px; }

/* ── Accounts: signing in, passwords, the user menu ───────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 24rem; background: var(--card); color: var(--card-foreground); border: 1px solid var(--border, #4a4038); border-radius: 12px; padding: 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.auth-card h1 { margin: 0; font-size: 1.5rem; }
.auth-hint { margin: 0; color: var(--muted-foreground, #b8ab9b); font-size: 0.9rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.75rem; margin: 0; }
.auth-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.auth-check input { width: auto; }
.auth-button { width: 100%; }
.auth-link { align-self: center; font-size: 0.9rem; }
.auth-panel { max-width: 24rem; }
.auth-panel form { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-new { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin: 1rem 0; }
.auth-new > * { flex: 1 1 10rem; }
.auth-new button { flex: 0 0 auto; }
.auth-issued { border: 1px solid var(--primary); border-radius: 10px; padding: 1rem; margin: 1rem 0; display: flex; flex-direction: column; gap: 0.5rem; }
.auth-issued p { margin: 0; }
.auth-temp code { font-size: 1.4rem; letter-spacing: 0.08em; padding: 0.25rem 0.5rem; }
.app-user { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
.app-user-name { font-weight: 600; }
@media (max-width: 640px) {
  .app-user { gap: 0.6rem; font-size: 0.8rem; }
  .app-user-name { display: none; }
}
.log-out-form { margin: 0; display: inline; }
.log-out-button { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; width: auto; }
.auth-card .log-out-form { align-self: center; }

/* Someone else's character: the controls are disabled inside these. */
fieldset.sheet-readonly { display: contents; border: 0; margin: 0; padding: 0; min-width: 0; }
.character-read-only { padding: 0.5rem 0.75rem; border-radius: 8px; border: 1px solid var(--primary); }
.owner-form { display: flex; gap: 0.5rem; align-items: center; margin: 0; }
.owner-form select { width: auto; }
.character-yours { margin-left: 0.5rem; color: var(--primary); }
