:root {
  /* game palette (public/style.css): black, orange, yellow */
  --bg: #120f0d; --bg-alt: #1b1613; --card: #231c17; --card-2: #2f261f; --line: #3a2e24;
  --text: #fff1dc; --muted: #c2a98c; --accent: #ff7a1a; --accent-hi: #ff8f3d; --yellow: #ffc933; --on-accent: #120f0d;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 28px rgba(0,0,0,.45);
  --fire: #ff6b4a; --water: #3fa9f5; --earth: #c9965a; --wind: #4fd1a5; --light: #ffc933; --dark: #a37cf0;
  --r: 20px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Noto Sans Thai", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, canvas { image-rendering: pixelated; }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.nav-in { display: flex; align-items: center; gap: 24px; height: 52px; }
.logo { font-weight: 700; letter-spacing: .02em; color: var(--text); font-size: 17px; }
.logo span { color: var(--accent); }
.logo:hover { text-decoration: none; }
.links { display: flex; gap: 22px; margin-left: auto; font-size: 13px; }
.links a { color: var(--muted); }
.links a:hover { color: var(--text); text-decoration: none; }
.lang { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.lang button { font: inherit; font-size: 12px; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 4px 10px; border-radius: 999px; cursor: pointer; min-height: 28px; }
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
@media (max-width: 680px) { .links { display: none; } .lang { margin-left: auto; } .nav-in { gap: 10px; } }

.btn { display: inline-block; background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--on-accent); font-weight: 600 !important; border: 0; border-radius: 999px; padding: 12px 22px; font: inherit; font-size: 16px; font-weight: 500; cursor: pointer; min-height: 44px; }
.btn:hover { background: var(--yellow); text-decoration: none; }
.btn-sm { padding: 6px 14px; font-size: 13px; min-height: 30px; }
.btn-ghost { background: transparent; color: var(--yellow); }
.btn-ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* ---------- hero: full-bleed sky-island town canvas (app.js town section), text over a dark fade ---------- */
.hero { --h: clamp(600px, 88svh, 820px);
  position: relative; height: var(--h); overflow: hidden; display: flex; align-items: center; isolation: isolate; }
.hero-bg { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; display: block; background: #6cc2ff; }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(18,15,13,.92) 0%, rgba(18,15,13,.82) 42%, rgba(18,15,13,.45) 54%, rgba(18,15,13,0) 66%),
              linear-gradient(0deg, var(--bg) 0, transparent 14%); }
/* desktop 50 / 50: text column = left half (inside a 1280 px wrap), the island owns the right half (app.js fitTown) */
/* text block (--tw wide) ends 40 px left of the centre line, so it sits toward the island instead of hugging the left edge */
.hero-in { --tw: min(580px, 50vw - 64px); width: 100%; padding: 0 0 0 calc(50vw - 40px - var(--tw)); }
.hero-in > * { max-width: var(--tw); }
.eyebrow { color: var(--yellow); font-size: 15px; font-weight: 600; margin: 0 0 14px; letter-spacing: .02em; }
h1 { font-size: clamp(44px, 5.6vw, 92px); font-weight: 700; text-shadow: 0 2px 24px rgba(0,0,0,.35); }
h1 em { font-style: normal; background: linear-gradient(90deg, var(--accent), var(--yellow)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: clamp(17px, 1.5vw, 22px); color: #f3dfc4; margin: 20px 0 0; }
.cta { margin-top: 32px; display: flex; gap: 12px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 8px; position: relative; text-align: center; }
.fact { background: var(--card); border-radius: var(--r); padding: 20px 12px; box-shadow: var(--shadow); }
.fact b { display: block; color: var(--yellow); font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.fact span { color: var(--muted); font-size: 14px; }
/* iPad / tablet: centred text, darker top for legibility */
@media (max-width: 1023px) {
  .hero { --h: clamp(640px, 82svh, 900px); align-items: flex-start; text-align: center; }
  .hero::after { background: linear-gradient(180deg, rgba(18,15,13,.86) 0%, rgba(18,15,13,.6) 38%, rgba(18,15,13,0) 52%), linear-gradient(0deg, var(--bg) 0, transparent 12%); }
  .hero-in { padding: 88px 16px 0; }
  .hero-in > * { max-width: 640px; margin-left: auto; margin-right: auto; }
  .lead { margin-top: 18px; }
  .cta { justify-content: center; }
}
/* phone */
@media (max-width: 680px) {
  .hero { --h: max(720px, 100svh); }
  .hero-in { padding-top: 56px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- sections ---------- */
.sec { padding: 96px 0; }
.sec.alt { background: var(--bg-alt); }
h2 { font-size: clamp(32px, 5vw, 48px); font-weight: 700; text-align: center; }
.sub { color: var(--muted); text-align: center; max-width: 680px; margin: 14px auto 36px; font-size: 18px; }
.sub.sm { font-size: 15px; margin-bottom: 20px; }
.h3 { font-size: 24px; text-align: center; margin-top: 64px; }
.empty { text-align: center; color: var(--muted); }

/* ---------- sprite (idle strip, CSS steps) ---------- */
.sprite { --f: 96px; --z: 1; display: inline-block; flex: none; width: calc(var(--f) * var(--z)); height: calc(var(--f) * var(--z)); background: var(--src) 0 0 / auto 200% no-repeat; image-rendering: pixelated; animation: play calc(var(--ms) * var(--n)) steps(var(--n)) infinite; }
@keyframes play { to { background-position-x: calc(var(--f) * var(--z) * var(--n) * -1); } }
@media (prefers-reduced-motion: reduce) { .sprite { animation: none; } }

/* ---------- search + chips ---------- */
.search { max-width: 520px; margin: 0 auto 18px; }
.search input { width: 100%; font: inherit; font-size: 17px; padding: 14px 20px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); outline: none; box-shadow: var(--shadow); -webkit-appearance: none; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.chip { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- monster grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 28px; }
.card { background: var(--card); border: 0; border-radius: var(--r); box-shadow: var(--shadow); padding: 8px 10px 14px; text-align: center; cursor: pointer; font: inherit; color: var(--text); transition: transform .2s ease; }
.card:hover { transform: translateY(-2px); }
.card .sprite { --z: 1.5; display: block; margin: 0 auto -8px; }
.card b { display: block; font-size: 15px; font-weight: 600; }
.card small { color: var(--muted); font-size: 12px; }
.card.secret { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); }
.card .sec { display: block; color: var(--yellow); font-weight: 600; margin: 2px 0; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.more-row { text-align: center; margin-top: 24px; }
.more { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.more:hover { background: var(--card-2); }

/* ---------- dialog ---------- */
dialog { border: 0; padding: 0; border-radius: 24px; background: var(--card); color: var(--text); width: min(880px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dlg-in { position: relative; padding: 28px 24px 32px; }
.x { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--card-2); color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.dh { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-right: 40px; }
.dh .sprite { --z: 1.5; margin: -12px -12px -16px -16px; }
.dh h3 { font-size: 30px; display: inline-block; vertical-align: middle; margin-right: 12px; }
.share { font: inherit; font-size: 13px; font-weight: 600; vertical-align: middle; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-2); color: var(--yellow); cursor: pointer; min-height: 32px; }
.share:hover { border-color: var(--accent); }
.share-url { display: block; width: 100%; max-width: 420px; margin-top: 8px; font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--card-2); color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.dsec { margin-top: 28px; }
.dsec h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.note { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

/* evolution: columns T1..T5, each a stack of options */
.evo { display: grid; grid-template-columns: repeat(5, minmax(108px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.ecol { display: flex; flex-direction: column; gap: 8px; }
.ecol > i { font-style: normal; font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; }
.eo { background: var(--card-2); border-radius: 14px; padding: 2px 6px 10px; text-align: center; font: inherit; color: var(--text); border: 2px solid transparent; cursor: pointer; }
.eo.me { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.eo .sprite { display: block; margin: 0 auto -6px; }
.eo b { display: block; font-size: 13px; font-weight: 600; }
.eo small { font-size: 11px; color: var(--muted); }
.eo.mut small { color: var(--yellow); font-weight: 600; }
.eo.lock { cursor: default; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 128px; color: var(--muted); }
.eo.lock .q { font-size: 34px; font-weight: 700; opacity: .35; line-height: 1; }
.stats { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.stats th, .stats td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats th { color: var(--muted); font-weight: 500; }
.from { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- skill trees ---------- */
.tabs { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; background: var(--card); padding: 4px; border-radius: 999px; width: fit-content; max-width: 100%; margin: 0 auto 12px; box-shadow: var(--shadow); }
.tab { font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--text); padding: 8px 16px; border-radius: 999px; cursor: pointer; min-height: 36px; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.tabs-sm { box-shadow: none; background: transparent; }
.tabs-sm .tab { border: 1px solid var(--line); background: var(--card); display: inline-flex; gap: 6px; align-items: center; }
.tabs-sm .tab[aria-selected="true"] { background: var(--c); border-color: var(--c); color: #1d1d1f; }
.tree { background: var(--card); border-radius: 24px; box-shadow: var(--shadow); padding: 28px 24px; margin-top: 16px; }
.tree-h { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.tree-h h3 { font-size: 26px; }
.tree-h span { color: var(--muted); }
.tier { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.tier > i { font-style: normal; color: var(--muted); font-size: 13px; font-weight: 600; padding-top: 4px; }
.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.node { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: start; }
.node img { width: 48px; height: 48px; border-radius: 12px; background: var(--bg-alt); }
.node b { font-size: 15px; font-weight: 600; }
.node p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.type { font-size: 11px; padding: 1px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 2px; background: var(--bg-alt); color: var(--muted); white-space: nowrap; }
.type.A { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.type.C { background: color-mix(in srgb, var(--yellow) 20%, transparent); color: var(--yellow); }
@media (max-width: 560px) { .tier { grid-template-columns: 1fr; } .tree { padding: 20px 16px; } }
.bridges { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.bridge { background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.bridge b { font-size: 15px; }
.bridge p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.bridge .pair { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- gear ---------- */
.grid-gear { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.gcard { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.gcard header { display: flex; gap: 12px; align-items: center; }
.gcard img { width: 48px; height: 48px; background: var(--bg-alt); border-radius: 12px; padding: 4px; }
.gcard b { font-size: 16px; }
.gcard p { margin: 10px 0 12px; font-size: 14px; color: var(--muted); }
.stars { display: grid; grid-template-columns: auto repeat(5, 1fr); gap: 2px 6px; font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.stars span:first-child, .stars .k { text-align: left; color: var(--muted); }
.stars .h { color: var(--yellow); }

/* ---------- aura ---------- */
.aura { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.stage { background: radial-gradient(ellipse at 50% 70%, color-mix(in srgb, var(--accent) 10%, var(--card)), var(--card) 70%); border-radius: 28px; box-shadow: var(--shadow); text-align: center; padding: 12px 12px 16px; position: sticky; top: 72px; }
.stage canvas { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 16px; }
.slot { font: inherit; font-size: 13px; padding: 10px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-align: left; min-height: 44px; }
.slot[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.slot small { display: block; color: var(--muted); font-size: 11px; }
.ainfo { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.ainfo h3 { font-size: 22px; }
.ainfo ul { padding-left: 18px; margin: 10px 0; font-size: 14px; }
.ainfo li { margin: 4px 0; }
.ainfo li b { font-weight: 600; }
.ainfo .set { margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 14%, var(--card)); font-size: 14px; }
@media (max-width: 760px) { .aura { grid-template-columns: 1fr; } .stage { position: static; } }

/* ---------- modes ---------- */
/* 2 × 3 cards: portrait in-game screen captures (web/s/mode-*.png) left, text right; stacked on phones */
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mode { background: var(--card); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; display: grid; grid-template-columns: 44% 1fr; align-items: center; }
.mode > img { width: 100%; height: 100%; aspect-ratio: 3 / 4; display: block; object-fit: cover; object-position: top; image-rendering: auto; }
.mode > div { padding: 20px 22px 24px; }
.mode h3 { font-size: 21px; }
.mode p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
@media (max-width: 860px) { .modes { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .mode { grid-template-columns: 1fr; } .mode > img { height: auto; aspect-ratio: 4 / 3; } }

.end { text-align: center; }
.end .sub { margin-bottom: 28px; }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 20px 0 32px; }
.foot-in { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.contact { display: flex; align-items: center; gap: 16px; }
.contact a { color: var(--text); font-weight: 600; }

/* ---------- game tags (copied from public/style.css: element-chip, grade-chip, lean-chip, mutant-tag) ---------- */
.gtags { --paper-2: #2f261f; --paper-3: #3d3027; --ink-2: #3a2e24; --black: #120f0d; --black-2: #1b1613; --shade: #0c0a08;
  --orange: #ff7a1a; --orange-d: #b84a00; --orange-l: #ffab5e; --yellow-d: #c98f00; --yellow-l: #fff08a;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; padding: 4px; }
.gtags > * { min-height: 30px; display: inline-flex; align-items: center; font-weight: 700; font-size: 14px; line-height: 1; }
.ico { --size: 24px; display: inline-block; width: var(--size); height: var(--size); flex: none; background: url(i/icons.png) no-repeat;
  background-size: calc(var(--icons-n, 16) * var(--size)) var(--size); background-position: calc(var(--i, 0) * -1 * var(--size)) 0; image-rendering: pixelated; }
.element-chip { gap: 6px; padding: 3px 10px 3px 6px; background: var(--el-core); color: var(--el-rim);
  box-shadow: 0 -2px 0 0 var(--el-rim), 0 2px 0 0 var(--el-rim), -2px 0 0 0 var(--el-rim), 2px 0 0 0 var(--el-rim); }
.grade-chip { --g-bg: var(--paper-2); --g-fg: var(--muted); --g-rim: var(--ink-2); --g-box: var(--black-2); --g-let: var(--muted);
  gap: 5px; padding: 2px 3px 2px 8px; background: var(--g-bg); color: var(--g-fg);
  box-shadow: 0 -2px 0 0 var(--g-rim), 0 2px 0 0 var(--g-rim), -2px 0 0 0 var(--g-rim), 2px 0 0 0 var(--g-rim), 3px 5px 0 0 var(--shade); }
.grade-chip b { display: inline-grid; place-items: center; min-width: 1.5em; align-self: stretch; padding: 0 4px; font-size: 1.05em; background: var(--g-box); color: var(--g-let); }
.grade-chip[data-grade="D"] { --g-rim: var(--orange-d); --g-let: var(--orange-l); }
.grade-chip[data-grade="C"] { --g-bg: var(--paper-3); --g-fg: var(--yellow-l); --g-rim: var(--yellow-d); --g-let: var(--yellow); }
.grade-chip[data-grade="B"] { --g-bg: var(--orange); --g-fg: var(--black); --g-rim: var(--orange-d); --g-box: var(--black); --g-let: var(--orange-l); }
.grade-chip[data-grade="A"] { --g-bg: var(--yellow); --g-fg: var(--black); --g-rim: var(--black); --g-box: var(--black); --g-let: var(--yellow);
  box-shadow: 0 -2px 0 0 var(--black), 0 2px 0 0 var(--black), -2px 0 0 0 var(--black), 2px 0 0 0 var(--black),
    0 -4px 0 0 var(--yellow-d), 0 4px 0 0 var(--yellow-d), -4px 0 0 0 var(--yellow-d), 4px 0 0 0 var(--yellow-d), 5px 7px 0 0 var(--shade); }
.grade-chip[data-grade="A"]::after { content: "✦"; color: var(--yellow-l); font-size: .8em; margin: 0 2px 0 -1px; text-shadow: 1px 1px 0 var(--orange-d); }
.lean-chip { padding: 0 10px; color: #fff; box-shadow: 3px 4px 0 0 var(--shade); }
.lean-attack { background: #d9542f; } .lean-defense { background: #3a7fc0; } .lean-speed { background: #3f9a70; } .lean-balanced { background: #9a6ae0; }
.mutant-tag { padding: 0 10px; color: #fff; text-shadow: 1px 1px 0 #000;
  background: linear-gradient(90deg, #ff4d4d, #ffa94d, #ffe066, #69db7c, #4dabf7, #9775fa, #ff4d4d) 0 0 / 200% 100%;
  box-shadow: 0 0 0 2px #000; animation: rainbow 3s linear infinite; }
@keyframes rainbow { to { background-position: 200% 0; } }
@media (prefers-reduced-motion: reduce) { .mutant-tag { animation: none; } }
.hatch-tag { padding: 0 10px; background: var(--paper-2); color: var(--muted); box-shadow: 0 0 0 2px var(--ink-2); font-weight: 600 !important; }
.more[hidden], .card[hidden] { display: none; }

/* ?og: 1200×630 social card capture (web/og-*.png): hero only, full viewport */
.og .nav { display: none; }
.og .hero { --h: 100vh; }
.og-brand { display: none; }
.og .og-brand { display: block; font-size: 30px; font-weight: 700; margin: 0 0 22px; }
.og-brand span { color: var(--accent); }
.og .cta { display: none; }
