@font-face {
  font-family: "Fusion Pixel";
  src: url("./assets/fonts/fusion-pixel-12px-proportional-zh_hans.otf.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --pixel-font: "Fusion Pixel", "Microsoft YaHei", sans-serif;

  --pixel-ink: #382b22;
  --pixel-paper: #f5e7c9;
  --pixel-surface: #fff3d5;
  --pixel-edge: #ae8054;
  --pixel-shadow: #9f7447;
  --pixel-focus: #e7a95a;
  --pixel-panel: #fff3d5;
  --pixel-timber: #efd5a5;
}

html body { font-family: var(--pixel-font); font-synthesis: none; }
h1, h2, h3, h4, nav a, .tab-btn, .dw-btn, .button, .main-title, .level-badge {
  font-family: var(--pixel-font);
  font-weight: 400;
  font-synthesis: none;
}

button, input, select, textarea { font-family: inherit; }
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--pixel-focus);
  outline-offset: 3px;
}

:where(button, .button, .action, .tab-btn, input, select, textarea) {
  border-radius: 0;
}

body:has(.route) { color: var(--pixel-ink); background: var(--pixel-paper); }
body:has(.route) main { background: var(--pixel-paper); }
body:has(.route) header { background: var(--pixel-surface); border-color: var(--pixel-edge); }
body:has(.route) header strong { font-family: var(--pixel-font); font-weight: 400; }
body:has(.route) nav { background: var(--pixel-timber); border-color: var(--pixel-edge); }
body:has(.route) nav a { color: var(--pixel-ink); border-color: var(--pixel-edge); }
body:has(.route) nav a:is(:hover, [aria-current="page"]) { background: #f5c77e; box-shadow: inset 0 -3px #a76232; }
.portal-brand { display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem 1rem; }
.portal-library, .home .button {
  display: inline-block;
  padding: .45rem .85rem;
  background: #f6c87e;
  border: 1px solid #a16c42;
  box-shadow: 2px 2px 0 var(--pixel-shadow);
  color: #511f1c;
  font-family: var(--pixel-font);
  text-decoration: none;
}
.portal-library:hover, .home .button:hover { background: #ffde9c; color: #511f1c; }
body:has(.route) .home { justify-content: end; padding: clamp(1rem, 4vw, 3.5rem); }
body:has(.route) .hero-copy {
  margin: 0;
  padding: clamp(1rem, 3.5vw, 2.4rem);
  max-width: 34rem;
  color: var(--pixel-ink);
  background: #fff0cdef;
  border: 2px solid #ac8052;
  box-shadow: 5px 5px 0 #77503399, inset 0 0 0 3px #ffeab8;
}
.hero-copy .eyebrow { color: #84422b; }
.route :is(.panel, .paper, .box, .version, .ability, .community),
.srd-modal-card, .srd-subclass-card {
  border-radius: 0;
  box-shadow: 3px 3px 0 #93663f55, inset 0 0 0 2px #c69b6a55;
}
.route :is(.button, button), .srd-modal-card :is(button, input, select) { border-radius: 0; }

[hidden] { display: none !important; }

body.game-entry {
  margin: 0;
  min-height: 100svh;
  background: #322720;
  color: #fff1d6;
}
.game-entry *, .game-entry *::before, .game-entry *::after { box-sizing: border-box; }
.entry-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem clamp(1rem, 4vw, 4rem);
  border-bottom: 2px solid #a77343;
  background: #f4dfb4;
  color: #44281c;
}
.entry-brand {
  color: inherit;
  text-decoration: none;
  font: 1.4rem var(--pixel-font);
  letter-spacing: .06em;
}
.entry-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 26rem);
  align-items: center;
  gap: clamp(2rem, 8vw, 9rem);
  min-height: calc(100svh - 64px);
  padding: clamp(2rem, 7vw, 7rem);
  background:
    linear-gradient(90deg, #1e15139c, #2f1c1433 46%, #201712ce),
    linear-gradient(0deg, #1f1614bb, transparent 44%),
    url("./assets/game-entry.jpg") center 38% / cover no-repeat;
}
.entry-title {
  align-self: end;
  max-width: 38rem;
  padding-bottom: clamp(1rem, 5vh, 4rem);
  text-shadow: 3px 4px 0 #251711;
}
.entry-title p {
  display: inline-block;
  margin: 0 0 .7rem;
  padding: .3rem .65rem;
  border: 1px solid #bf9159;
  color: #f8d89b;
  background: #39241cd9;
  font: 1rem var(--pixel-font);
}
.entry-title h1 {
  margin: 0;
  color: #ffe2a6;
  font-size: clamp(3rem, 9vw, 7.5rem);
  line-height: 1.1;
}
.entry-panel {
  padding: clamp(1.4rem, 3vw, 2.3rem);
  color: #45291e;
  background: #fff1d2;
  border: 3px solid #71472c;
  box-shadow: inset 0 0 0 3px #ca9b60, inset 0 0 0 6px #f8d99d, 5px 5px 0 #2a1a14aa;
}
.entry-panel h2 { margin: 0 0 1.4rem; font-size: 1.75rem; }
.entry-panel form, .entry-panel label { display: grid; gap: .45rem; }
.entry-panel form { gap: 1rem; }
.entry-panel label { font-size: .95rem; }
.entry-panel input {
  width: 100%;
  min-height: 2.75rem;
  padding: .55rem .7rem;
  background: #fff9ea;
  border: 1px solid #a97d52;
  color: #34251e;
  font: inherit;
}
.entry-primary, .entry-back {
  display: inline-grid;
  place-items: center;
  min-height: 2.75rem;
  padding: .45rem .8rem;
  border: 2px solid #a6764a;
  font: 1rem var(--pixel-font);
  text-decoration: none;
  cursor: pointer;
}
.entry-primary {
  width: 100%;
  margin-top: .35rem;
  border-color: #b77a48;
  background: #862f29;
  color: #fff1d6;
  box-shadow: inset 0 0 0 2px #d29154, 2px 3px 0 #97704b;
}
.entry-primary:hover { background: #a74635; }
.entry-primary:disabled { opacity: .65; cursor: wait; }
.entry-back { color: #532e1f; background: #f5deb0; }
.entry-back:hover { background: #ffe9b9; }
#signed .entry-back { width: 100%; margin-top: .8rem; }
.entry-panel #status { margin: .85rem 0 0; color: #863429; }
.entry-panel #status:empty { display: none; }

@media (max-width: 760px) {
  .entry-stage { grid-template-columns: minmax(0, 1fr); gap: 1.4rem; padding: 2rem 1rem; background-position: center, center, 40% center; }
  .entry-title { align-self: end; padding-bottom: 0; }
  .entry-panel { max-width: 30rem; width: 100%; }
}

.dw-theme {
  --font-serif: var(--pixel-font);
  --font-sans: var(--pixel-font);
  --font-mono: var(--pixel-font);
  --font-header: var(--pixel-font);
  color-scheme: light;
  --bo3-primary: #9b3f32;
  --bo3-primary-hover: #ad503a;
  --bg-dark: var(--pixel-paper);
  --bg-header: var(--pixel-timber);
  --bg-card: var(--pixel-panel);
  --bg-surface: #f8e4bf;
  --bg-input: #fff8e7;
  --bg-hover: #f8d792;
  --border-bo3: #ae8054;
  --border-subtle: #c8a377;
  --text-main: var(--pixel-ink);
  --text-muted: #725f4b;
  --text-gold: #885224;
  --text-red: #9b3f32;
  --text-blue: #395a70;
}

.dw-theme :is(
  .dw-header, .vault-hero-banner, .vault-char-card, .creation-panel, .resource-card,
  .defense-stats-box, .paperdoll-container, .gear-slot, .weapon-slot, .slot-icon-box,
  .attr-card, .bag-equipment-panel, .bag-slot-card, .inventory-grid-panel, .grid-cell,
  .currency-card, .levelup-bottom-bar, .armor-formula-card, .f-card, .dh-card,
  .dw-modal-window, .picker-item-card, .level-dialog, .ws-workbench, .ws-preview-box
) {
  border-radius: 0;
  box-shadow: 3px 3px 0 #ae805466, inset 0 0 0 2px #d0a56f55;
}
.dw-theme :is(.dw-header, .vault-hero-banner, .ws-page-hero, .combat-dashboard, .page-tabs) {
  background: var(--pixel-timber);
  color: var(--pixel-ink);
}
.dw-theme .vault-hero-content h1 { color: var(--pixel-ink); }
.dw-theme .vault-layout-grid { grid-template-columns: minmax(13rem, 19rem) minmax(0, 1fr); gap: 1.2rem; }
.dw-theme .vault-creator-section { max-width: 46rem; }
.dw-theme .vault-cards-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: .55rem;
}
.vault-choice {
  min-height: 2.75rem;
  padding: .65rem .8rem;
  text-align: start;
  background: var(--pixel-surface);
  border: 1px solid var(--pixel-edge);
  color: var(--pixel-ink);
  cursor: pointer;
}
.vault-choice[aria-pressed="true"] { background: #f3cb8e; border-left: 5px solid #9b3f32; }
.vault-preview {
  min-width: 0;
  min-height: 25rem;
  padding: 1rem;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  background: radial-gradient(ellipse at 50% 38%, #fff5db 0%, #ead4ae 58%, #c6a77d 100%);
  border: 3px solid #805033;
  box-shadow: inset 0 0 0 2px #d2a56c, 3px 4px 0 #b9915d;
}
.vault-preview canvas { width: min(100%, 256px); height: auto; image-rendering: pixelated; }
.vault-preview-footer {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem;
  padding: .75rem;
  background: #fff1d5;
  color: var(--pixel-ink);
  border: 2px solid var(--pixel-edge);
}
.vault-preview-footer > div { margin-inline-end: auto; }
.vault-preview-footer :is(h2, p) { margin: 0; }
.vault-preview-footer summary { cursor: pointer; }
.dw-theme :is(.vault-char-card, .vault-create-card, .creator-card) {
  background: #fff2d4;
  color: var(--pixel-ink);
  border: 2px solid #8e613b;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px #c69758, 2px 3px 0 #ba9367;
}
.dw-theme .vault-char-card { padding: .4rem; gap: .45rem; }
.dw-theme .vault-char-card.active-char { border-color: #a7553f; }
.dw-theme .vcard-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; }
.dw-theme .vcard-avatar {
  width: 100%;
  height: 9.5rem;
  background: #f4e4c1;
  border: 0;
  border-bottom: 1px solid #bd935f;
  border-radius: 0;
  box-shadow: none;
}
.dw-theme .vcard-avatar canvas { width: 128px; height: 128px; image-rendering: pixelated; }
.dw-theme .vcard-meta { padding: .2rem .25rem; }
.dw-theme .vcard-name-row, .dw-theme .vcard-tags { flex-wrap: wrap; }
.dw-theme .vcard-actions { margin-top: auto; }
.dw-theme :is(.vcard-btn-enter, .vcard-btn-icon) {
  background: #f6dfb4;
  border: 1px solid #ae8054;
  border-radius: 0;
  color: #5b3023;
}
.dw-theme .vcard-btn-enter:hover { background: #f5c77e; }
.dw-theme .vault-create-card {
  padding: .8rem;
  min-height: 3.25rem;
  display: grid;
  place-content: center;
  gap: .4rem;
  cursor: pointer;
  font: 1.05rem var(--pixel-font);
}
.dw-theme .vault-create-card span { font-size: 1.8rem; }
.dw-theme .vault-create-card:hover { background: #ffe4ae; }
.dw-theme .vault-switcher-pill { border-radius: 0; }
.dw-theme :is(.paperdoll-container, .dw-modal-window, .more-dropdown, .ws-workbench, .ws-preview-box) {
  background: var(--pixel-panel);
  color: var(--pixel-ink);
}
.dw-theme #paperdoll { background: radial-gradient(ellipse, #ffe9b3, #e7c38c 75%); border-color: #a67a4a; box-shadow: 3px 3px 0 #b48758; }
.dw-theme :is(.dw-btn-gold, .tab-btn.active, .res-btn, .stepper-btn) {
  background: #f6c87e;
  color: #511f1c;
  text-shadow: none;
}
.dw-theme :is(.dw-btn, .tab-btn, .res-btn, .stepper-btn):hover { color: #511f1c; background: #ffde9c; }
.dw-theme :is(.gender-badge, .sync-badge) .status-dot { color: #3e7035; }
.dw-theme .sync-badge.offline .status-dot { color: #9b3f32; }

.dw-theme :is(.dw-btn, .res-btn, .stepper-btn, .tab-btn, .roll-trigger-btn, .dw-input, .dw-select, .dw-textarea, .coin-input) {
  border-radius: 0;
}
.dw-theme :is(.dw-btn, .res-btn, .stepper-btn, .tab-btn, .roll-trigger-btn) { box-shadow: 2px 2px 0 #ad805566; }
.dw-theme .tab-btn.active { box-shadow: inset 0 -3px var(--pixel-focus); }
.dw-theme .avatar-tag { flex-wrap: wrap; }
.dw-theme .avatar-tag :is(.gender-badge, .ancestry-badge, .class-badge, .level-badge) {
  padding: 3px 7px;
  border: 1px solid var(--border-bo3);
  border-radius: 0;
  background: var(--pixel-surface);
  color: var(--pixel-ink);
}
.dw-theme .ancestry-badge { color: var(--text-muted); }
.dw-theme .resource-tracks-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dw-theme .resource-card { grid-column: span 2; }
.dw-theme .defense-stats-box { grid-column: span 4; align-items: center; }
.life-thresholds {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .65rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border-bo3);
  color: var(--text-muted);
  font-size: .82rem;
}
.life-thresholds strong { color: var(--text-gold); }
.quick-value { display: inline-flex; align-items: center; }
.quick-value button {
  min-width: 1.65rem;
  min-height: 1.8rem;
  background: var(--bg-input);
  color: var(--text-gold);
  border: 1px solid var(--border-bo3);
  cursor: pointer;
}
.dw-theme .quick-value input { width: 2.9rem; padding: .25rem; text-align: center; }
.limit-control { color: var(--text-muted); font-size: .82rem; }
.dw-theme .overview-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); }
.dw-theme .attr-stepper { flex-wrap: wrap; justify-content: end; }
.dw-theme input.attr-mod {
  width: 3rem;
  border: 1px solid var(--border-bo3);
  background: var(--bg-input);
  color: var(--text-gold);
  font-size: .9rem;
  text-align: center;
}
.trait-mark { color: var(--text-muted); font-size: .82rem; white-space: nowrap; }
.wallet-section h3 { margin: 0 0 .55rem; }
.dw-theme .wallet-section .currency-panel { margin: 0; }
.dw-theme .wallet-section .currency-card { justify-content: space-between; }
.wallet-section small { display: block; margin-top: .4rem; color: var(--text-muted); }
.dw-theme .inventory-container { margin-top: .8rem; }
#inventory-space-note { color: var(--text-muted); }
.inventory-overflow { margin-top: .8rem; }

@media (max-width: 1100px) {
  .dw-theme .overview-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  body:has(.route) .home { justify-content: start; }
  .dw-theme .vault-layout-grid { grid-template-columns: minmax(0, 1fr); }
  .vault-preview { min-height: 18rem; }
  .dw-theme .vcard-actions { flex-wrap: wrap; }
  .dw-theme .vcard-avatar { height: 7.25rem; }
  .dw-theme .vcard-avatar canvas { width: 96px; height: 96px; }
  .dw-theme .resource-tracks-grid { grid-template-columns: minmax(0, 1fr); }
  .dw-theme .resource-card, .dw-theme .defense-stats-box { grid-column: auto; }
  .dw-theme .defense-stats-box { flex-wrap: wrap; gap: .7rem; }
  .dw-theme .wallet-section .currency-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dw-theme .wallet-section .currency-card { padding: .35rem; gap: .25rem; }
  .dw-theme .wallet-section .coin-input { width: 100%; min-width: 0; }
}
.gear-effect-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: .65rem;
  margin-block: .65rem;
}
.gear-effect-fields label { display: grid; gap: .25rem; }

.dw-theme [data-quality="white"] { --gear-edge: #a89677; --gear-fill: #fff8e7; }
.dw-theme [data-quality="green"] { --gear-edge: #648051; --gear-fill: #e8f0d4; }
.dw-theme [data-quality="blue"] { --gear-edge: #4e7c9e; --gear-fill: #dfedf5; }
.dw-theme [data-quality="purple"] { --gear-edge: #8b5a9e; --gear-fill: #efe2f4; }
.dw-theme [data-quality="orange"] { --gear-edge: #b96a32; --gear-fill: #ffe8c7; }
.dw-theme [data-quality="red"] { --gear-edge: #aa4e4a; --gear-fill: #f8ddda; }
.dw-theme [data-quality] {
  border-color: var(--gear-edge);
  background: linear-gradient(145deg, #fff8e7, var(--gear-fill));
  box-shadow: inset 0 0 0 1px var(--gear-edge);
}
.dw-theme [data-suit-tier="1"] { --suit-metal: #4f5159; --suit-glow: #50576655; }
.dw-theme [data-suit-tier="2"] { --suit-metal: #a56843; --suit-glow: #c97f4c77; }
.dw-theme [data-suit-tier="3"] { --suit-metal: #778c9e; --suit-glow: #95aecf88; }
.dw-theme [data-suit-tier="4"] { --suit-metal: #b28131; --suit-glow: #e7b450aa; }
.dw-theme [data-suit-tier] {
  outline: 1px solid var(--suit-metal);
  outline-offset: 2px;
  box-shadow: inset 0 0 0 1px var(--gear-edge), inset 0 0 12px var(--suit-glow), 0 0 8px var(--suit-glow);
}
.dw-theme [data-suit-tier]:focus-visible { outline: 2px solid var(--pixel-focus); }
