/* Grimoire — dark arcane theme */
:root {
  --bg-0: #0d0a14;
  --bg-1: #171321;
  --panel: rgba(255,255,255,0.045);
  --panel-border: rgba(255,255,255,0.09);
  --ink: #ece7f2;
  --ink-2: #b5aec6;
  --muted: #8d86a0;
  --gold: #d8a83f;
  --gold-soft: #e9c979;
  --accent: #7b5cd6;
  --danger: #d0483b;
  /* colour-identity chart fills (labels + icons always accompany these) */
  --mtg-w: #e5dcbe; --mtg-u: #3f8fe0; --mtg-b: #a08cc0;
  --mtg-r: #e05a4a; --mtg-g: #3fa860; --mtg-m: #d8a83f; --mtg-c: #8a8a92;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 15% -10%, rgba(123,92,214,0.22), transparent 60%),
    radial-gradient(900px 450px at 95% 0%, rgba(216,168,63,0.10), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 60%);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
a { color: var(--gold-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.7rem 1.4rem;
  background: rgba(13,10,20,0.75);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}
.brand {
  font-family: Iowan Old Style, Palatino, Georgia, serif;
  font-size: 1.35rem; letter-spacing: 0.06em; color: var(--gold-soft);
  display: flex; align-items: center; gap: 0.45rem;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.5rem; filter: drop-shadow(0 0 6px rgba(216,168,63,0.6)); }
.nav { display: flex; gap: 0.25rem; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--ink-2); padding: 0.45rem 0.85rem; border-radius: 8px; font-size: 0.95rem;
}
.nav a:hover { color: var(--ink); background: var(--panel); text-decoration: none; }
.nav a.active { color: var(--gold-soft); background: rgba(216,168,63,0.10); }
.nav-signout { display: none; }
@media (max-width: 560px) {
  .topbar.nav-open .nav-signout {
    display: block; border-top: 1px solid var(--panel-border);
    margin-top: 0.4rem; padding-top: 0.8rem; color: var(--muted);
  }
}
.userbox { display: flex; align-items: center; gap: 0.8rem; }
.nav-toggle {
  display: none; place-items: center; width: 38px; height: 38px;
  font-size: 1.25rem; border-radius: 9px; cursor: pointer;
  background: rgba(0,0,0,0.25); border: 1px solid var(--panel-border); color: var(--ink-2);
}
.nav-toggle:hover, .topbar.nav-open .nav-toggle { color: var(--gold-soft); border-color: rgba(216,168,63,0.4); }
.nav-badge {
  display: inline-grid; place-items: center; min-width: 1.15rem; height: 1.15rem;
  padding: 0 0.28rem; border-radius: 999px; vertical-align: 0.1em;
  background: #d0483b; color: #fff; font-size: 0.68rem; font-weight: 800;
  box-shadow: 0 0 8px rgba(208,72,59,0.6);
}
.nav-toggle { position: relative; }
.nav-toggle.has-dot::after {
  content: ''; position: absolute; top: -3px; right: -3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #d0483b; border: 2px solid var(--bg-1);
}
.lang-menu { position: relative; }
.lang-globe {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 50%; border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.25); color: var(--ink-2); cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.lang-globe:hover, .lang-globe[aria-expanded="true"] {
  color: var(--gold-soft); background: rgba(216,168,63,0.12); border-color: rgba(216,168,63,0.4);
}
.lang-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 150px; z-index: 60;
  background: linear-gradient(180deg, #221c31, #171221);
  border: 1px solid var(--panel-border); border-radius: 12px; padding: 0.35rem;
  box-shadow: 0 18px 40px rgba(0,0,0,0.55);
}
.lang-item {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.5rem 0.7rem; border-radius: 8px; color: var(--ink-2); font-size: 0.92rem;
}
.lang-item:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
.lang-item.active { color: var(--gold-soft); }
.lang-check { font-weight: 700; }
.username { color: var(--ink-2); font-size: 0.95rem; }
a.username:hover { color: var(--gold-soft); text-decoration: none; }
.nav-account { display: none; }
@media (max-width: 860px) { .topbar.nav-open .nav-account { display: block; } }
.alert-ok { background: rgba(63,168,96,0.14); border-color: rgba(63,168,96,0.5); color: #a4dfb8; }
.account-form { display: flex; flex-direction: column; gap: 0.9rem; max-width: 380px; }
.account-form .btn { align-self: flex-start; }

.page { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.6rem 1.4rem 3rem; }
.footer {
  text-align: center; font-size: 0.8rem; color: var(--muted);
  padding: 1.2rem; border-top: 1px solid var(--panel-border);
}
.page-title {
  font-family: Iowan Old Style, Palatino, Georgia, serif;
  font-weight: 600; letter-spacing: 0.02em; font-size: 1.7rem; margin: 0.2rem 0 1.2rem;
}
h2 { font-size: 1.05rem; font-weight: 600; color: var(--ink-2); margin: 0 0 0.9rem; }
.muted { color: var(--muted); }

/* ---- buttons & forms ---- */
.btn {
  border: 1px solid var(--panel-border); border-radius: 9px;
  background: var(--panel); color: var(--ink);
  padding: 0.5rem 1rem; font-size: 0.95rem; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: rgba(255,255,255,0.09); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, #caa02f, #a37718);
  border-color: rgba(233,201,121,0.5); color: #1c1406; font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(135deg, #e0b542, #b8871f); }
.btn-danger { border-color: rgba(208,72,59,0.6); color: #f0a49b; }
.btn-danger:hover { background: rgba(208,72,59,0.15); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; margin-top: 0.6rem; }
input, select {
  background: rgba(0,0,0,0.35); color: var(--ink);
  border: 1px solid var(--panel-border); border-radius: 9px;
  padding: 0.55rem 0.75rem; font-size: 0.95rem; font-family: inherit;
}
input:focus, select:focus { outline: 2px solid rgba(216,168,63,0.45); border-color: var(--gold); }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--ink-2); }
.hint { color: var(--muted); font-size: 0.8rem; }
.alert {
  background: rgba(208,72,59,0.14); border: 1px solid rgba(208,72,59,0.5);
  color: #f2b3ab; border-radius: 9px; padding: 0.6rem 0.9rem; margin-bottom: 1rem; font-size: 0.92rem;
}

/* ---- auth ---- */
.auth-wrap { display: grid; place-items: center; min-height: 70vh; }
.auth-card {
  width: min(400px, 92vw); text-align: center;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 18px; padding: 2.2rem 2rem;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
}
.auth-emblem { font-size: 3rem; filter: drop-shadow(0 0 14px rgba(216,168,63,0.55)); }
.auth-card h1 {
  font-family: Iowan Old Style, Palatino, Georgia, serif;
  margin: 0.4rem 0 0.2rem; letter-spacing: 0.08em; color: var(--gold-soft);
}
.auth-sub { color: var(--muted); font-size: 0.92rem; margin-top: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 0.9rem; text-align: left; margin-top: 1.2rem; }
.auth-alt { font-size: 0.9rem; color: var(--muted); margin-top: 1.2rem; }

/* ---- stat tiles ---- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat-tile {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 1.1rem 1.2rem;
}
.stat-value { font-size: 2rem; font-weight: 650; color: var(--ink); }
.stat-link { display: block; color: inherit; cursor: pointer; }
.stat-menu { position: relative; }
.stat-menu .lang-dropdown { top: calc(100% - 6px); left: 0; right: auto; min-width: 200px; }
.stat-link:hover { text-decoration: none; border-color: rgba(216,168,63,0.4); background: rgba(216,168,63,0.07); }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* ---- panels & dashboard ---- */
.panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 1.2rem 1.3rem; margin-bottom: 1.4rem;
}
.panel.narrow { max-width: 640px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.4rem; }
@media (max-width: 760px) { .dash-grid { grid-template-columns: 1fr; } }

/* labelled bar rows (colour identity, rarity) */
.colour-bars { display: flex; flex-direction: column; gap: 0.55rem; }
.cbar-row { display: grid; grid-template-columns: 9.5rem 1fr 3rem; align-items: center; gap: 0.7rem; font-size: 0.9rem; }
.cbar-label { display: flex; align-items: center; gap: 0.45rem; color: var(--ink-2); }
.cbar-track { height: 12px; background: rgba(0,0,0,0.35); border-radius: 6px; overflow: hidden; }
.cbar-fill { display: block; height: 100%; border-radius: 6px; min-width: 2px; }
.cbar-count { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.fill-W { background: var(--mtg-w); } .fill-U { background: var(--mtg-u); }
.fill-B { background: var(--mtg-b); } .fill-R { background: var(--mtg-r); }
.fill-G { background: var(--mtg-g); } .fill-M { background: var(--mtg-m); }
.fill-C { background: var(--mtg-c); }
.fill-generic { background: linear-gradient(90deg, var(--gold-soft), var(--mtg-m)); }
.fill-rarity-common { background: #b8b3c4; }
.fill-rarity-uncommon { background: #9ac0cf; }
.fill-rarity-rare { background: #d8b95e; }
.fill-rarity-mythic { background: #e0703a; }
.rarity-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.rarity-common { background: #b8b3c4; } .rarity-uncommon { background: #9ac0cf; }
.rarity-rare { background: #d8b95e; } .rarity-mythic { background: #e0703a; }

/* ---- mana pips ---- */
.pip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25em; height: 1.25em; border-radius: 50%;
  font-size: 0.78em; font-weight: 700; color: #1a1a17;
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.35); vertical-align: -0.15em; margin-right: 1px;
}
.pip-w { background: #f8f6d8; } .pip-u { background: #9bd0f5; }
.pip-b { background: #beb4ad; } .pip-r { background: #f5a084; }
.pip-g { background: #97d0ae; } .pip-c { background: #cfc9c2; }
.pip-gold { background: linear-gradient(135deg, #e9c979, #c08f24); }
.pip-img {
  width: 1.18em; height: 1.18em; vertical-align: -0.2em; margin-right: 1px;
  border-radius: 50%; box-shadow: -1px 1px 0 rgba(0,0,0,0.55);
}

/* ---- card grids ---- */
.search-bar { display: flex; gap: 0.7rem; margin-bottom: 0.8rem; }
.search-bar input { flex: 1; font-size: 1.05rem; }
.filter-row { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filter-pills {
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--panel-border);
  border-radius: 999px; padding: 4px 7px;
}
.fpill {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer;
  border-radius: 999px; padding: 3px 7px;
  color: var(--ink-2); font-size: 0.82rem; font-family: inherit;
}
.fpill:hover { background: rgba(255,255,255,0.08); }
.fpill.active { background: rgba(216,168,63,0.2); outline: 1px solid rgba(216,168,63,0.5); color: var(--gold-soft); }
.chip-row { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; margin: 0.2rem 0 0.8rem; }
.chip-label { color: var(--muted); font-size: 0.82rem; }
#recent-chips { display: contents; }
.chip {
  border: 1px solid var(--panel-border); border-radius: 999px;
  background: rgba(255,255,255,0.05); color: var(--ink-2);
  font-size: 0.82rem; padding: 0.22rem 0.75rem; cursor: pointer;
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip:hover { color: var(--gold-soft); border-color: rgba(216,168,63,0.4); background: rgba(216,168,63,0.08); }
.chip-clear { color: var(--muted); background: transparent; }
.chip-card {
  border: none; padding: 0; background: none; cursor: pointer;
  width: 68px; border-radius: 6px; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.chip-card img { width: 100%; display: block; border-radius: 6px; }
.chip-card:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 10px 22px rgba(0,0,0,0.5), 0 0 14px rgba(216,168,63,0.25);
}
.filter-row input[type="search"] { flex: 1; min-width: 180px; }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.1rem;
}
.card-tile {
  position: relative; border-radius: 4.75% / 3.5%;
  cursor: pointer; transition: transform 0.18s, box-shadow 0.18s;
}
.card-tile:hover, .card-tile:focus-visible {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 34px rgba(0,0,0,0.55), 0 0 22px rgba(216,168,63,0.18);
  z-index: 2;
}
.card-tile img { width: 100%; display: block; border-radius: 4.75% / 3.5%; }
.card-noimg {
  aspect-ratio: 63/88; display: grid; place-items: center; text-align: center;
  padding: 1rem; background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 4.75% / 3.5%;
}
.qty-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(13,10,20,0.85); border: 1px solid var(--gold);
  color: var(--gold-soft); font-size: 0.8rem; font-weight: 700;
  padding: 0.15rem 0.5rem; border-radius: 999px;
}
.card-tile-bar { padding: 0.45rem 0.2rem 0; display: flex; flex-direction: column; }
.card-tile-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-tile-meta { font-size: 0.78rem; color: var(--muted); }
.price { color: var(--gold-soft); }

/* recently-added strip */
.card-strip { display: flex; gap: 0.8rem; overflow-x: auto; padding-bottom: 0.4rem; }
.mini-card { position: relative; flex: 0 0 110px; }
.mini-card img { width: 100%; border-radius: 6px; display: block; }
.mini-card-qty {
  position: absolute; bottom: 4px; right: 4px; font-size: 0.75rem; font-weight: 700;
  background: rgba(13,10,20,0.85); color: var(--gold-soft);
  padding: 0.05rem 0.4rem; border-radius: 999px; border: 1px solid var(--panel-border);
}

/* ---- modal ---- */
.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5,3,10,0.72); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 1rem;
}
.modal {
  position: relative; width: min(1000px, 96vw); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #201a2e, #14101e);
  border: 1px solid var(--panel-border); border-radius: 16px;
  box-shadow: 0 40px 100px rgba(0,0,0,0.7); padding: 1.4rem;
}
.modal-close {
  position: absolute; top: 0.6rem; right: 0.8rem; font-size: 1.6rem;
  background: none; border: none; color: var(--muted); cursor: pointer;
}
.modal-close:hover { color: var(--ink); }
.modal-body { display: grid; grid-template-columns: 300px 1fr; gap: 1.4rem; }
@media (max-width: 640px) { .modal-body { grid-template-columns: 1fr; } }
.modal-img img { width: 100%; border-radius: 4.75% / 3.5%; box-shadow: 0 12px 30px rgba(0,0,0,0.5); }
.modal-info h2 { font-size: 1.3rem; color: var(--ink); margin: 0 0 0.3rem; }
.mana { margin-left: 0.3rem; }
.type-line { color: var(--ink-2); font-weight: 600; }
.pt { margin-left: 0.5rem; color: var(--gold-soft); }
.oracle { line-height: 1.5; color: var(--ink); }
.modal-price { font-size: 1.05rem; }
.modal-controls { border-top: 1px solid var(--panel-border); margin-top: 1rem; padding-top: 1rem; display: flex; flex-direction: column; gap: 0.8rem; }
.qty-stepper { display: inline-flex; align-items: center; gap: 0.3rem; }
.qty-stepper input { width: 4.5rem; text-align: center; }
.check { flex-direction: row; align-items: center; gap: 0.5rem; }
.modal-actions { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; }
.action-row { display: flex; gap: 0.6rem; align-items: center; }
.label-inline { flex-direction: row; align-items: center; gap: 0.5rem; }
.qty-row { gap: 1.4rem; flex-wrap: wrap; }
#m-lang-row:not([hidden]) { display: flex; align-items: center; gap: 0.5rem; }
.qty-row input[type="number"] { width: 4rem; text-align: center; }
.m-toggle {
  border: 1px solid var(--panel-border); border-radius: 999px;
  background: rgba(0,0,0,0.25); color: var(--ink-2); cursor: pointer;
  font-size: 0.88rem; font-family: inherit; padding: 0.35rem 0.85rem;
  transition: color 0.15s, background 0.15s;
}
.m-toggle:hover:not(:disabled) { color: var(--ink); }
.m-toggle.active {
  color: var(--gold-soft); background: rgba(216,168,63,0.2);
  border-color: rgba(216,168,63,0.55); font-weight: 600;
}
.m-toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.lang-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.lang-pill {
  border: 1px solid var(--panel-border); border-radius: 999px;
  background: rgba(0,0,0,0.25); color: var(--muted); cursor: pointer;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em; padding: 0.18rem 0.55rem;
}
.lang-pill:hover { color: var(--ink); }
.lang-pill.active { color: var(--gold-soft); background: rgba(216,168,63,0.15); border-color: rgba(216,168,63,0.45); }
.action-row > .btn { flex: 0 0 13rem; white-space: nowrap; }
.action-row select { flex: 1; min-width: 0; }
.prints-slot { flex: 1; min-width: 0; display: flex; }
.prints-slot select { width: 100%; }
.print-picker { position: relative; flex: 1; min-width: 0; }
.print-current {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  background: rgba(0,0,0,0.35); color: var(--ink);
  border: 1px solid var(--panel-border); border-radius: 9px;
  padding: 0.5rem 0.75rem; font-size: 0.92rem; font-family: inherit; cursor: pointer;
}
.print-current:hover { border-color: rgba(216,168,63,0.4); }
.print-current-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.print-list {
  position: fixed; z-index: 130;   /* escapes the modal's overflow clipping */
  max-height: 280px; overflow-y: auto;
  background: linear-gradient(180deg, #241d33, #171221);
  border: 1px solid var(--panel-border); border-radius: 10px; padding: 4px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.6);
}
.print-item {
  padding: 0.38rem 0.6rem; border-radius: 7px; cursor: pointer;
  font-size: 0.88rem; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.print-item:hover { background: rgba(216,168,63,0.14); color: var(--ink); }
.print-item.active { color: var(--gold-soft); }
@media (max-width: 640px) { .action-row { flex-wrap: wrap; } .action-row > .btn { flex-basis: 100%; } }

/* ---- decks ---- */
.deck-list { display: flex; flex-direction: column; gap: 0.9rem; }
.deck-item {
  display: flex; gap: 1.1rem; align-items: stretch;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 14px; overflow: hidden; color: var(--ink);
  transition: transform 0.15s, box-shadow 0.15s;
}
.deck-item:hover {
  transform: translateY(-2px); text-decoration: none;
  box-shadow: 0 12px 28px rgba(0,0,0,0.45), 0 0 18px rgba(216,168,63,0.12);
}
.deck-item-cover { flex: 0 0 170px; position: relative; overflow: hidden; background: rgba(0,0,0,0.3); min-height: 96px; }
.deck-item-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.deck-item-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 55%, rgba(23,19,33,0.9)); }
.deck-item-info { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 0.45rem; padding: 0.85rem 1.1rem 0.85rem 0; min-width: 0; }
.deck-item-top { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.deck-pips { margin-left: auto; font-size: 1.05rem; white-space: nowrap; }
.deck-facts { display: flex; gap: 1.4rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.deck-fact-n { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.deck-progress { height: 5px; border-radius: 3px; background: rgba(0,0,0,0.35); overflow: hidden; max-width: 420px; }
.deck-progress span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--gold-soft), var(--mtg-m)); }
@media (max-width: 560px) {
  .deck-item { flex-direction: column; }
  .deck-item-cover { flex-basis: 90px; }
  .deck-item-cover::after { background: linear-gradient(180deg, transparent 40%, rgba(23,19,33,0.9)); }
  .deck-item-info { padding: 0 1rem 0.9rem; }
}
.deck-tile {
  display: block; border-radius: 14px; overflow: hidden;
  background: var(--panel); border: 1px solid var(--panel-border);
  transition: transform 0.18s, box-shadow 0.18s; color: var(--ink);
}
.deck-tile:hover {
  transform: translateY(-4px); text-decoration: none;
  box-shadow: 0 16px 34px rgba(0,0,0,0.5), 0 0 20px rgba(216,168,63,0.15);
}
.deck-cover { height: 130px; overflow: hidden; position: relative; background: rgba(0,0,0,0.3); }
.deck-cover img { width: 100%; height: 200%; object-fit: cover; object-position: center 18%; }
.deck-cover::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(13,10,20,0.85));
}
.deck-cover-empty { height: 100%; display: grid; place-items: center; font-size: 2.5rem; opacity: 0.35; }
.deck-tile-info { padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.35rem; }
.deck-tile-name { font-weight: 650; font-size: 1.02rem; }
.deck-tile-meta { display: flex; align-items: center; gap: 0.6rem; font-size: 0.82rem; }
.format-badge {
  text-transform: capitalize; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em;
  color: var(--gold-soft); background: rgba(216,168,63,0.13);
  border: 1px solid rgba(216,168,63,0.35); border-radius: 999px; padding: 0.1rem 0.55rem;
}
.new-deck-row h2 { margin-bottom: 0.6rem; }
.badge-virtual { color: #9ac0cf; background: rgba(154,192,207,0.1); border-color: rgba(154,192,207,0.45); }

.deck-header { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.deck-name-input {
  flex: 1; min-width: 200px; font-size: 1.35rem; font-weight: 650;
  font-family: Iowan Old Style, Palatino, Georgia, serif;
  background: transparent; border: 1px solid transparent;
}
.deck-name-input:hover, .deck-name-input:focus { background: rgba(0,0,0,0.35); border-color: var(--panel-border); }
.deck-count {
  font-variant-numeric: tabular-nums; color: var(--gold-soft); font-weight: 700;
  background: rgba(216,168,63,0.1); border: 1px solid rgba(216,168,63,0.3);
  border-radius: 999px; padding: 0.3rem 0.8rem;
}
.del-menu { position: relative; }
.del-dd { top: calc(100% + 6px); min-width: 280px; cursor: pointer; }
.del-dd .lang-item:hover { color: #f0a49b; }
.send-dd { top: calc(100% + 6px); min-width: 230px; padding: 0.7rem; }
.send-dd:not([hidden]) { display: flex; flex-direction: column; gap: 0.55rem; }
.deck-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.4rem; align-items: start; }
@media (max-width: 860px) { .deck-layout { grid-template-columns: 1fr; } }
.deck-group { padding: 0.9rem 1rem; margin-bottom: 1rem; }
.deck-group h2 { margin-bottom: 0.5rem; }
.deck-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.28rem 0.2rem; border-radius: 8px; font-size: 0.93rem;
}
.deck-row:hover { background: rgba(255,255,255,0.04); }
.deck-row-name { flex: 1; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-row-name:hover { color: var(--gold-soft); }
.deck-row-mana { white-space: nowrap; }
.qty-ctl { display: inline-flex; align-items: center; gap: 0.15rem; }
.qty-n { min-width: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; }
.icon-btn {
  width: 24px; height: 24px; display: inline-grid; place-items: center;
  border-radius: 6px; border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.25); color: var(--ink-2); cursor: pointer; font-size: 0.9rem;
}
.icon-btn:hover { color: var(--ink); background: rgba(255,255,255,0.08); }
.owned-dot { color: #6fcf8e; font-weight: 700; }
.have-note { color: #6fcf8e; font-size: 0.9rem; font-weight: 600; }
.cmd-btn { filter: grayscale(1); opacity: 0.45; }
.cmd-btn.on, .cmd-btn:hover { filter: none; opacity: 1; }
.deck-side { display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 76px; }
.deck-side .panel { margin-bottom: 0; }
.deck-side input[type="search"] { width: 100%; }
.add-results { margin-top: 0.7rem; display: flex; flex-direction: column; gap: 0.4rem; max-height: 420px; overflow-y: auto; }
.add-row { display: flex; align-items: center; gap: 0.6rem; }
.add-row img { width: 34px; border-radius: 4px; }
.add-row-name { flex: 1; font-size: 0.88rem; line-height: 1.25; }
.add-btn { flex: 0 0 auto; }
.curve { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 1.2rem; }
.curve-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.curve-n { font-size: 0.75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.curve-bar { width: 100%; background: linear-gradient(180deg, var(--gold-soft), var(--mtg-m)); border-radius: 4px 4px 0 0; min-height: 2px; }
.curve-x { font-size: 0.75rem; color: var(--muted); }

/* import report */
.report { margin-top: 1.4rem; border-top: 1px solid var(--panel-border); padding-top: 1rem; }
.report ul { columns: 2; font-size: 0.9rem; color: var(--ink-2); }
.report ul.failed { color: #f0a49b; }
@media (max-width: 640px) { .report ul { columns: 1; } }
code { background: rgba(0,0,0,0.35); padding: 0.1rem 0.35rem; border-radius: 5px; font-size: 0.88em; }
#import-form { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }

/* ---- play / matches ---- */
.invite-form { display: flex; flex-direction: column; gap: 0.9rem; }
.invite-row { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.invite-row > label { flex: 1; min-width: 220px; }
.invite-row .btn { flex: 0 0 auto; }
.when-picker { display: flex; gap: 0.4rem; align-items: center; }
.when-picker input[type="date"] { flex: 1; min-width: 0; }
.when-sep { color: var(--muted); font-weight: 700; }
.match-card {
  border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 0.9rem 1.1rem; margin-bottom: 0.9rem; background: rgba(0,0,0,0.18);
}
.match-head { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.match-when { color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.status-chip {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em;
  border-radius: 999px; padding: 0.15rem 0.6rem; border: 1px solid;
}
.st-pending { color: var(--gold-soft); border-color: rgba(216,168,63,0.5); background: rgba(216,168,63,0.1); }
.st-accepted { color: #8ad8a4; border-color: rgba(63,168,96,0.5); background: rgba(63,168,96,0.12); }
.st-declined { color: #f0a49b; border-color: rgba(208,72,59,0.5); background: rgba(208,72,59,0.12); }
.st-cancelled { color: var(--muted); border-color: var(--panel-border); background: rgba(255,255,255,0.04); }
.st-finished { color: #9ac0cf; border-color: rgba(154,192,207,0.5); background: rgba(154,192,207,0.1); }
.res-win { color: #8ad8a4; border-color: rgba(63,168,96,0.5); background: rgba(63,168,96,0.12); }
.res-loss { color: #f0a49b; border-color: rgba(208,72,59,0.5); background: rgba(208,72,59,0.12); }
.res-draw { color: var(--muted); border-color: var(--panel-border); background: rgba(255,255,255,0.04); }
.history-row {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--panel-border); font-size: 0.92rem;
}
.history-row:last-child { border-bottom: none; }
.match-decks { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; margin: 0.6rem 0; }
.match-actions { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin-top: 0.4rem; }
.counter-box { display: inline-flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.shuffle-view { border-top: 1px solid var(--panel-border); margin-top: 0.8rem; padding-top: 0.8rem; }
.board-bar { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; }
.hand-strip { padding: 0.3rem 0; }
.hand-card {
  flex: 0 0 96px; cursor: pointer; border-radius: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.hand-card img { width: 100%; border-radius: 6px; display: block; }
.hand-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 26px rgba(0,0,0,0.55), 0 0 16px rgba(216,168,63,0.3);
}
.cmd-card img { outline: 2px solid var(--gold); outline-offset: -2px; }
.turn-row { border-top: 1px dashed var(--panel-border); padding: 0.6rem 0; }
.turn-label { color: var(--gold-soft); font-weight: 700; font-size: 0.85rem; margin-bottom: 0.4rem; }
.turn-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .turn-sides { grid-template-columns: 1fr; } }
.side-name { display: block; color: var(--muted); font-size: 0.8rem; margin-bottom: 0.3rem; }
.played-mine { cursor: pointer; }
.played-mine:hover { outline: 2px solid var(--danger); outline-offset: -2px; border-radius: 6px; }
.shuffle-view h3 { font-size: 0.92rem; color: var(--ink-2); margin: 0.6rem 0 0.5rem; }
.library-list { columns: 3; font-size: 0.88rem; color: var(--ink-2); margin: 0; padding-left: 1.4rem; }
@media (max-width: 700px) { .library-list { columns: 2; } }
@media (max-width: 480px) { .library-list { columns: 1; } }

/* ---- multiplayer game page ---- */
.game-layout { display: grid; grid-template-columns: 1fr 280px; gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .game-layout { grid-template-columns: 1fr; } }
.player-panel { margin-bottom: 1rem; }
.player-panel.turn-active { border-color: rgba(216,168,63,0.55); box-shadow: 0 0 18px rgba(216,168,63,0.12); }
.life-chip {
  font-weight: 800; color: #f0a49b; background: rgba(208,72,59,0.12);
  border: 1px solid rgba(208,72,59,0.4); border-radius: 999px; padding: 0.15rem 0.7rem;
}
.life-n { min-width: 2.2rem; text-align: center; font-size: 1.2rem; color: var(--gold-soft); }
.zone-label { color: var(--muted); font-size: 0.78rem; margin: 0.55rem 0 0.25rem; text-transform: uppercase; letter-spacing: 0.05em; }
.zone-dim { opacity: 0.55; }
.gc-mine { cursor: pointer; }
.gc-mine:hover { outline: 2px solid var(--gold); outline-offset: -2px; border-radius: 6px; }
.card-menu { position: fixed; z-index: 140; min-width: 210px; }
.card-menu .lang-item { cursor: pointer; }
.game-log-panel { position: sticky; top: 76px; max-height: 80vh; overflow-y: auto; }
.game-log { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-2); }
.log-row { border-bottom: 1px dashed rgba(255,255,255,0.06); padding-bottom: 0.3rem; }

/* ---- mobile ---- */
@media (max-width: 860px) {
  .topbar { gap: 0.7rem; padding: 0.6rem 0.9rem; }
  .nav { display: none; }
  .nav-toggle { display: grid; }
  .topbar.nav-open .nav {
    display: flex; flex-direction: column; gap: 2px;
    position: absolute; top: 100%; left: 0; right: 0;
    background: rgba(13,10,20,0.97); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--panel-border);
    padding: 0.5rem 0.9rem 0.9rem;
    box-shadow: 0 18px 40px rgba(0,0,0,0.5);
  }
  .topbar.nav-open .nav a { padding: 0.75rem 0.9rem; font-size: 1.05rem; }
  .username { display: none; }
  .brand { font-size: 1.15rem; }
}
@media (max-width: 560px) {
  .page { padding: 1rem 0.8rem 2.2rem; }
  .page-title { font-size: 1.35rem; }
  .signout-btn { display: none; }              /* sign out stays reachable: see nav panel */
  .topbar.nav-open .nav::after { content: ''; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.7rem; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
  .stat-value { font-size: 1.5rem; }
  .panel { padding: 0.9rem 1rem; }
  .search-bar { flex-direction: column; }
  .search-bar .btn { width: 100%; }
  .modal { padding: 1rem; }
  .cbar-row { grid-template-columns: 7.5rem 1fr 2.5rem; }
  .deck-side { position: static; }
  .filter-row { gap: 0.5rem; }
}
