:root {
  /* Light tokens are the base; dark applies for data-theme="dark", or for the system choice when it prefers dark. */
  color-scheme: light;
  --bg: #f3f5fb;
  --panel: #ffffffe6;
  --line: #0b10201f;
  --text: #141a33;
  --muted: #5a6385;
  --accent: #4361ee;
  --accent-2: #e0459b;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --glass: #0b10200a;
  --glass-2: #0b102014;
  --toolbar: #f3f5fbf2;
  --scrim: #0b102066;
  --aurora: .16;
  --shine-a: #4361ee; --shine-b: #141a33; --shine-c: #e0459b;
  --radius: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --G: #3fb950; --R: #ff6b3d; --W: #3aa5ff; --L: #f5c518; --P: #b46cff;
  --F: #d9823b; --D: #4b5a7a; --M: #9fb3c8; --N: #c9a227; --C: #d8dbe6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1020; --panel: #131a30cc; --line: #ffffff1a; --text: #eef1ff; --muted: #9aa3c7;
    --accent: #6d8bff; --accent-2: #ff6fd8; --surface: #111832f2; --surface-2: #151d3af5;
    --glass: #ffffff0d; --glass-2: #ffffff1f; --toolbar: #0b1020f0; --scrim: #050814b3; --aurora: .3;
    --shine-a: #8fb0ff; --shine-b: #fff; --shine-c: #ff9de6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020; --panel: #131a30cc; --line: #ffffff1a; --text: #eef1ff; --muted: #9aa3c7;
  --accent: #6d8bff; --accent-2: #ff6fd8; --surface: #111832f2; --surface-2: #151d3af5;
  --glass: #ffffff0d; --glass-2: #ffffff1f; --toolbar: #0b1020f0; --scrim: #050814b3; --aurora: .3;
  --shine-a: #8fb0ff; --shine-b: #fff; --shine-c: #ff9de6;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  transition: background-color .3s, color .3s;
  font: 16px/1.6 "IBM Plex Sans Thai", system-ui, sans-serif;
  overflow-x: hidden;
}
h1, h2, h3, .eyebrow { font-family: Kanit, "IBM Plex Sans Thai", sans-serif; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- background aurora (transform/opacity only) ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  background: radial-gradient(closest-side, var(--c), transparent);
  opacity: var(--aurora); translate: 0 0; will-change: translate;
}
.aurora i:nth-child(1) { --c: #3b4cff; top: -30vmax; left: -20vmax; }
.aurora i:nth-child(2) { --c: #c13cff; top: 5vmax; right: -30vmax; }
.aurora i:nth-child(3) { --c: #00c2ff; bottom: -35vmax; left: 15vmax; }
@media (prefers-reduced-motion: no-preference) {
  .aurora i { animation: drift 22s var(--ease) infinite alternate; }
  .aurora i:nth-child(2) { animation-duration: 28s; animation-delay: -6s; }
  .aurora i:nth-child(3) { animation-duration: 34s; animation-delay: -12s; }
}
@keyframes drift { to { translate: 8vmax 6vmax; } }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 24px;
  max-width: 1200px; margin: 0 auto; padding: 24px 24px 24px;
}
.eyebrow { margin: 0; color: var(--accent); letter-spacing: .08em; font-weight: 500; font-size: .9rem; }
h1 { margin: .2em 0 .3em; font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.15; font-weight: 700; }
.shine {
  background: linear-gradient(100deg, var(--shine-a) 20%, var(--shine-b) 40%, var(--shine-c) 60%, var(--shine-a) 80%) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
@media (prefers-reduced-motion: no-preference) {
  .shine { animation: sweep 3s linear 2; }
}
@keyframes sweep { to { background-position: 300% 0; } }
.lede { color: var(--muted); max-width: 36ch; margin: 0; }
.lede span { color: var(--text); font-weight: 600; }

.fan { --s: 1; position: relative; height: 340px; perspective: 1200px; }
.fan img {
  position: absolute; left: 50%; top: 50%; width: 170px; aspect-ratio: 367 / 512;
  border-radius: 10px; box-shadow: 0 18px 40px #0008;
  translate: calc(-50% + var(--x) * var(--s)) -50%; rotate: var(--r); scale: 1;
  transition: translate .6s var(--ease), rotate .6s var(--ease), scale .6s var(--ease);
}
@media (prefers-reduced-motion: no-preference) {
  .fan img { animation: deal .9s var(--ease) backwards, bob 5s ease-in-out infinite alternate; animation-delay: var(--d), calc(var(--d) + .9s); }
  .fan:hover img { translate: calc(-50% + var(--x) * var(--s) * 1.35) -54%; }
  .fan img:hover { scale: 1.08; z-index: 9; }
}
.hero.off .fan img { animation-play-state: paused; }
@keyframes deal { from { translate: -50% 40%; rotate: 0deg; opacity: 0; } }
@keyframes bob { to { translate: calc(-50% + var(--x) * var(--s)) calc(-50% - 10px); } }

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px max(24px, (100% - 1152px) / 2) 20px;
  background: linear-gradient(var(--toolbar) 70%, transparent);
}
.search {
  flex: 1 1 280px; display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px;
  transition: border-color .2s;
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 10px 0; outline: none; }
select, .seg, .toggle {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
}
select { padding: 9px 14px; max-width: 220px; }
.seg { display: flex; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; transition: background .25s var(--ease); }
.seg button[aria-checked="true"] { background: var(--accent); color: #fff; }
.types { display: flex; gap: 6px; flex-wrap: wrap; }
.types button {
  width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  background: none; opacity: .62; filter: saturate(.6); scale: 1; transition: opacity .2s, scale .2s var(--ease), border-color .2s;
}
.types button:hover { opacity: 1; filter: none; scale: 1.1; }
.types button[aria-pressed="true"] { opacity: 1; filter: none; border-color: var(--text); }
.types .e { width: 100%; height: 100%; font-size: .8rem; }
.toggle { display: flex; align-items: center; gap: 8px; padding: 7px 14px; cursor: pointer; font-size: .9rem; }
.toggle input { accent-color: var(--accent); }

/* ---------- energy icon ---------- */
.e {
  display: inline-grid; place-items: center; width: 1.35em; height: 1.35em; border-radius: 50%;
  vertical-align: -.25em; font: 700 .72em/1 Kanit, sans-serif; color: #fff;
  background: radial-gradient(circle at 35% 30%, #fff6, transparent 55%), var(--c);
  box-shadow: inset 0 0 0 1px #0004;
}
.e svg { width: 70%; height: 70%; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.e-G { --c: var(--G); } .e-R { --c: var(--R); } .e-W { --c: var(--W); } .e-L { --c: var(--L); color: #3a2c00; }
.e-P { --c: var(--P); } .e-F { --c: var(--F); } .e-D { --c: var(--D); } .e-M { --c: var(--M); color: #1c2733; }
.e-N { --c: var(--N); } .e-C { --c: var(--C); color: #333; }

/* ---------- grid ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 0 24px 48px; }
.result { color: var(--muted); font-size: .9rem; margin: 4px 0 14px; }
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px;
}
.grid li { content-visibility: auto; contain-intrinsic-size: auto 150px auto 240px; }
.card {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
}
.card .tilt { border-radius: 8px; }
.card .meta { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; font-size: .82rem; }
.card .meta b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta span { color: var(--muted); flex: none; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .grid li { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
  }
}
@keyframes rise { from { opacity: 0; translate: 0 30px; scale: .94; } }

/* ---------- tilt + holo (shared by grid and detail) ---------- */
.tilt {
  --rx: 0deg; --ry: 0deg; --mx: 50%; --my: 50%; --o: 0;
  position: relative; aspect-ratio: 367 / 512; overflow: hidden; background: var(--glass);
  transform: perspective(700px) rotateX(var(--rx)) rotateY(var(--ry));
  translate: 0 0; scale: 1;
  transition: transform .5s var(--ease), translate .3s var(--ease), box-shadow .3s;
  box-shadow: 0 6px 18px #0006;
}
.tilt img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s; }
.tilt img.ok { opacity: 1; }

.glare {
  position: absolute; inset: 0; pointer-events: none; opacity: var(--o); transition: opacity .3s; mix-blend-mode: overlay;
  background: radial-gradient(circle at var(--mx) var(--my), #fffc, #fff0 55%);
}
.holo .glare {
  mix-blend-mode: color-dodge;
  background:
    radial-gradient(circle at var(--mx) var(--my), #fff9, #fff0 45%),
    repeating-linear-gradient(115deg, #ff008033 0 6%, #ffd30033 12%, #00ff9933 18%, #00c8ff33 24%, #a000ff33 30%) var(--mx) var(--my) / 300% 300%;
}
.card:hover .tilt, .card:focus-visible .tilt { translate: 0 -6px; box-shadow: 0 16px 34px #0006, 0 0 0 1px var(--line); }
.tilt.active { transition: transform .08s linear, translate .3s var(--ease), box-shadow .3s; --o: 1; }

/* ---------- detail dialog ---------- */
dialog {
  width: min(980px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 28px; border: 1px solid var(--line);
  border-radius: 22px; background: var(--surface); color: var(--text); overflow: auto;
  display: grid; grid-template-columns: minmax(220px, 360px) 1fr; gap: 32px; align-items: start;
}
dialog:not([open]) { display: none; }
dialog::backdrop { background: var(--scrim); }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: pop .45s var(--ease); }
  dialog[open]::backdrop { animation: fade .3s; }
}
@keyframes pop { from { opacity: 0; scale: .96; translate: 0 12px; } }
@keyframes fade { from { opacity: 0; } }
.close {
  position: absolute; top: 12px; right: 14px; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--glass); font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.close:hover { background: var(--glass-2); }
.d-card { position: sticky; top: 0; }
.d-card .tilt { border-radius: 16px; box-shadow: 0 24px 60px #000c; view-transition-name: hero-card; }
.d-info h2 { margin: 0 40px 4px 0; font-size: 2rem; line-height: 1.2; }
.d-info .sub { color: var(--muted); margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--glass-2); font-size: .85rem; color: var(--text); }
.hp { font: 700 1.6rem Kanit, sans-serif; margin-left: auto; }
.hp small { font-size: .75rem; color: var(--muted); margin-right: 4px; }
.block { border-top: 1px solid var(--line); padding: 14px 0; }
.block-head { display: flex; align-items: center; gap: 10px; }
.block-head .cost { display: flex; gap: 2px; }
.block-head h3 { margin: 0; font-size: 1.15rem; font-weight: 500; }
.block-head h3 small { display: block; font: 400 .78rem "IBM Plex Sans Thai", sans-serif; color: var(--muted); }
.block-head .dmg { margin-left: auto; font: 700 1.4rem Kanit, sans-serif; }
.tag { font: 600 .72rem Kanit, sans-serif; letter-spacing: .05em; padding: 2px 8px; border-radius: 6px; background: #e0403a; color: #fff; }
.block p { margin: 8px 0 0; }
.en { color: var(--muted); font-size: .88rem; }
.hide-en .en { display: none; }
.stats { display: flex; gap: 24px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font-size: .9rem; }
.stats b { color: var(--text); font-weight: 500; margin-left: 6px; }
.d-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 18px; font-size: .82rem; color: var(--muted); }
.d-foot label { display: flex; gap: 6px; align-items: center; cursor: pointer; }

::view-transition-group(hero-card) { animation-duration: .45s; animation-timing-function: var(--ease); }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

.more { height: 1px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
footer { max-width: 1200px; margin: 0 auto; padding: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
footer p { margin: 0 0 8px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding: 32px 16px 8px; text-align: center; }
  .lede { margin: 0 auto; }
  .fan { --s: .62; height: 220px; }
  .fan img { width: 112px; }
  .toolbar { position: static; padding: 8px 16px 12px; gap: 8px; }
  .search { flex-basis: 100%; }
  select { flex: 1; min-width: 0; }
  .types { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px; }
  .types button { flex: none; }
  .toggle { font-size: .82rem; }
  main, footer { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
  dialog { grid-template-columns: 1fr; padding: 60px 16px 20px; gap: 16px; }
  .d-card { position: static; max-width: 260px; margin: 0 auto; width: 100%; }
}

/* ---------- more filters ---------- */
.more-filters { position: relative; }
.more-filters summary {
  list-style: none; cursor: pointer; padding: 7px 14px; border-radius: 999px; font-size: .9rem;
  background: var(--panel); border: 1px solid var(--line); display: flex; gap: 8px; align-items: center;
}
.more-filters summary::-webkit-details-marker { display: none; }
.more-filters summary::after { content: ""; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 2px 2px 0; rotate: 45deg; translate: 0 -2px; transition: rotate .25s var(--ease); }
.more-filters[open] summary::after { rotate: -135deg; translate: 0 2px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-2); color: #fff; font: 600 .75rem/20px Kanit, sans-serif; text-align: center; }
.panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 6; width: min(320px, calc(100vw - 32px));
  display: grid; gap: 12px; padding: 16px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line); box-shadow: 0 20px 50px #0005;
}
@media (prefers-reduced-motion: no-preference) {
  .more-filters[open] .panel { animation: pop .3s var(--ease); }
}
.panel label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.panel select { max-width: none; width: 100%; border-radius: 10px; color: var(--text); }
.panel fieldset { border: 0; padding: 0; margin: 0; display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.panel legend { padding: 0; margin-bottom: 4px; }
.panel input[type="number"] { width: 100%; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); color: var(--text); }
.panel .check { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.panel .check input { accent-color: var(--accent); }
.link { justify-self: start; border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: .85rem; }

/* ---------- versions in detail ---------- */
.d-info { min-width: 0; } /* lets the versions row scroll instead of widening the dialog */
.versions { border-top: 1px solid var(--line); padding: 14px 0 0; margin-top: 14px; }
.versions h3 { margin: 0 0 10px; font-size: 1rem; font-weight: 500; }
.versions h3 small { color: var(--muted); font: 400 .8rem "IBM Plex Sans Thai", sans-serif; margin-left: 6px; }
.versions ul { list-style: none; margin: 0; padding: 0 0 6px; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; }
.versions li { flex: none; scroll-snap-align: start; }
.ver { width: 76px; padding: 0; border: 0; background: none; cursor: pointer; text-align: center; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.ver img { display: block; width: 100%; aspect-ratio: 367 / 512; object-fit: cover; border-radius: 6px; margin-bottom: 4px; outline: 2px solid transparent; outline-offset: 2px; translate: 0 0; transition: translate .25s var(--ease), outline-color .2s; }
.ver:hover img { translate: 0 -3px; }
.ver[aria-current] { color: var(--text); }
.ver[aria-current] img { outline-color: var(--accent); }

@media (max-width: 760px) {
  #sort { flex: 1; min-width: 0; }
  .more-filters { width: 100%; }
  .more-filters summary { width: fit-content; }
  .panel { position: static; width: 100%; margin-top: 8px; box-shadow: none; }
}

/* ---------- top bar: brand, tabs, feedback, theme ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  max-width: 1200px; margin: 0 auto; padding: 16px 24px 0;
}
.brand { font: 700 1.25rem Kanit, sans-serif; color: var(--text); text-decoration: none; letter-spacing: .01em; }
.brand b { color: var(--accent); }
.tabs { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 6px 16px; border-radius: 999px; cursor: pointer; font-weight: 500; transition: background .25s var(--ease), color .25s; }
.tabs button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pill { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: .9rem; }
.pill svg, .theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill:hover { border-color: var(--accent); }
.theme { display: flex; padding: 3px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.theme button { display: grid; place-items: center; width: 32px; height: 30px; border: 0; border-radius: 999px; background: none; cursor: pointer; color: var(--muted); transition: background .2s, color .2s; }
.theme button[aria-checked="true"] { background: var(--glass-2); color: var(--text); }

/* ---------- deck mode ---------- */
.deck-hint { display: none; margin: -8px 0 14px; font-size: .85rem; color: var(--muted); }
.deck-mode .deck-hint { display: block; }
.grid li { position: relative; }
.info, .qty { display: none; }
.deck-mode .info {
  display: grid; place-items: center; position: absolute; bottom: 40px; right: 6px; z-index: 2;
  width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: #000a; color: #fff; font: 700 .85rem Kanit, sans-serif;
}
.deck-mode .qty:not(:empty) {
  display: block; position: absolute; top: 6px; left: 6px; z-index: 2; padding: 2px 9px; border-radius: 999px;
  background: var(--accent); color: #fff; font: 700 .85rem Kanit, sans-serif; box-shadow: 0 2px 8px #0006;
}
@media (prefers-reduced-motion: no-preference) {
  .deck-mode .qty:not(:empty) { animation: bump .3s var(--ease); }
}
@keyframes bump { 50% { scale: 1.25; } }

.layout { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: start; }
.deck-mode .layout { grid-template-columns: 1fr 340px; }
.deck {
  /* sits below the sticky filter toolbar (~130px tall on desktop) */
  position: sticky; top: 136px; max-height: calc(100dvh - 152px); display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface-2); overflow: hidden;
}
/* display:flex above would otherwise override the hidden attribute */
.deck[hidden], .set-banner[hidden], .sets[hidden], .grid[hidden] { display: none; }
.deck-bar { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border: 0; background: none; font: 600 1rem Kanit, sans-serif; cursor: default; text-align: left; }
.deck-bar b { margin-left: auto; padding: 2px 10px; border-radius: 999px; background: var(--glass-2); }
.deck-bar b.full { background: #2ea043; color: #fff; }
.chev { display: none; }
.deck-body { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 16px; overflow: auto; }
.deck-name { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); }
.energy-pick { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
.energy-pick small { font-size: .78rem; }
#deck-energy { display: flex; gap: 6px; flex-wrap: wrap; }
#deck-energy button { width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: none; cursor: pointer; opacity: .35; transition: opacity .2s, border-color .2s; }
#deck-energy button[aria-pressed="true"] { opacity: 1; border-color: var(--text); }
#deck-energy button.auto[aria-pressed="true"] { border-style: dashed; }
#deck-energy .e { width: 100%; height: 100%; }
.deck-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.deck-list li { display: flex; align-items: center; gap: 10px; padding: 4px; border-radius: 10px; background: var(--glass); }
.deck-list img { width: 34px; aspect-ratio: 367 / 512; object-fit: cover; border-radius: 4px; }
.deck-list .nm { flex: 1; min-width: 0; font-size: .88rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-list .nm small { display: block; color: var(--muted); font-size: .74rem; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1rem; line-height: 1; }
.stepper b { min-width: 1.2em; text-align: center; }
.deck-empty { margin: 0; font-size: .85rem; color: var(--muted); }
.deck-issues { margin: 0; padding-left: 18px; font-size: .82rem; color: #e5534b; }
.deck-actions { display: grid; gap: 8px; }
.primary, .ghost { padding: 10px 14px; border-radius: 12px; cursor: pointer; font-weight: 500; }
.primary { border: 0; background: var(--accent); color: #fff; }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.ghost { border: 1px solid var(--line); background: none; }
.ghost.danger { color: #e5534b; }

/* ---------- sheet dialogs (QR, feedback) ---------- */
.sheet { display: block; width: min(460px, calc(100vw - 32px)); grid-template-columns: none; }
.sheet:not([open]) { display: none; }
.sheet h2 { margin: 0 40px 14px 0; font-size: 1.35rem; }
.qr-box { background: #fff; border-radius: 14px; padding: 8px; max-width: 320px; margin: 0 auto 14px; }
.qr-box svg { display: block; width: 100%; height: auto; }
.steps { margin: 0 0 10px; padding-left: 20px; font-size: .9rem; display: grid; gap: 4px; }
.note { font-size: .8rem; color: var(--muted); margin: 8px 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row > * { flex: 1 1 auto; }
.field { display: grid; gap: 4px; margin-bottom: 12px; font-size: .85rem; color: var(--muted); }
.field select, .field textarea { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); color: var(--text); resize: vertical; font: inherit; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.check input { accent-color: var(--accent); }
.shot { margin: 10px 0 0; }
.shot img { display: block; width: 100%; max-height: 220px; object-fit: contain; object-position: left top; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); }
.shot img:not([src]) { height: 120px; }
.shot figcaption { font-size: .78rem; color: var(--muted); margin-top: 4px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: .9rem; box-shadow: 0 10px 30px #0005;
  translate: -50% 20px; opacity: 0; pointer-events: none; transition: translate .3s var(--ease), opacity .3s;
}
.toast.show { translate: -50% 0; opacity: 1; pointer-events: auto; }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; }

@media (max-width: 760px) {
  .topbar { padding: 12px 16px 0; gap: 10px; }
  .pill span { display: none; }
  .tabs { order: 3; width: 100%; }
  .tabs button { flex: 1; }
  .deck-mode .layout { grid-template-columns: 1fr; }
  /* Deck becomes a bottom sheet: a bar that expands. */
  .deck { position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto; z-index: 20; max-height: 75dvh; box-shadow: 0 -10px 40px #0006; }
  .deck-bar { cursor: pointer; }
  .chev { display: block; width: 8px; height: 8px; border: solid var(--muted); border-width: 2px 2px 0 0; rotate: -45deg; transition: rotate .25s var(--ease); }
  .deck.open .chev { rotate: 135deg; }
  .deck:not(.open) .deck-body { display: none; }
  .deck-mode main { padding-bottom: 90px; }
  .toast { bottom: 90px; }
}
.attach { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.attach .ghost { padding: 8px 12px; font-size: .9rem; }
.file { position: relative; overflow: hidden; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.row.secondary { margin-top: 8px; }
.row.secondary .ghost { padding: 8px 10px; font-size: .88rem; }
footer .link { font-size: inherit; }

/* ---------- logo: Pokéball in Thai flag colours ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.logo { width: 30px; height: 30px; flex: none; rotate: 0deg; transition: rotate .6s var(--ease); filter: drop-shadow(0 2px 6px #0004); }
@media (prefers-reduced-motion: no-preference) {
  .brand:hover .logo { rotate: 360deg; }
}

/* ---------- sets gallery ---------- */
.sets { padding-bottom: 24px; }
.series { font-size: 1.1rem; margin: 18px 0 12px; color: var(--muted); font-weight: 500; }
.set-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.set-card {
  width: 100%; display: grid; gap: 4px; justify-items: center; padding: 16px 12px 14px; cursor: pointer; text-align: center;
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel);
  translate: 0 0; transition: translate .3s var(--ease), border-color .2s, box-shadow .3s;
}
.set-card:hover, .set-card:focus-visible { translate: 0 -4px; border-color: var(--accent); box-shadow: 0 14px 30px #0004; }
.set-card b { font-weight: 600; margin-top: 8px; line-height: 1.3; }
.set-card small { color: var(--muted); font-size: .78rem; }
/* 1–3 pack images fanned out; they spread a little more on hover */
.packs { position: relative; display: block; width: 100%; height: 170px; }
.packs img {
  position: absolute; left: 50%; bottom: 0; height: 100%; aspect-ratio: 334 / 644; object-fit: contain;
  translate: calc(-50% + var(--x, 0px)) 0; rotate: var(--r, 0deg); transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 14px #0006); transition: translate .4s var(--ease), rotate .4s var(--ease);
}
.packs.n2 img:nth-child(1) { --x: -22px; --r: -8deg; } .packs.n2 img:nth-child(2) { --x: 22px; --r: 8deg; }
.packs.n3 img:nth-child(1) { --x: -38px; --r: -12deg; } .packs.n3 img:nth-child(2) { z-index: 1; } .packs.n3 img:nth-child(3) { --x: 38px; --r: 12deg; }
@media (prefers-reduced-motion: no-preference) {
  .set-card:hover .packs.n2 img:nth-child(1) { --x: -32px; --r: -12deg; } .set-card:hover .packs.n2 img:nth-child(2) { --x: 32px; --r: 12deg; }
  .set-card:hover .packs.n3 img:nth-child(1) { --x: -52px; --r: -16deg; } .set-card:hover .packs.n3 img:nth-child(3) { --x: 52px; --r: 16deg; }
  .set-card:hover .packs.n1 img { translate: -50% -6px; }
}

/* ---------- banner above a chosen set ---------- */
.set-banner { margin-bottom: 18px; padding: 14px 18px 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); }
.banner-body { display: flex; gap: 22px; align-items: center; }
.set-banner .packs { width: 150px; height: 150px; flex: none; }
.set-banner h2 { margin: 2px 0; font-size: 1.6rem; line-height: 1.2; }
.set-banner .muted { margin: 0; color: var(--muted); font-size: .9rem; }
.pack-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pack-chips button {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--glass); font-size: .88rem;
}
.pack-chips button:first-child { padding-left: 12px; }
.pack-chips img { height: 28px; border-radius: 4px; }
.pack-chips button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 760px) {
  .set-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .packs { height: 130px; }
  .banner-body { gap: 14px; }
  .set-banner .packs { width: 96px; height: 110px; }
  .set-banner h2 { font-size: 1.25rem; }
}

/* ---------- popularity ---------- */
.pop { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: -4px 0 14px; font-size: .88rem; color: var(--muted); }
.pop-num b { color: var(--text); font-weight: 600; }
.reacts { display: flex; gap: 6px; margin-left: auto; }
.react {
  display: inline-flex; align-items: center; gap: 4px; min-width: 40px; height: 32px; padding: 0 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--glass); font-size: .95rem; scale: 1; transition: background .2s, border-color .2s, scale .15s;
}
.react b { font-size: .78rem; font-weight: 600; color: var(--muted); }
.react b:empty { display: none; }
.react:hover { border-color: var(--accent); }
.react:active { scale: .92; }
.react[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
.react[aria-pressed="true"] b { color: var(--text); }
@media (prefers-reduced-motion: no-preference) {
  .react.bump span { animation: react-bump .45s var(--ease); }
}
@keyframes react-bump { 40% { scale: 1.5; rotate: -12deg; } 70% { scale: .9; } }
@media (max-width: 760px) { .reacts { margin-left: 0; width: 100%; } }
