/* ═══════════════════════════════════════════════
   CZN Deck Builder — E7bot-inspired dark theme
   ═══════════════════════════════════════════════ */

:root {
  /* surfaces */
  --bg-0:        #0a0b14;
  --bg-1:        #10121e;
  --bg-2:        #161a2b;
  --bg-3:        #1f2339;
  --bg-4:        #2a2f4c;
  --border:      #2e3450;
  --border-hi:   #3d4670;

  /* text */
  --text:        #e8eaf2;
  --text-dim:    #b3b8cc;
  --muted:       #7a8096;
  --muted-dim:   #565c75;

  /* accents */
  --accent:      #a78bfa;     /* purple — characters */
  --accent-2:    #60a5fa;     /* blue — neutrals / links */
  --accent-3:    #22d3ee;     /* cyan — cost numbers / highlights */
  --accent-4:    #f59e0b;     /* amber — forbidden / starter */
  --accent-5:    #34d399;     /* green — ok / monster common */
  --danger:      #f87171;
  --warn:        #fbbf24;

  /* card type hues */
  --hue-character: 262;
  --hue-neutral:   217;
  --hue-forbidden:  38;
  --hue-monster:   157;

  /* misc */
  --radius:      12px;
  --radius-sm:   8px;
  --radius-xs:   4px;
  --shadow:      0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.35);
  --sidebar-w:   88px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(ellipse at top left, rgba(167, 139, 250, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(96, 165, 250, 0.04) 0%, transparent 50%),
    var(--bg-0);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }

button, select, input, textarea { font: inherit; color: inherit; }

/* ─── app shell ─────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── sidebar ─────────────────────────────── */

.sidebar {
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 0 20px;
}

.sidebar-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 28px;
  padding: 0 12px;
}
.brand-mark {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0b14;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-weight: 900;
  letter-spacing: 0.5px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(167, 139, 250, 0.25);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  padding: 0 8px;
}

.sidebar-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
}
.sidebar-nav a:hover {
  background: var(--bg-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--bg-2);
  color: var(--accent);
  border-color: var(--border);
}
.sidebar-nav .icon {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-auth {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 0 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 8px;
}
.sidebar-auth .username {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-auth .btn-sm { padding: 4px 8px; font-size: 10px; width: 100%; }

/* ─── main view ─────────────────────────────── */

.view {
  padding: 32px 40px 56px;
  max-width: 1600px;
  width: 100%;
}

.view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.view-header h1 { margin: 0; flex: 1; }

.view-subtitle {
  margin: -16px 0 20px;
  color: var(--muted);
  font-size: 14px;
}
.view-subtitle a { color: var(--accent); font-weight: 500; }

h1 { font-size: 32px; font-weight: 700; line-height: 1.2; letter-spacing: -0.5px; }
h2 { font-size: 22px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.3px; }
h3 {
  font-size: 11px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
p { color: var(--text-dim); margin: 0 0 12px; }

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 24px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border) 0%, transparent 100%);
}

/* ─── forms ─────────────────────────────── */

.form {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  max-width: 460px;
  margin: 64px auto;
  box-shadow: var(--shadow);
}
.form h1 { margin-bottom: 24px; font-size: 28px; }
.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}
.input, .select, .textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-size: 15px;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}
.textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}

/* ─── buttons ─────────────────────────────── */

.btn {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-hi); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0b14;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(167, 139, 250, 0.25);
}
.btn-primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.4);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.12); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--bg-2); border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ─── filters ─────────────────────────────── */

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
  padding: 18px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .filters { grid-template-columns: 1fr; } }
.filters .input, .filters .select { max-width: none; }

/* ─── card tile (E7bot-inspired) ─────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.card-tile {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  min-height: 330px;
  display: flex;
  flex-direction: column;
}
.card-tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-hi);
  box-shadow: var(--shadow);
}

/* type-tinted art/background panel */
.card-art {
  position: relative;
  height: 150px;
  background: linear-gradient(
    135deg,
    hsl(var(--card-hue, 262), 65%, 22%) 0%,
    hsl(var(--card-hue, 262), 55%, 14%) 55%,
    hsl(var(--card-hue, 262), 40%, 10%) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* when we have a real card image, let the art panel scale to full card aspect */
.card-tile.has-image .card-art {
  height: auto;
  aspect-ratio: 2 / 3;
  background: hsl(var(--card-hue, 262), 40%, 8%);
}

.card-art-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 1;
}

.card-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%,
              hsla(var(--card-hue, 262), 80%, 65%, 0.25) 0%,
              transparent 60%);
  pointer-events: none;
}
.card-tile.has-image .card-art::before { display: none; }

.card-art::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 60%, rgba(10, 11, 20, 0.7) 100%);
  pointer-events: none;
}
.card-tile.has-image .card-art::after { display: none; }

.card-art-glyph {
  position: relative;
  font-size: 56px;
  font-weight: 900;
  color: hsla(var(--card-hue, 262), 75%, 70%, 0.55);
  text-shadow: 0 4px 20px hsla(var(--card-hue, 262), 70%, 50%, 0.4);
  font-family: ui-serif, Georgia, serif;
  letter-spacing: -4px;
  transform: rotate(-6deg);
  user-select: none;
}

/* hues per type — applies to any element with .type-<x> class */
.type-character, .type-unique { --card-hue: var(--hue-character); }
.type-neutral   { --card-hue: var(--hue-neutral); }
.type-forbidden { --card-hue: var(--hue-forbidden); }
.type-monster   { --card-hue: var(--hue-monster); }

/* cost badge */
.card-cost {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 11, 20, 0.7);
  border: 1.5px solid var(--accent-3);
  border-radius: 6px;
  color: var(--accent-3);
  font-weight: 800;
  font-size: 18px;
  backdrop-filter: blur(6px);
  z-index: 2;
}

/* cost for forbidden = amber, etc */
.card-tile.type-forbidden .card-cost { border-color: var(--accent-4); color: var(--accent-4); }

.card-rarity-pips {
  position: absolute;
  top: 14px;
  right: 12px;
  display: flex;
  gap: 2px;
  z-index: 2;
}
.card-rarity-pips .pip {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 7px solid var(--accent-4);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.card-rarity-pips.rarity-common    .pip { border-bottom-color: #cbd5e1; }
.card-rarity-pips.rarity-rare      .pip { border-bottom-color: var(--accent-2); }
.card-rarity-pips.rarity-legendary .pip { border-bottom-color: var(--accent-4); }
.card-rarity-pips.rarity-mythic    .pip { border-bottom-color: var(--accent); }

.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
  color: var(--text);
}
.card-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.card-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* tag / badge */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.tag-character { background: rgba(167, 139, 250, 0.18); color: var(--accent); }
.tag-neutral   { background: rgba(96, 165, 250, 0.18); color: var(--accent-2); }
.tag-forbidden { background: rgba(245, 158, 11, 0.18); color: var(--accent-4); }
.tag-monster   { background: rgba(52, 211, 153, 0.18); color: var(--accent-5); }
.tag-rarity-common    { background: rgba(255,255,255,0.08); color: var(--text-dim); }
.tag-rarity-rare      { background: rgba(96, 165, 250, 0.18); color: var(--accent-2); }
.tag-rarity-legendary { background: rgba(245, 158, 11, 0.22); color: var(--accent-4); }
.tag-rarity-mythic    { background: rgba(167, 139, 250, 0.22); color: var(--accent); }

/* element tags — CZN elements with themed colors */
.tag-element-justice  { background: rgba(96, 165, 250, 0.20); color: #7cc0ff; }
.tag-element-passion  { background: rgba(248, 113, 113, 0.20); color: #ff8a8a; }
.tag-element-void     { background: rgba(167, 139, 250, 0.22); color: var(--accent); }
.tag-element-order    { background: rgba(52, 211, 153, 0.20); color: #5eecb3; }
.tag-element-instinct { background: rgba(245, 158, 11, 0.22); color: var(--accent-4); }
.tag-element-reason   { background: rgba(34, 211, 238, 0.20); color: var(--accent-3); }
.tag-element-calm     { background: rgba(148, 163, 184, 0.20); color: #cbd5e1; }

/* ─── combatants ─────────────────────────────── */

.combatant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}

.combatant-tile {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.combatant-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.combatant-portrait {
  position: relative;
  /* Gamekee portraits bake the Chinese name into the bottom ~20% of the PNG.
     Shrinking the container aspect ratio crops that strip cleanly. */
  aspect-ratio: 195 / 240;
  background: linear-gradient(135deg, var(--bg-3) 0%, var(--bg-1) 100%);
  overflow: hidden;
}
.combatant-portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 125%;          /* slightly scale up so we don't lose the face */
  object-fit: cover;
  object-position: center top;
}
/* soft bottom fade into the body for a clean edge */
.combatant-portrait::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 28%;
  background: linear-gradient(to bottom, transparent 0%, var(--bg-1) 95%);
  pointer-events: none;
}
.combatant-portrait .card-rarity-pips,
.combatant-portrait .combatant-stars {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: flex;
  gap: 1px;
}
.combatant-portrait .combatant-stars .star {
  font-size: 12px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.combatant-stars.rarity-mythic    .star { color: var(--accent); }
.combatant-stars.rarity-legendary .star { color: var(--accent-4); }
.combatant-stars.rarity-rare      .star { color: var(--accent-2); }
.combatant-stars.rarity-common    .star { color: var(--text-dim); }

.combatant-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
}
.combatant-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.combatant-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── combatant detail ─────────────────────────────── */

.combatant-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-0) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

.combatant-hero-portrait {
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--accent);
  background: var(--bg-3);
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.35);
}
.combatant-hero-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
}

.combatant-hero-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.combatant-hero-name {
  margin: 0;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}
.combatant-hero-stars {
  display: flex;
  gap: 2px;
  font-size: 16px;
  line-height: 1;
  color: var(--accent-4);
}
.combatant-hero-stars.rarity-mythic    { color: var(--accent); }
.combatant-hero-stars.rarity-legendary { color: var(--accent-4); }
.combatant-hero-stars.rarity-rare      { color: var(--accent-2); }
.combatant-hero-stars.rarity-common    { color: var(--text-dim); }
.combatant-hero-stars .star {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.combatant-hero-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.combatant-section { margin-bottom: 32px; }
.combatant-section .section-title { margin-top: 0; }

.card-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

@media (max-width: 600px) {
  .combatant-hero { padding: 16px; gap: 14px; }
  .combatant-hero-portrait { width: 64px; height: 64px; }
  .combatant-hero-name { font-size: 26px; }
}

/* ─── deck list ─────────────────────────────── */

.deck-list { display: grid; gap: 12px; }
.deck-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: border-color 0.15s;
}
.deck-row:hover { border-color: var(--border-hi); }
.deck-row .deck-name { font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.deck-row .deck-meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.deck-row .actions { display: flex; gap: 8px; }

.tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.tier-badge.nightmare { background: linear-gradient(90deg, rgba(248,113,113,0.15), rgba(167,139,250,0.15)); color: var(--danger); border-color: rgba(248,113,113,0.3); }

/* ─── builder ─────────────────────────────── */

.builder {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1100px) { .builder { grid-template-columns: 1fr; } }

.builder-main {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.builder-header {
  display: grid;
  grid-template-columns: 1fr 160px 160px;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 700px) { .builder-header { grid-template-columns: 1fr; } }

.deck-cards { display: grid; gap: 10px; margin-top: 12px; }
.deck-card-row {
  display: grid;
  grid-template-columns: 40px 1fr 130px 130px 36px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.deck-card-row:hover { border-color: var(--border-hi); }
.deck-card-row .mini-art {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg,
              hsl(var(--card-hue, 262), 55%, 25%),
              hsl(var(--card-hue, 262), 40%, 12%));
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsla(var(--card-hue, 262), 70%, 70%, 0.7);
  font-weight: 900;
  font-size: 18px;
  font-family: ui-serif, Georgia, serif;
}
.deck-card-row .card-label { font-weight: 600; font-size: 15px; }
.deck-card-row .card-sublabel { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ─── tile-slot (card tile + controls row) ─────────────────────────────── */

.starter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.starter-grid > .empty {
  grid-column: 1 / -1;
}

.tile-slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.tile-slot .card-tile { cursor: default; }
.tile-slot .card-tile:hover { transform: none; }

.tile-slot.is-removed .card-tile {
  opacity: 0.42;
  filter: grayscale(0.5);
}
.tile-slot.is-removed .card-name { text-decoration: line-through; }

.tile-controls {
  display: flex;
  gap: 6px;
}
.tile-controls .select,
.tile-controls .btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  font-size: 12.5px;
}

/* Hover overlay with action pills, anchored to the .tile-slot (not the tile
   itself — that way the overlay stays at full opacity even when the card is
   dimmed/grayscaled by the .is-removed state). Overlay covers the card-art
   area (aspect-ratio 2/3) so the card body (name/desc) stays clickable. */
.tile-slot { position: relative; }
.tile-actions {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: flex-end;
  padding: 10px;
  gap: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(to top,
    rgba(10, 11, 20, 0.92) 0%,
    rgba(10, 11, 20, 0.55) 45%,
    rgba(10, 11, 20, 0.1)  85%,
    transparent 100%);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.tile-slot:hover .tile-actions,
.tile-slot:focus-within .tile-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
@media (hover: none) {
  .tile-actions { opacity: 1; transform: translateY(0); pointer-events: auto; }
}

.tile-action {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  text-align: center;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.1s, border-color 0.1s, transform 0.05s;
}
.tile-action:hover  { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.3); }
.tile-action:active { transform: scale(0.97); }

.tile-action.active {
  background: var(--accent);
  color: #0a0b14;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 12px rgba(167, 139, 250, 0.35);
}
.tile-action.danger {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--danger);
}
.tile-action.danger:hover {
  background: rgba(248, 113, 113, 0.3);
  border-color: rgba(248, 113, 113, 0.6);
}
.tile-action.danger.active {
  background: var(--danger);
  color: #0a0b14;
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger), 0 4px 12px rgba(248, 113, 113, 0.35);
}

/* starter-row — legacy accented deck row (unused for starters now, kept for future) */
.starter-row {
  border-color: rgba(245, 158, 11, 0.35);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.06), var(--bg-2));
}
.starter-row.is-removed {
  border-color: rgba(248, 113, 113, 0.5);
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.08), var(--bg-2));
  opacity: 0.85;
}
.starter-row.is-removed .card-label { text-decoration: line-through; color: var(--muted); }

.builder-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.55;
}

/* ─── FM sidebar ─────────────────────────────── */

.fm-sidebar {
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: sticky;
  top: 24px;
  box-shadow: var(--shadow-sm);
}
.fm-sidebar h2 { margin-bottom: 4px; }
.fm-sidebar h3 { margin-top: 18px; }

.fm-total {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
  margin: 12px 0 10px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-3);
}
.fm-total .slash { color: var(--muted-dim); font-weight: 400; font-size: 26px; }
.fm-total .cap   { color: var(--muted); font-size: 26px; font-weight: 500; }

.fm-bar {
  background: var(--bg-0);
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.fm-bar-fill {
  height: 100%;
  transition: width 0.3s ease, background 0.2s;
  background: linear-gradient(90deg, var(--accent-5), var(--accent-3));
}
.fm-bar-fill.warn   { background: linear-gradient(90deg, var(--accent-3), var(--warn)); }
.fm-bar-fill.danger { background: linear-gradient(90deg, var(--warn), var(--danger)); }

.fm-breakdown { display: grid; gap: 6px; margin-top: 4px; }
.fm-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dashed transparent;
}
.fm-breakdown-row + .fm-breakdown-row { border-top: 1px dashed var(--bg-3); }
.fm-breakdown-row .label { color: var(--muted); }
.fm-breakdown-row .value { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

.fm-warnings {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.5;
}
.fm-warnings strong { display: block; margin-bottom: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.fm-warnings ul { margin: 4px 0 0; padding-left: 18px; }

/* ─── modal ─────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 24px;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 1000px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-body { overflow-y: auto; margin-top: 14px; padding-right: 4px; }

/* ─── toast ─────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 12px 18px;
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s, opacity 0.2s;
  z-index: 30;
  max-width: 360px;
  font-size: 14px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.ok    { border-color: var(--accent-5); color: var(--accent-5); }

/* ─── utility ─────────────────────────────── */

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--bg-1);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.row  { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

/* ─── scrollbar ─────────────────────────────── */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

/* ─── responsive: collapse sidebar labels on narrow ─────────────────────────────── */

@media (max-width: 600px) {
  :root { --sidebar-w: 64px; }
  .sidebar-nav a { font-size: 0; }
  .sidebar-nav .icon { width: 24px; height: 24px; }
  .sidebar-auth .username { display: none; }
  .view { padding: 24px 20px; }
}
