/* Crown & Pawn — a single dark royal theme, painted explicitly. */
:root {
  --bg: #150911;
  --bg2: #22101b;
  --panel: #2a1422;
  --panel2: #3a1c2f;
  --line: #57304a;
  --ink: #f7ecdf;
  --muted: #c3aab8;
  --gold: #ecc46d;
  --gold-d: #a87f2c;
  --me: #55b8ff;
  --foe: #ff5f80;
  --good: #6fe6a1;
  --bad: #ff7272;
  --pp: #ecc46d;
  --pe: #ff5ca9;
  --r: 12px;
  --display: "Cinzel", "Times New Roman", serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(120% 70% at 50% -10%, #4a1630 0%, transparent 60%),
    radial-gradient(90% 60% at 50% 110%, #2b0f22 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
body[data-screen="game"] { overflow: hidden; }
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; letter-spacing: .02em; text-wrap: balance; }

/* ── Generic controls ─────────────────────────────────────────────────── */
.btn {
  display: block; width: 100%; padding: 13px 16px; margin: 8px 0 0;
  border-radius: var(--r); background: var(--panel2); border: 1px solid var(--line);
  font-weight: 800; text-align: center;
}
.btn:active, .big:active, .mid:active { transform: scale(.98); }
.btn.gold, .big.gold { background: linear-gradient(180deg, #f3d27f, #c89a3c); color: #2a1406; border-color: #f7dc96; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(255, 114, 114, .35); }
.btn.sm { display: inline-block; width: auto; padding: 7px 12px; margin: 0; font-size: 14px; }
.btn small { color: var(--muted); font-weight: 600; margin-left: 6px; }
.link { display: block; margin: 18px auto 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.hint { color: var(--muted); font-size: 14px; margin: 10px 2px; }
.stars { color: var(--gold); letter-spacing: -1px; font-size: 12px; }
.stars i { color: rgba(236, 196, 109, .22); font-style: normal; }
.gold { color: var(--gold); font-weight: 800; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--foe); vertical-align: middle; }

.screen { padding: max(10px, env(safe-area-inset-top)) 14px calc(40px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  margin: 0 -14px 6px; padding: 10px 14px; background: rgba(21, 9, 17, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(87, 48, 74, .6);
}
.topbar h2 { flex: 1; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar h2 small { font-family: var(--body); color: var(--muted); font-size: 13px; }
.back { width: 36px; height: 36px; border-radius: 50%; background: var(--panel2); font-size: 26px; line-height: 32px; flex: none; }
.tb-right { flex: none; }
.count { font-weight: 800; color: var(--bad); }
.count.ok { color: var(--good); }

/* ── Home ─────────────────────────────────────────────────────────────── */
.logo { text-align: center; padding: 34px 0 10px; }
.logo.small { padding-top: 18px; }
.crest {
  width: 78px; height: 78px; margin: 0 auto 10px; border-radius: 50%;
  display: grid; place-items: center; font-size: 46px; color: #2a1406;
  background: radial-gradient(circle at 35% 30%, #fbe3a2, #c4932f 70%);
  box-shadow: 0 0 0 4px rgba(236, 196, 109, .18), 0 8px 30px rgba(236, 196, 109, .25);
}
.logo h1 { font-size: 38px; font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 #5b2a12; }
.logo h1 span { color: var(--ink); font-size: .7em; }
.logo p { margin: 4px 0 0; color: var(--muted); font-style: italic; }
.purse { display: flex; justify-content: center; gap: 18px; margin: 12px 0 20px; font-weight: 800; }
.menu { display: grid; gap: 10px; }
.big {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 17px;
  border-radius: 16px; font-family: var(--display); font-weight: 700; font-size: 20px;
  background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .35);
}
.big em { font-family: var(--body); font-style: normal; font-size: 12px; color: var(--gold); border: 1px solid var(--gold-d); border-radius: 99px; padding: 1px 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mid { padding: 15px 8px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-weight: 800; }

/* ── Starter ──────────────────────────────────────────────────────────── */
.lead { text-align: center; color: var(--muted); margin: 6px 6px 16px; }
.arch-list { display: grid; gap: 9px; }
.arch {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px; border-radius: 14px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tag) 18%, var(--panel)), var(--panel));
  border: 1px solid color-mix(in srgb, var(--tag) 45%, transparent);
}
.a-icon { font-size: 30px; width: 46px; text-align: center; flex: none; }
.a-body b { display: block; font-family: var(--display); font-size: 17px; color: var(--tag); }
.a-body small { color: var(--muted); font-size: 13px; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  --rc: #b9c0cc;
  position: relative; flex: none; font-size: 10px; width: 7.4em; height: 10.8em;
  border-radius: .9em; padding: .45em .45em .5em;
  background:
    radial-gradient(90% 55% at 50% 38%, color-mix(in srgb, var(--tag) 30%, transparent), transparent 70%),
    linear-gradient(180deg, #34192b, #1b0d17);
  border: .2em solid var(--rc);
  box-shadow: 0 .3em .8em rgba(0, 0, 0, .45), inset 0 0 0 .1em rgba(255, 255, 255, .05);
  display: flex; flex-direction: column; align-items: center;
  transition: transform .15s ease, opacity .15s;
}
.rar-R { --rc: #5aa9ff; }
.rar-E { --rc: #b57bff; }
.rar-L { --rc: #ffb340; box-shadow: 0 0 1.2em rgba(255, 179, 64, .35), 0 .3em .8em rgba(0, 0, 0, .45); }
.c-top { width: 100%; display: flex; justify-content: space-between; align-items: center; height: 1.75em; flex: none; }
.c-rank { color: var(--gold); font-size: 1em; letter-spacing: -.05em; }
.c-rank b { font-weight: 400; }
.c-rank .rep { font-size: 1.5em; line-height: 1; }
.c-pow {
  min-width: 1.8em; height: 1.8em; border-radius: 50%; display: grid; place-items: center;
  background: #0b0509; border: .12em solid var(--rc); font-weight: 900; font-size: 1.15em;
}
.c-art { font-size: 2.4em; line-height: 1.05; flex: none; filter: drop-shadow(0 .06em .1em rgba(0, 0, 0, .6)); }
.c-name {
  font-weight: 800; font-size: .9em; text-align: center; line-height: 1.08; height: 2.16em; flex: none;
  overflow: hidden; margin: .15em 0 .2em; display: flex; align-items: center; justify-content: center;
}
.c-grid { display: grid; grid-template-columns: repeat(5, .56em); gap: .1em; margin-top: auto; flex: none; }
.c-grid i { width: .56em; height: .56em; border-radius: .1em; background: rgba(255, 255, 255, .09); }
.c-grid.lg { grid-template-columns: repeat(5, 22px); gap: 4px; margin: 0; }
.c-grid.lg i { width: 22px; height: 22px; border-radius: 4px; }
.g-x { background: #fff !important; }
.g-p { background: var(--pp) !important; }
.g-e { background: var(--pe) !important; }
.g-b { background: linear-gradient(135deg, var(--pp) 50%, var(--pe) 50%) !important; }
.c-ab { position: absolute; left: .5em; bottom: .45em; color: var(--pe); font-size: .9em; }
.c-badge {
  position: absolute; top: -.75em; left: 50%; transform: translateX(-50%); white-space: nowrap; padding: .1em .55em; border-radius: 99px; font-size: .95em; font-weight: 900;
  background: var(--gold); color: #2a1406; box-shadow: 0 .1em .3em rgba(0, 0, 0, .5);
}
.c-info {
  position: absolute; right: -.45em; bottom: -.45em; width: 2.1em; height: 2.1em; border-radius: 50%;
  background: var(--panel2); border: .1em solid var(--line); font-weight: 900; font-size: .95em; font-family: Georgia, serif; font-style: italic;
}
.card.dim { opacity: .45; }
.card.locked { filter: grayscale(1) brightness(.55); }
.card.locked .c-art { opacity: .5; }
.card.xl { font-size: 17px; margin: 0 auto 12px; }

/* ── Detail sheet ─────────────────────────────────────────────────────── */
.detail { text-align: center; }
.detail h3 { font-size: 22px; color: var(--gold); }
.d-meta { color: var(--muted); font-size: 14px; margin: 2px 0 10px; }
.d-stats { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.d-stats span { background: var(--panel2); border-radius: 99px; padding: 3px 11px; font-weight: 800; font-size: 14px; }
.d-pattern { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 14px 0 6px; }
.legend { display: grid; gap: 6px; text-align: left; font-size: 13px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.legend em { font-size: 12px; }
.d-text { font-size: 16px; background: var(--bg2); border-radius: var(--r); padding: 12px; margin: 12px 0 4px; user-select: text; }

/* ── Modal & toast ────────────────────────────────────────────────────── */
#modal {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: flex-end; justify-content: center;
  background: rgba(8, 3, 6, .66); backdrop-filter: blur(3px);
}
#modal.open { display: flex; animation: fade .18s ease; }
.sheet {
  width: min(480px, 100%); max-height: 92dvh; overflow: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 20px 20px 0 0; animation: rise .22s ease;
}
.sheet h3 { text-align: center; font-size: 21px; margin-bottom: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: .4; } }
#toast {
  position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top)); z-index: 60; transform: translate(-50%, -20px);
  max-width: 90vw; padding: 9px 16px; border-radius: 99px; background: rgba(20, 8, 15, .94); border: 1px solid var(--line);
  font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Rules ────────────────────────────────────────────────────────────── */
.rules ol { padding-left: 20px; margin: 10px 0; }
.rules li { margin: 8px 0; font-size: 15px; }
.rules .tip { background: var(--bg2); padding: 10px 12px; border-radius: var(--r); color: var(--gold); font-size: 14px; }
.hl-p { color: var(--pp); font-weight: 800; }
.hl-e { color: var(--pe); font-weight: 800; }
.pip { color: var(--gold); }

/* ── Duel select ──────────────────────────────────────────────────────── */
.deckchip {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 10px 12px; border-radius: var(--r);
  background: var(--bg2); border: 1px dashed var(--line); font-size: 14px; text-align: left;
}
.deckchip b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deckchip em { color: var(--gold); font-style: normal; font-size: 12px; }
.foes { display: grid; gap: 10px; }
.foe {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; cursor: pointer;
  background: linear-gradient(90deg, var(--panel2), var(--panel)); border: 1px solid var(--line);
}
.foe:active { transform: scale(.985); }
.f-av, .gf-av {
  width: 50px; height: 50px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 28px;
  background: radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--tag) 45%, #2a1422), #1a0b14);
  border: 2px solid var(--tag);
}
.f-body { flex: 1; min-width: 0; }
.f-body b { display: block; font-family: var(--display); font-size: 16px; }
.f-body small { display: block; color: var(--muted); font-size: 13px; }
.f-tags { font-size: 12px; margin-top: 2px; }
.f-side { text-align: right; display: grid; justify-items: end; gap: 2px; }
.f-side small { color: var(--muted); font-size: 12px; }
.reward { font-weight: 800; color: var(--gold); font-size: 13px; }

/* ── Game ─────────────────────────────────────────────────────────────── */
.game {
  height: 100dvh; display: flex; flex-direction: column; gap: 4px;
  padding: max(6px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom));
}
.g-foe, .g-me { display: flex; align-items: center; gap: 10px; flex: none; }
.g-foe { padding: 2px 4px; }
.gf-av { width: 40px; height: 40px; font-size: 22px; }
.gf-body { flex: 1; min-width: 0; display: grid; }
.gf-body b { font-family: var(--display); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gf-body .cnt { color: var(--muted); font-size: 12px; margin-left: 4px; }
.passed { font-style: normal; font-size: 10px; font-weight: 900; color: var(--gold); border: 1px solid var(--gold-d); padding: 0 5px; border-radius: 99px; }
.total {
  min-width: 46px; height: 46px; padding: 0 6px; border-radius: 23px; display: grid; place-items: center; flex: none;
  font-family: var(--display); font-weight: 900; font-size: 24px; background: #0c0509; border: 2px solid var(--line);
}
.foe-t { color: var(--foe); }
.me-t { color: var(--me); }
.total.lead { border-color: var(--gold); box-shadow: 0 0 14px rgba(236, 196, 109, .35); }

.arena { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.lanes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; flex: none; }
.lane {
  height: 24px; border-radius: 99px; display: flex; align-items: center; justify-content: center; gap: 5px;
  background: rgba(255, 255, 255, .04); font-weight: 900; font-size: 15px; transition: .2s;
}
.l1 .lane { color: var(--foe); }
.l0 .lane { color: var(--me); }
.lane small { font-size: 11px; color: var(--gold); }
.lane .pts { font-size: 11px; font-weight: 800; color: var(--gold); }
.lane .cr { font-size: 12px; color: var(--gold); }
.l1 .lane.win { background: rgba(255, 95, 128, .18); box-shadow: inset 0 0 0 1px rgba(255, 95, 128, .6); }
.l0 .lane.win { background: rgba(85, 184, 255, .18); box-shadow: inset 0 0 0 1px rgba(85, 184, 255, .6); }

.board {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(5, 1fr); gap: 5px;
  padding: 5px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(87, 48, 74, .7);
}
.tile { position: relative; border-radius: 10px; min-height: 0; transition: background .2s, box-shadow .2s; }
.own-n { background: rgba(255, 255, 255, .025); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.own0 { background: rgba(85, 184, 255, .1); box-shadow: inset 0 0 0 1px rgba(85, 184, 255, .3); }
.own1 { background: rgba(255, 95, 128, .1); box-shadow: inset 0 0 0 1px rgba(255, 95, 128, .3); }
.tile.valid { box-shadow: inset 0 0 0 2px var(--gold); animation: glow 1.2s ease-in-out infinite; }
.tile.valid-dim { box-shadow: inset 0 0 0 1px rgba(236, 196, 109, .45); }
@keyframes glow { 50% { box-shadow: inset 0 0 0 2px var(--gold), 0 0 12px rgba(236, 196, 109, .45); } }
.tile.pv-p { box-shadow: inset 0 0 0 3px var(--pp); animation: none; }
.tile.pv-e { box-shadow: inset 0 0 0 3px var(--pe); animation: none; }
.tile.pv-b { box-shadow: inset 0 0 0 3px var(--pp), inset 0 0 0 6px var(--pe); animation: none; }
.tile.pv-here { box-shadow: 0 0 0 2px #fff, 0 0 18px rgba(255, 255, 255, .4); animation: none; }
.tile.pv-here .bc { opacity: .9; }
.tile.inspect { box-shadow: 0 0 0 2px #fff; }

.pawns { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 2px; pointer-events: none; }
.pawns svg { width: 15px; height: 20px; fill: currentColor; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }
.pawns.o0 { color: var(--me); }
.pawns.o1 { color: var(--foe); }

.bc {
  position: absolute; inset: 2px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; pointer-events: none;
}
.bc.o0 { background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--tag) 30%, #1f4166), #10213a); border: 2px solid var(--me); }
.bc.o1 { background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--tag) 30%, #6a2238), #3a1020); border: 2px solid var(--foe); }
.bc-art { font-size: clamp(18px, min(7.5vw, 5.2dvh), 34px); line-height: 1.1; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .55)); }
.bc-name { font-size: 9.5px; font-weight: 800; opacity: .9; max-width: 94%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-pow {
  position: absolute; top: 3px; right: 3px; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; gap: 1px;
  background: rgba(0, 0, 0, .7); font-weight: 900; font-size: 14px;
}
.bc.enh .bc-pow { color: var(--good); }
.bc.enf .bc-pow { color: var(--bad); }
.bc-delta { font-size: 10px; opacity: .8; }
.bc-delta.up + * { color: var(--good); }
.bc-ab { position: absolute; left: 4px; top: 2px; font-size: 10px; color: var(--pe); }
.doom { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; color: var(--bad); text-shadow: 0 0 8px #000; pointer-events: none; }

.pop .bc { animation: pop .38s cubic-bezier(.2, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.flash0 { animation: flash0 .9s ease; }
.flash1 { animation: flash1 .9s ease; }
@keyframes flash0 { 30% { box-shadow: 0 0 0 3px var(--me), 0 0 24px var(--me); } }
@keyframes flash1 { 30% { box-shadow: 0 0 0 3px var(--foe), 0 0 24px var(--foe); } }
.float {
  position: absolute; left: 50%; top: 40%; z-index: 3; transform: translate(-50%, 0); pointer-events: none;
  font-weight: 900; font-size: 20px; text-shadow: 0 2px 4px #000; animation: float 1.1s ease-out forwards;
}
.float.up { color: var(--good); }
.float.down { color: var(--bad); }
@keyframes float { to { transform: translate(-50%, -34px); opacity: 0; } }
.boom {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; font-size: 30px; pointer-events: none;
  filter: grayscale(1); animation: boom .9s ease-out forwards;
}
@keyframes boom { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.8) rotate(20deg); opacity: 0; } }

.info {
  flex: none; height: 52px; padding: 6px 10px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line);
  overflow: hidden; font-size: 13px; display: flex; flex-direction: column; justify-content: center;
}
.info.status { text-align: center; color: var(--muted); font-size: 14px; }
.info.status b { color: var(--gold); }
.i-head { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.i-head b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.i-head span { color: var(--muted); font-size: 12px; }
.i-score b { color: var(--gold); }
.i-text { color: var(--muted); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.i-text em { color: var(--bad); font-style: normal; }
.i-cta { color: var(--gold); font-weight: 800; }
.me-c { color: var(--me) !important; }
.foe-c { color: var(--foe) !important; }
.think i { animation: blink 1.2s infinite; font-style: normal; }
.think i:nth-child(2) { animation-delay: .2s; }
.think i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: 0; } }

.hand {
  flex: none; display: flex; gap: 7px; overflow-x: auto; overflow-y: visible; padding: 10px 4px 4px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.hand::-webkit-scrollbar { display: none; }
.hand .card { scroll-snap-align: start; cursor: pointer; }
.hand .card.sel { transform: translateY(-7px); box-shadow: 0 0 0 2px #fff, 0 8px 18px rgba(0, 0, 0, .6); }
.empty-hand { color: var(--muted); padding: 30px 0; width: 100%; text-align: center; }
.foe-turn .hand .card { opacity: .8; }

.g-me { padding: 2px 4px; }
.g-menu { width: 40px; height: 40px; border-radius: 50%; background: var(--panel2); font-size: 18px; flex: none; }
.g-deck { flex: 1; color: var(--muted); font-size: 13px; font-weight: 700; }
.pass {
  padding: 11px 22px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); font-weight: 900; transition: .15s;
}
.pass:disabled { opacity: .4; }
.pass.armed { background: var(--bad); color: #2a0808; border-color: #ffb0b0; }
.pass.must { background: linear-gradient(180deg, #f3d27f, #c89a3c); color: #2a1406; animation: glow2 1.2s infinite; }
@keyframes glow2 { 50% { box-shadow: 0 0 16px rgba(236, 196, 109, .6); } }

@media (max-height: 700px) {
  .hand .card { font-size: 8.6px; }
  .info { height: 46px; }
  .g-foe .total, .g-me .total { min-width: 40px; height: 40px; font-size: 21px; }
  .gf-av, .g-menu { width: 34px; height: 34px; }
}

/* ── Mulligan / results ───────────────────────────────────────────────── */
.mull-cards, .spoils { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 14px 0; }
.mull-cards .card, .spoils .card { cursor: pointer; }
.card.marked { transform: rotate(-6deg) scale(.94); opacity: .5; }
.card.marked::after {
  content: "↺"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 4em; color: var(--gold); text-shadow: 0 0 10px #000;
}
.card.picked { box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(236, 196, 109, .55); transform: translateY(-4px); }
.result { text-align: center; }
.result h2 { font-size: 34px; }
.result.win h2 { color: var(--gold); }
.result.loss h2 { color: var(--bad); }
.result p { color: var(--muted); }
.final { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0; }
.final div { display: grid; }
.final small { color: var(--muted); font-size: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final b { font-family: var(--display); font-size: 40px; }
.final div:first-child b { color: var(--me); }
.final div:last-child b { color: var(--foe); }
.earn { font-weight: 900; color: var(--gold); font-size: 18px; margin: 8px 0; }
.spoil-text { min-height: 40px; font-size: 14px; color: var(--muted); background: var(--bg2); border-radius: var(--r); padding: 8px 10px; }

/* ── Tournament ───────────────────────────────────────────────────────── */
.cups { display: grid; gap: 10px; margin-top: 8px; }
.cup {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px; border-radius: 14px; text-align: left;
  background: linear-gradient(90deg, var(--panel2), var(--panel)); border: 1px solid var(--line);
}
.cup.locked { opacity: .5; }
.cup-icon { font-size: 34px; flex: none; }
.cup-body { flex: 1; display: grid; }
.cup-body b { font-family: var(--display); font-size: 17px; }
.cup-body small { color: var(--muted); font-size: 12.5px; }
.cup-fee { font-weight: 900; color: var(--gold); flex: none; }
.bracket { display: grid; gap: 14px; margin-top: 18px; }
.round h4 { font-size: 14px; color: var(--gold); margin-bottom: 6px; }
.match { border-radius: 12px; background: var(--bg2); border: 1px solid rgba(87, 48, 74, .6); margin-bottom: 6px; overflow: hidden; }
.match.mine { border-color: var(--gold-d); }
.match div { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; font-size: 14px; }
.match div + div { border-top: 1px solid rgba(87, 48, 74, .5); }
.match .w { font-weight: 900; background: rgba(236, 196, 109, .08); }
.match .l { opacity: .45; text-decoration: line-through; }
.match .you { color: var(--me); font-weight: 900; }
.champ { text-align: center; font-family: var(--display); font-size: 22px; color: var(--gold); margin: 16px 0 4px; }
.screen > .foe { margin: 6px 0; cursor: default; }

/* ── Collection & decks ───────────────────────────────────────────────── */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-width: 38px; padding: 6px 10px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line);
  font-weight: 800; font-size: 14px;
}
.chip.r { color: var(--rc, var(--ink)); }
.chip.on { background: var(--gold); color: #2a1406; border-color: var(--gold); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 18px 6px; justify-items: center; margin-top: 12px; }
.grid .card { cursor: pointer; }
.decks { display: grid; gap: 8px; margin: 6px 0 10px; }
.deck { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.deck.active { border-color: var(--gold-d); background: linear-gradient(90deg, rgba(236, 196, 109, .12), var(--panel)); }
.dk-body { flex: 1; min-width: 0; cursor: pointer; }
.dk-body b { display: block; font-family: var(--display); }
.dk-body small { color: var(--muted); }
.badge { font-size: 12px; font-weight: 900; color: var(--gold); border: 1px solid var(--gold-d); padding: 2px 8px; border-radius: 99px; }
.curve { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--gold); margin: 4px 0 8px; }
.curve span { background: var(--bg2); padding: 3px 8px; border-radius: 99px; }
.curve .btn:first-of-type { margin-left: auto; }
.decklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-bottom: 8px; min-height: 40px; }
.decklist .hint { grid-column: 1 / -1; }
.dl-row {
  display: flex; align-items: center; gap: 4px; padding: 5px 7px; border-radius: 9px; text-align: left; font-size: 12.5px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tag) 22%, var(--bg2)), var(--bg2)); border-left: 3px solid var(--rc, #b9c0cc);
}
.dl-row.rar-R { --rc: #5aa9ff; } .dl-row.rar-E { --rc: #b57bff; } .dl-row.rar-L { --rc: #ffb340; }
.dl-rank { color: var(--gold); font-size: 9px; width: 18px; flex: none; }
.dl-art { flex: none; }
.dl-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.dl-pow { font-weight: 900; flex: none; }
.dl-n { color: var(--gold); font-weight: 900; flex: none; }
.arch-pick .btn { text-align: left; border-left: 4px solid var(--tag); }

/* ── Shop ─────────────────────────────────────────────────────────────── */
.packs { display: grid; gap: 10px; }
.pack {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px; border-radius: 14px; text-align: left; width: 100%;
  background: linear-gradient(90deg, var(--panel2), var(--panel)); border: 1px solid var(--line);
}
.pack.house { border-bottom-left-radius: 0; border-bottom-right-radius: 0; margin-bottom: -10px; }
.p-icon { font-size: 34px; flex: none; }
.p-body { flex: 1; display: grid; }
.p-body b { font-family: var(--display); font-size: 17px; }
.p-body small { color: var(--muted); font-size: 13px; }
.p-price { font-weight: 900; color: var(--gold); flex: none; }
.house-pick {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px; border-radius: 0 0 14px 14px;
  background: var(--panel); border: 1px solid var(--line); border-top: 0;
}
.hp { display: grid; justify-items: center; padding: 8px 2px; border-radius: 10px; background: var(--bg2); border-bottom: 3px solid var(--tag); font-size: 22px; }
.hp small { font-size: 11px; font-weight: 800; }
.hp em { font-style: normal; font-size: 10px; color: var(--muted); }
.odds { color: var(--muted); font-size: 12px; text-align: center; margin-top: 14px; }
.reveal { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 12px 0; }
.flip { width: 74px; height: 108px; perspective: 600px; position: relative; cursor: pointer; }
.flip > div { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .5s; }
.flip .back {
  display: grid; place-items: center; font-size: 34px; color: var(--gold); border-radius: 9px;
  background: repeating-linear-gradient(45deg, #3d1a2f 0 6px, #2c1222 6px 12px); border: 2px solid var(--gold-d);
}
.flip .front { transform: rotateY(180deg); }
.flip.open .back { transform: rotateY(180deg); }
.flip.open .front { transform: rotateY(360deg); }

/* ── Record ───────────────────────────────────────────────────────────── */
.statbox { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-top: 8px; }
.statbox div { background: var(--panel); border-radius: 14px; padding: 12px 4px; display: grid; }
.statbox small { color: var(--muted); }
.statbox b { font-family: var(--display); font-size: 30px; }
.sub { margin: 18px 0 6px; font-size: 15px; color: var(--gold); }
.statrows { display: grid; gap: 4px; }
.statrows div { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--bg2); border-radius: 10px; }
.statrows span { flex: 1; }
.statrows.rar b { flex: 1; }
.settings { margin-top: 18px; }
.menu-sheet .hint { text-align: center; }
