:root {
  --parchment: #eee5ce;
  --parchment-dark: #e0d3ac;
  --ink: #2b1b12;
  --maroon: #58180d;
  --maroon-dark: #3b0f07;
  --gold: #c9ad6a;
  --gold-light: #ddc78a;
  --green: #2f5d34;
  --red: #7a1e14;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 24px 12px 60px;
  background: #4b3520;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.03), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0,0,0,0.15), transparent 50%);
  font-family: 'EB Garamond', 'Georgia', serif;
  color: var(--ink);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  background:
    repeating-radial-gradient(circle at 10% 20%, rgba(120,90,50,0.05) 0, transparent 3px),
    repeating-radial-gradient(circle at 80% 60%, rgba(120,90,50,0.05) 0, transparent 4px),
    linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border: 10px solid var(--maroon);
  outline: 3px solid var(--gold);
  outline-offset: -16px;
  border-radius: 4px;
  padding: 32px 40px 40px;
  box-shadow: 0 0 40px rgba(0,0,0,0.6), inset 0 0 120px rgba(88,24,13,0.08);
  position: relative;
}

.hb-title {
  text-align: center;
  border-bottom: 3px double var(--maroon);
  padding-bottom: 14px;
  margin-bottom: 28px;
}

.hb-title h1 {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  font-size: 2.6em;
  margin: 0 0 6px;
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.4);
}

.hb-title .subtitle {
  font-style: italic;
  color: #6b4a2b;
  margin: 0;
  font-size: 1.1em;
}

.hb-section {
  margin-bottom: 34px;
  scroll-margin-top: 64px;
}

/* ---------- Nav menu ---------- */

.hb-nav {
  position: sticky;
  top: 8px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  background: linear-gradient(180deg, var(--maroon), var(--maroon-dark));
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 28px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.hb-nav a {
  font-family: 'MedievalSharp', cursive;
  color: var(--gold-light);
  text-decoration: none;
  font-size: 0.85em;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.hb-nav a:hover {
  color: #fff;
  border-color: var(--gold);
  background: rgba(255,255,255,0.08);
}

.section-title {
  font-family: 'MedievalSharp', cursive;
  color: #fff;
  background: linear-gradient(90deg, var(--maroon) 0%, var(--maroon-dark) 100%);
  padding: 8px 16px;
  border-radius: 3px;
  border: 1px solid var(--gold);
  font-size: 1.3em;
  letter-spacing: 0.5px;
  margin: 0 0 16px;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

.group-title {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.05em;
  margin: 10px 0 8px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--gold);
}
.enemy-title { color: var(--red); }
.ally-title { color: var(--green); }

/* ---------- Dashboard / Riepilogo ---------- */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-tile {
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 10px 14px;
  text-align: center;
}

.dashboard-tile-label {
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #4a3420;
  margin-bottom: 4px;
}

.dashboard-tile-value {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.6em;
  color: var(--maroon-dark);
}

.dashboard-tile-value-small {
  font-size: 1em;
  font-family: 'EB Garamond', serif;
  font-weight: 700;
}

.dashboard-section {
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.3);
}

.dashboard-section-title {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  font-size: 1.05em;
  margin-bottom: 6px;
}

.dashboard-list {
  margin: 0;
  padding-left: 20px;
}

.dashboard-list li {
  margin-bottom: 3px;
}

.dashboard-more {
  font-style: italic;
  font-size: 0.85em;
  color: #6b4a2b;
  margin-top: 4px;
}

/* ---------- Round & Time trackers ---------- */

.tracker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.tracker-box {
  background: rgba(255,255,255,0.35);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 14px 18px;
  text-align: center;
}

.tracker-box h2 {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  font-size: 1.1em;
  margin: 0 0 8px;
}

.round-display {
  font-family: 'MedievalSharp', cursive;
  font-size: 3em;
  color: var(--maroon-dark);
  line-height: 1;
  margin-bottom: 8px;
}

.time-display {
  font-family: 'MedievalSharp', cursive;
  font-size: 2.2em;
  color: var(--maroon-dark);
  line-height: 1;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.ingame-time {
  margin-top: 10px;
  font-size: 0.95em;
  color: #4a3420;
}

.small-label {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.85em;
}

.small-label input {
  width: 50px;
  margin-left: 4px;
}

.btn-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Buttons & inputs ---------- */

button {
  font-family: 'EB Garamond', serif;
  font-weight: 600;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: var(--maroon-dark);
  border: 1px solid var(--maroon);
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.95em;
  transition: transform 0.05s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

.btn-small {
  min-width: 36px;
  font-size: 1.2em;
  padding: 2px 10px;
}

.btn-secondary {
  background: linear-gradient(180deg, #d8cba8, #c2b18a);
}

.btn-danger {
  background: linear-gradient(180deg, #b23a2b, var(--red));
  color: #fff;
  border-color: var(--maroon-dark);
}

.btn-remove {
  background: transparent;
  border: none;
  color: var(--red);
  font-weight: bold;
  font-size: 1.1em;
  padding: 0 6px;
  cursor: pointer;
}
.btn-remove:hover { color: var(--maroon-dark); }

input, select {
  font-family: 'EB Garamond', serif;
  border: 1px solid #a98f5c;
  border-radius: 3px;
  background: #fbf6e9;
  padding: 5px 8px;
  font-size: 0.95em;
  color: var(--ink);
}

input:focus, select:focus {
  outline: 2px solid var(--gold);
}

input[type="number"] { width: 80px; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--gold);
}

.pc-form input[type="text"], .npc-form input[type="text"] { width: 160px; }

/* ---------- Casters / spell slots ---------- */

.caster-card, .rage-card {
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.caster-header, .rage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.caster-header .name, .rage-header .name {
  font-weight: 700;
  color: var(--maroon);
  font-size: 1.1em;
}

.caster-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
}

.level-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.3);
  border: 1px solid #cbb87f;
  border-radius: 4px;
  padding: 6px 10px;
}

.level-label {
  font-size: 0.8em;
  font-weight: 700;
  color: #4a3420;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 140px;
}

.pip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--maroon);
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.pip.used {
  background: var(--maroon);
}

.level-remove {
  background: transparent;
  border: none;
  color: var(--red);
  font-size: 0.75em;
  cursor: pointer;
  padding: 0;
}

.add-level-form {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}
.add-level-form select, .add-level-form input { width: auto; }
.add-level-form input[type="number"] { width: 60px; }

/* ---------- Rage ---------- */

.rage-pips .pip {
  width: 22px;
  height: 22px;
  border-color: #7a3b0a;
}
.rage-pips .pip.used {
  background: #b3541a;
}

.rage-unlimited-badge {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon-dark);
  font-size: 1.1em;
  margin-top: 8px;
}

.rage-count {
  font-size: 0.9em;
  color: #4a3420;
  margin-left: 8px;
}

/* ---------- Table ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gold);
  border-radius: 6px;
}

.hb-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255,255,255,0.35);
  min-width: 640px;
}

.hb-table thead th {
  background: linear-gradient(180deg, var(--maroon), var(--maroon-dark));
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-family: 'MedievalSharp', cursive;
  font-weight: normal;
  font-size: 0.95em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.hb-table thead th:hover { background: linear-gradient(180deg, #6f2010, var(--maroon-dark)); }
.hb-table thead th.col-actions { cursor: default; }
.hb-table thead th.col-actions:hover { background: linear-gradient(180deg, var(--maroon), var(--maroon-dark)); }

.sort-arrow { font-size: 0.8em; }

.hb-table tbody tr:nth-child(odd) { background: rgba(201,173,106,0.12); }
.hb-table tbody tr:hover { background: rgba(201,173,106,0.28); }

.hb-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #d8c79a;
  vertical-align: middle;
}

.hb-table td input[type="text"] { width: 130px; }
.hb-table td input[type="number"] { width: 64px; }

.condition-checks {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85em;
  white-space: nowrap;
}
.condition-checks label { display: flex; align-items: center; gap: 3px; cursor: pointer; }

.condition-cell {
  min-width: 220px;
  max-width: 280px;
}

.condition-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.condition-chip {
  font-size: 0.72em;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid #a98f5c;
  background: rgba(255,255,255,0.5);
  color: #5a4526;
  cursor: pointer;
  white-space: nowrap;
}

.condition-chip:hover {
  border-color: var(--maroon);
}

.condition-chip-active {
  background: var(--maroon);
  border-color: var(--maroon-dark);
  color: #fff;
}

.exhaustion-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75em;
  color: #4a3420;
  margin-left: 4px;
}

.exhaustion-input {
  width: 40px !important;
}

.concentration-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.concentration-toggle {
  font-size: 0.72em;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid #a98f5c;
  background: rgba(255,255,255,0.5);
  color: #5a4526;
  cursor: pointer;
  white-space: nowrap;
}
.concentration-toggle:hover { border-color: var(--maroon); }

.concentration-active {
  background: #2f6f4f;
  border-color: #1f4a34;
  color: #fff;
}

.concentration-spell-input {
  width: 110px !important;
  font-size: 0.8em;
}

.death-saves {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.death-save-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.death-save-label {
  font-size: 0.7em;
  text-transform: uppercase;
  color: #4a3420;
  min-width: 60px;
  white-space: nowrap;
}

.death-save-pips .pip {
  width: 14px;
  height: 14px;
}

.death-pip-success.used { background: #2f6f4f; border-color: #1f4a34; }
.death-pip-failure.used { background: var(--red); border-color: #7a1d1d; }

.death-save-status {
  font-family: 'MedievalSharp', cursive;
  font-weight: 700;
  font-size: 0.9em;
}
.death-save-status.dead { color: var(--red); }
.death-save-status.stable { color: #2f6f4f; }

.death-save-reset {
  font-size: 0.72em;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid #a98f5c;
  background: transparent;
  cursor: pointer;
}

.condition-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.badge {
  font-size: 0.75em;
  background: var(--red);
  color: #fff;
  padding: 2px 6px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ---------- NPC cards ---------- */

.npc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 10px;
}

.npc-card {
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--gold);
  border-left: 5px solid var(--red);
  border-radius: 6px;
  padding: 10px 14px;
}

.npc-card.ally { border-left-color: var(--green); }

.npc-card .npc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.npc-card .npc-header input[type="text"] {
  font-weight: 700;
  color: var(--maroon);
  border: none;
  background: transparent;
  font-size: 1.05em;
  width: 130px;
  padding: 2px 0;
  border-bottom: 1px dashed transparent;
}
.npc-card .npc-header input[type="text"]:focus { border-bottom: 1px dashed var(--gold); }

.npc-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 0.9em;
}

.npc-stats label {
  display: flex;
  flex-direction: column;
  font-size: 0.78em;
  color: #4a3420;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  gap: 2px;
}

.npc-stats input { width: 100%; }

.npc-condition {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  font-size: 0.85em;
}
.npc-condition label { display: flex; align-items: center; gap: 3px; cursor: pointer; }

.empty-hint {
  font-style: italic;
  color: #7a6444;
  padding: 6px 2px;
}

/* ---------- Name generators ---------- */

.section-hint {
  font-style: italic;
  color: #6b4a2b;
  margin: -6px 0 14px;
  font-size: 0.92em;
}

.generator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.generator-box {
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 12px 16px;
}

.generator-box h3 {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  margin: 0 0 8px;
  font-size: 1.05em;
}

.check-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9em;
}

.generated-result {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.4em;
  color: var(--maroon-dark);
  margin: 10px 0;
  min-height: 1.4em;
}

.generated-history {
  font-size: 0.85em;
  color: #6b4a2b;
  font-style: italic;
  margin-top: 6px;
}

/* ---------- Encounter builder ---------- */

.stacked-label {
  display: flex;
  flex-direction: column;
  font-size: 0.8em;
  color: #4a3420;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  gap: 2px;
}

.xp-thresholds {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.threshold-badge {
  flex: 1 1 120px;
  text-align: center;
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid var(--gold);
  background: rgba(255,255,255,0.35);
}

.threshold-badge .label {
  display: block;
  font-family: 'MedievalSharp', cursive;
  font-size: 0.85em;
  color: var(--maroon);
}

.threshold-badge .value {
  display: block;
  font-size: 1.15em;
  font-weight: 700;
}

.encounter-summary {
  margin-top: 14px;
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 12px 16px;
  line-height: 1.7;
}

.diff-pill {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 12px;
  color: #fff;
  font-weight: 700;
  font-size: 0.95em;
}

.diff-trivial { background: #7a7a7a; }
.diff-easy { background: var(--green); }
.diff-medium { background: #b3841a; }
.diff-hard { background: #b3541a; }
.diff-deadly { background: var(--red); }

#encounterTable input[type="text"] { width: 130px; }
#encounterTable input[type="number"] { width: 60px; }

/* ---------- Taverna Casuale ---------- */

.tavern-sheet {
  margin-top: 14px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.45);
}

.tavern-header {
  border-bottom: 2px double var(--maroon);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.tavern-name {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  font-size: 1.5em;
  margin: 0 0 4px;
}

.tavern-innkeeper {
  font-style: italic;
  color: #4a3420;
}

.tavern-lodging {
  margin: 10px 0;
  font-weight: 600;
  color: var(--maroon-dark);
}

.tavern-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 14px 0;
}

.tavern-columns h4, .tavern-sheet > div > h4 {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  margin: 0 0 6px;
  font-size: 1.05em;
}

.tavern-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tavern-menu-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px dashed #cbb87f;
}

.tavern-price {
  font-weight: 700;
  color: var(--maroon-dark);
  white-space: nowrap;
}

.tavern-npc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.tavern-npc-card {
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.35);
}

.tavern-npc-name {
  font-weight: 700;
  color: var(--maroon);
  margin-bottom: 4px;
}

.tavern-npc-desc {
  font-size: 0.9em;
  line-height: 1.4;
}

.tavern-gossip-list {
  margin: 0;
  padding-left: 20px;
}

.tavern-gossip-list li {
  margin-bottom: 6px;
  line-height: 1.4;
}

/* ---------- Generatore di Tesori ---------- */

.treasure-sheet {
  margin-top: 14px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.45);
}

.treasure-tier {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  font-size: 1.2em;
  margin-bottom: 8px;
}

.treasure-coins {
  font-weight: 600;
  margin-bottom: 10px;
}

.treasure-sheet h4 {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  margin: 10px 0 6px;
  font-size: 1.05em;
}

.treasure-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.treasure-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px dashed #cbb87f;
}

.treasure-value {
  font-weight: 700;
  color: var(--maroon-dark);
  white-space: nowrap;
}

.treasure-total {
  font-weight: 700;
  font-size: 1.1em;
  color: var(--maroon-dark);
  margin-top: 8px;
  border-top: 1px dashed var(--gold);
  padding-top: 8px;
}

.treasure-hint {
  font-style: italic;
  font-size: 0.88em;
  color: #6b4a2b;
  margin-top: 6px;
}

/* ---------- Compendio (Oggetti, Tesori, Mostri persistenti) ---------- */

.compendium-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.monster-gen-card {
  margin-top: 8px;
  margin-bottom: 14px;
}

.monster-gen-source {
  font-style: italic;
  font-size: 0.85em;
  color: #6b4a2b;
  margin-top: 6px;
}

.compendium-card {
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.4);
}

.compendium-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.compendium-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compendium-title-group input[type="text"] {
  font-weight: 700;
  color: var(--maroon);
  width: 160px;
}

.compendium-badge {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--gold);
  color: var(--maroon-dark);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.compendium-badge-rarity {
  background: var(--maroon);
  color: #fff;
}

/* Shared with Rubrica: label used as a block wrapper above a text/textarea input */
.roster-textarea-label {
  display: block;
  margin-top: 8px;
  font-size: 0.8em;
  font-weight: 700;
  color: #4a3420;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.roster-textarea-label textarea,
.roster-textarea-label input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-family: 'EB Garamond', serif;
  font-size: 0.95em;
  resize: vertical;
}

.btn-small-outline {
  background: transparent;
  border: 1px solid var(--maroon);
  color: var(--maroon);
  font-size: 0.8em;
  padding: 3px 8px;
}

/* ---------- Rubrica di PNG e Fazioni ---------- */

.roster-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.roster-card {
  border: 1px solid var(--gold);
  border-left: 5px solid var(--gold);
  border-radius: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.4);
}

.roster-card.roster-alleato { border-left-color: var(--green); }
.roster-card.roster-nemico { border-left-color: var(--red); }
.roster-card.roster-neutrale { border-left-color: #b3841a; }
.roster-card.roster-sconosciuto { border-left-color: #7a7a7a; }

.roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.roster-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.roster-title-group input[type="text"] {
  font-weight: 700;
  color: var(--maroon);
  width: 160px;
}

.roster-type-badge {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--maroon);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.roster-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

.roster-meta label {
  display: flex;
  flex-direction: column;
  font-size: 0.78em;
  color: #4a3420;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  gap: 2px;
}

.roster-meta input[type="text"] { width: 150px; }

/* ---------- Diario di Sessione ---------- */

.session-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.session-card {
  border: 1px solid var(--gold);
  border-left: 5px solid #2f5da0;
  border-radius: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.4);
}

.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.session-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.session-number {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  font-size: 1.05em;
  white-space: nowrap;
}

.session-title-group input[type="text"] {
  font-weight: 700;
  color: var(--maroon-dark);
  width: 220px;
}

.session-card .roster-textarea-label textarea {
  min-height: 110px;
}

/* ---------- Tracker Quest/Obiettivi ---------- */

.quest-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.quest-card {
  border: 1px solid var(--gold);
  border-left: 5px solid var(--gold);
  border-radius: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.4);
}

.quest-card-attiva { border-left-color: #2f5da0; }
.quest-card-sospeso { border-left-color: #b3841a; }
.quest-card-completata { border-left-color: var(--green); }
.quest-card-fallita { border-left-color: var(--red); opacity: 0.85; }

.quest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.quest-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quest-title-group input[type="text"] {
  font-weight: 700;
  color: var(--maroon);
  width: 200px;
}

.quest-status-badge {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  color: #fff;
}

.quest-status-attiva { background: #2f5da0; }
.quest-status-sospeso { background: #b3841a; }
.quest-status-completata { background: var(--green); }
.quest-status-fallita { background: var(--red); }

.quest-objectives {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.quest-objective-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quest-objective-row input[type="text"] {
  flex: 1;
  width: auto;
}

.quest-objective-done input[type="text"] {
  text-decoration: line-through;
  color: #7a6444;
}

.quest-objective-add {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.quest-objective-add input[type="text"] {
  flex: 1;
}

/* ---------- Ordine di Iniziativa ---------- */

.initiative-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.initiative-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border: 1px solid var(--gold);
  border-left: 5px solid var(--gold);
  border-radius: 6px;
  background: rgba(255,255,255,0.35);
}

.initiative-row.initiative-pg { border-left-color: #2f5da0; }
.initiative-row.initiative-ally { border-left-color: var(--green); }
.initiative-row.initiative-enemy { border-left-color: var(--red); }

.initiative-row.initiative-active {
  background: rgba(201,173,106,0.4);
  box-shadow: 0 0 0 2px var(--maroon) inset;
}

.initiative-pos {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon);
  min-width: 24px;
}

.initiative-name {
  font-weight: 700;
  flex: 1;
}

.initiative-init {
  font-size: 0.9em;
  color: #4a3420;
}

.initiative-tag {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--maroon);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ---------- Wild Magic / Eventi Negativi ---------- */

.wm-result-card {
  border: 2px solid var(--gold);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0 18px;
  background: rgba(255,255,255,0.45);
}

.wm-result-header {
  font-family: 'MedievalSharp', cursive;
  color: var(--maroon-dark);
  font-size: 1.05em;
  margin-bottom: 6px;
}

.wm-pagination {
  justify-content: center;
  align-items: center;
  margin-top: 12px;
}

.wm-page-info {
  font-size: 0.9em;
  color: #4a3420;
  min-width: 200px;
  text-align: center;
}

.wm-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wm-result-text {
  font-size: 1.02em;
  line-height: 1.5;
}

.wm-result-card.wm-extreme { border-color: var(--red); }
.wm-result-card.wm-moderate { border-color: #b3841a; }
.wm-result-card.wm-nuisance { border-color: var(--green); }

#wmTable td { font-size: 0.92em; line-height: 1.4; }
#wmFilter { width: 220px; }

.footer-actions {
  text-align: center;
  margin-top: 30px;
  border-top: 3px double var(--maroon);
  padding-top: 20px;
}

.hb-footer {
  text-align: center;
  font-size: 0.8em;
  color: #7a6444;
  margin-top: 14px;
  font-style: italic;
}

@media (max-width: 820px) {
  /* Keep the sticky nav compact on phones/small tablets: a single
     swipeable row instead of wrapping into many rows and permanently
     covering a large chunk of the viewport. */
  .hb-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }
  .hb-nav a {
    flex: 0 0 auto;
  }
}

@media (max-width: 640px) {
  .page { padding: 20px 14px 30px; }
  .hb-title h1 { font-size: 1.9em; }

  /* Enlarge the most-repeated destructive control (row/card delete)
     to a comfortable touch target; other small controls (pips, level
     remove links) stay compact on purpose. */
  .btn-remove {
    min-width: 34px;
    min-height: 34px;
    font-size: 1.3em;
    padding: 4px 8px;
  }
}
