:root {
  color-scheme: light;
  --paper: #f3f5ee;
  --surface: #fffefa;
  --ink: #142e25;
  --muted: #55665d;
  --line: #dde4d8;
  --green: #1e6349;
  --bright: #d8f580;
  font: 14px/1.5 Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #319569; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h2, h3 { line-height: 1.22; }
img { display: block; max-width: 100%; }
.topbar { background: #142b24; color: #f8fbef; border-bottom: 1px solid #31483c; }
.topbar-inner, .shell { max-width: 1436px; margin-inline: auto; padding-inline: clamp(16px, 3.2vw, 48px); }
.topbar-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 19px; letter-spacing: .03em; }
.brand strong span { color: var(--bright); }
.brand small { display: block; color: #b7c8bc; font-family: "Courier Prime", ui-monospace, monospace; font-size: 10px; letter-spacing: .16em; }
.topbar nav { display: flex; align-items: center; gap: 12px; }
.nav-link, .new-game { border-radius: 9px; min-height: 37px; padding: 6px 13px; font-weight: 650; white-space: nowrap; }
.nav-link { background: transparent; color: #e4efe4; border: 1px solid #466255; }
.nav-link:hover { background: #284538; }
.help-icon { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1px solid currentColor; border-radius: 50%; font: 11px/1 sans-serif; margin-right: 3px; }
.new-game { background: var(--bright); color: #203623; border: 1px solid transparent; }
.new-game:hover { background: #ecffa7; }
.shell { padding-block: 26px 34px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 21px; }
.page-heading h1 { font-size: clamp(29px, 4vw, 44px); line-height: 1.13; font-weight: 790; letter-spacing: -.04em; }
.page-heading p { color: var(--muted); margin-top: 7px; }
.turn-pill { min-width: max-content; display: flex; align-items: center; gap: 8px; border: 1px solid #d0ded0; padding: 7px 12px; border-radius: 999px; background: #e7f0e3; font-size: 12px; font-weight: 700; }
.turn-pill::before { content: ""; width: 8px; aspect-ratio: 1; border-radius: 50%; background: #33815c; box-shadow: 0 0 0 3px #cce2cb; }
.turn-pill.final { background: #fce9c2; border-color: #e6ce95; }
.turn-pill.final::before { background: #9a6221; box-shadow: none; }
.table-layout { display: grid; grid-template-columns: minmax(0, 760px) minmax(300px, 1fr); align-items: start; justify-content: center; gap: 20px; }
#market { display: grid; gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 16px; box-shadow: 0 2px 5px #193b2510; }
.side { display: grid; gap: 13px; }
.panel-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.panel-heading h2 { font-size: 16px; }
.panel-heading span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.specials { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.special-card { --accent: #725691; position: relative; isolation: isolate; overflow: hidden; text-align: left; display: grid; align-items: center; min-height: 119px; border: 1px solid #c9bae3; border-radius: 15px; padding: 12px 17px; background: linear-gradient(115deg,#efe9f9,#e3d8f4); }
.special-card.legendary { --accent: #80521b; border-color: #dfc491; background: linear-gradient(115deg,#fff3d7,#f8dca9); }
.special-card:not(:disabled):hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.special-card::before { content: ""; width: 155px; aspect-ratio: 1; right: -3px; top: -13px; border: 1px solid currentColor; border-radius: 50%; position: absolute; z-index: -1; opacity: .13; box-shadow: 0 0 0 13px #fff9, 0 0 0 23px #fff3; }
.special-info { max-width: 100%; position: relative; z-index: 1; }
.special-head { display: flex; align-items: center; gap: 7px; }
.special-pts {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  background: #ffffffeb;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}
.special-kind { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--accent); }
.special-name { display: block; font-size: 21px; line-height: 1.2; margin: 4px 0 8px; }
.special-art { width: 128px; height: 115px; object-fit: contain; position: absolute; right: 8px; bottom: -2px; filter: drop-shadow(0 5px 4px #48283532); }
.special-card .card-costs {
  position: static;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
}
.special-card .costs-label { margin-right: 2px; }
.special-meta { display: flex; align-items: center; gap: 7px; }
.score-badge { display: inline-flex; align-items: center; gap: 3px; background: #fbfff0dc; color: #274030; border: 1px solid #ffffffb0; border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 750; }
.score-badge i { color: #b07810; font-style: normal; }
.tier { border: 1px solid var(--line); background: #fafbf5; padding: 12px; border-radius: 16px; }
.tier-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.tier-title { display: flex; align-items: center; gap: 7px; }
.tier-title h2 { font-size: 14px; }
.stage-icon { width: 21px; height: 21px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 750; background: #e1ecda; color: #1a5837; }
.tier[data-tier="2"] .stage-icon { background: #dcebf1; color: #235b73; }
.tier[data-tier="3"] .stage-icon { background: #efe4eb; color: #774164; }
.tier[data-tier="special"] .stage-icon { background: #f6e7c4; color: #8c5a12; }
.special-counts { font-size: 11px; color: var(--muted); font-weight: 600; }
.specials-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.deck { padding: 2px 7px; border: 1px solid #dbe4d9; border-radius: 6px; background: white; font-size: 11px; font-weight: 650; }
.deck:not(:disabled):hover { border-color: #327553; }
.deck:disabled { color: var(--muted); background: transparent; border-color: transparent; }
.cards { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
[data-color="red"] { --ball: #e84848; --stripe: #9e2329; --head-1: #f06c5d; --head-2: #d8433b; --pill: #c6352e; --tint: #fdebe5; --tint-2: #f7d4c6; }
[data-color="blue"] { --ball: #3b95dc; --stripe: #1b5485; --head-1: #62b6ea; --head-2: #358ac9; --pill: #1f6fad; --tint: #e3f3fc; --tint-2: #c5e5f7; }
[data-color="black"] { --ball: #3c4352; --stripe: #1d222c; --head-1: #6c7589; --head-2: #464e5f; --pill: #2d3442; --tint: #ebedf2; --tint-2: #d4d9e4; }
[data-color="pink"] { --ball: #e672a4; --stripe: #9c3464; --head-1: #f095bd; --head-2: #d86597; --pill: #b84276; --tint: #fcebf3; --tint-2: #f5d2e2; }
[data-color="yellow"] { --ball: #eab22d; --stripe: #946312; --head-1: #f5cb54; --head-2: #dfa020; --pill: #b07610; --tint: #fdf6dc; --tint-2: #f6e6b3; }
[data-color="master"] { --ball: #976ee0; --stripe: #5a3494; --head-1: #b08ee8; --head-2: #8259c9; --pill: #673fa8; --tint: #f2ecfb; --tint-2: #ddd0f3; }
.ball { --ball-size: 13px; flex: 0 0 auto; display: inline-block; width: var(--ball-size); height: var(--ball-size); border: 1px solid var(--stripe); border-radius: 50%; position: relative; background: linear-gradient(to bottom,var(--ball) 44%,var(--stripe) 45% 56%,#fefcf6 57%); vertical-align: middle; }
.ball::after { content: ""; position: absolute; inset: 50% auto auto 50%; transform: translate(-50%,-50%); width: 28%; aspect-ratio: 1; background: #fffdf6; border: 1px solid var(--stripe); border-radius: 50%; }
.brand-ball { --ball-size: 32px; border-width: 2px; box-shadow: 0 0 0 4px #ffffff13; }
.brand-ball::after, .bank-ball .ball::after { border-width: 2px; }
/* Authentic Physical Splendor Pokémon Card Layout (63:88 portrait ratio) */
.card {
  min-width: 0;
  display: block;
  width: 100%;
  aspect-ratio: 63 / 88;
  text-align: left;
  padding: 4px;
  overflow: hidden;
  border: 1.5px solid #cbd6c8;
  border-radius: 13px;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(20, 38, 28, .16), 0 1px 2px rgba(20, 38, 28, .12);
  position: relative;
  transition: transform .13s, box-shadow .15s, border-color .15s;
}
.card:not(:disabled):hover {
  transform: translateY(-3px);
  border-color: var(--stripe);
  box-shadow: 0 10px 20px rgba(20, 38, 28, .24), 0 0 0 2px color-mix(in srgb, var(--ball) 45%, transparent);
}
.card.affords {
  border-color: #2f855a;
  box-shadow: 0 4px 12px rgba(33, 110, 67, .26), 0 0 0 2.5px #6fd494;
}
.card-frame {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--tint) 0%, var(--tint-2) 100%);
  position: relative;
}

/* Top Colored Header Band (~24% height): Left Points, Center Evolution Crest, Right Big Pokéball */
.card-top {
  position: relative;
  flex: 0 0 25%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 3px 6px 2px;
  background: linear-gradient(180deg, var(--head-1) 0%, var(--head-2) 100%);
  border-bottom: 2px solid #ffffffd8;
  z-index: 2;
}
.card-pts {
  grid-column: 1;
  justify-self: start;
  font-size: clamp(22px, 2.5vw, 31px);
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  -webkit-text-stroke: 1.5px var(--stripe);
  paint-order: stroke fill;
  text-shadow: 0 2px 3px rgba(0, 0, 0, .28);
  font-variant-numeric: tabular-nums;
}
.card-pts.zero { visibility: hidden; }

/* Center Evolution Crest (Evolved Sprite over Upward House/Chevron Badge) */
.evo-crest {
  grid-column: 2;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 48px;
  margin-bottom: -2px;
}
.evo-sprite-wrap {
  width: 42px;
  height: 29px;
  display: grid;
  place-items: center;
  margin-bottom: -5px;
  z-index: 1;
}
.evo-sprite-wrap img {
  width: 42px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .38));
}
.evo-house {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 46px;
  padding: 7px 6px 3px;
  background: linear-gradient(180deg, var(--head-1), var(--head-2));
  clip-path: polygon(50% 0%, 100% 34%, 100% 100%, 0% 100%, 0% 34%);
  filter: drop-shadow(0 -1px 0 rgba(255, 255, 255, .9));
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}
.evo-house[data-color="yellow"] { color: #2b1d04; }
.evo-count {
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.evo-house[data-color="yellow"] .evo-count { text-shadow: 0 1px 0 rgba(255, 255, 255, .6); }
.evo-house .ball { --ball-size: 13px; border-width: 1px; }

/* Right Permanent Bonus Big Pokéball */
.card-bonus {
  grid-column: 3;
  justify-self: end;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 999px;
  background: #ffffffeb;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .24);
}
.card-bonus .ball { --ball-size: clamp(20px, 2.1vw, 27px); border-width: 1.8px; }
.card-bonus.double { padding: 2px 3px; }
.card-bonus.double .ball { --ball-size: clamp(16px, 1.7vw, 21px); }
.card-bonus.double .ball + .ball { margin-left: -6px; }

/* Special (Rare / Legendary) center crest & framing */
.special-crest {
  grid-column: 2;
  justify-self: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: .04em;
  white-space: nowrap;
  border: 1.2px solid rgba(255, 255, 255, .88);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .22);
}
.special-crest.rare { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #ffffff; }
.special-crest.legendary { background: linear-gradient(135deg, #f59e0b, #b45309); color: #fffdf5; }
.card.kind-rare { border-color: #a78bfa; box-shadow: 0 4px 12px rgba(109, 40, 217, .2); }
.card.kind-legendary { border-color: #eab308; box-shadow: 0 4px 14px rgba(180, 83, 9, .24); }

/* Main Body (~75% height): Centered Large Artwork, Bottom-Left Capture Cost Box, Bottom-Right Name Pill */
.card-stage {
  position: relative;
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse 70% 24% at 54% 84%, rgba(255, 255, 255, .65) 0%, transparent 72%),
    radial-gradient(circle at 55% 42%, rgba(255, 255, 255, .68) 0%, transparent 56%),
    linear-gradient(180deg, var(--tint) 0%, var(--tint-2) 100%);
}
.card-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(rgba(255, 255, 255, .72) 1.2px, transparent 1.2px);
  background-size: 11px 11px;
  opacity: .55;
}
.card-sprite {
  width: 78%;
  height: 76%;
  object-fit: contain;
  transform: translate(8%, -5%);
  filter: drop-shadow(0 6px 5px rgba(24, 38, 34, .28));
}

/* Bottom-Left White Rounded "捕捉" Cost Stack */
.card-costs {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 6px 5px 5px;
  border-top-right-radius: 10px;
  background: rgba(255, 255, 255, .88);
  border-top: 1px solid rgba(255, 255, 255, .95);
  border-right: 1px solid rgba(255, 255, 255, .95);
  box-shadow: 2px -1px 6px rgba(0, 0, 0, .09);
}
.costs-label {
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .06em;
  color: #465852;
  line-height: 1;
  text-align: center;
  margin-bottom: 1px;
}
.cost-row {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.cost-num {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--ball) 72%, #fff), var(--ball) 58%, var(--stripe));
  border: 1px solid rgba(255, 255, 255, .9);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .48);
  font-variant-numeric: tabular-nums;
}
.cost-row[data-color="yellow"] .cost-num {
  color: #2b1d04;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}
.cost-row .ball { --ball-size: 12px; }

/* Bottom-Right Colored Name Pill */
.card-name-pill {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 3;
  max-width: 60%;
  padding: 2px 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--head-2), var(--pill));
  border: 1.2px solid rgba(255, 255, 255, .85);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
}

.costs { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 5px; color: #273c31; }
.cost { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 750; }
.free { font-size: 11px; color: var(--muted); }
.empty-card { aspect-ratio: 63 / 88; display: grid; place-content: center; border: 1.5px dashed #cdd8c8; border-radius: 13px; color: var(--muted); font-size: 12px; }
.trainer-list { display: grid; gap: 7px; }
.trainer { display: grid; grid-template-columns: 35px minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid #e4e9df; border-radius: 10px; background: #f8f9f3; }
.trainer.active { border-color: #95ba91; background: #eaf3df; }
.avatar { width: 34px; height: 34px; border-radius: 9px; background: #e5ebd9; object-fit: contain; padding: 2px; }
.who { font-size: 13px; font-weight: 750; }
.trainer:last-child .avatar { background: #ede6f3; }
.trainer-counts { display: flex; gap: 8px; color: var(--muted); font-size: 10px; }
.trainer-points { text-align: right; font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; }
.trainer-points small { font-size: 10px; color: var(--muted); font-weight: 500; }
.bank-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.bank-ball { display: grid; justify-items: center; align-content: center; position: relative; padding: 8px 3px 6px; min-height: 69px; border: 1px solid #e4e8de; border-radius: 9px; background: #f5f7f0; font-size: 10px; color: #4e6056; }
.bank-ball .ball { --ball-size: 29px; border-width: 2px; box-shadow: 0 2px 0 #3046372b; margin-bottom: 4px; }
.bank-ball.selected, .bank-ball:not(:disabled):hover { background: var(--tint); border-color: var(--stripe); }
.bank-ball b { position: absolute; top: 5px; right: 7px; color: var(--ink); font-size: 13px; }
.bank-ball em { color: var(--green); position: absolute; left: 5px; top: 5px; font-size: 10px; font-style: normal; font-weight: 750; }
.bank-ball:disabled { opacity: .75; }
.bank-actions { display: grid; gap: 8px; padding-top: 10px; }
.bank-actions p, .empty-state, .history, .guidance { color: var(--muted); font-size: 11px; }
.primary, .secondary { padding: 8px 14px; border-radius: 8px; min-height: 36px; font-weight: 700; }
.primary { color: white; background: #236548; border: 1px solid transparent; }
.primary:hover:not(:disabled) { background: #194b35; }
.primary:disabled, .secondary:disabled { color: #657266; background: #e9ede6; border-color: #dfe5dd; }
.secondary { background: #f8faf3; border: 1px solid #d6e1d4; }
.secondary:hover:not(:disabled) { border-color: #5d8965; }
.primary.full { width: 100%; }
.team-tabs { display: flex; gap: 5px; border-bottom: 1px solid var(--line); }
.tab { border: 0; border-radius: 6px 6px 0 0; background: transparent; color: var(--muted); padding: 4px 7px; font-size: 12px; font-weight: 700; }
.tab.active { background: #e7f0e1; color: var(--green); }
.team-content { padding: 8px 0 0; }
.inventory { display: grid; grid-template-columns: repeat(6,1fr); gap: 4px; text-align: center; }
.inventory-cell { display: grid; justify-items: center; gap: 2px; padding: 3px; background: #f1f4ec; border-radius: 6px; font-size: 12px; font-weight: 750; }
.inventory-cell .ball { --ball-size: 15px; }
.inventory-legend { margin: 5px 0 9px; color: var(--muted); font-size: 10px; }
.team-section + .team-section { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); }
.team-subhead { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.team-subhead h3 { font-size: 12.5px; font-weight: 800; color: var(--ink); }
.team-subhead span { font-size: 11px; color: var(--muted); }
.empty-state { font-size: 11.5px; color: var(--muted); padding: 4px 0; }
.hand-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.hand-grid .card { padding: 2px; border-radius: 8px; }
.hand-grid .card-frame { border-radius: 6px; }
.hand-grid .card-top { padding: 2px 3px; }
.hand-grid .card-pts { font-size: 13px; -webkit-text-stroke: 0.8px var(--stripe); }
.hand-grid .card-bonus { padding: 1px; }
.hand-grid .card-bonus .ball { --ball-size: 12px; border-width: 1px; }
.hand-grid .card-bonus.double .ball { --ball-size: 10px; }
.hand-grid .card-bonus.double .ball + .ball { margin-left: -4px; }
.hand-grid .special-crest { font-size: 7.5px; padding: 1px 4px; }
.hand-grid .evo-crest { min-width: 24px; }
.hand-grid .evo-sprite-wrap { width: 18px; height: 13px; margin-bottom: -2px; }
.hand-grid .evo-sprite-wrap img { width: 18px; height: 14px; }
.hand-grid .evo-house { min-width: 24px; padding: 3px 2px 1px; font-size: 8px; gap: 1px; }
.hand-grid .evo-house .ball { --ball-size: 7.5px; }
.hand-grid .card-costs { padding: 2px 3px; gap: 1.5px; border-top-right-radius: 6px; }
.hand-grid .costs-label { display: none; }
.hand-grid .cost-num { width: 12px; height: 12px; font-size: 8px; }
.hand-grid .cost-row .ball { --ball-size: 8px; }
.hand-grid .card-name-pill { font-size: 8.5px; padding: 1px 4px; right: 2px; bottom: 2px; max-width: 68%; }
.history { margin-top: 9px; }
.history summary { cursor: pointer; }
.history ol { margin: 5px 0 0; padding-left: 18px; }
.history li { margin-bottom: 4px; }
dialog { border: 1px solid #d3dfd4; border-radius: 17px; padding: 19px; width: min(460px,calc(100% - 26px)); max-height: 88dvh; overscroll-behavior: contain; background: var(--surface); color: var(--ink); box-shadow: 0 15px 70px #162b254a; }
dialog::backdrop { background: #172b24aa; backdrop-filter: blur(3px); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 12px; }
.modal-head h2 { font-size: 22px; }
.close { display: grid; place-content: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: #f4f7ee; font-size: 21px; line-height: 1; }
.modal-actions { display: flex; gap: 8px; justify-content: end; margin-top: 15px; }
.card-detail { display: grid; grid-template-columns: minmax(100px,34%) 1fr; gap: 11px; margin-bottom: 12px; }
.detail-art { border-radius: 10px; height: 122px; width: 100%; object-fit: contain; background: var(--tint); }
.card-detail p { font-size: 13px; margin: 4px 0 7px; }
.rules li { margin-bottom: 8px; }
.rules p a { color: var(--green); }
.setup-options { display: grid; gap: 7px; margin-block: 10px; }
.setup-options label { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.setup-options label:has(input:checked) { border-color: #548b66; background: #edf5e5; }
hr { border: 0; border-top: 1px solid var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (min-width: 1000px) { .side { position: sticky; top: 12px; } }
@media (max-width: 999px) { .table-layout { grid-template-columns: minmax(0,1fr) 260px; gap: 12px; } .panel { padding: 11px; } .special-art { width: 100px; } }
@media (max-width: 680px) {
  .table-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .side { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #trainers, #supply, #team { min-width: 0; }
  .bank-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
  .bank-ball { min-height: 54px; padding: 6px 2px 4px; font-size: 9px; }
  .bank-ball .ball { --ball-size: 20px; margin-bottom: 2px; }
  .bank-ball b { font-size: 10px; right: 3px; top: 2px; }
  .inventory { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .page-heading { margin-bottom: 10px; align-items: center; }
  .page-heading h1 { font-size: 24px; }
  .shell { padding-top: 12px; }
}
@media (max-width: 440px) { .topbar-inner { min-height: 55px; gap: 5px; } .brand strong { font-size: 13px; } .brand-ball { --ball-size: 22px; } .brand { gap: 7px; } .brand small { font-size: 8px; letter-spacing: .04em; } .topbar nav { gap: 6px; } .nav-link,.new-game { font-size: 11px; padding: 4px 6px; min-height: 30px; } .help-icon { display: none; } .card-art { height: 58px; } .card-art img { height: 56px; } .cards { gap: 5px; } .card-art .bonus, .card-art .score-badge { top: 3px; font-size: 9px; padding: 0 3px; } .card-art .bonus { right: 2px; } .card-art .score-badge { left: 2px; } .card-copy { padding: 4px; } .card-name { font-size: 11px; } .cost { font-size: 10px; } .cost .ball { --ball-size: 10px; } .special-card { padding: 8px; min-height: 93px; } .special-art { width: 73px; height: 87px; opacity: .93; top: 0; right: 0; } .special-name { font-size: 16px; } .trainer { grid-template-columns: 24px 1fr auto; gap: 3px; padding: 3px; } .avatar { width: 23px; height: 23px; } .trainer-counts { gap: 4px; } .panel-heading span { font-size: 10px; } .bank-ball { min-height: 50px; font-size: 9px; padding: 5px 2px 3px; } .bank-ball .ball { --ball-size: 21px; } .bank-ball b { font-size: 10px; right: 3px; top: 2px; } .turn-pill { padding: 5px 7px; font-size: 10px; } }
.card-art, .card-copy { display: block; }
.card-art img { margin-inline: auto; }
.special-card.affords { box-shadow: inset 0 0 0 1px #548c61; }
.evolution-list { display: grid; gap: 5px; }
.inventory-cell small { font-size: 10px; color: var(--green); }
#announcement { position: fixed; }
@media (max-width: 440px) {
  .shell, .topbar-inner { padding-inline: 10px; }
  .special-art { opacity: .65; }
  .special-meta { gap: 4px; }
  .special-meta .costs { max-width: 102px; }
}
.card-art .score-badge, .card-art .bonus { z-index: 1; }
.special-info { max-width: 62%; }
.special-art { max-width: 43%; }
.trainer { width: 100%; text-align: left; }
.trainer:hover { border-color: #70aa7b; }
.payment { margin-top: 8px; color: var(--muted); font-size: 12px; }
.payment summary { cursor: pointer; }
.payment > div { display: flex; flex-wrap: wrap; gap: 6px 10px; padding-top: 6px; }
.payment label { display: flex; align-items: center; gap: 4px; }
.payment input { width: 48px; padding: 3px; border: 1px solid var(--line); border-radius: 5px; font: inherit; }
.dex-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.dex-entry { display: grid; place-items: center; padding: 5px 2px; border-radius: 7px; background: #f0f3ec; color: var(--muted); font-size: 10px; text-align: center; }
.dex-entry img { width: 42px; height: 42px; object-fit: contain; filter: brightness(0); opacity: .18; }
.dex-entry.discovered { background: #e7f2dd; color: var(--green); }
.dex-entry.discovered img { filter: none; opacity: 1; }
@media (max-width: 390px) { .topbar nav { gap: 3px; } .brand strong { font-size: 11px; } .special-name { font-size: 14px; } }

[hidden] { display: none !important; }

.home-hero {
  --home-accent: #d8f580;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(275px, .85fr) minmax(0, 1.15fr);
  align-items: center;
  overflow: hidden;
  min-height: min(610px, 76vh);
  padding: clamp(30px, 5.8vw, 92px);
  border: 1px solid #234b3e;
  border-radius: 24px;
  background: radial-gradient(ellipse at 77% 55%, #427557 0%, transparent 58%), linear-gradient(128deg, #132f27, #1c4638 65%, #2b5946);
  color: #f8fbef;
}
.home-main { position: relative; z-index: 2; }
.home-main h1 { font-size: clamp(44px, 7.4vw, 104px); letter-spacing: -.065em; line-height: 1.04; white-space: nowrap; }
.home-main h1 span { display: block; color: var(--home-accent); }
.home-intro { margin-top: 18px; color: #d9e8d8; font-size: clamp(13px, 1.3vw, 17px); }
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 26px; }
.home-actions button { padding: 10px 16px; min-height: 44px; border-radius: 8px; font-weight: 750; }
.home-actions .primary { background: var(--home-accent); color: #1a3529; }
.home-actions .primary:hover { background: #ecffa7; }
.home-secondary { background: #244e3f; color: #f5faec; border: 1px solid #6a8c78; }
.home-secondary:hover { background: #366351; }
.home-save { margin-top: 9px; font-size: 12px; color: #c3dac7; }
.home-links { display: flex; gap: 8px; margin-top: 19px; }
.home-links .nav-link { border-color: #628171; }
.home-art { position: absolute; right: 1%; inset-block: 0; width: 61%; display: grid; place-items: center; }
.home-orbit { width: 66%; max-width: 530px; aspect-ratio: 1; border-radius: 50%; border: 1px solid #bed89554; box-shadow: 0 0 0 21px #dae9a70b, 0 0 0 44px #dae9a709, inset 0 0 60px #daf5871a; }
.home-art img { position: absolute; height: auto; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 18px 18px #102d238c); }
.hero-charizard { width: 58%; top: 4%; right: 12%; }
.hero-venusaur { width: 43%; bottom: 4%; left: 5%; z-index: 1; }
.hero-blastoise { width: 43%; bottom: 7%; right: 0; z-index: 1; }

.catalog-heading h1 { font-size: clamp(30px, 5vw, 46px); letter-spacing: -.045em; margin-top: 12px; }
.catalog-heading p, .catalog-result { color: var(--muted); }
.catalog-heading p { margin-top: 3px; }
.catalog-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 20px; margin-top: 16px; }
.catalog-search { display: grid; gap: 4px; width: min(100%, 315px); font-size: 12px; font-weight: 700; }
.catalog-search input { width: 100%; min-height: 40px; padding: 8px 10px; font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid #b7c7b9; border-radius: 8px; }
.catalog-search input:focus-visible { outline: 2px solid #319569; outline-offset: 2px; }
.catalog-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.catalog-filters button { min-height: 40px; }
.catalog-filters [aria-pressed="true"] { background: #e1efdd; border-color: #78a383; color: #205e43; }
.catalog-result:not(:empty) { margin-top: 12px; }
.catalog-section { margin-top: 23px; }
.catalog-section h2 { font-size: 19px; margin-bottom: 10px; }
.catalog-chains { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.catalog-family { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: clamp(4px, 1vw, 12px); padding: clamp(6px, 1.25vw, 15px); border: 1px solid var(--line); border-radius: 14px; background: #eaf0e7; }
.catalog-species { display: grid; min-width: 0; justify-items: center; width: 100%; padding: 0 0 7px; border: 1px solid #cbd8cc; border-radius: 10px; overflow: hidden; background: var(--surface); }
.catalog-species:hover { border-color: #548667; box-shadow: 0 0 0 1px #8cb794; }
.catalog-species strong { margin: 4px 0 1px; }
.catalog-art { --art-height: clamp(62px, 9.2vw, 115px); display: grid; place-items: center; width: 100%; height: var(--art-height); overflow: hidden; background: radial-gradient(ellipse at 52% 54%, #fffc 0%, transparent 64%), var(--tint); }
.catalog-art img { width: min(100%, 110px); height: var(--art-height); object-fit: contain; padding: 4px; filter: drop-shadow(0 5px 4px #2a3a3a3d); }
.catalog-card-count { color: var(--muted); font-size: 11px; }
.catalog-step { display: grid; justify-items: center; align-content: center; gap: 2px; color: var(--green); }
.catalog-step .costs { justify-content: center; }
.catalog-arrow { font-size: clamp(17px, 2.4vw, 29px); line-height: 1; }
.catalog-singles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.catalog-detail-head { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: center; margin-bottom: 13px; }
.catalog-detail-head .detail-art { height: 100px; }
.catalog-detail-head p { margin: 5px 0; }
.catalog-variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 7px; }
.catalog-variant { padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #f4f7ef; }
.catalog-variant h3 { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 6px; font-size: 13px; }
.catalog-variant p { display: grid; gap: 2px; margin-top: 5px; font-size: 11px; color: var(--muted); }
.catalog-shortcut { display: inline-block; margin-top: 8px; padding: 0; border: 0; background: transparent; color: var(--green); text-decoration: underline; text-underline-offset: 3px; font-size: 12px; }

@media (max-width: 850px) {
  .home-hero { min-height: 480px; padding: clamp(24px, 4vw, 48px); }
}
@media (max-width: 660px) {
  .home-hero { display: flex; flex-direction: column; align-items: stretch; min-height: 0; padding-bottom: 12px; }
  .home-main h1 { font-size: clamp(48px, 10vw, 70px); white-space: normal; }
  .home-art { position: relative; inset: auto; width: 100%; aspect-ratio: 1.7; }
  .home-orbit { width: 48%; }
  .hero-charizard { width: 48%; top: -13%; right: 20%; }
  .hero-venusaur { width: 35%; bottom: 0; left: 10%; }
  .hero-blastoise { width: 35%; bottom: 2%; right: 8%; }
  .catalog-chains { grid-template-columns: 1fr; }
}
@media (max-width: 530px) {
  .topbar-inner:has(#game-tools:not([hidden])) { flex-direction: column; align-items: flex-start; gap: 6px; padding-block: 6px 9px; }
  .topbar nav { flex-wrap: wrap; }
  .catalog-singles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .catalog-family { padding: 7px; }
}

.catalog-family { align-items: start; }
.catalog-step { align-self: start; margin-top: clamp(27px, 5vw, 58px); }
.catalog-entry { min-width: 0; overflow: hidden; border: 1px solid #cbd8cc; border-radius: 10px; background: var(--surface); }
.catalog-entry .catalog-species { border: 0; border-radius: 0; }
.catalog-entry .catalog-species:hover { background: #f0f6ea; box-shadow: none; }
.catalog-entry .catalog-species:focus-visible { outline-offset: -3px; }
.catalog-inline-variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 90px), 1fr)); gap: 4px; padding: 0 4px 4px; }
.catalog-inline-variant { min-width: 0; padding: 4px 5px; border-radius: 6px; border: 1px solid var(--line); background: #f4f7ef; }
.catalog-inline-variant p { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1px 4px; font-size: 11px; color: var(--muted); }
.catalog-inline-variant p + p { margin-top: 2px; }
.catalog-inline-variant .catalog-variant-title { justify-content: space-between; color: var(--ink); padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.catalog-variant-title strong { margin-left: auto; }
.catalog-inline-variant .costs { gap: 1px 5px; }
.catalog-inline-variant .ball { --ball-size: 11px; }
.online-panel { max-width: 580px; margin-inline: auto; padding: clamp(16px, 4vw, 34px); }
.online-panel h1 { font-size: clamp(27px, 4.4vw, 38px); margin: 13px 0 9px; letter-spacing: -.035em; }
.room-form { display: grid; gap: 12px; margin-block: 15px; }
.room-form label, .invite-label { display: grid; gap: 4px; font-weight: 700; }
.room-form label span, .room-heading p { font-weight: 400; color: var(--muted); }
.room-form input, .invite-label input { min-width: 0; width: 100%; color: inherit; font: inherit; background: #fff; border: 1px solid #b7c7b9; border-radius: 7px; padding: 8px 10px; }
.room-link { display: inline-block; margin-top: 10px; text-decoration: none; }
.room-heading h2 { margin-bottom: 4px; }
.room-seats { display: grid; padding: 0; list-style-type: none; gap: 5px; }
.room-seats li { display: flex; gap: 8px; justify-content: space-between; padding: 7px 10px; background: #edf4e8; border-radius: 7px; }
.room-seats li span { color: var(--muted); font-size: 12px; }
.invite-panel { display: grid; gap: 7px; margin: 10px 0; padding: 10px; background: #edf4e8; border: 1px solid var(--line); border-radius: 8px; }
.invite-label input { font-size: 12px; font-weight: 500; }
.invite-feedback:empty, .online-message:empty { display: none; }
.online-message, .online-game-status { margin-top: 12px; font-size: 12px; }
.online-message.error, .online-game-status { color: #803c25; }
.online-game-status { margin: 0 0 12px; padding: 7px 10px; background: #f9ead4; border-radius: 7px; }
.room-form-actions { display: flex; gap: 7px; }
@media (max-width: 950px) {
  .catalog-chains { grid-template-columns: 1fr; }
}
@media (max-width: 440px) {
  .catalog-inline-variant { padding-inline: 3px; }
  .catalog-inline-variant .costs { gap: 1px 3px; }
  .catalog-inline-variant .cost { font-size: 10px; }
}
/* Keep consistent 4-column desktop-style layout on mobile with crisp compact scaling */
@media (max-width: 760px) {
  .tier { padding: 8px; border-radius: 12px; }
  .tier-header { margin-bottom: 6px; }
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .card { padding: 2.5px; border-radius: 9px; }
  .card-frame { border-radius: 7px; }
  .card-top { padding: 2px 3px 1px; }
  .card-pts { font-size: 16px; -webkit-text-stroke: 1px var(--stripe); }
  .card-bonus { padding: 1.5px; }
  .card-bonus .ball { --ball-size: 15px; border-width: 1.2px; }
  .card-bonus.double { padding: 1.5px 2px; }
  .card-bonus.double .ball { --ball-size: 12px; }
  .card-bonus.double .ball + .ball { margin-left: -4px; }
  .special-crest { font-size: 8.5px; padding: 1px 5px; }
  .evo-crest { min-width: 28px; }
  .evo-sprite-wrap { width: 24px; height: 17px; margin-bottom: -3px; }
  .evo-sprite-wrap img { width: 24px; height: 18px; }
  .evo-house { min-width: 28px; padding: 4px 3px 1px; font-size: 9px; gap: 1px; }
  .evo-house .ball { --ball-size: 8.5px; }
  .card-costs { padding: 2px 3px 3px; gap: 1.5px; border-top-right-radius: 6px; }
  .costs-label { font-size: 7px; }
  .cost-num { width: 13px; height: 13px; font-size: 8.5px; }
  .cost-row { gap: 1.5px; }
  .cost-row .ball { --ball-size: 8.5px; }
  .card-name-pill { font-size: 8.5px; padding: 1px 5px; right: 2px; bottom: 2px; max-width: 66%; }
  .hand-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
}
@media (max-width: 420px) {
  .cards { gap: 4px; }
  .card { padding: 2px; border-radius: 8px; }
  .card-pts { font-size: 14px; }
  .card-bonus .ball { --ball-size: 13px; }
  .card-bonus.double .ball { --ball-size: 10.5px; }
  .evo-sprite-wrap { width: 20px; height: 14px; }
  .evo-sprite-wrap img { width: 20px; height: 15px; }
  .evo-house { min-width: 24px; font-size: 8px; }
  .evo-house .ball { --ball-size: 7.5px; }
  .costs-label { display: none; }
  .cost-num { width: 12px; height: 12px; font-size: 8px; }
  .cost-row .ball { --ball-size: 7.5px; }
  .card-name-pill { font-size: 7.5px; padding: 1px 4px; }
}

/* AI Difficulty & Roguelike Relics UI */
.setup-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.setup-section h3 { font-size: 13px; margin-bottom: 7px; }
.diff-grid { display: grid; gap: 6px; }
.diff-opt {
  display: flex;
  gap: 8px;
  align-items: start;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: #fafbf6;
}
.diff-opt:has(input:checked) { border-color: #327a57; background: #e8f4e2; }
.diff-opt span { display: grid; gap: 1px; }
.diff-opt strong { font-size: 12.5px; }
.diff-opt strong small { color: #226a48; font-weight: 700; margin-left: 4px; }
.diff-opt > span > small { font-size: 11px; color: var(--muted); line-height: 1.35; }
.setup-relics-bar {
  margin-top: 9px;
  padding: 7px 9px;
  border-radius: 8px;
  background: #f3f6ec;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}
.active-relics { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.relic-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ebf5e3;
  border: 1px solid #9dc597;
  color: #1c5739;
  font-size: 11px;
  font-weight: 700;
}
.meta-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.meta-stats span {
  display: grid;
  justify-items: center;
  padding: 6px 4px;
  border-radius: 8px;
  background: #f2f6ec;
  border: 1px solid var(--line);
}
.meta-stats b { font-size: 15px; color: var(--green); font-variant-numeric: tabular-nums; }
.meta-stats small { font-size: 10px; color: var(--muted); }
.relic-box-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.relic-box-row .guidance { flex: 1 1 200px; }
.relic-notice { margin-bottom: 8px; padding: 6px 9px; border-radius: 7px; background: #e5f3df; border: 1px solid #96c590; color: #195134; font-size: 12px; font-weight: 650; }
.relic-grid, .reward-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.reward-choices { grid-template-columns: 1fr; margin-top: 7px; }
.relic-card {
  display: grid;
  gap: 4px;
  padding: 8px 9px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fafbf7;
  text-align: left;
}
.relic-card.locked { opacity: .52; background: #f2f3ef; }
.relic-card.owned:not(:disabled):hover { border-color: #347c58; background: #eff7ea; }
.relic-card.equipped { border-color: #257a4f; background: #e4f4dc; box-shadow: 0 0 0 1px #8bc995; }
.relic-card.rarity-rare.owned { border-color: #c89b3c; }
.relic-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: 12px; }
.relic-tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: #e9efe6; color: var(--muted); font-weight: 700; white-space: nowrap; }
.relic-card.equipped .relic-tag { background: #226a48; color: #fff; }
.relic-card p { font-size: 11px; color: var(--muted); line-height: 1.4; }
.victory-reward { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.reward-title { font-weight: 800; font-size: 14px; color: var(--green); margin-bottom: 4px; }
@media (max-width: 460px) { .relic-grid { grid-template-columns: 1fr; } .meta-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
