:root {
  --bg: #0d1118;
  --surface: #151c26;
  --surface-2: #1c2633;
  --surface-3: #243142;
  --line: #344456;
  --text: #f3f6f4;
  --muted: #aab8bb;
  --jade: #6ed7bd;
  --jade-dark: #193d39;
  --gold: #e3ba67;
  --danger: #ff9a91;
  --warn: #ffd18a;
  --info: #91bfff;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 300px;
  background:
    radial-gradient(circle at 12% -10%, rgba(67,160,143,.18), transparent 32rem),
    radial-gradient(circle at 92% 5%, rgba(184,131,55,.13), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.62;
}

a { color: var(--jade); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--text); color: var(--bg); border-radius: 10px; }
.skip-link:focus { top: 12px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 10px max(18px, calc((100% - 1240px) / 2));
  border-bottom: 1px solid rgba(105,129,145,.35);
  background: rgba(13,17,24,.9);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; line-height: 1.1; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #579c91; border-radius: 13px; background: linear-gradient(145deg, #24554f, #162b2d); color: #a8f2df; font: 800 1.35rem Georgia, serif; box-shadow: inset 0 0 18px rgba(110,215,189,.13); }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 5px; color: var(--muted); font-size: .72rem; letter-spacing: .12em; }
.primary-nav { display: flex; gap: 6px; }
.primary-nav a { padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: .92rem; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.nav-toggle { display: none; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); padding: 8px 11px; }

#app { width: min(1240px, calc(100% - 32px)); min-height: calc(100vh - 190px); margin: 0 auto; padding: 42px 0 70px; outline: none; }
.loading-state { display: grid; place-items: center; min-height: 50vh; color: var(--muted); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--jade); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, .55fr); gap: 28px; align-items: end; margin-bottom: 32px; }
.eyebrow { margin: 0 0 8px; color: var(--jade); font-size: .78rem; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3 { line-height: 1.22; }
h1 { margin: 0; max-width: 18ch; font-size: clamp(2rem, 6vw, 4.4rem); letter-spacing: -.04em; }
h2 { margin: 0; font-size: clamp(1.45rem, 3vw, 2rem); }
h3 { margin: 0; font-size: 1.08rem; }
.hero-copy { margin: 18px 0 0; max-width: 66ch; color: var(--muted); font-size: 1.02rem; }
.version-card { padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(34,49,66,.9), rgba(21,28,38,.9)); box-shadow: var(--shadow); }
.version-card strong { display: block; color: var(--gold); font-size: 1.35rem; }
.version-card span, .version-card small { display: block; color: var(--muted); }

.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 10px; margin: 24px 0; }
.control { min-height: 46px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
.control::placeholder { color: #77878c; }
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0 30px; }
.stat-card { padding: 15px 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(21,28,38,.82); }
.stat-card small { color: var(--muted); }
.stat-card strong { display: block; margin-top: 4px; font-size: 1.35rem; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 30px 0 16px; }
.section-head p { margin: 5px 0 0; color: var(--muted); }
.type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.type-card { position: relative; min-height: 220px; padding: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(150deg, var(--surface-2), var(--surface)); color: var(--text); text-decoration: none; transition: transform .16s ease, border-color .16s ease; }
.type-card::after { content: ""; position: absolute; right: -40px; bottom: -50px; width: 145px; height: 145px; border-radius: 50%; background: var(--type-color, var(--jade)); opacity: .09; filter: blur(2px); }
.type-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--type-color, var(--jade)), white 20%); }
.type-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.type-glyph { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: color-mix(in srgb, var(--type-color, var(--jade)), transparent 78%); color: var(--type-color, var(--jade)); font-weight: 900; }
.status-pill, .tag, .tier { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .74rem; font-weight: 800; }
.status-pill.complete { border-color: rgba(110,215,189,.45); color: var(--jade); }
.type-card h3 { margin-top: 30px; font-size: 1.3rem; }
.type-card h3 small { display: block; margin-top: 5px; color: var(--muted); font-size: .76rem; font-weight: 600; }
.type-card p { margin: 10px 0 0; color: var(--muted); font-size: .9rem; }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; color: var(--muted); font-size: .87rem; }
.breadcrumbs a { color: var(--muted); }
.guide-hero { display: grid; grid-template-columns: 1fr auto; gap: 25px; align-items: end; padding: 28px; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(135deg, color-mix(in srgb, var(--type-color), transparent 86%), var(--surface)); box-shadow: var(--shadow); }
.guide-hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); }
.guide-hero h1 small { display: block; margin-top: 7px; color: var(--muted); font-size: .95rem; letter-spacing: .04em; }
.guide-summary { max-width: 70ch; color: var(--muted); }
.score-ring { display: grid; place-items: center; width: 110px; height: 110px; border: 8px solid color-mix(in srgb, var(--type-color), transparent 35%); border-radius: 50%; background: var(--surface); text-align: center; }
.score-ring strong { display: block; font-size: 1.55rem; }
.score-ring small { display: block; color: var(--muted); font-size: .7rem; }
.guide-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; margin-top: 26px; }
.guide-content { min-width: 0; }
.guide-section { margin-bottom: 18px; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(21,28,38,.86); }
.guide-section > p:last-child { margin-bottom: 0; }
.guide-section h2 { margin-bottom: 12px; font-size: 1.35rem; }
.guide-section h3 { margin: 22px 0 8px; }
.callout { padding: 14px 16px; border-left: 3px solid var(--type-color, var(--jade)); border-radius: 0 10px 10px 0; background: color-mix(in srgb, var(--type-color, var(--jade)), transparent 91%); }
.facts { display: grid; gap: 10px; padding-left: 20px; }
.facts li::marker { color: var(--type-color, var(--jade)); }
.guide-nav { position: sticky; top: 92px; align-self: start; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.guide-nav strong { display: block; margin-bottom: 8px; }
.guide-nav a { display: block; padding: 7px 8px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .88rem; }
.guide-nav a:hover { color: var(--text); background: var(--surface-2); }

.rating-list { display: grid; gap: 12px; }
.rating-item { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.rating-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rating-item p { margin: 8px 0 0; color: var(--muted); }
.tier.almost { color: var(--jade); border-color: rgba(110,215,189,.45); }
.tier.conditional { color: var(--warn); border-color: rgba(255,209,138,.4); }
.tier.trap { color: var(--danger); border-color: rgba(255,154,145,.4); }
.tag.pairing { color: var(--info); border-color: rgba(145,191,255,.42); background: rgba(68,111,169,.12); }
.monster-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.team-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.monster-card, .team-card { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.monster-card p, .team-card p { margin: 7px 0 0; color: var(--muted); font-size: .9rem; }
.core-monster-card { display: grid; gap: 10px; }
.core-monster-card > p { margin: 0; }
.monster-strip { margin-top: 13px; padding-top: 11px; border-top: 1px solid rgba(105,129,145,.28); }
.monster-strip > strong { display: block; margin-bottom: 8px; color: var(--muted); font-size: .78rem; letter-spacing: .04em; }
.monster-chip-list { display: flex; flex-wrap: wrap; gap: 7px; }
.monster-chip { display: grid; grid-template-columns: 44px minmax(0,1fr); align-items: center; min-width: 138px; max-width: 200px; min-height: 50px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #121925; color: var(--text); text-decoration: none; }
.monster-chip:hover { border-color: var(--jade); }
.monster-chip img { width: 44px; height: 48px; object-fit: contain; background: #0a0f16; }
.monster-chip span { padding: 4px 7px; font-size: .76rem; font-weight: 800; line-height: 1.2; }
.monster-chip small { display: block; margin-top: 3px; color: var(--muted); font-size: .62rem; font-weight: 600; }
.monster-profile-card { display: block; min-width: 0; overflow: hidden; border: 2px solid #705285; border-radius: 6px; background: linear-gradient(145deg,#2a1d43,#171c31); color: var(--text); text-decoration: none; box-shadow: inset 0 0 0 1px rgba(215,171,228,.2); }
.monster-profile-card:hover { border-color: #a984bd; }
.profile-main { display: grid; grid-template-columns: 94px minmax(0,1fr); min-height: 124px; }
.profile-portrait { width: 94px; height: 124px; padding: 8px; object-fit: contain; background: rgba(7,12,23,.38); }
.profile-data { min-width: 0; padding: 10px 9px 8px; }
.profile-data > strong { display: block; margin-bottom: 7px; color: #fff; font-size: .92rem; line-height: 1.12; }
.profile-data > strong small { display: block; margin-top: 3px; color: #e1d8eb; font-size: .65rem; }
.shifted-label { display: inline-flex; margin-bottom: 6px; padding: 2px 6px; border: 1px solid #9a78b0; border-radius: 999px; color: #e6c8f3; font-size: .61rem; font-weight: 800; }
.profile-types { display: grid; gap: 4px; }
.profile-type { display: grid; grid-template-columns: 20px minmax(0,1fr); align-items: center; gap: 5px; color: #f6e7bd; font-size: .67rem; font-weight: 800; line-height: 1.15; }
.profile-type b { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid color-mix(in srgb,var(--badge-color),white 25%); border-radius: 5px; background: color-mix(in srgb,var(--badge-color),transparent 72%); color: var(--badge-color); font-size: .68rem; }
.profile-type small { display: inline; color: #cbbfd4; font-size: .57rem; }
.profile-elements { display: flex; gap: 7px; min-height: 42px; padding: 6px 9px; border-top: 1px solid rgba(202,156,218,.3); background: rgba(8,12,26,.35); }
.profile-element { display: inline-flex; align-items: center; gap: 3px; }
.profile-element img { width: 30px; height: 30px; object-fit: contain; }
.profile-element small { color: #d8c9e3; font-size: .58rem; font-weight: 700; }
.monster-profile-card.compact { width: 238px; }
.monster-profile-card.compact .profile-main { grid-template-columns: 82px minmax(0,1fr); min-height: 116px; }
.monster-profile-card.compact .profile-portrait { width: 82px; height: 116px; }
.owned-card-state { border-color: rgba(110,215,189,.7); }
.missing-card-state { border-color: rgba(255,154,145,.48); opacity: .78; }
.synergy-monsters { margin-top: 13px; }
.monster-strip.secondary { opacity: .88; }
.muted-inline { color: var(--muted); font-size: .78rem; }
.team-slots { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; margin-top: 12px; }
.team-slots .monster-profile-card.compact { width: 100%; }
.owned { border-color: rgba(110,215,189,.5); color: var(--jade); }
.missing { border-color: rgba(255,154,145,.5); color: var(--danger); }

.owned-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.owned-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.owned-card img { display: block; width: 100%; aspect-ratio: 1.45; object-fit: contain; background: #0b1016; image-rendering: auto; }
.owned-card-body { padding: 12px; }
.owned-card h3 small { display: block; color: var(--muted); font-size: .7rem; }
.form-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.form-toggle { min-height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.form-toggle[aria-pressed="true"] { border-color: var(--jade); background: var(--jade-dark); color: var(--text); }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.button { min-height: 42px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; }
.button.primary { border-color: #4e9f91; background: #24564f; }
.button.danger { color: var(--danger); }
.notice { padding: 15px; border: 1px solid rgba(145,191,255,.35); border-radius: 12px; background: rgba(59,94,139,.13); color: #c9dcf8; }
.empty { padding: 30px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }
.site-footer { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 34px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.site-footer p { margin: 4px 0; }

@media (max-width: 900px) {
  .hero, .guide-layout { grid-template-columns: 1fr; }
  .guide-nav { position: static; order: -1; }
  .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .owned-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  #app { width: min(100% - 22px, 1240px); padding-top: 26px; }
  .nav-toggle { display: block; }
  .primary-nav { position: absolute; top: 66px; left: 11px; right: 11px; display: none; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
  .primary-nav.open { display: grid; }
  .hero { gap: 20px; }
  .toolbar { grid-template-columns: 1fr; }
  .type-grid, .monster-list, .team-grid { grid-template-columns: 1fr; }
  .team-slots { grid-template-columns: 1fr; }
  .monster-profile-card.compact { width: min(100%,280px); }
  .owned-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-hero { grid-template-columns: 1fr; padding: 21px; }
  .score-ring { width: 90px; height: 90px; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #111; --muted: #444; --line: #bbb; }
  body { background: #fff; color: #111; font-size: 10pt; }
  .site-header, .site-footer, .guide-nav, .action-row, .toolbar { display: none !important; }
  #app { width: 100%; padding: 0; }
  .guide-hero, .guide-section, .rating-item, .monster-card, .team-card { box-shadow: none; break-inside: avoid; }
  .guide-layout { display: block; }
  a { color: #111; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; }
}
