:root {
  color-scheme: dark;
  --bg: #110f0d;
  --panel: #1b1612;
  --field: #14110e;
  --gold: #c8a458;
  --light-gold: #efd69c;
  --ink: #f2e9d8;
  --muted: #bdae98;
  --line: #493826;
  --display: "Songti TC", "Noto Serif CJK TC", "PMingLiU", Georgia, serif;
  font: 16px/1.55 system-ui, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, dl { margin: 0; }
h1, h2, h3 { font-family: var(--display); line-height: 1.25; }
a { color: var(--light-gold); }
button, input, select { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--light-gold); outline-offset: 3px; }
.wrap { width: min(1240px, 100% - 64px); margin-inline: auto; }
.skip { position: absolute; top: 8px; left: 8px; z-index: 2; padding: 10px; background: var(--field); }
.skip:not(:focus) { clip-path: inset(50%); }

.masthead {
  border-top: 2px solid #7b5b33;
  background:
    linear-gradient(90deg, #170f0bea 18%, #1a120df2 36%, #1a110f5c 75%, #110f0dbf),
    url("/assets/ui/login_bg.webp") right 40% / max(740px, 65%) auto no-repeat, #1b130f;
}
.masthead-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding-block: 31px 20px;
}
.identity { display: flex; align-items: center; gap: 20px; min-width: 0; }
.crest {
  flex: 0 0 46px;
  aspect-ratio: 1;
  transform: rotate(45deg);
  border: 1px solid var(--gold);
  outline: 1px solid #77532d;
  outline-offset: 4px;
  background: linear-gradient(140deg, #5b3822, #20140e 72%);
  box-shadow: inset 0 0 0 4px #20140e, 0 3px 15px #090706b3;
  position: relative;
}
.crest::after {
  content: "";
  position: absolute;
  inset: 8px;
  transform: rotate(-45deg);
  background: url("/assets/ui/icon_adena.webp") center / contain no-repeat;
}
.brand { color: var(--light-gold); font-size: .82rem; letter-spacing: .2em; margin-bottom: 5px; }
h1 { font-size: clamp(1.75rem, 4.1vw, 3.4rem); color: #f8e6bd; letter-spacing: .06em; text-shadow: 0 2px 12px #0a0705; }
.play {
  display: inline-flex;
  justify-content: space-between;
  align-items: center;
  min-height: 46px;
  gap: 16px;
  padding: 7px 14px;
  text-decoration: none;
  font-weight: 650;
  border: 1px solid var(--gold);
  background: linear-gradient(#604327, #342317);
  box-shadow: inset 0 0 0 2px #342318, 0 3px 10px #0f0a07bb;
}
.play:hover { background: #66472b; }
.in-drawer .play { display: none; }
.play span { font-size: 1.35rem; }
.overview { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: .81rem; }
.overview span { padding: 3px 8px; border: 1px solid #624d32; background: #140f0de8; }
.overview span:first-child { border-color: #a07b40; background: #38291bea; color: var(--ink); }
.overview b { margin-inline-start: 5px; color: var(--light-gold); font-variant-numeric: tabular-nums; }
.nav { background: #17120f; border-block: 1px solid var(--line); }
.tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(0, 1.2fr); }
.tabs a {
  text-decoration: none;
  text-align: center;
  padding: 13px 5px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 650;
}
.tabs a:hover { color: var(--light-gold); background: #211911; }
.tabs [aria-current] { color: var(--light-gold); border-color: var(--gold); background: linear-gradient(0deg, #402b1b, #211811); }

.catalog { padding-block: 28px 50px; }
.catalog-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}
.catalog-head::before {
  flex: 0 0 8px;
  aspect-ratio: 1;
  content: "";
  border: 1px solid var(--gold);
  transform: rotate(45deg);
}
.catalog-head h2 { font-size: clamp(1.43rem, 3vw, 2rem); color: var(--light-gold); }
.filters {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  align-items: end;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #695032;
  background: linear-gradient(115deg, #241b14, var(--panel));
  box-shadow: inset 0 0 0 3px #1b1511;
}
.filters:empty { display: none; }
label.field { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: .83rem; }
input[type="search"], select, .btn {
  min-height: 44px;
  border: 1px solid #675038;
  border-radius: 2px;
  background: var(--field);
  padding: 6px 11px;
}
input[type="search"], select { font-size: 1rem; width: 100%; min-width: 0; }
input[type="search"]::placeholder { color: #a99a87; }
.check { min-height: 44px; display: flex; align-items: center; gap: 7px; font-size: .9rem; }
.check input { accent-color: var(--gold); width: 17px; height: 17px; margin: 0; }
.btn:hover:not(:disabled), .close:hover { border-color: var(--gold); background: #352519; }
.status { margin: 14px 0 10px; color: var(--muted); font-size: .88rem; }
.status:empty { display: none; }
.status .btn { margin-inline-start: 10px; }
.list { list-style: none; padding: 0; border: 1px solid var(--line); background: #16120f; }
.list li + li { border-top: 1px solid #382a1e; }
.list-head, .monster-row {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(130px, 1.25fr) 62px minmax(0, 1.25fr);
  gap: 12px;
  padding: 9px 15px;
}
.list-head { border-bottom: 1px solid #60482c; background: #251b13; color: var(--muted); font-size: .81rem; }
.monster-row { text-decoration: none; min-height: 54px; }
.monster-row:hover, .item-tile:hover { background: #302318; color: #ffe6b0; }
.monster-row strong { font-size: .98rem; }
.monster-row .maps { color: var(--muted); font-size: .87rem; }
.monster-row .level { font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block;
  padding: 1px 6px;
  background: #3f211d;
  border: 1px solid #805346;
  color: #f8c29f;
  font: 650 .7rem/1.45 system-ui, sans-serif;
  vertical-align: middle;
  margin-inline-start: 6px;
}
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card, .item-tile {
  min-width: 0;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, #211912, #191410);
}
.card { padding: 14px 15px; }
.card h3 { color: var(--light-gold); font-size: 1.15rem; overflow-wrap: anywhere; }
.item-tile { display: flex; align-items: center; gap: 10px; padding: 12px; text-decoration: none; min-height: 68px; }
.item-tile strong { display: block; overflow-wrap: anywhere; }
.subtle { color: var(--muted); font-size: .84rem; }
.identifier { font-size: .78rem; color: var(--muted); }
.tile-copy { min-width: 0; }
.icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 34px;
  vertical-align: middle;
  image-rendering: pixelated;
}
.inline-item { display: inline-flex; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.inline-item .icon { width: 29px; height: 29px; flex-basis: 29px; }
.cluster { display: flex; flex-wrap: wrap; gap: 6px 12px; list-style: none; padding: 0; }
.cluster li { max-width: 100%; }
.recipe-head, .doll-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.doll-head { justify-content: flex-start; }
.rate { flex: none; color: #e4cc95; font-variant-numeric: tabular-nums; font-size: .86rem; }
.card-label { margin: 9px 0 3px; font-size: .8rem; color: var(--muted); }
.qty { white-space: nowrap; color: var(--muted); font-size: .85rem; }
.description { margin-top: 8px; overflow-wrap: anywhere; white-space: pre-line; }
.group + .group { margin-top: 22px; }
.group-title { margin-bottom: 8px; color: var(--light-gold); font-size: 1.15rem; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-block-start: 18px; color: var(--muted); }

dialog {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  padding: 0;
  width: min(640px, 100%);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid #8b6b3d;
  box-shadow: -14px 0 60px #070503b3;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #0b0805b5; }
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  padding: max(12px, env(safe-area-inset-top)) max(15px, env(safe-area-inset-right)) 12px max(15px, env(safe-area-inset-left));
  border-bottom: 1px solid #7f6138;
  background: linear-gradient(135deg, #382619, #211710);
}
.detail-head h2 { overflow-wrap: anywhere; color: var(--light-gold); font-size: 1.4rem; }
.close { min-height: 44px; flex: none; border: 1px solid #705332; padding: 4px 10px; background: #241a13; }
.close span { margin-inline-start: 3px; font-size: 1.1rem; }
.detail-body { overflow: auto; overscroll-behavior: contain; padding: 15px max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.detail-section { margin-top: 18px; }
.detail-section > h3 { color: var(--light-gold); margin-bottom: 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; font-size: 1.15rem; }
.detail-section .card + .card { margin-top: 8px; }
.detail-lead { display: flex; align-items: center; gap: 8px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(83px, 1fr)); gap: 5px; margin-top: 8px; }
.metric { background: #17120f; border: 1px solid #3e2f21; padding: 5px 7px; min-width: 0; }
.metric dt { color: var(--muted); font-size: .75rem; }
.metric dd { overflow-wrap: anywhere; margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
.relation { width: 100%; border-collapse: collapse; font-size: .86rem; }
.relation th, .relation td { text-align: start; padding: 6px; border-bottom: 1px solid #3b2d22; }
.relation th { color: var(--muted); font-weight: 600; }
.relation :is(td, th):not(:first-child) { white-space: nowrap; text-align: end; }
.relation a { min-height: 32px; }
.relation tbody tr:hover { background: #271e16; }
.coin { width: 16px; height: 16px; vertical-align: text-bottom; }

.endgame {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 5fr);
  gap: 16px;
  align-items: start;
}
.war-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid #705332;
  background: linear-gradient(145deg, #231a13, #17120f);
  box-shadow: inset 0 0 0 3px #17120f;
}
.war-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.war-panel-head h3 { color: var(--light-gold); font-size: clamp(1.15rem, 2.3vw, 1.48rem); }
.war-panel-head .btn { min-width: max-content; color: var(--light-gold); font-size: .88rem; }
.board-switch { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.board-switch button {
  min-width: 0;
  min-height: 44px;
  padding: 4px;
  border: 1px solid #59432f;
  background: #15100d;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 650;
}
.board-switch button:hover { border-color: #967541; color: var(--light-gold); }
.board-switch [aria-pressed="true"] { border-color: #ac8b4e; background: #3b2919; color: var(--light-gold); }
.war-status { margin-block: 10px; color: var(--muted); font-size: .85rem; }
.war-status:empty { display: none; }
#ranking-board .relation { table-layout: fixed; }
#ranking-board .relation :is(th, td) { white-space: normal; overflow-wrap: anywhere; }
#ranking-board .relation :is(th, td):first-child { width: 3rem; color: var(--light-gold); }
#ranking-board .relation strong { color: var(--ink); }
#ranking-board .relation :is(th, td):nth-child(2) { text-align: start; }
#ranking-board .relation :is(th, td):last-child { width: 7rem; font-variant-numeric: tabular-nums; }
.rank-note { display: block; color: var(--muted); font-size: .83rem; }
.castle-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.castle-card {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-top-color: #79603b;
  background: linear-gradient(145deg, #2b2017, #1b1511);
}
.castle-card h4 { margin: 0 0 6px; color: var(--light-gold); font: 700 1.08rem/1.25 var(--display); }
.castle-card dl > div { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px; }
.castle-card dt { color: var(--muted); font-size: .79rem; }
.castle-card dd { margin: 0; text-align: end; font-size: .85rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

@media (max-width: 890px) {
  .wrap { width: calc(100% - 40px); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 740px) {
  .endgame { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 590px) {
  .wrap { width: calc(100% - 28px); }
  .masthead-inner { grid-template-columns: 1fr; gap: 11px; padding-block: 19px 13px; }
  .identity { gap: 15px; padding-inline-start: 5px; }
  .crest { flex-basis: 32px; }
  .crest::after { inset: 5px; }
  .brand { margin-bottom: 2px; }
  .play { justify-self: start; min-height: 42px; font-size: .86rem; }
  .overview { gap: 4px; font-size: .72rem; }
  .overview span { padding: 2px 5px; }
  .tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tabs a { font-size: .84rem; padding: 10px 3px; min-height: 44px; }
  .tabs a:last-child { grid-column: 1 / -1; }
  .catalog { padding-block-start: 19px; }
  .catalog-head { margin-bottom: 11px; }
  .filters { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 9px; padding: 10px; }
  .search-field { grid-column: 1 / -1; }
  .list-head, .monster-row { padding: 8px; gap: 6px; grid-template-columns: minmax(0, 1fr) 32px minmax(0, .9fr); }
  .monster-row strong, .monster-row .maps { font-size: .83rem; overflow-wrap: anywhere; }
  .monster-row .level { font-size: .82rem; }
  .monster-row .badge { margin-inline-start: 3px; }
  .grid { gap: 7px; }
  .grid.cards { grid-template-columns: 1fr; }
  .item-tile { padding: 7px; gap: 5px; font-size: .88rem; }
  .item-tile .icon { flex-basis: 25px; width: 25px; height: 25px; }
  .pagination { gap: 7px; font-size: .83rem; }
  .war-panel { padding: 10px; }
  .castle-grid { gap: 6px; }
  .castle-card { padding: 8px; }
  #ranking-board .relation :is(th, td):last-child { width: 6rem; }
}
.list-rows { list-style: none; padding: 0; }
