/* Shared visual contract. Loaded after feature styles; never styles terrain/team colors.
   Keep the single wooden navigation and all existing character/item artwork. */
:root {
  --realm-bg: #111722;
  --realm-surface: #202938;
  --realm-raised: #293447;
  --realm-inset: #151d2a;
  --realm-edge: #465166;
  --realm-text: #ece7dc;
  --realm-muted: #adb5c2;
  --realm-gold: #c5a365;
  --realm-danger: #c95650;
  --realm-success: #65b58b;
  --realm-space: 8px;
  --realm-frame: inset 0 0 0 1px #ffffff09, inset 0 0 0 4px #10172266, 0 8px 20px #080d1640;
  --ink: var(--realm-text);
  --muted: var(--realm-muted);
  --paper: var(--realm-surface);
  --paper-deep: var(--realm-inset);
  --line: var(--realm-edge);
  --teal: var(--realm-success);
  --gold: var(--realm-gold);
  --input-surface: var(--realm-inset);
  --shadow: 0 8px 24px #080d164d;
}
body {
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 0, #2b364b 0, transparent 65%), var(--realm-bg);
}
body::before {
  background: none;
}
h1,
h2,
h3,
label {
  color: var(--ink);
}
p,
li {
  overflow-wrap: anywhere;
}
small,
.muted,
.eyebrow {
  color: var(--muted);
}
.ui-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 24px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  pointer-events: none;
}
button > .action-icon {
  width: 19px;
  height: 21px;
}
button:has(> .action-icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.commander-chip {
  background: var(--realm-inset);
  border-color: var(--line);
  color: var(--ink);
  border-radius: 6px;
  box-shadow: inset 0 1px #ffffff0a;
}
.commander-chip small {
  color: var(--muted);
}
.workspace-heading h1 {
  font-size: clamp(23px, 3vw, 30px);
}
.workspace-heading {
  border-bottom: 1px solid #46516670;
  margin-bottom: 24px;
}
/* Metal frame. */
.panel,
.ref-wood,
.ref-stone,
.gate-card,
.battle-feeds,
.room-header {
  position: relative;
  background: linear-gradient(135deg, #ffffff04, transparent 40%), var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px 3px 10px 3px;
  box-shadow: var(--realm-frame);
}
.panel > h2 {
  color: var(--ink);
  background: linear-gradient(90deg, #202938, #2e394b);
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
  min-height: 62px;
}
.panel > h2 .ui-icon,
.ref-plaque .ui-icon {
  color: var(--gold);
}
.panel-body {
  padding: 24px;
}
.ref-wood,
.ref-stone {
  margin: 0 0 24px;
  padding: 24px;
}
.ref-plaque,
.ref-plaque.brown {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  width: fit-content !important;
  margin: 0 0 24px;
  padding: 10px 16px;
  transform: none;
  color: var(--ink) !important;
  background: linear-gradient(#344055, #232d3d);
  border: 1px solid #647087;
  border-inline-start: 3px solid var(--gold);
  border-radius: 3px;
  box-shadow:
    inset 0 1px #ffffff10,
    0 3px 0 #111722;
  font-size: 19px !important;
}
.ref-stat,
.economy-summary > div,
.skills-grid > div {
  background: var(--realm-inset);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: inset 0 1px #ffffff06;
  padding: 12px;
}
.economy-summary small {
  color: var(--muted);
}
.ref-stat .ui-icon {
  color: var(--gold);
  width: 26px;
  height: 28px;
}
.ref-stat b,
.economy-summary b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.hero-reference-main {
  background: var(--realm-inset);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: none;
}
.hero-reference-main > h3 {
  background: var(--realm-raised);
  border-bottom: 2px solid var(--gold);
  color: var(--ink);
  border-radius: 3px;
}
.ref-hero-stats {
  gap: 12px;
}
.ref-vitals meter {
  accent-color: var(--realm-success);
}
.ref-hero-actions {
  gap: 12px;
}
.hero-reference-slot button {
  border: 1px solid var(--line);
  background: var(--realm-inset);
  border-radius: 6px;
}
.hero-reference-slot.selected button {
  border: 2px solid var(--gold);
  background: #352f25;
}
/* Cards have a consistent baseline, selected state and quieter inner surface. */
.hero-choice,
.hero-choice.is-locked,
.item-card,
.spell-card,
.mode-card,
.alliance-card,
.gem-package,
.race-grid > div,
.training-tier,
.training-tier.locked,
.room-commander,
.room-map {
  background: linear-gradient(155deg, #2b3647, #192231);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px 3px 8px 3px;
  box-shadow: inset 0 1px #ffffff0a;
}
.hero-choice.is-active,
.item-card.equipped,
.spell-loadout-slot.is-chosen .spell-loadout-pick {
  border-color: var(--gold);
  background: linear-gradient(155deg, #38352e, #1b2532);
  box-shadow: inset 0 0 0 1px #c5a36566;
}
.hero-choice p,
.item-card p,
.item-card small,
.alliance-card p,
.race-grid p,
.gem-package small {
  color: var(--muted);
}
.hero-choice > a,
.item-card .text-button {
  color: #e4c68d;
}
.hero-choice,
.item-card {
  padding: 20px;
}
.spell-card {
  padding: 20px;
  gap: 12px;
}
.spell-card.is-owned,
.room-commander.is-ready {
  border-color: var(--realm-success);
}
.spell-icon {
  border-color: var(--line);
  border-radius: 6px;
  background: var(--realm-inset);
}
.spell-card footer {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.spell-loadout-pick,
.spell-choice,
.spell-hero-picker a,
.spell-detail,
.spell-hint,
.spell-track {
  background: var(--realm-inset);
  border-color: var(--line);
  color: var(--ink);
}
.spell-bar {
  background: var(--paper);
  border-color: var(--line);
}
.spell-slot.is-ready {
  border-color: var(--gold);
}
.spell-slot.is-targeting {
  border-color: #ead2a1;
  box-shadow: 0 0 0 2px #c5a36566;
}
.store-tabs {
  flex-wrap: wrap;
  gap: 8px;
}
.store-tabs a,
.inventory-category-links a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
}
.store-tabs a.active,
.spell-hero-picker a.active,
.training-tabs .is-selected,
.battle-feed-tabs [aria-selected='true'] {
  background: #393326;
  border-color: var(--gold);
  color: #ffe0a4;
  box-shadow: inset 0 -2px var(--gold);
}
.training-tabs button {
  background: var(--realm-inset);
  color: var(--ink);
}
.training-tier.locked {
  opacity: 0.7;
}
/* Buttons: gold primary, steel secondary, red only for destructive actions. */
button,
.button {
  background: linear-gradient(#344156, #253043);
  border: 1px solid #617087;
  border-bottom-color: #39465a;
  border-radius: 5px 2px 5px 2px;
  color: var(--ink);
  box-shadow:
    inset 0 1px #ffffff0e,
    0 2px 0 #090e1880;
  min-height: 44px;
  transition:
    background-color 160ms,
    border-color 160ms,
    box-shadow 160ms;
}
button.primary,
.button.primary,
.gate-card .primary,
.battle-entry-tabs .primary {
  color: #211b12;
  background: linear-gradient(#dfc38a, #c5a365);
  border-color: #efd8a4;
  border-bottom-color: #8e7040;
  box-shadow:
    inset 0 1px #fff0c250,
    0 2px 0 #4c3b24;
  font-weight: 700;
}
button.danger,
.button.danger,
.room-leave {
  color: #ffe3df;
  background: linear-gradient(#743c3d, #512a31);
  border-color: var(--realm-danger);
}
button.ghost,
.text-button {
  color: #dfc58f;
  background: transparent;
  box-shadow: none;
}
button:disabled {
  opacity: 0.55;
  filter: saturate(0.4);
  cursor: not-allowed;
  box-shadow: none;
}
button:disabled:hover {
  transform: none;
  filter: saturate(0.4);
}
button:not(:disabled):hover,
.button:hover {
  border-color: var(--gold);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid #efd8a4;
  outline-offset: 3px;
}
input:not([type='checkbox']):not([type='range']),
select,
textarea,
.gate-card input:not([type='checkbox']):not([type='range']),
.gate-card select {
  background: var(--input-surface);
  border-color: #68758b;
  color: var(--ink);
  border-radius: 5px;
  box-shadow: inset 0 2px 3px #0003;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}
select option {
  background: var(--realm-inset);
  color: var(--ink);
}
input[type='checkbox'],
input[type='range'] {
  accent-color: var(--gold);
}
.form-error {
  color: #ffaaa2;
}
.badge {
  background: #293647;
  border-color: #62718a;
  color: #e3e8f0;
  border-radius: 4px;
}
.badge.gold {
  background: #443824;
  border-color: #a58b56;
  color: #f4d99d;
}
.badge.green {
  background: #203f35;
  border-color: #559b78;
  color: #b8ebcf;
}
.notice {
  background: #3b3325;
  border-color: #a58b56;
  color: #f3dfb8;
}
.empty,
.empty .icon {
  color: var(--muted);
}
.filter-bar,
.stat-strip,
.section-heading,
.barracks-figure,
.battle-entry-rules,
.battle-entry-button,
.ref-map-preview,
.arena-scene,
.duel-round,
.result-banner,
.dialog-nav a,
.stage-list > div {
  background: var(--paper-deep);
  border-color: var(--line);
  color: var(--ink);
}
.result-banner h2,
.big-number,
.economy-row b {
  color: var(--gold);
}
.economy-row.total b {
  color: #a2dfbc;
}
.list-row,
.history-row,
.topic-row,
.message-row,
.mission-row,
.training-row,
.activity-list li,
.economy-row {
  border-color: var(--line);
}
.activity-list li > span {
  color: var(--muted);
}
table {
  background: var(--paper-deep);
  color: var(--ink);
}
.table-scroll {
  border-color: var(--line);
}
th {
  background: #2d384a;
  color: #e7d3ac;
  border-color: var(--line);
}
td {
  color: var(--ink);
  border-color: var(--line);
}
tbody tr:nth-child(even) {
  background: #232e40;
}
/* Battle furniture only: don't override SVG terrain, fog, ownership or targeting. */
.map-panel {
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.battle-resources,
.battle-orders,
.field-command-bar {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
.battle-resources small,
.field-hint {
  color: var(--muted);
}
.battle-orders hr,
.battle-orders details,
.participant,
.event-log p {
  border-color: var(--line);
}
.event-log time,
.chat-log time {
  color: var(--muted);
}
.chat-log p {
  background: var(--realm-inset);
  color: var(--ink);
}
.room-header {
  background: linear-gradient(110deg, #303b4e, #202938);
}
.room-code {
  border-radius: 4px;
}
.room-offline {
  background: #512a31;
  border-color: var(--realm-danger);
  color: #ffe3df;
}
.room-countdown {
  background: #403626;
  box-shadow: inset 0 0 0 1px #c5a36544;
}
dialog,
dialog.training-modal {
  background: var(--paper);
  border: 2px solid #758096;
  color: var(--ink);
  border-radius: 8px 3px 8px 3px;
  box-shadow:
    var(--realm-frame),
    0 24px 80px #0008;
}
dialog::backdrop {
  background: #090e18c9;
}
dialog h2 {
  color: var(--ink);
  border-color: var(--line);
}
.dialog-close,
.training-modal .dialog-close {
  background: #293447;
  border-color: var(--line);
  color: var(--ink);
}
#toast {
  background: #203e34;
  border-color: #65b58b;
  color: #dcf2e7;
}
#toast.error {
  background: #512a31;
  border-color: var(--realm-danger);
  color: #ffe3df;
}
.gate-card h2 {
  color: var(--ink);
}
.gate-card .eyebrow,
.gate-card .demo-hint,
.demo-hint {
  color: var(--muted);
}
.public-preview {
  background: #111722ed;
}
.classic-screen-links a {
  background: var(--paper);
  border-color: var(--line);
}
@media (max-width: 550px) {
  .ref-wood,
  .ref-stone,
  .panel-body {
    padding: 16px;
  }
  .panel > h2 {
    padding: 14px 16px;
  }
  .ref-plaque {
    font-size: 17px !important;
    padding: 9px 12px;
    margin-bottom: 20px;
  }
  .ref-stat {
    padding: 8px;
    gap: 6px;
  }
  .ref-stat .ui-icon {
    width: 22px;
    height: 24px;
  }
  .hero-choice,
  .item-card,
  .spell-card {
    padding: 16px;
  }
  .training-tabs button {
    padding: 8px 4px;
  }
  .training-tabs .action-icon {
    display: none;
  }
  .hero-reference-layout {
    gap: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  button,
  .button,
  .spell-slot,
  .hero-choice {
    transition: none;
    animation: none;
  }
}
.hero-skill-table th > .ui-icon {
  width: 20px;
  height: 22px;
  margin-inline-end: 8px;
  color: var(--gold);
}
.hero-level {
  padding: 12px 16px;
  background: var(--realm-inset);
  border-inline-start: 3px solid var(--gold);
  border-radius: 3px;
}
.hero-level-next {
  margin: 16px 0;
}
.progress i {
  background: linear-gradient(90deg, #8e7040, #dfc38a);
}
.ref-vitals meter::-webkit-meter-bar {
  background: #111722;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.ref-vitals meter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, #38785a, #65b58b);
  border-radius: 4px;
}
.ref-vitals meter::-moz-meter-bar {
  background: #65b58b;
  border-radius: 4px;
}
@media (max-width: 550px) {
  .mode-grid:has(> .gem-package) {
    grid-template-columns: minmax(0, 1fr);
  }
  .gem-package {
    min-width: 0;
  }
  .gem-package button {
    max-width: 100%;
  }
}
.troop-ref-row,
.ref-weapon-skills > div {
  background: var(--realm-inset);
  border-color: var(--line);
  color: var(--ink);
}
.barracks-capacity,
.barracks-stock {
  background: var(--realm-inset);
  border-color: var(--line);
}
.hero-label,
.spell-mini {
  border-radius: 4px;
}

/* Permanent skill progress: raw value / this level's cap, never spell bonuses. */
.ref-stat[data-hero-skill] {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 16px;
}
.hero-skill-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-skill-heading > b {
  font-size: 15px;
  text-align: start;
}
.hero-skill-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}
.hero-skill-progress {
  min-width: 105px;
  width: 100%;
}
.hero-skill-progress-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.hero-skill-progress-label b {
  font-size: 15px;
  min-width: 0;
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: isolate;
}
.hero-skill-progress-label > span {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hero-skill-progress progress {
  display: block;
  width: 100%;
  height: 12px;
  margin-top: 6px;
  accent-color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--realm-inset);
}
.hero-skill-progress progress::-webkit-progress-bar {
  background: var(--realm-inset);
}
.hero-skill-progress progress::-webkit-progress-value {
  background: linear-gradient(90deg, #8e7040, #dfc38a);
}
.hero-skill-progress progress::-moz-progress-bar {
  background: #c5a365;
}
.skill-full {
  color: #a2dfbc;
}
.skill-equipment {
  color: #dfc58f;
}
.hero-skill-table td:has(.hero-skill-progress) {
  min-width: 125px;
}
@media (max-width: 550px) {
  .ref-stat[data-hero-skill] {
    padding: 12px;
  }
  .ref-hero-stats:has([data-hero-skill]) {
    grid-template-columns: minmax(0, 1fr);
  }
  .hero-skill-table th > .ui-icon {
    display: none;
  }
  .hero-skill-table td,
  .hero-skill-table th {
    padding: 10px 6px;
  }
  .hero-skill-table th:nth-child(5),
  .hero-skill-table td:nth-child(5) {
    display: none;
  }
  .hero-skill-table .action-icon {
    display: none;
  }
}

/* Roster previews use the same six canonical skills, even before a hero is unlocked. */
.hero-specialization {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  background: #c5a36510;
  border: 1px solid #c5a36566;
  border-inline-start: 3px solid var(--gold);
  border-radius: 4px;
  text-align: start;
}
.hero-specialization > .ui-icon {
  color: var(--gold);
}
.hero-specialization small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.9;
}
.hero-roster-stats {
  width: 100%;
  text-align: start;
  margin: 12px 0;
}
.hero-mini-skills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 10px 0;
}
.hero-mini-skill {
  min-width: 0;
  padding: 8px;
  background: var(--realm-inset);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.hero-mini-skill.is-specialty {
  border-color: var(--gold);
}
.hero-mini-skill > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 12px;
}
.hero-mini-skill b {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.hero-mini-skill progress {
  display: block;
  width: 100%;
  height: 7px;
  margin-top: 6px;
  accent-color: var(--gold);
  border: 0;
  background: var(--realm-bg);
}
.hero-mini-skill progress::-webkit-progress-bar {
  background: var(--realm-bg);
}
.hero-mini-skill progress::-webkit-progress-value {
  background: var(--gold);
}
.hero-mini-skill progress::-moz-progress-bar {
  background: var(--gold);
}
.hero-level-reference {
  margin-top: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.hero-level-reference summary {
  cursor: pointer;
  color: #dfc58f;
  min-height: 44px;
}
.hero-level-reference .table-scroll {
  margin-top: 12px;
}
.hero-level-reference th,
.hero-level-reference td {
  white-space: nowrap;
  padding: 10px 12px;
}
.hero-level-reference .is-current-level {
  outline: 1px solid var(--gold);
  outline-offset: -1px;
}
@media (max-width: 550px) {
  .hero-mini-skills {
    gap: 8px;
  }
  .hero-level-reference {
    padding: 10px;
  }
}
@media (max-width: 650px) {
  .hero-choice {
    display: flex;
    align-items: stretch;
    text-align: center;
    gap: 10px;
  }
  .hero-choice > .hero-choice-art {
    width: 100%;
    height: 210px;
    margin: 0;
    align-self: center;
  }
  .hero-choice > .badge {
    align-self: center;
  }
  .hero-choice > .hero-choice-vitals {
    justify-content: center;
  }
  .hero-choice > .hero-specialization,
  .hero-choice > .hero-roster-stats {
    width: 100%;
  }
}

/* Hero roster: the corner button opens a card's six skills; the guide sits at the page bottom. */
.hero-choice {
  position: relative;
}
.hero-choice > .hero-skill-toggle {
  /* A small round corner button, opposite the card's status badge; theme card buttons are full width. */
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px !important;
  max-width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #c9a35c;
  background: #141c27e6;
  color: #f3d58a;
}
.hero-choice > .hero-skill-toggle[aria-expanded='true'] {
  background: #c9a35c;
  color: #141c27;
}
.hero-skill-toggle .icon {
  width: 22px;
  height: 22px;
}
.hero-mini-help {
  display: block;
  margin-top: 2px;
  color: #a9b5c7;
  font-size: 12px;
  line-height: 1.7;
}
.hero-skill-guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin: 0;
}
.hero-skill-guide > div {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #ffffff1f;
  background: #0b1219a6;
}
.hero-skill-guide dt {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f1e3c0;
}
.hero-skill-guide dt .icon {
  width: 22px;
  height: 22px;
}
.hero-skill-guide dd {
  margin: 6px 0 0;
  color: #c9d3de;
  line-height: 1.8;
}
