:root {
  --bg: #0f1014;
  --bg-2: #171920;
  --panel: #1d2029;
  --line: #2c303c;
  --text: #f1ede4;
  --muted: #9a9eab;
  --gold: #e3b45c;
  --smash: #3fd68c;
  --pass: #ff5a64;
  --super: #ffc83d;
  --adopt: #c79bff;
  --accent: var(--gold);
  --radius: 22px;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { min-height: 100vh; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
  transition: background 0.6s;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--gold); }
h1, h2, h3 { font-family: var(--display); letter-spacing: 0.02em; margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
/* Header contents line up with the game grid; the bar itself stays full-bleed. */
.topbar-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; text-align: left; }
.brand-mark { font-size: 26px; }
.brand-text { font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1; }
.brand-text em { font-style: normal; color: var(--gold); }
.brand-text small { display: block; font-family: var(--body); font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 3px; }
.tally { display: flex; gap: 12px; white-space: nowrap; font-size: 14px; font-variant-numeric: tabular-nums; }
.tally-smash { color: var(--smash); }
.tally-pass { color: var(--pass); }
.tally b { display: inline-block; transition: transform 0.2s; }
.tally b.bump { transform: scale(1.4); }
.icon-btn { font-size: 20px; width: 40px; height: 40px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }

/* ---------- screens ---------- */
body { display: flex; flex-direction: column; }
main { flex: 1 0 auto; padding: 0 16px 24px; }
.screen { display: none; }
.screen.active { display: block; animation: fade-in 0.3s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }

.loader { display: grid; place-items: center; gap: 16px; min-height: 60vh; color: var(--muted); text-align: center; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader code { background: var(--panel); padding: 2px 6px; border-radius: 6px; color: var(--text); }

/* ---------- game select ---------- */
.games-head { max-width: 1100px; margin: 28px auto 20px; text-align: center; }
.games-head h1 { font-size: clamp(26px, 5vw, 40px); }
.games-head p { color: var(--muted); margin: 10px 0 16px; }
.c-smash { color: var(--smash); }
.c-pass { color: var(--pass); }
.filters { display: inline-flex; gap: 8px; }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 14px; cursor: pointer; user-select: none;
}
.chip-toggle input { accent-color: var(--gold); margin: 0; }

.game-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.game-tile {
  --tile: var(--gold);
  position: relative; overflow: hidden; text-align: left;
  min-height: 220px; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(160deg, color-mix(in srgb, var(--tile) 30%, var(--panel)), var(--panel) 60%);
  border: 1px solid color-mix(in srgb, var(--tile) 35%, var(--line));
  display: flex; flex-direction: column; justify-content: flex-end;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.game-tile:hover, .game-tile:focus-visible { transform: translateY(-4px); box-shadow: 0 16px 40px -12px color-mix(in srgb, var(--tile) 60%, transparent); border-color: var(--tile); outline: none; }
.game-tile img {
  position: absolute; right: -12%; top: -6%; width: 85%; height: 85%; object-fit: contain;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.5)); opacity: 0.9; pointer-events: none;
  transition: transform 0.4s;
}
.game-tile:hover img { transform: scale(1.06) rotate(-2deg); }
.game-tile .tile-body { position: relative; }
.game-tile .short { font-family: var(--display); font-weight: 800; font-size: 30px; color: var(--tile); text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.game-tile .full { font-size: 13px; color: var(--text); opacity: 0.85; margin-top: 2px; }
.game-tile .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.game-tile .bar { height: 4px; background: rgba(255,255,255,.08); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.game-tile .bar i { display: block; height: 100%; background: var(--tile); border-radius: 4px; }
.game-tile .resume { position: absolute; top: 14px; left: 14px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; background: rgba(0,0,0,.45); color: var(--tile); }
/* ---------- sticky footer ---------- */
.site-footer {
  position: sticky; bottom: 0; z-index: 20;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.credit { max-width: 1100px; margin: 0 auto; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.45; }

/* ---------- play ---------- */
.play-head { max-width: 440px; margin: 14px auto 10px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.play-title { text-align: center; font-family: var(--display); font-weight: 800; font-size: 17px; color: var(--accent); }
.play-title small { display: block; font-family: var(--body); font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 2px; }
.preload { justify-self: end; display: flex; gap: 4px; }
.preload i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background 0.2s; }
.preload i.loading { background: color-mix(in srgb, var(--accent) 45%, var(--line)); animation: pulse 1s infinite; }
.preload i.ready { background: var(--accent); }
.preload i.error { background: var(--pass); }
@keyframes pulse { 50% { opacity: 0.4; } }

.ghost-btn { white-space: nowrap; padding: 8px 12px; border-radius: 12px; color: var(--muted); border: 1px solid var(--line); background: var(--bg-2); font-size: 14px; justify-self: start; }
.ghost-btn:hover { color: var(--text); }
.primary-btn { padding: 12px 20px; border-radius: 14px; background: var(--accent); color: #1a1408; font-weight: 700; }
.danger-btn { padding: 10px 16px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--pass) 50%, var(--line)); color: var(--pass); background: transparent; }
.danger-btn.armed { background: var(--pass); color: #fff; }

.deck-wrap { display: grid; place-items: center; }
.deck { position: relative; width: min(100%, 420px); height: min(calc(100dvh - 310px), 860px); min-height: 520px; }

.card {
  position: absolute; inset: 0;
  border-radius: var(--radius); overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 30%, color-mix(in srgb, var(--accent) 35%, #242836), #14161c 75%);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.8);
  display: flex; flex-direction: column;
  user-select: none; touch-action: none;
  transform-origin: 50% 90%;
  transition: transform 0.3s ease, opacity 0.3s ease;
  will-change: transform;
}
.card[data-depth="0"] { z-index: 3; cursor: grab; }
.card[data-depth="0"].dragging { cursor: grabbing; }
.card[data-depth="1"] { z-index: 2; transform: translateY(12px) scale(0.955); opacity: 0.9; pointer-events: none; }
.card[data-depth="2"] { z-index: 1; transform: translateY(24px) scale(0.91); opacity: 0.6; pointer-events: none; }
.card[data-depth="1"] .card-info, .card[data-depth="2"] .card-info { opacity: 0; }

.card-art { position: relative; flex: 0 0 44%; min-height: 0; overflow: hidden; display: grid; place-items: center; }
.card[data-depth="0"] .card-art { cursor: zoom-in; }
.card-art::before { /* subtle hex pattern */
  content: ''; position: absolute; inset: 0; opacity: 0.07;
  background-image: radial-gradient(circle at 1px 1px, #fff 1px, transparent 0);
  background-size: 18px 18px;
}
/* Size and position are set by fitArt() in app.js. */
.card-art img { position: absolute; max-width: none; filter: drop-shadow(0 12px 24px rgba(0,0,0,.55)); pointer-events: none; }
.card-art.opaque img { border-radius: 16px; box-shadow: 0 12px 30px rgba(0,0,0,.5); filter: none; }
.card-art .skeleton { width: 60%; aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,.04); animation: pulse 1.2s infinite; }
.card-art .broken { color: var(--muted); font-size: 14px; }

/* Always-open profile panel; scrolls vertically while horizontal drags still swipe the card. */
.card-info {
  position: relative; flex: 1 1 auto; min-height: 0;
  padding: 16px 18px 20px;
  background: linear-gradient(to bottom, rgba(10,11,14,.7), rgba(10,11,14,.97) 40px);
  border-top: 1px solid rgba(255,255,255,.06);
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  transition: opacity 0.2s;
}
.card-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-info .card-name { padding-right: 76px; }
/* Two-sided layout toggle: [ one column | two columns ], active side highlighted. */
.layout-toggle {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  display: flex; padding: 2px; gap: 2px; border-radius: 10px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
}
.layout-toggle button {
  position: relative; width: 30px; height: 28px; display: grid; place-items: center;
  border-radius: 8px; color: var(--muted); transition: background 0.15s, color 0.15s;
}
.layout-toggle button:hover { color: var(--text); background: rgba(255,255,255,.06); }
.layout-toggle button[aria-pressed="true"] { color: #1a1408; background: var(--gold); }
.card.friendly .layout-toggle button[aria-pressed="true"] { background: #7cc4ff; color: #0d1b29; }
.layout-toggle svg { width: 17px; height: 17px; display: block; }
/* Hover label under each side */
.layout-toggle button::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); right: 0;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none;
  font-size: 11px; font-weight: 600; color: var(--text); background: #000c; border: 1px solid var(--line);
  opacity: 0; transform: translateY(-2px); transition: opacity 0.15s, transform 0.15s;
}
.layout-toggle button:hover::after, .layout-toggle button:focus-visible::after { opacity: 1; transform: none; }
.card-name h2 { font-size: 27px; line-height: 1.1; }
.card-name .ctitle { font-size: 13px; color: var(--gold); font-style: italic; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.tag { font-size: 11px; font-weight: 600; letter-spacing: .03em; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.08); color: #d9d6cf; }
.tag.npc { background: color-mix(in srgb, var(--gold) 25%, transparent); color: var(--gold); }
.tag.el-Fire { background: #ff6b3d33; color: #ff9a74; }
.tag.el-Water { background: #3da5ff33; color: #86c6ff; }
.tag.el-Thunder { background: #ffd23d33; color: #ffe07a; }
.tag.el-Ice { background: #9be7ff33; color: #c2f1ff; }
.tag.el-Dragon { background: #b25cff33; color: #d4a4ff; }
.tag.loc { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.card-bio { font-size: 14.5px; line-height: 1.55; color: #e6e2d9; margin: 0; }
.card-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 0; }
.fact { margin: 0; padding: 8px 11px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.05); min-width: 0; }
.fact dt { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.fact dd { margin: 2px 0 0; font-size: 13.5px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.fact-status, .fact-lookingFor { grid-column: 1 / -1; }
.fact-lookingFor { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.fact-lookingFor dd { color: var(--accent); }
.card.friendly .fact-lookingFor { background: #7cc4ff22; border-color: #7cc4ff55; }
.card.friendly .fact-lookingFor dd { color: #7cc4ff; }
.card-more { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.card-more h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.card-more p { margin: 0 0 10px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.card-more a { font-size: 13px; }
.card-verdict { position: absolute; top: 14px; right: 14px; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: rgba(0,0,0,.5); color: var(--muted); }

.stamp {
  position: absolute; top: 34px; z-index: 5;
  font-family: var(--display); font-weight: 800; font-size: 44px; letter-spacing: .06em;
  padding: 4px 14px; border: 5px solid currentColor; border-radius: 12px;
  opacity: 0; pointer-events: none;
}
.card.friendly { border-color: color-mix(in srgb, #7cc4ff 45%, var(--line)); background: radial-gradient(120% 70% at 50% 30%, #2b4a66, #14161c 75%); }
.card.friendly .stamp { top: 58px; }
.card.friendly .stamp-smash { color: #7cc4ff; font-size: 34px; }
.card.friendly .stamp-pass { color: #ffb86b; font-size: 34px; }
.mode-badge { position: absolute; top: 14px; left: 14px; z-index: 4; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 5px 10px; border-radius: 999px; background: #7cc4ff; color: #0d1b29; }
.layout-split .mode-badge {display: none;}
.mode-badge.regular { background: var(--smash); color: #0d1f16; }
.act-smash.friendly { color: #7cc4ff; font-size: 28px; }
.act-pass.friendly { color: #ffb86b; font-size: 28px; }
.thumb.hug { border-color: color-mix(in srgb, #7cc4ff 55%, var(--line)); }
.thumb.handshake { border-color: color-mix(in srgb, #ffb86b 55%, var(--line)); }
.thumb.supersmash { border: 2px solid var(--super); box-shadow: 0 0 16px -4px var(--super); }
.stamp-smash { left: 22px; color: var(--smash); transform: rotate(-16deg); }
.stamp-pass { right: 22px; color: var(--pass); transform: rotate(16deg); }
/* Super smash / adopt: swipe up. Centered, lower on the art so it reads as a different verdict. */
.stamp-super { top: 30%; left: 50%; transform: translateX(-50%) rotate(-6deg); color: var(--super); white-space: nowrap; font-size: 38px; }
.card.friendly .stamp-super { color: var(--adopt); font-size: 34px; }

.actions { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 23px; }
.act {
  display: grid; place-items: center; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 8px 20px -8px rgba(0,0,0,.7);
  transition: transform 0.15s, background 0.15s;
}
.act:active { transform: scale(0.9); }
.act-pass, .act-smash { width: 68px; height: 68px; font-size: 30px; }
.act-super { width: 54px; height: 54px; font-size: 24px; color: var(--super); }
.act-super:hover { background: color-mix(in srgb, var(--super) 20%, var(--panel)); }
.act-super.friendly:hover { background: color-mix(in srgb, var(--adopt) 22%, var(--panel)); }
.act-undo { width: 48px; height: 48px; font-size: 20px; color: var(--muted); }
.act-pass { color: var(--pass); }
.act-smash { color: var(--smash); }
.act-pass:hover { background: color-mix(in srgb, var(--pass) 20%, var(--panel)); }
.act-smash:hover { background: color-mix(in srgb, var(--smash) 20%, var(--panel)); }
.act:disabled { opacity: 0.35; cursor: default; }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---------- done + stats ---------- */
.done, .stats { max-width: 760px; margin: 28px auto; }
.done { text-align: center; }
.done h2 { font-size: 34px; }
.done p { color: var(--muted); }
.done h3, .stats h3 { font-size: 16px; margin: 28px 0 12px; color: var(--muted); text-align: left; }
.done-actions { display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.ratio { margin: 16px auto; max-width: 420px; }
.ratio-bar { height: 12px; border-radius: 999px; background: var(--pass); overflow: hidden; }
.ratio-bar i { display: block; height: 100%; background: var(--smash); transition: width 0.6s; }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.thumb span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; padding: 12px 4px 4px; text-align: center; background: linear-gradient(transparent, rgba(0,0,0,.85)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb.smash { border-color: color-mix(in srgb, var(--smash) 55%, var(--line)); }
.thumb.pass { border-color: color-mix(in srgb, var(--pass) 55%, var(--line)); opacity: .75; }
.empty { color: var(--muted); font-size: 14px; grid-column: 1 / -1; }

.stats-head { display: flex; align-items: center; gap: 14px; }
.stats-head h2 { font-size: 24px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-top: 20px; }
.stat-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.stat-tile b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.stat-tile span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat-rows { display: grid; gap: 10px; }
.stat-row { display: grid; grid-template-columns: 110px 1fr 70px; gap: 12px; align-items: center; font-size: 14px; }
.stat-row .name { font-family: var(--display); font-weight: 600; }
.stat-row .pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.stat-row .ratio-bar { height: 10px; }
.stat-row .ratio-bar.none { background: var(--line); }
.stats-foot { margin-top: 32px; text-align: center; }

@media (max-width: 480px) {
  .brand-text small { display: none; }
  .brand-text { font-size: 16px; }
  .brand-mark { font-size: 22px; }
  .tally { gap: 8px; }
  .deck { height: calc(100dvh - 295px); min-height: 440px; }
  .credit { font-size: 10.5px; }
  .play-head { margin: 8px auto 6px; }
  .hint { display: none; }
  .card-name h2 { font-size: 23px; }
  .stat-row { grid-template-columns: 80px 1fr 56px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- profile extras + friendly stats ---------- */
.fact-snack { grid-column: 1 / -1; }
.friendly-head { color: #7cc4ff !important; }
.stat-tiles.friendly { margin: 0 0 16px; }
.stat-tiles.friendly .stat-tile { border-color: #7cc4ff33; background: color-mix(in srgb, #7cc4ff 6%, var(--panel)); }
.ratio-bar.friendly { background: #ffb86b; }
.ratio-bar.friendly i { background: #7cc4ff; }
.ratio-bar.friendly.none { background: var(--line); }

/* ---------- stats: accordions + character list ---------- */
.accordion { margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); }
.accordion summary {
  list-style: none; cursor: pointer; padding: 12px 16px;
  font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: '▾'; font-family: var(--body); transition: transform 0.2s; }
.accordion[open] summary::after { transform: rotate(180deg); }
.accordion summary:hover { color: var(--text); }
.accordion .stat-rows { padding: 4px 16px 16px; }
.accordion.friendly { border-color: #7cc4ff33; }

.char-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.char-controls input, .char-controls select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; min-width: 0;
}
.char-controls input { flex: 1 1 240px; }
.char-controls select { flex: 0 1 auto; max-width: 100%; }
.char-controls input:focus, .char-controls select:focus { outline: none; border-color: var(--gold); }
.char-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.chip:hover { color: var(--text); }
.chip.active { background: color-mix(in srgb, var(--gold) 18%, var(--panel)); border-color: var(--gold); color: var(--text); }
.chip-count { font-size: 11px; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,.08); }
.char-count { color: var(--muted); font-size: 12px; margin: 12px 0 8px; }
/* Character grid: border = verdict; hover shows the name over a verdict-colored gradient. */
.char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.char-tile {
  --vc: var(--muted);
  position: relative; overflow: hidden; aspect-ratio: 3 / 4; padding: 0;
  border-radius: 14px; border: 2px solid color-mix(in srgb, var(--vc) 70%, transparent);
  background: radial-gradient(90% 60% at 50% 35%, color-mix(in srgb, var(--vc) 14%, #242836), var(--panel));
  transition: transform 0.15s, box-shadow 0.2s;
}
.char-tile.v-none { --vc: #4a4f5e; }
.char-tile.v-smash { --vc: var(--smash); }
.char-tile.v-pass { --vc: var(--pass); }
.char-tile.v-hug { --vc: #7cc4ff; }
.char-tile.v-handshake { --vc: #ffb86b; }
.char-tile.v-supersmash { --vc: var(--super); border-width: 3px; }
.char-tile.v-adopt { --vc: var(--adopt); border-width: 3px; }
.char-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 10px; filter: drop-shadow(0 6px 12px rgba(0,0,0,.5)); transition: transform 0.3s; }
.char-tile::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, color-mix(in srgb, var(--vc) 85%, #000) 0%, color-mix(in srgb, var(--vc) 35%, transparent) 45%, transparent 75%);
  opacity: 0; transition: opacity 0.2s;
}
.char-tile-label {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 8px 8px 9px;
  display: flex; flex-direction: column; text-align: left; line-height: 1.2;
  opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s;
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
}
.char-tile-label b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-tile-label small { font-size: 10.5px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-tile:hover, .char-tile:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--vc) 80%, transparent); outline: none; }
.char-tile:hover img, .char-tile:focus-visible img { transform: scale(1.05); }
.char-tile:hover::after, .char-tile:focus-visible::after,
.char-tile:hover .char-tile-label, .char-tile:focus-visible .char-tile-label { opacity: 1; transform: none; }
/* No hover on touch screens: always show a lighter version of the label. */
@media (hover: none) {
  .char-tile::after { opacity: .75; }
  .char-tile-label { opacity: 1; transform: none; }
}
.char-more { display: block; margin: 12px auto 0; }

/* ---------- card modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6,7,10,.78); backdrop-filter: blur(6px); animation: fade-in .2s ease; }
.modal-body { position: relative; width: min(100%, 420px); display: flex; flex-direction: column; align-items: center; animation: modal-in .25s cubic-bezier(.2,.9,.3,1.2); }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.modal .deck { height: min(calc(100dvh - 150px), 820px); min-height: 0; }
.modal .actions { margin-top: 14px; }
.modal-close {
  position: absolute; top: -8px; right: -8px; z-index: 10; width: 36px; height: 36px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 15px;
}
.modal-close:hover { color: var(--text); }

/* ---------- two-column cards (info left, image right) ---------- */
/* Only on screens wide enough for it; phones always get the stacked card and no toggle. */
@media (max-width: 759px) {
  .layout-toggle { display: none; }
}
@media (min-width: 760px) {
  .layout-split .deck { width: min(100%, 1040px); }
  .layout-split .play-head { max-width: 1040px; }
  .layout-split .modal-body { width: min(100%, 1040px); }
  .layout-split .card { flex-direction: row-reverse; }
  .layout-split .card-art { flex: 0 0 58%; border-left: 1px solid rgba(255,255,255,.06); }
  .layout-split .card-info { border-top: none; background: rgba(10,11,14,.92); padding-top: 20px; }
  .layout-split .card-verdict { right: auto; left: 14px; top: auto; bottom: 14px; }
}

/* ---------- large image preview ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60; cursor: zoom-out;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  background: rgba(6,7,10,.92); backdrop-filter: blur(8px); animation: fade-in .2s ease;
}
.lightbox img { width: min(96vw, 1400px); height: calc(100dvh - 120px); object-fit: contain; filter: drop-shadow(0 20px 40px rgba(0,0,0,.6)); }
.lightbox-caption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 14px; text-align: center; cursor: auto; }
.lightbox-name { font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--text); }
.lightbox-credit { font-size: 13px; color: var(--muted); }
.lightbox-credit a { color: var(--gold); }
.lightbox-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 52px; height: 52px; border-radius: 50%; font-size: 30px; line-height: 1;
  color: var(--text); background: rgba(255,255,255,.08); border: 1px solid var(--line); cursor: pointer;
}
.lightbox-nav:hover { background: rgba(255,255,255,.16); }
.lightbox-nav.prev { left: 20px; }
.lightbox-nav.next { right: 20px; }
.lightbox.single .lightbox-nav { display: none; }
.lightbox-close { position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; }

/* ---------- card image gallery ---------- */
.art-frame { position: absolute; inset: 0; display: grid; place-items: center; }
.art-credit {
  position: absolute; left: 12px; bottom: 8px; z-index: 2; max-width: 60%;
  font-size: 11px; font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.art-credit span { color: var(--text); padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.55); }
.art-credit a { color: var(--text); text-decoration: none; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.55); }
.art-credit a:hover { color: var(--gold); text-decoration: underline; }
.art-dots { position: absolute; right: 12px; bottom: 10px; z-index: 2; display: flex; gap: 5px; }
.art-dot { width: 8px; height: 8px; padding: 0; border-radius: 50%; background: rgba(255,255,255,.3); border: 0; cursor: pointer; }
.art-dot.official { border-radius: 2px; } /* the square dot is the official render */
.art-dot[aria-current="true"] { background: var(--gold); }
.card.friendly .art-dot[aria-current="true"] { background: #7cc4ff; }
.art-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1;
  color: var(--text); background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.15);
  opacity: 0; transition: opacity 0.15s;
}
.art-nav.prev { left: 10px; }
.art-nav.next { right: 10px; }
.card[data-depth="0"] .card-art:hover .art-nav, .art-nav:focus-visible { opacity: 1; }
.art-nav:hover { background: rgba(0,0,0,.75); }
.card[data-depth="1"] .card-art > :not(.art-frame), .card[data-depth="2"] .card-art > :not(.art-frame) { visibility: hidden; }
@media (hover: none) { .art-nav { opacity: .85; } }
