@import url('https://fonts.googleapis.com/css2?family=Chiron+GoRound+TC:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --ink: #183329;
  --muted: #65786f;
  --paper: #fbf8ec;
  --cream: #f3eed9;
  --leaf: #2d704d;
  --leaf-dark: #1e5138;
  --sun: #f4a62a;
  --coral: #e66c4e;
  --line: rgba(24, 51, 41, 0.16);
  --shadow: 0 18px 45px rgba(42, 65, 48, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 24%, rgba(244, 166, 42, 0.11), transparent 24rem),
    linear-gradient(180deg, #cfe9dc 0 480px, var(--paper) 480px 100%);
  font-family: "Chiron GoRound TC", sans-serif;
  min-height: 100vh;
}

button, input { font: inherit; }
button { color: inherit; }

.sky {
  position: absolute;
  inset: 0 0 auto;
  height: 480px;
  overflow: hidden;
  pointer-events: none;
}

.sky::after {
  content: "";
  position: absolute;
  inset: auto -5% -1px;
  height: 100px;
  background: var(--paper);
  clip-path: polygon(0 82%, 8% 48%, 17% 76%, 28% 30%, 39% 72%, 52% 20%, 63% 76%, 76% 38%, 87% 68%, 100% 28%, 100% 100%, 0 100%);
}

.cloud {
  position: absolute;
  width: 110px;
  height: 28px;
  border-radius: 50px;
  background: rgba(255,255,255,.5);
  animation: drift 22s ease-in-out infinite alternate;
}

.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before { width: 52px; height: 52px; left: 18px; bottom: 0; }
.cloud::after { width: 38px; height: 38px; right: 17px; bottom: 0; }
.cloud-one { top: 138px; left: 7%; }
.cloud-two { top: 85px; right: 12%; transform: scale(.72); animation-delay: -8s; }
.cloud-three { top: 300px; right: 28%; transform: scale(.45); animation-delay: -14s; }

.site-header, main, footer {
  position: relative;
  width: min(1160px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 96px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 50% 45% 50% 38%;
  background: var(--sun);
  font: 700 21px/1 "DM Mono", monospace;
  transform: rotate(-7deg);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: .08em; }
.brand small { margin-top: 2px; font: 500 9px/1.2 "DM Mono", monospace; letter-spacing: .15em; }

.version-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid rgba(24, 51, 41, .25);
  border-radius: 99px;
  font: 500 11px/1 "DM Mono", monospace;
  background: rgba(255,255,255,.35);
}

.version-pill span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--leaf);
  box-shadow: 0 0 0 4px rgba(45,112,77,.13);
}

.hero {
  min-height: 384px;
  display: grid;
  grid-template-columns: 1fr .8fr;
  gap: 80px;
  align-items: center;
  padding: 34px 24px 72px;
}

.eyebrow, .section-number {
  margin: 0 0 16px;
  color: var(--leaf);
  font: 500 11px/1 "DM Mono", monospace;
  letter-spacing: .18em;
}

h1 {
  margin: 0;
  font-size: clamp(46px, 6vw, 76px);
  line-height: 1.08;
  letter-spacing: -.07em;
}

h1 em { color: var(--leaf); font-style: normal; }

.hero-intro {
  max-width: 580px;
  margin: 24px 0 0;
  color: #496259;
  font-size: 15px;
  line-height: 1.8;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 26px 0;
  border-block: 1px solid rgba(24,51,41,.22);
}

.hero-stats article { padding: 0 20px; border-right: 1px solid rgba(24,51,41,.18); }
.hero-stats article:first-child { padding-left: 0; }
.hero-stats article:last-child { border: 0; }
.hero-stats span { display: block; font: 500 clamp(28px, 4vw, 44px)/1 "DM Mono", monospace; }
.hero-stats p { margin: 9px 0 0; color: var(--muted); font-size: 12px; }

.explorer { padding: 76px 0 100px; }

.explorer-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.explorer h2 { margin: 0; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.04em; }
.result-count { margin: 0 0 7px; color: var(--muted); font: 400 12px/1 "DM Mono", monospace; }

.search-panel {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.62);
  box-shadow: 0 12px 35px rgba(51,75,58,.06);
  backdrop-filter: blur(12px);
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
}

.search-box > span { font: 500 29px/1 "DM Mono", monospace; transform: rotate(-15deg); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 15px; }
.search-box input::placeholder { color: #87968f; }
.search-box kbd { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--cream); font: 11px/1 "DM Mono", monospace; }

.filters { display: flex; gap: 6px; }
.filter-button { padding: 10px 14px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-size: 12px; white-space: nowrap; }
.filter-button:hover { background: var(--cream); }
.filter-button.active { color: white; background: var(--leaf); }

.monster-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.monster-card {
  position: relative;
  padding: 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  animation: rise .45s both;
}

.monster-card::after {
  content: "";
  position: absolute;
  right: -36px;
  bottom: -48px;
  width: 120px;
  height: 120px;
  border: 18px solid rgba(45,112,77,.045);
  border-radius: 48% 52% 44% 56%;
  transform: rotate(-18deg);
}

.monster-card:hover { border-color: rgba(45,112,77,.4); box-shadow: var(--shadow); }
.card-header { position: relative; z-index: 1; display: grid; gap: 13px; }
.monster-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.monster-image-shell { display: grid; flex: 0 0 76px; place-items: center; width: 76px; height: 76px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg, #e9f3e7, #fff9e8); }
.monster-image { width: 66px; height: 66px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 5px 4px rgba(24,51,41,.14)); }
.monster-level { color: var(--leaf); font: 500 12px/1 "DM Mono", monospace; }
.monster-name { position: relative; z-index: 1; margin: 6px 0 0; font-size: 20px; line-height: 1.2; letter-spacing: -.03em; }
.card-label { display: inline-block; margin-top: 7px; color: var(--coral); font: 500 9px/1 "DM Mono", monospace; letter-spacing: .12em; }
.card-counts { display: flex; gap: 20px; margin: 0; padding-top: 11px; border-top: 1px solid var(--line); }
.card-counts strong { display: block; font: 500 17px/1 "DM Mono", monospace; }
.card-counts small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.stat-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 14px 0 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.58); }
.stat-grid div { min-width: 0; padding: 8px 6px; text-align: center; }
.stat-grid div:not(:nth-child(3n + 1)) { border-left: 1px solid var(--line); }
.stat-grid div:nth-child(n + 4) { border-top: 1px solid var(--line); }
.stat-grid dt { color: var(--muted); font-size: 8px; font-weight: 600; letter-spacing: .08em; }
.stat-grid dd { overflow: hidden; margin: 4px 0 0; color: var(--ink); font: 500 11px/1.1 "DM Mono", monospace; text-overflow: ellipsis; }
.card-details { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 18px; }

.empty-state { padding: 70px 20px; text-align: center; }
.empty-state span { display: grid; place-items: center; width: 65px; height: 65px; margin: auto; border-radius: 50%; color: white; background: var(--coral); font: 500 34px/1 "DM Mono", monospace; transform: rotate(8deg); }
.empty-state h3 { margin: 20px 0 6px; font-size: 22px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

.load-more { display: block; min-width: 190px; margin: 34px auto 0; padding: 13px 22px; border: 1px solid var(--ink); border-radius: 99px; background: transparent; cursor: pointer; }
.load-more:hover { color: white; background: var(--ink); }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px 0 42px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
footer p { margin: 0; }
footer p:first-child { color: var(--ink); font-family: "DM Mono", monospace; letter-spacing: .12em; }

.monster-dialog {
  width: min(860px, calc(100% - 28px));
  max-height: min(86vh, 900px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(20,45,34,.32);
}

.monster-dialog::backdrop { background: rgba(17,42,32,.55); backdrop-filter: blur(5px); }
.dialog-shell { position: relative; padding: 38px; }
.dialog-close { position: sticky; z-index: 2; top: 0; float: right; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); cursor: pointer; font-size: 24px; }
.dialog-kicker { margin: 0 0 10px; color: var(--coral); font: 500 11px/1 "DM Mono", monospace; letter-spacing: .14em; }
.dialog-title { margin: 0; font: 500 clamp(36px, 7vw, 58px)/1 "DM Mono", monospace; letter-spacing: -.04em; }
.dialog-level { margin: 10px 0 0; color: var(--muted); font: 400 11px/1 "DM Mono", monospace; letter-spacing: .1em; }
.dialog-episode { margin: 26px 0 32px; padding: 18px 20px; border-left: 3px solid var(--sun); color: #51645c; background: var(--cream); white-space: pre-line; font-size: 13px; line-height: 1.75; }
.detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.detail-section h3, .detail-section h4 { display: flex; justify-content: space-between; margin: 0 0 8px; padding-bottom: 7px; border-bottom: 1px solid var(--line); font-size: 12px; }
.detail-section h3 span, .detail-section h4 span { color: var(--muted); font: 400 10px/1 "DM Mono", monospace; }
.map-details summary { display: flex; align-items: center; justify-content: space-between; padding: 8px 30px 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12px; font-weight: 600; list-style: none; position: relative; }
.map-details summary::-webkit-details-marker { display: none; }
.map-details summary::after { position: absolute; right: 3px; content: "+"; color: var(--leaf-dark); font: 500 18px/1 "DM Mono", monospace; transition: transform .2s ease; }
.map-details[open] summary::after { transform: rotate(45deg); }
.map-details summary span { color: var(--muted); font: 400 10px/1 "DM Mono", monospace; }
.map-details-content { padding-top: 8px; }
.id-list { display: grid; gap: 5px; }
.id-chip { display: grid; gap: 3px; min-height: 38px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--leaf-dark); background: white; }
.id-chip.has-image { grid-template-columns: 34px minmax(0, 1fr); align-items: center; padding: 4px 7px 4px 4px; }
.item-image-shell { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--cream); }
.item-image { width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; }
.chip-copy { display: grid; min-width: 0; gap: 4px; }
.id-chip strong { font-size: 10px; font-weight: 600; line-height: 1.3; }
.id-chip small { overflow: hidden; color: var(--muted); font: 400 8px/1.25 "DM Mono", monospace; text-overflow: ellipsis; white-space: nowrap; }
.no-data { margin: 0; color: var(--muted); font-size: 12px; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes drift { to { transform: translateX(35px); } }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 34px; padding-inline: 0; }
  .hero-stats { max-width: 570px; }
  .monster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-panel { align-items: stretch; flex-direction: column; }
  .search-box { min-height: 46px; border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
}

@media (max-width: 560px) {
  body { background: linear-gradient(180deg, #cfe9dc 0 560px, var(--paper) 560px 100%); }
  .site-header, main, footer { width: min(100% - 26px, 1160px); }
  .version-pill { padding: 8px; font-size: 9px; }
  .hero { min-height: 460px; padding-top: 45px; }
  h1 { font-size: 48px; }
  .hero-stats article { padding-inline: 10px; }
  .hero-stats span { font-size: 25px; }
  .explorer { padding-top: 58px; }
  .explorer-heading { align-items: start; flex-direction: column; gap: 10px; }
  .filters { overflow-x: auto; }
  .monster-grid { grid-template-columns: 1fr; }
  .monster-card { padding: 15px; }
  .dialog-shell { padding: 28px 20px; }
  .detail-columns { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
