:root {
  --bg: #f6f3ec;
  --panel: #ffffff;
  --panel-2: #efe9dc;
  --text: #2a2620;
  --muted: #776e60;
  --line: #ddd4c2;
  --accent: #2f7d5b;
  --accent-text: #ffffff;
  --link: #22684a;
  --t-common: #6b6b6b;
  --t-uncommon: #2f8a3a;
  --t-rare: #2b62c4;
  --t-epic: #8a3cc4;
  --boss: #c0392b;
  --elite: #c27a12;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b;
    --panel: #212328;
    --panel-2: #2a2d33;
    --text: #e9e6df;
    --muted: #9c978c;
    --line: #363941;
    --accent: #4fae84;
    --accent-text: #0f1a14;
    --link: #79d2a8;
    --t-common: #b0b0b0;
    --t-uncommon: #6fd17a;
    --t-rare: #78a6ff;
    --t-epic: #c690ff;
    --boss: #ff7a6b;
    --elite: #f0b04a;
  }
}
:root[data-theme="dark"] {
  --bg: #17181b; --panel: #212328; --panel-2: #2a2d33; --text: #e9e6df; --muted: #9c978c; --line: #363941;
  --accent: #4fae84; --accent-text: #0f1a14; --link: #79d2a8;
  --t-common: #b0b0b0; --t-uncommon: #6fd17a; --t-rare: #78a6ff; --t-epic: #c690ff; --boss: #ff7a6b; --elite: #f0b04a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "Noto Sans Thai", system-ui, "Segoe UI", Tahoma, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img.px { image-rendering: pixelated; }

#side {
  position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 20;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 12px; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); padding: 0 6px; }
.brand span { color: var(--accent); }
a.brand:hover { text-decoration: none; }
#search {
  width: 100%; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
#nav .grp { margin: 14px 6px 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
#nav summary.grp { display: flex; align-items: center; gap: 6px; padding: 4px 2px; border-radius: 6px; cursor: pointer; list-style: none; user-select: none; }
#nav summary.grp::-webkit-details-marker { display: none; }
#nav summary.grp::before { content: "▸"; font-size: 11px; transition: transform .15s; }
#nav details[open] > summary.grp::before { transform: rotate(90deg); }
#nav summary.grp:hover { color: var(--text); background: var(--panel-2); }
#nav details.fold { margin-bottom: 2px; }
#nav a { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; color: var(--text); font-size: 14px; }
#nav a img { width: 20px; height: 20px; object-fit: contain; }
#nav a.sub { margin: 0; padding-left: 30px; font-size: 13px; color: var(--muted); } /* .sub is also the page subtitle class */
#nav a:hover { background: var(--panel-2); text-decoration: none; }
#nav a.on { background: var(--accent); color: var(--accent-text); }
.page { margin-left: 250px; min-width: 0; }
.mobile-top { display: none; }
#scrim { display: none; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 24px 40px; }
footer { max-width: 1100px; margin: 0 auto; padding: 0 24px 24px; color: var(--muted); font-size: 13px; }

.guide p, .guide li { max-width: 760px; }
.guide ul, .guide ol { padding-left: 22px; }
.update-entry { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.update-entry h3 { font-size: 15px; margin: 14px 0 6px; }
.update-entry ul { margin: 0; padding-left: 22px; }
.update-entry td:nth-child(-n+2) { white-space: nowrap; }
.guide li { margin: 3px 0; }
.note { border-left: 4px solid var(--accent); background: var(--panel); padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 12px 0; }
.formula { font-family: ui-monospace, Consolas, monospace; background: var(--panel-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }

.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text);
}
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card img { width: 40px; height: 40px; object-fit: contain; flex: none; }
.card .t { font-weight: 600; }
.card .m { color: var(--muted); font-size: 13px; }
.big .card img { width: 64px; height: 64px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.head { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.head img { width: 72px; height: 72px; object-fit: contain; background: var(--panel-2); border-radius: 10px; padding: 4px; }
.desc { white-space: pre-line; }

/* Card art (144x192) at whole-pixel scales, like the game's item panel. */
.card-art { display: block; width: 216px; height: 288px; image-rendering: pixelated; filter: drop-shadow(0 6px 10px #0006); }
.card-art-wrap { display: flex; justify-content: center; align-items: flex-start; }
.card-gallery { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin: 0 0 20px; }
.card-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-align: center; }
a.card-tile:hover { border-color: var(--accent); text-decoration: none; }
.card-tile .card-art { width: 144px; height: 192px; margin-bottom: 4px; }
.card-tile .t { font-weight: 600; }
.card-tile .m { color: var(--muted); font-size: 13px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.tabs a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); background: var(--panel); font-size: 14px; }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 14px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--panel-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td img { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; margin-right: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; border: 1px solid currentColor; margin-left: 6px; vertical-align: middle; }
.tier-common { color: var(--t-common); }
.tier-uncommon { color: var(--t-uncommon); }
.tier-rare { color: var(--t-rare); }
.tier-epic { color: var(--t-epic); }
.rank-boss { color: var(--boss); }
.rank-elite { color: var(--elite); }
.muted { color: var(--muted); }
.cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

@media (max-width: 900px) {
  #side { transform: translateX(-100%); transition: transform .2s; }
  body.menu-open #side { transform: none; }
  body.menu-open #scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgb(0 0 0 / .4); }
  .page { margin-left: 0; }
  .mobile-top {
    position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  }
  #menu { font-size: 20px; line-height: 1; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; }
  main { padding: 18px 16px 32px; }
  footer { padding: 0 16px 20px; }
}
@media (max-width: 600px) {
  h1 { font-size: 22px; }
  .head img { width: 56px; height: 56px; }
}

/* Shown by app.js when version.json changes (wiki/watch.mjs rebuilt the data). */
.update { position: sticky; top: 0; z-index: 12; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.update[hidden] { display: none; }
.update button { font: inherit; padding: 2px 12px; border-radius: 6px; border: 0; background: var(--accent-text); color: var(--accent); cursor: pointer; }

/* Collapsible blocks in page content (e.g. crafting stations → sets). */
details.acc { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; }
details.acc > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 10px 14px; cursor: pointer; list-style: none; user-select: none; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before { content: "▸"; font-size: 12px; color: var(--muted); transition: transform .15s; }
details.acc[open] > summary::before { transform: rotate(90deg); }
details.acc > summary:hover { background: var(--panel-2); border-radius: 10px; }
details.acc > :not(summary) { margin: 0 12px 12px; }
details.acc.sub { background: var(--bg); }
