:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Commander identity accents, updated live by app.js */
  --accent: #c9a24b;
  --accent-2: #8a6d2f;
  --accent-soft: rgba(201, 162, 75, 0.22);

  --bg-0: #0b0f14;
  --bg-1: #121924;
  --panel-top: #1b2534;
  --panel-bottom: #121a26;
  --ink: #eef3f8;
  --ink-dim: #9fb0c0;
  --line: rgba(255, 255, 255, 0.08);

  color: var(--ink);
  background: var(--bg-0);
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win over component display rules
   (e.g. .stack sets display:grid, which would otherwise keep hidden forms visible). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(255, 255, 255, 0.05), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  position: relative;
  transition: background 400ms ease;
}

.glow-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 40% at 50% 0%, var(--accent-soft), transparent 70%);
  opacity: 0.8;
  transition: background 400ms ease;
  z-index: 0;
}

.topbar,
.layout {
  position: relative;
  z-index: 1;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 30px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.15));
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05), 0 10px 30px rgba(0, 0, 0, 0.4);
}

.brand h1 {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

h2 {
  font-size: 17px;
  letter-spacing: 0.3px;
  margin-bottom: 16px;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(
      180deg,
      #fff6cf 0%,
      #f4d97e 15%,
      #e7bc45 37%,
      #c8912a 52%,
      #a9761d 62%,
      #f0cf76 82%,
      #c99a2f 100%
    );
  border: 1px solid #7a5713;
  border-radius: 10px;
  color: #3a2a05;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 11px 16px;
  text-shadow: 0 1px 0 rgba(255, 248, 214, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -2px 5px rgba(120, 80, 10, 0.55),
    inset 0 0 12px rgba(255, 240, 190, 0.35),
    0 8px 18px rgba(0, 0, 0, 0.4);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

/* High-luster foil sheen that sweeps across on hover. */
button:not(.ghost)::before {
  content: "";
  position: absolute;
  top: -20%;
  left: -70%;
  width: 45%;
  height: 140%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 35%,
    rgba(255, 255, 255, 0.85) 50%,
    rgba(255, 255, 255, 0.15) 65%,
    transparent 100%
  );
  transform: skewX(-20deg);
  pointer-events: none;
  transition: left 650ms ease;
}

button:not(.ghost):hover:not(:disabled)::before {
  left: 130%;
}

button:hover:not(:disabled) {
  filter: brightness(1.06) saturate(1.08);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -2px 6px rgba(120, 80, 10, 0.6),
    inset 0 0 16px rgba(255, 244, 200, 0.5),
    0 12px 26px rgba(0, 0, 0, 0.5);
}

button:disabled {
  background: linear-gradient(180deg, #3a4656, #2a3342);
  color: #8496a6;
  cursor: not-allowed;
  text-shadow: none;
  box-shadow: none;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  text-shadow: none;
  box-shadow: none;
}

button.ghost:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Top-right account area */
.account-area {
  align-items: center;
  display: flex;
  gap: 10px;
}

.auth-signed-out,
.auth-signed-in {
  align-items: center;
  display: flex;
  gap: 10px;
}

.plan-pill {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  text-transform: uppercase;
}

.plan-pill.plus {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #10151b;
}

.account-email {
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 700;
}

.account-menu-wrap {
  position: relative;
}

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  display: grid;
  gap: 8px;
  min-width: 220px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  z-index: 5;
}

.account-menu[hidden] {
  display: none;
}

/* Membership panel */
.membership {
  display: grid;
  gap: 14px;
}

.membership-head {
  align-items: center;
  display: flex;
  gap: 10px;
}

.usage-bars {
  display: grid;
  gap: 12px;
}

.usage-item .usage-label {
  color: var(--ink-dim);
  display: flex;
  font-size: 13px;
  font-weight: 700;
  justify-content: space-between;
  margin-bottom: 6px;
}

.usage-track {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.usage-fill {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  height: 100%;
  transition: width 250ms ease;
}

.usage-fill.full {
  background: linear-gradient(90deg, #ff7a5c, #d0432a);
}

.muted {
  color: var(--ink-dim);
  margin: 0;
}

/* Modals */
.modal {
  align-items: center;
  background: rgba(4, 7, 10, 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
  position: fixed;
  overscroll-behavior: contain;
  z-index: 20;
  backdrop-filter: blur(4px);
  -webkit-overflow-scrolling: touch;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--line);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  max-height: calc(100dvh - 40px);
  max-width: 420px;
  overflow-y: auto;
  padding: 26px;
  position: relative;
  width: 100%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  -webkit-overflow-scrolling: touch;
}

.modal-close {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 22px;
  padding: 4px 8px;
  position: absolute;
  right: 12px;
  top: 10px;
}

@supports not (height: 100dvh) {
  .modal-card {
    max-height: calc(100vh - 40px);
  }
}

@media (max-width: 700px) {
  .modal {
    align-items: flex-start;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }

  .modal-card {
    max-height: calc(100dvh - 24px);
    padding: 18px 16px 22px;
  }

  .modal-close {
    align-items: center;
    background: rgba(12, 18, 27, 0.88);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-flex;
    float: right;
    height: 36px;
    justify-content: center;
    margin: -6px -4px 8px 10px;
    min-width: 36px;
    position: sticky;
    top: 0;
    z-index: 2;
  }
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  margin-top: 2px;
  padding-right: 34px; /* keep the right tab clear of the absolute close button */
}

.modal-tabs .tab {
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--ink-dim);
  flex: 1;
}

.modal-tabs .tab:hover:not(:disabled) {
  box-shadow: none;
  filter: none;
  transform: none;
}

.modal-tabs .tab.active {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #10151b;
}

.auth-error {
  color: #ff8a78;
  font-weight: 700;
  margin: 12px 0 0;
  min-height: 18px;
}

.paywall .plan-benefits {
  color: var(--ink);
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 16px 0;
  padding: 0;
}

.paywall .plan-benefits li {
  padding-left: 26px;
  position: relative;
}

.paywall .plan-benefits li::before {
  color: var(--accent);
  content: "\2726";
  left: 0;
  position: absolute;
}

.paywall-copy {
  color: var(--ink-dim);
  line-height: 1.5;
}

.paywall-price {
  color: var(--ink);
  font-weight: 800;
  margin: 8px 0 16px;
}

.paywall-price .price {
  color: var(--accent);
  font-size: 30px;
}

.paywall button {
  width: 100%;
}

.paywall button.ghost {
  margin-top: 8px;
}

/* Mana symbols */
.mana-row {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

/* Scanner import group + voice controls */
.scan-meta {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.scan-meta .field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.scan-meta .field input,
.scan-meta .field select {
  width: auto;
}

#toggle-voice.voice-on {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    #eafff0 0%,
    #9be9ad 15%,
    #52c46e 37%,
    #2f9c4c 52%,
    #1f7d3a 62%,
    #7fe098 82%,
    #2fa251 100%
  );
  border: 1px solid #175a2c;
  color: #06210f;
  text-shadow: 0 1px 0 rgba(230, 255, 236, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -2px 5px rgba(15, 70, 30, 0.55),
    inset 0 0 12px rgba(190, 255, 205, 0.35),
    0 8px 18px rgba(0, 0, 0, 0.4);
}

/* Sweeping foil luster, always animating while listening. */
#toggle-voice.voice-on::before {
  content: "";
  position: absolute;
  top: -20%;
  left: -70%;
  width: 45%;
  height: 140%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 35%,
    rgba(255, 255, 255, 0.85) 50%,
    rgba(255, 255, 255, 0.15) 65%,
    transparent 100%
  );
  transform: skewX(-20deg);
  pointer-events: none;
  animation: voice-sheen 2.4s ease-in-out infinite;
}

@keyframes voice-sheen {
  0% { left: -70%; }
  60%, 100% { left: 130%; }
}

.voice-state {
  color: var(--accent);
  font-weight: 700;
}

.voice-panel {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-left: 3px solid #3fae5a;
  border-radius: 8px;
  margin: 8px 0;
  padding: 10px 12px;
}

.voice-status {
  color: #7fe098;
  font-weight: 800;
  margin: 0 0 6px;
}

.voice-legend {
  color: var(--ink-dim);
  font-size: 13px;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.voice-legend strong {
  color: var(--ink);
}

/* Official Scryfall mana/symbol icons. */
.mana-icon {
  height: 22px;
  width: 22px;
  vertical-align: middle;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
}

.brand h1 .mana-icon {
  height: 26px;
  width: 26px;
}

.mana {
  align-items: center;
  border-radius: 999px;
  color: #1a1a1a;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  height: 26px;
  justify-content: center;
  width: 26px;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.65), inset 0 -3px 5px rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.mana-w { background: radial-gradient(circle at 30% 25%, #fffef2, #efe6c8); }
.mana-u { background: radial-gradient(circle at 30% 25%, #bfe3ff, #4a90c2); color: #08202e; }
.mana-b { background: radial-gradient(circle at 30% 25%, #b9adb0, #2b2529); color: #f2e9ec; }
.mana-r { background: radial-gradient(circle at 30% 25%, #ffb59a, #d0432a); color: #2a0d06; }
.mana-g { background: radial-gradient(circle at 30% 25%, #bfe8ac, #3f8f45); color: #08240c; }
.mana-c { background: radial-gradient(circle at 30% 25%, #e7ecef, #a9b4bd); }

/* Official set/edition symbol (Keyrune webfont), rarity-tinted. */
.set-symbol {
  font-size: 26px;
  line-height: 1;
  margin-left: 12px;
  vertical-align: -6px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

/* Commons are near-black in the font; give them a bright, visible tint on dark UI. */
.set-symbol-common,
.set-symbol-special,
.set-symbol-bonus {
  color: #e6ebf1;
}

.finish-toggle .inline-check {
  gap: 6px;
}

.layout {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 24px 30px 40px;
}

.panel {
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 40px rgba(0, 0, 0, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.status-panel,
.commander-panel {
  grid-column: 1 / -1;
}

.commander-panel {
  border-image: linear-gradient(120deg, var(--accent), transparent 60%) 1;
}

.status-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.status-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.status-ok { border-left: 4px solid #46d39a; }
.status-error { border-left: 4px solid #ff6a5a; }

.stack {
  display: grid;
  gap: 14px;
}

.commander-identity {
  min-height: 26px;
}

.commander-card {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.1));
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
}

.commander-archetype {
  color: var(--accent);
  font-weight: 800;
  margin: 0 0 6px;
}

.commander-strategy {
  color: var(--ink-dim);
  line-height: 1.5;
  margin: 0;
}

.deck-output {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-top: 16px;
}

.deck-section {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.16));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.deck-section h3 {
  align-items: center;
  display: flex;
  font-size: 14px;
  justify-content: space-between;
  margin: 0 0 8px;
}

.deck-section .count-pill {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
}

.deck-section ul {
  color: var(--ink-dim);
  font-size: 13px;
  list-style: none;
  margin: 0;
  max-height: 168px;
  overflow: auto;
  padding: 0;
}

.deck-section li {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.07);
  padding: 4px 0;
}

.deck-summary {
  color: var(--ink-dim);
  font-weight: 700;
  grid-column: 1 / -1;
  margin: 0;
}

.scanner {
  display: grid;
  gap: 12px;
}

.scanner-result:empty {
  display: none;
}

.camera-frame {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: radial-gradient(circle at 50% 40%, #121b24, #060a0e);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

#camera-video {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

/* Frozen snapshot shown after "Snap Picture" until recognition completes. */
.snapshot-frame {
  height: 100%;
  inset: 0;
  object-fit: cover;
  position: absolute;
  width: 100%;
  z-index: 2;
}

.scan-square {
  aspect-ratio: 5 / 7;
  border: 3px solid var(--accent);
  border-radius: 14px / 10px;
  box-shadow: 0 0 0 999px rgba(4, 7, 10, 0.55), 0 0 22px var(--accent-soft) inset;
  height: min(88%, 520px);
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
}

.camera-placeholder {
  color: var(--ink-dim);
  font-weight: 700;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.camera-frame.camera-on .camera-placeholder {
  display: none;
}

.scanner-controls {
  margin-top: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.scanner-state {
  color: var(--ink-dim);
  font-size: 14px;
  font-weight: 700;
  margin: 12px 0;
}

label {
  color: var(--ink-dim);
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

input,
select,
textarea {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 11px;
  width: 100%;
}

/* Force the native dropdown popup to match the dark theme instead of OS white. */
select {
  color-scheme: dark;
}

option,
optgroup {
  background-color: #10151b;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.output {
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-dim);
  min-height: 72px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.output.summary {
  white-space: normal;
}

.output.summary p {
  margin: 0 0 6px;
}

.reco-top {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.reco-art {
  border: 1px solid var(--accent);
  border-radius: 10px;
  display: block;
  margin-bottom: 8px;
  max-width: 220px;
  width: 100%;
}

.reco-price {
  color: var(--ink);
  font-size: 14px;
  margin: 2px 0 6px;
}

.cap-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cap-list li {
  color: var(--ink);
  font-size: 13px;
  padding: 3px 0;
}

.reco-name {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.reco-conf {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  padding: 2px 10px;
}

@media (max-width: 999px) {
  .layout,
  .status-grid {
    grid-template-columns: 1fr;
  }

  /* Collapsed single-column: surface the Camera Scanner first. */
  .scanner-panel {
    order: -1;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .button-row {
    display: grid;
  }
}

/* ============================================================
   MTG branding: original mana-wheel crest + fantasy display type
   ============================================================ */
.brand {
  align-items: center;
  display: flex;
  gap: 18px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-tagline {
  color: var(--ink-dim);
  font-size: 13px;
  margin: 6px 0 0;
}

.brand h1,
.panel h2 {
  font-family: "Cinzel", Georgia, "Times New Roman", serif;
}

.crest {
  align-items: center;
  aspect-ratio: 63 / 88;
  border-radius: 9px;
  display: flex;
  flex: 0 0 auto;
  height: 118px;
  justify-content: center;
  overflow: hidden;
  position: relative;
  width: auto;
  padding: 0;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.crest-cardback {
  border-radius: 9px;
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

/* ============================================================
   Rich desktop / laptop dashboard (>= 1000px, non-touch)
   ============================================================ */
@media (min-width: 1000px) {
  [data-device="desktop"] .layout {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 20px;
    margin-inline: auto;
    max-width: 1680px;
    padding: 26px 34px 52px;
  }

  [data-device="desktop"] .status-panel {
    order: 1;
    grid-column: 1 / -1;
  }
  [data-device="desktop"] .scanner-panel {
    order: 2;
    grid-column: span 5;
  }
  [data-device="desktop"] .deckbuilder-panel {
    order: 3;
    grid-column: span 7;
  }
  [data-device="desktop"] .membership-panel {
    order: 4;
    grid-column: span 5;
  }
  [data-device="desktop"] .advisor-panel {
    order: 5;
    grid-column: span 7;
  }
  [data-device="desktop"] .constructed-panel {
    order: 6;
    grid-column: 1 / -1;
  }
  [data-device="desktop"] .inventory-panel {
    order: 7;
    grid-column: 1 / -1;
  }
  [data-device="desktop"] .import-panel {
    order: 8;
    grid-column: 1 / -1;
  }

  [data-device="desktop"] .topbar {
    padding: 26px 40px;
  }

  [data-device="desktop"] h1 {
    font-size: 34px;
    letter-spacing: 1px;
  }

  [data-device="desktop"] .panel {
    border-radius: 16px;
    padding: 24px 26px;
  }

  [data-device="desktop"] .panel h2 {
    border-bottom: 1px solid var(--line);
    font-size: 19px;
    letter-spacing: 1.5px;
    padding-bottom: 12px;
    text-transform: uppercase;
  }

  [data-device="desktop"] .status-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  [data-device="desktop"] .camera-frame {
    aspect-ratio: 4 / 3;
  }

  /* Deck output gets more room to breathe on wide screens */
  [data-device="desktop"] .deck-output {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* ============================================================
   Streamlined mobile / tablet (touch) experience
   ============================================================ */
[data-device="mobile"] .layout {
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 0 0 16px;
}

/* Scanner-first flow on phones */
[data-device="mobile"] .scanner-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  order: -1;
  padding: 0;
}

[data-device="mobile"] .scanner-panel h2 {
  margin: 0;
  padding: 14px 16px 10px;
}

[data-device="mobile"] .scanner {
  gap: 0;
}
[data-device="mobile"] .commander-panel,
[data-device="mobile"] .deckbuilder-panel {
  order: 2;
}
[data-device="mobile"] .import-panel {
  order: 3;
}
[data-device="mobile"] .inventory-panel {
  order: 4;
}
[data-device="mobile"] .constructed-panel {
  order: 5;
}
[data-device="mobile"] .membership-panel {
  order: 6;
}
[data-device="mobile"] .advisor-panel {
  order: 7;
}
[data-device="mobile"] .status-panel {
  order: 8;
}

[data-device="mobile"] .topbar {
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}

[data-device="mobile"] .brand-tagline {
  display: none;
}

[data-device="mobile"] .crest {
  height: 60px;
  width: auto;
}

[data-device="mobile"] h1 {
  font-size: 22px;
}

[data-device="mobile"] .status-grid {
  grid-template-columns: 1fr 1fr;
}

/* Bigger tap targets and full-width controls on touch devices */
[data-device="mobile"] button {
  padding: 14px 16px;
}
[data-device="mobile"] .button-row {
  display: grid;
}
[data-device="mobile"] .account-area {
  flex-wrap: wrap;
  width: 100%;
}
[data-device="mobile"] .camera-frame {
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 -80px 120px rgba(0, 0, 0, 0.28);
  height: min(72dvh, 640px);
  min-height: 380px;
  width: 100%;
}
[data-device="mobile"] .scan-square {
  display: none;
}
[data-device="mobile"] .camera-placeholder {
  background: rgba(10, 15, 22, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 10px 14px;
}
[data-device="mobile"] .scanner-controls,
[data-device="mobile"] .scanner-state,
[data-device="mobile"] #voice-state,
[data-device="mobile"] .voice-panel {
  margin-left: 16px;
  margin-right: 16px;
}
[data-device="mobile"] .scanner-controls {
  margin-top: 14px;
}
[data-device="mobile"] #recognition-output {
  border-radius: 0;
  margin: 0;
  padding: 14px 16px 16px;
}
[data-device="mobile"] .reco-art {
  max-width: 160px;
}

@supports not (height: 100dvh) {
  [data-device="mobile"] .camera-frame {
    height: min(72vh, 640px);
  }
}

/* ============================================================
   Inventory panel
   ============================================================ */
.add-to-inv {
  margin-top: 10px;
}

.reco-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.reco-actions .add-to-inv {
  margin-top: 0;
}

.inventory-add {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 80px 130px auto;
  margin-bottom: 14px;
}

.inventory-add .field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.inventory-add .field input {
  width: 100%;
}

.field-cap {
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.inventory-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.inventory-controls #inventory-search {
  flex: 1 1 160px;
  width: auto;
}

.inventory-controls select {
  flex: 0 0 auto;
  width: auto;
}

.inventory-controls #inventory-sort-dir {
  flex: 0 0 auto;
  padding: 8px 12px;
}

.inventory-filterbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.inventory-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.filter-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-row .filter-field {
  flex: 0 0 auto;
  width: auto;
}

.filter-row .filter-value {
  align-items: center;
  display: inline-flex;
  flex: 1 1 auto;
  gap: 6px;
}

.filter-row .filter-value input[type="text"],
.filter-row .filter-value input[type="number"],
.filter-row .filter-value select {
  width: auto;
  flex: 1 1 120px;
}

.filter-colors {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-color-opt {
  gap: 3px;
}

.filter-color-opt .mana-icon {
  height: 18px;
  width: 18px;
}

.filter-remove {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1;
  padding: 4px 10px;
}

.inventory-toolbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.inventory-toolbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Link styled as a gold button (matches the gold set). */
.btn-link {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid #7a5713;
  color: #3a2a05;
  cursor: pointer;
  display: inline-block;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 10px 16px;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(255, 248, 214, 0.7);
  background: linear-gradient(180deg, #fff6cf 0%, #f4d97e 15%, #e7bc45 37%, #c8912a 52%, #a9761d 62%, #f0cf76 82%, #c99a2f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -2px 5px rgba(120, 80, 10, 0.55), 0 8px 18px rgba(0, 0, 0, 0.4);
}

.btn-link:hover {
  filter: brightness(1.06) saturate(1.08);
}

/* Analytics charts */
.chart-panel {
  min-width: 0;
}

.chart-box {
  height: 280px;
  position: relative;
}

.chart-box.chart-wide {
  height: 340px;
}

.inventory-total {
  color: var(--ink);
  font-weight: 800;
}

.inventory-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.inv-item {
  align-items: stretch;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.16));
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.inv-item:hover {
  border-color: var(--accent);
}

.inv-title {
  color: var(--ink);
  font-weight: 800;
  text-align: left;
}

.inv-body {
  align-items: flex-start;
  display: flex;
  gap: 12px;
}

.inv-thumb {
  align-self: flex-start;
  aspect-ratio: 63 / 88;
  border-radius: 6px;
  flex: 0 0 auto;
  height: 150px;
  object-fit: cover;
  width: auto;
}

.inv-info {
  align-items: flex-start;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
}

.inv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inv-name {
  color: var(--ink);
  font-weight: 800;
}

.inv-qty {
  color: var(--accent);
}

.inv-meta {
  font-size: 12px;
  margin: 2px 0;
}

.inv-links a {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}

.inv-links a:hover {
  text-decoration: underline;
}

.inv-remove {
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 1.1;
  padding: 4px 14px;
  width: auto;
}

.inv-finishes {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.inv-finish-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 6px;
}

.inv-finish-label {
  color: var(--ink);
  font-weight: 700;
}

[data-device="mobile"] .inventory-list {
  grid-template-columns: 1fr;
}
[data-device="mobile"] .inventory-add {
  grid-template-columns: 1fr 80px;
}
[data-device="mobile"] .inventory-add .field:first-child,
[data-device="mobile"] .inventory-add button {
  grid-column: 1 / -1;
}

/* Inventory pips, group badge, and generic mana symbol */
.inv-pips {
  margin: 1px 0;
}

.inv-group {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  padding: 1px 8px;
}

.mana-generic {
  background: radial-gradient(circle at 30% 25%, #d8d2c4, #a49c88);
  color: #201a12;
}

/* Card detail modal */
.card-detail {
  max-width: 900px;
}

.card-detail-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(220px, 320px) 1fr;
}

.card-faces {
  display: grid;
  gap: 10px;
}

.card-face-img {
  border-radius: 12px;
  width: 100%;
}

/* Foil view: holographic sheen over the card art. */
.card-detail-art {
  position: relative;
}

.card-detail-art.is-foil::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  pointer-events: none;
  mix-blend-mode: color-dodge;
  opacity: 0.5;
  background:
    linear-gradient(115deg, transparent 20%, rgba(255, 120, 180, 0.55) 35%, rgba(120, 220, 255, 0.55) 50%, rgba(180, 255, 140, 0.55) 65%, transparent 80%),
    linear-gradient(245deg, transparent 30%, rgba(255, 235, 130, 0.4) 50%, transparent 70%);
  background-size: 250% 250%, 200% 200%;
  animation: foil-shift 5s ease-in-out infinite;
}

@keyframes foil-shift {
  0% { background-position: 0% 50%, 100% 0%; }
  50% { background-position: 100% 50%, 0% 100%; }
  100% { background-position: 0% 50%, 100% 0%; }
}

/* Foil / Standard toggle under the card art. */
.finish-switch {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.finish-opt {
  background: linear-gradient(180deg, #2f3a49, #232d3a);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  flex: 1 1 0;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  text-shadow: none;
  box-shadow: none;
}

.finish-opt::before {
  content: none;
}

.finish-opt.active {
  background: linear-gradient(180deg, #fff6cf, #e7bc45 52%, #c8912a 63%, #f0cf76 82%, #c99a2f);
  border-color: #7a5713;
  color: #3a2a05;
  text-shadow: 0 1px 0 rgba(255, 248, 214, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 -2px 4px rgba(120, 80, 10, 0.5);
}

.card-detail-info h3 {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-family: "Cinzel", Georgia, serif;
  gap: 8px;
  margin: 0 0 4px;
}

.card-type {
  margin: 0 0 10px;
}

.oracle {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  color: var(--ink);
  line-height: 1.5;
  margin: 0 0 12px;
  padding: 10px 12px;
}

.face-block {
  margin-bottom: 12px;
}

.face-block h4 {
  align-items: center;
  display: flex;
  gap: 6px;
  margin: 0 0 4px;
}

.detail-row {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 6px 0;
}

.detail-row > span:first-child {
  color: var(--ink-dim);
  font-weight: 700;
}

.group-edit {
  align-items: center;
  display: flex;
  gap: 6px;
}

.group-edit input {
  width: 120px;
}

.group-edit button,
.detail-save-group {
  font-size: 12px;
  padding: 6px 10px;
}

.detail-links {
  margin: 12px 0;
}

.detail-links a {
  color: var(--accent);
  text-decoration: none;
}

button.danger {
  background: linear-gradient(180deg, #c0453a, #8f2f27);
  color: #fff;
}

/* Per-finish quantity steppers in the card detail modal. */
.qty-stepper {
  align-items: center;
  display: inline-flex;
  gap: 10px;
}

.qty-stepper .qty-val {
  color: var(--ink);
  font-weight: 800;
  min-width: 18px;
  text-align: center;
}

.qty-btn {
  border-radius: 8px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  padding: 4px 10px;
}

/* Smaller red-gold "Remove from inventory" button that matches the gold set. */
button.detail-remove {
  align-self: flex-start;
  background:
    linear-gradient(
      180deg,
      #f5d98a 0%,
      #e0a24a 18%,
      #c65a3c 45%,
      #a83428 60%,
      #e0a24a 82%,
      #b64a30 100%
    );
  border: 1px solid #6e2418;
  color: #2a0d08;
  font-size: 12px;
  margin-top: 12px;
  padding: 7px 16px;
  text-shadow: 0 1px 0 rgba(255, 235, 200, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 -2px 5px rgba(90, 25, 10, 0.55),
    0 8px 18px rgba(0, 0, 0, 0.4);
}

/* Constructed builder color picker */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-check {
  align-items: center;
  display: flex;
  gap: 4px;
  text-transform: none;
  font-weight: 700;
}

.color-check input {
  width: auto;
}

.inline-check {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
  text-transform: none;
}

.inline-check input {
  width: auto;
}

.import-improve {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.import-improve label {
  flex: 1 1 240px;
}

/* Remove confirmation dialog */
.confirm-card {
  max-width: 420px;
  text-align: center;
}

.confirm-skip {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 14px 0;
  text-transform: none;
  font-weight: 600;
}

.confirm-skip input {
  width: auto;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

[data-device="mobile"] .card-detail-grid {
  grid-template-columns: 1fr;
}

