:root {
  --ink: #eef4ed;
  --muted: #a9b7b3;
  --faint: #71817e;
  --night: #040813;
  --panel: rgba(13, 27, 35, 0.94);
  --panel-light: rgba(20, 42, 48, 0.92);
  --emerald: #55c49b;
  --emerald-dark: #173f38;
  --gold: #e4c572;
  --gold-soft: #9d8347;
  --danger: #e08a87;
  --line: rgba(151, 188, 172, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
  background:
    radial-gradient(circle at 50% -20%, rgba(52, 121, 102, 0.3), transparent 38rem),
    linear-gradient(rgba(4, 8, 19, 0.93), rgba(4, 8, 19, 0.98)),
    url("../assets/title/title-bg.webp") center top / cover fixed;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

a {
  color: inherit;
}

.guide-hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(228, 197, 114, 0.42);
  background:
    linear-gradient(90deg, rgba(3, 12, 20, 0.98), rgba(10, 35, 36, 0.9), rgba(3, 12, 20, 0.98)),
    url("../assets/title/title-bg.webp") center 38% / cover;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.42);
}

.guide-hero::before,
.guide-hero::after {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28%;
  pointer-events: none;
  content: "";
  background: linear-gradient(90deg, rgba(228, 197, 114, 0.13), transparent);
  clip-path: polygon(0 0, 100% 0, 58% 100%, 0 100%);
}

.guide-hero::after {
  right: 0;
  transform: scaleX(-1);
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 24px;
  text-align: center;
}

.back-link {
  position: absolute;
  top: 22px;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid rgba(228, 197, 114, 0.34);
  border-radius: 4px;
  color: #e7d7a4;
  font-size: 13px;
  text-decoration: none;
  background: rgba(2, 12, 18, 0.74);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.back-link:hover {
  border-color: var(--gold);
  background: rgba(25, 58, 52, 0.88);
  transform: translateX(-2px);
}

.hero-kicker {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.guide-hero h1 {
  margin: 0;
  color: #f8f3df;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.15;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 0 #0a191b, 0 0 22px rgba(104, 210, 166, 0.2);
}

.guide-hero h1::after {
  display: block;
  width: 78px;
  height: 2px;
  margin: 13px auto 10px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.hero-summary {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.guide-tabs {
  display: inline-flex;
  gap: 4px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid rgba(135, 181, 162, 0.2);
  border-radius: 7px;
  background: rgba(1, 8, 13, 0.68);
}

.guide-tabs a {
  min-width: 112px;
  padding: 8px 14px;
  border-radius: 4px;
  color: #9eb2ad;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease;
}

.guide-tabs a:hover {
  color: #f5edcf;
  background: rgba(52, 103, 88, 0.35);
}

.guide-tabs a[aria-current="page"] {
  color: #07130f;
  background: linear-gradient(#dfc875, #b99b4f);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.42);
}

.guide-main,
.roster,
.class-compendium {
  width: min(1120px, calc(100% - 32px));
  margin: 30px auto 0;
}

.roster {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.faction-header,
.class-section-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 -2px;
  color: #e9d38d;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.faction-header::after,
.class-section-title::after {
  flex: 1;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, rgba(228, 197, 114, 0.5), transparent);
}

.char-card {
  position: relative;
  display: flex;
  min-width: 0;
  gap: 17px;
  padding: 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(145deg, rgba(24, 49, 52, 0.78), rgba(10, 20, 31, 0.96)),
    var(--panel);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22), inset 0 1px rgba(255, 255, 255, 0.035);
  transition: border-color 170ms ease, transform 170ms ease, box-shadow 170ms ease;
}

.char-card::after,
.class-card::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 54px;
  height: 54px;
  pointer-events: none;
  content: "";
  border-top: 1px solid rgba(228, 197, 114, 0.5);
  border-right: 1px solid rgba(228, 197, 114, 0.5);
  opacity: 0.45;
  clip-path: polygon(32% 0, 100% 0, 100% 68%);
  background: linear-gradient(135deg, transparent 48%, rgba(228, 197, 114, 0.14) 49%);
}

.char-card:hover {
  z-index: 1;
  border-color: rgba(228, 197, 114, 0.55);
  box-shadow: 0 15px 36px rgba(0, 0, 0, 0.34), 0 0 22px rgba(65, 161, 127, 0.08);
  transform: translateY(-2px);
}

.portrait-slot {
  position: relative;
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
  overflow: hidden;
  border: 2px solid #a58d50;
  border-radius: 4px;
  color: var(--faint);
  font-size: 11px;
  background:
    radial-gradient(circle at 50% 35%, rgba(98, 169, 144, 0.22), transparent 54%),
    #111d28;
  box-shadow: 0 0 0 3px rgba(3, 11, 17, 0.8), 0 6px 15px rgba(0, 0, 0, 0.38);
}

.portrait-slot::after {
  position: absolute;
  inset: 5px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 235, 168, 0.2);
}

.portrait-slot img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  object-fit: cover;
}

.char-info {
  min-width: 0;
  flex: 1;
}

.char-name {
  margin-top: 1px;
  color: #fff5d2;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.04em;
}

.char-name .class-tag {
  display: block;
  margin: 5px 0 0;
  color: #8ecdb7;
  font-family: "Segoe UI", "PingFang TC", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.char-join {
  display: inline-flex;
  margin-top: 8px;
  padding: 3px 7px;
  border-left: 2px solid var(--gold);
  color: #b9c8c3;
  font-family: "Segoe UI", "PingFang TC", sans-serif;
  font-size: 11px;
  background: rgba(228, 197, 114, 0.07);
}

.char-desc {
  margin-top: 11px;
  color: #c4cfcc;
  font-size: 13px;
  line-height: 1.72;
}

.char-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 13px;
}

.stat-badge,
.class-badge,
.weapon-badge,
.type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(144, 171, 163, 0.24);
  border-radius: 3px;
  color: #aebdb9;
  font-family: "Segoe UI", "PingFang TC", sans-serif;
  font-size: 11px;
  background: rgba(4, 13, 20, 0.5);
}

.stat-badge.highlight {
  border-color: rgba(85, 196, 155, 0.44);
  color: #83d9ba;
  background: rgba(35, 104, 82, 0.19);
}

.stat-badge.weak {
  border-color: rgba(224, 138, 135, 0.42);
  color: #eba5a2;
  background: rgba(111, 47, 48, 0.16);
}

.class-compendium {
  padding-bottom: 20px;
}

.class-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  background: rgba(9, 24, 30, 0.78);
}

.class-intro strong {
  color: var(--gold);
}

.class-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.class-filter {
  min-height: 29px;
  padding: 4px 10px;
  border: 1px solid rgba(144, 171, 163, 0.28);
  border-radius: 3px;
  color: #aebdb9;
  font-family: "Segoe UI", "PingFang TC", sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  background: rgba(4, 13, 20, 0.62);
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.class-filter:hover {
  border-color: rgba(228, 197, 114, 0.56);
  color: #f2e6bb;
}

.class-filter[aria-pressed="true"] {
  border-color: #d8ba68;
  color: #07130f;
  background: linear-gradient(#dfc875, #b99b4f);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.4);
}

.class-filter:focus-visible {
  outline: 2px solid #74d8b5;
  outline-offset: 2px;
}

.class-section[hidden] {
  display: none;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}

.class-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(150deg, var(--panel-light), var(--panel));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  transition: border-color 170ms ease, transform 170ms ease, box-shadow 170ms ease;
}

.class-card:hover {
  border-color: rgba(228, 197, 114, 0.55);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  transform: translateY(-2px);
}

.class-card.enemy-class {
  border-color: rgba(154, 88, 91, 0.38);
  background: linear-gradient(150deg, rgba(56, 30, 37, 0.94), rgba(17, 17, 28, 0.97));
}

.class-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(151, 188, 172, 0.14);
}

.class-sprite {
  display: grid;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  place-items: center;
  border: 1px solid rgba(228, 197, 114, 0.35);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(61, 139, 112, 0.25), transparent 64%),
    rgba(3, 12, 18, 0.68);
}

.class-sprite canvas {
  display: block;
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
}

.class-heading {
  min-width: 0;
}

.class-rank {
  margin-bottom: 3px;
  color: #91aaa3;
  font-family: "Segoe UI", "PingFang TC", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.class-name {
  color: #fff1c5;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.class-core {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px 14px;
  padding: 12px 14px 13px;
}

.class-label {
  color: #70847e;
  font-family: "Segoe UI", "PingFang TC", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.class-value {
  min-width: 0;
  color: #c8d3cf;
  font-size: 12px;
}

.class-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.weapon-badge {
  border-color: rgba(228, 197, 114, 0.32);
  color: #eadcae;
}

.type-badge {
  color: #9ccbbb;
}

.mov-value {
  color: #f0d98b;
  font-size: 16px;
  font-weight: 800;
}

.bonus-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.bonus-stat {
  padding: 5px 2px;
  border: 1px solid rgba(126, 163, 151, 0.16);
  border-radius: 3px;
  text-align: center;
  background: rgba(3, 12, 18, 0.4);
}

.bonus-stat span {
  display: block;
  color: #71817d;
  font-family: "Segoe UI", "PingFang TC", sans-serif;
  font-size: 9px;
}

.bonus-stat strong {
  color: #8fd3ba;
  font-family: "Segoe UI", "PingFang TC", sans-serif;
  font-size: 12px;
}

.bonus-stat.negative strong {
  color: var(--danger);
}

.promotion-route {
  color: #d9be72;
  line-height: 1.6;
}

.guide-footer {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto 0;
  padding: 22px 0 34px;
  border-top: 1px solid rgba(228, 197, 114, 0.2);
  color: #657873;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 920px) {
  .roster {
    grid-template-columns: 1fr;
  }

  .class-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    background-attachment: scroll;
  }

  .hero-inner {
    padding-top: 70px;
  }

  .back-link {
    top: 16px;
  }

  .guide-tabs {
    display: flex;
    width: 100%;
  }

  .guide-tabs a {
    min-width: 0;
    flex: 1;
  }

  .class-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .class-legend {
    justify-content: flex-start;
  }

  .class-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .guide-main,
  .roster,
  .class-compendium,
  .guide-footer,
  .hero-inner {
    width: min(100% - 20px, 1120px);
  }

  .guide-hero h1 {
    font-size: 27px;
  }

  .hero-summary {
    font-size: 12px;
  }

  .roster {
    gap: 12px;
    margin-top: 20px;
  }

  .faction-header,
  .class-section-title {
    margin-top: 12px;
    font-size: 13px;
  }

  .char-card {
    align-items: center;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    text-align: center;
  }

  .portrait-slot {
    width: 96px;
    height: 96px;
    flex-basis: 96px;
  }

  .char-name {
    font-size: 17px;
  }

  .char-name .class-tag {
    font-size: 10px;
  }

  .char-desc {
    font-size: 12px;
    text-align: left;
  }

  .char-info {
    display: block;
    width: 100%;
  }

  .char-stats {
    justify-content: center;
  }

  .class-card-header {
    padding-right: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .char-card,
  .class-card,
  .back-link {
    transition: none;
  }
}
