/* MEGA Wiki. Colours from the in-game HUD (HudWidgets.cs). */
@font-face { font-family: "Agenda"; src: url("../fonts/agenda-14.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Retimoa"; src: url("../fonts/retimoa-straight.otf") format("opentype"); font-display: swap; }

:root {
  --bg: #090b12;
  --s1: #10131c;
  --s2: #171b27;
  --s3: #20263a;
  --bd: #2a3044;
  --bd2: #394058;
  --text: #e8e6dc;
  --text2: #a3a9b4;
  --link: #3cc9ee;
  --gold: #ffbd4a;
  --red: #ff6a57;
  --side: 250px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 "Agenda", "Segoe UI", system-ui, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
strong { color: #fff; }
.muted { color: var(--text2); }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 18px; background: #0d1018; border-bottom: 1px solid var(--bd); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: "Retimoa", sans-serif; font-size: 22px; letter-spacing: .08em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; object-fit: contain; }
.brand small { font-family: "Agenda", sans-serif; font-size: 16px; letter-spacing: 0; color: var(--text2); }
.menu-btn { display: none; background: none; border: 1px solid var(--bd2); color: var(--text); width: 40px; height: 36px; font-size: 19px; cursor: pointer; }
.search { position: relative; margin-left: auto; width: min(340px, 40vw); }
.search input { width: 100%; height: 36px; padding: 0 11px; border-radius: 2px; border: 1px solid var(--bd2); background: #07090f; color: var(--text); font: inherit; font-size: 15px; }
.search input:focus { outline: 1px solid var(--link); border-color: var(--link); }
.results { position: absolute; top: 40px; left: 0; right: 0; background: var(--s2); border: 1px solid var(--bd2); box-shadow: 0 6px 16px rgba(0,0,0,.5); display: none; max-height: 60vh; overflow: auto; }
.results.open { display: block; }
.results a { display: block; padding: 7px 12px; color: var(--text); border-bottom: 1px solid var(--bd); }
.results a:hover, .results a.active { background: var(--s3); text-decoration: none; }
.results a small { display: block; color: var(--text2); font-size: 13px; }
.results .none { padding: 9px 12px; color: var(--text2); font-size: 15px; }

/* Layout */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100vh - 56px); }
.side { position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto; padding: 20px 14px 36px; border-right: 1px solid var(--bd); background: #0d1018; scrollbar-width: thin; }
.side h4 { margin: 18px 8px 4px; font-size: 14px; font-weight: normal; color: var(--text2); }
.side h4:first-child { margin-top: 0; }
.side a { display: flex; align-items: center; gap: 9px; padding: 4px 8px; color: var(--text); font-size: 16px; }
.side a img { width: 18px; height: 18px; object-fit: contain; opacity: .8; }
.side a:hover { color: var(--link); text-decoration: none; }
.side a.on { background: var(--s3); color: #fff; }

main { padding: 32px clamp(18px, 3.5vw, 48px) 70px; width: 100%; min-width: 0; }
.page-grid { max-width: 1160px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 44px; }
.rail { display: none; }
.rail-in { position: sticky; top: 84px; padding-left: 20px; border-left: 1px solid var(--bd); }
.rail h4 { margin: 0 0 6px; font-size: 15px; font-weight: bold; color: var(--text); }
.rail-toc { display: flex; flex-direction: column; margin-bottom: 24px; }
.rail-toc a { padding: 3px 0; font-size: 15px; line-height: 1.35; }
.rail-pic { display: block; margin-bottom: 10px; }
.rail-pic img { border: 1px solid var(--bd2); width: 100%; height: auto; }
.rail-pic:hover img { border-color: var(--link); }
@media (min-width: 1280px) {
  .page-grid.has-rail { max-width: 1300px; grid-template-columns: minmax(0, 1fr) 280px; }
  .has-rail .rail { display: block; }
  .has-rail .toc { display: none; }
}
.crumbs { display: none; }
h1, h2, h3 { font-weight: normal; line-height: 1.2; }
h1 { font-family: "Retimoa", sans-serif; font-size: clamp(34px, 5vw, 50px); margin: 0 0 12px; letter-spacing: .02em; }
h2 { font-size: clamp(23px, 2.6vw, 27px); margin: 40px 0 12px; padding-bottom: 4px; color: #fff; border-bottom: 1px solid var(--bd2); scroll-margin-top: 76px; }
h3 { font-size: 19px; font-weight: bold; margin: 26px 0 6px; scroll-margin-top: 76px; }
.lede { font-size: 19px; max-width: 900px; margin: 0 0 10px; }
p { max-width: 900px; }
ul, ol { max-width: 900px; padding-left: 24px; }
li { margin: 4px 0; }

/* Home */
.banner-img { margin: 0 0 22px; border: 1px solid var(--bd2); }
.banner-img img { width: 100%; height: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 16px 0 8px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px 18px; background: var(--s2); border: 1px solid var(--bd2); border-radius: 3px; color: var(--text); }
.tile:hover { border-color: var(--link); text-decoration: none; }
.tile img { width: 38px; height: 38px; object-fit: contain; margin-bottom: 4px; }
.tile b { font-family: "Retimoa", sans-serif; font-weight: normal; font-size: 20px; line-height: 1.15; }
.tile span { color: var(--text2); font-size: 15px; line-height: 1.45; }

/* Notes */
.note { max-width: 900px; margin: 18px 0; padding: 10px 14px; background: var(--s2); border: 1px solid var(--bd2); }
.note b { margin-right: 4px; }
.note b::after { content: ":"; }

/* Keys */
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 7px; border: 3px solid #f2f2f2; border-radius: 7px; font: 14px "Agenda", sans-serif; color: #f2f2f2; vertical-align: middle; line-height: 1; margin: 0 2px; }
.ki { height: 30px; width: auto; display: inline-block; vertical-align: middle; margin: 0 2px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 14px 0 22px; }
table { border-collapse: collapse; font-size: 15.5px; background: var(--s2); border: 1px solid var(--bd2); }
.table-wrap table { width: 100%; }
th, td { padding: 8px 12px; text-align: left; border: 1px solid var(--bd2); vertical-align: middle; }
th { font-weight: bold; color: #fff; background: var(--s3); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .thumb { width: 46px; height: 46px; object-fit: contain; }
.name-cell { display: flex; align-items: center; gap: 12px; min-width: 180px; scroll-margin-top: 76px; }
.name-cell b { font-size: 16px; line-height: 1.25; }
td .name-cell .thumb { flex: none; }
.tag { font-size: 14px; color: var(--text2); white-space: nowrap; }
.tag::before { content: "("; } .tag::after { content: ")"; }

/* Titan cards */
.titans { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin: 20px 0; }
.titan { background: var(--s2); border: 1px solid var(--bd2); scroll-margin-top: 76px; }
.titan .pic { aspect-ratio: 1 / 1; background: #161f21; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--bd2); }
.titan .pic img { width: 82%; height: 82%; object-fit: contain; }
.titan .body { padding: 14px 16px 18px; }
.titan h3 { margin: 0 0 2px; font-size: 23px; }
.titan .role { font-size: 15px; color: var(--text2); }
.stat { display: grid; grid-template-columns: 92px 1fr 46px; align-items: center; gap: 10px; font-size: 15px; margin: 6px 0; }
.stat .bar { height: 7px; background: #2a3044; }
.stat .bar i { display: block; height: 100%; background: var(--link); }
.stat .v { text-align: right; font-variant-numeric: tabular-nums; }
.special { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--bd); }
.special b { font-size: 17px; }
.special .tag { margin-left: 4px; }
.special p { font-size: 15.5px; color: var(--text2); margin: 4px 0 0; }

/* Figures */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin: 16px 0 24px; }
figure { margin: 0; }
figure img { border: 1px solid var(--bd2); width: 100%; height: auto; }
figure.wide { margin: 16px 0 24px; }
figcaption { font-size: 14px; color: var(--text2); margin-top: 4px; }
.gallery figure a { display: block; }
.gallery figure a:hover img { border-color: var(--link); }

/* On-page contents (narrow screens) */
.toc { margin: 12px 0 6px; font-size: 15.5px; max-width: 900px; }
.toc::before { content: "Contents: "; color: var(--text2); }
.toc a + a::before { content: " · "; color: var(--text2); }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; padding-top: 14px; border-top: 1px solid var(--bd2); font-size: 16px; }
.pager .next { margin-left: auto; text-align: right; }

footer { padding: 22px clamp(18px, 4vw, 48px); border-top: 1px solid var(--bd); color: var(--text2); font-size: 14px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: inline-block; }
  .side { position: fixed; top: 56px; left: 0; width: min(290px, 84vw); z-index: 15; transform: translateX(-100%); transition: transform .15s ease; border-right: 1px solid var(--bd2); }
  body.nav-open .side { transform: none; }
  .brand small { display: none; }
  .search { width: auto; flex: 1; }
  main { padding-top: 24px; }
  .gallery { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Picture guide: slideshow + hover previews (js/guide.js) */
html.lb-lock { overflow: hidden; }
.lb { position: fixed; inset: 0; z-index: 100; display: none; grid-template-rows: auto minmax(0, 1fr) auto; background: rgba(6, 8, 13, .97); color: #e8e6dc; font-family: "Agenda", "Segoe UI", sans-serif; }
.lb.open { display: grid; }
.lb-top { display: flex; align-items: center; gap: 14px; padding: 10px 14px 8px 18px; border-bottom: 1px solid #2a3044; }
.lb-cap { font-size: 17px; }
.lb-cap small { color: #a3a9b4; font-size: 14px; margin-left: 10px; }
.lb-count { margin-left: auto; color: #a3a9b4; font-size: 14px; font-variant-numeric: tabular-nums; }
.lb button { font: inherit; color: #e8e6dc; background: #171b27; border: 1px solid #394058; cursor: pointer; }
.lb button:hover { border-color: #3cc9ee; }
.lb-close { width: 36px; height: 34px; font-size: 22px; line-height: 1; }
.lb-stage { position: relative; display: flex; align-items: center; justify-content: center; padding: 14px 64px; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid #394058; background: #000; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 72px; font-size: 34px; line-height: 1; }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lb-strip { display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px 12px; border-top: 1px solid #2a3044; scrollbar-width: thin; }
.lb .lb-thumb { flex: none; width: 128px; padding: 0; border: 2px solid transparent; background: none; opacity: .55; }
.lb .lb-thumb.on { border-color: #3cc9ee; opacity: 1; }
.lb .lb-thumb:hover { opacity: 1; border-color: #394058; }
.lb-thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.lb-all { display: block; margin: 10px 0 0; padding: 4px 10px; font: inherit; font-size: 14px; color: #3cc9ee; background: #171b27; border: 1px solid #394058; cursor: pointer; }
.lb-all:hover { border-color: #3cc9ee; }
[data-guide] { cursor: zoom-in; }
tr[data-guide]:hover td { background: #222839; }
.gtip { position: fixed; z-index: 90; width: 330px; background: #171b27; border: 1px solid #394058; box-shadow: 0 8px 22px rgba(0,0,0,.6); pointer-events: none; display: none; font-family: "Agenda", "Segoe UI", sans-serif; color: #e8e6dc; }
.gtip.open { display: block; }
.gt-pic { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-bottom: 1px solid #394058; }
.gt-head { display: flex; align-items: center; gap: 11px; padding: 9px 11px 2px; }
.gt-head b { font-size: 16px; color: #fff; line-height: 1.25; }
.gt-icon { width: 76px; height: 76px; object-fit: contain; flex: none; background: #161f21; border: 1px solid #2a3044; padding: 2px; }
.gtip p { margin: 3px 11px 8px; font-size: 13.5px; line-height: 1.45; color: #c9ccd2; max-width: none; }
.gtip dl { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; margin: 0 11px 9px; padding-top: 6px; border-top: 1px solid #2a3044; font-size: 13px; }
.gtip dt { color: #a3a9b4; }
.gtip dd { margin: 0; text-align: right; }
.gtip small { display: block; padding: 0 11px 8px; font-size: 12.5px; color: #a3a9b4; }
@media (max-width: 700px) {
  .lb-stage { padding: 10px 8px; }
  .lb-prev, .lb-next { width: 36px; height: 56px; font-size: 26px; background: rgba(23,27,39,.85); }
  .lb-prev { left: 4px; } .lb-next { right: 4px; }
  .lb .lb-thumb { width: 96px; }
}
