*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Theme tokens ── */

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-2: #2a2a2a;
  --surface-3: #252525;
  --border: #1e1e1e;
  --border-2: #2a2a2a;
  --border-3: #333;
  --text-1: #f0f0f0;
  --text-2: #e0e0e0;
  --text-muted: #bbb;
  --text-dim: #999;
  --text-faint: #666;
  --text-ghost: #555;
  --text-sep: #444;
  --accent: #4a9eff;
  --accent-hover: #6ab5ff;
  --accent-bg: #1a2a3a;
  --hover-bg: #1a1a1a;
  --pip-border: rgba(255, 255, 255, 0.1);
  --record-bg: #2a2a2a;
  --record-color: #ccc;
  --kbd-bg: #1a1a1a;
  --kbd-border: #2a2a2a;
  --kbd-color: #888;
  --banner-bg: #4a9eff;
  --banner-color: #0f0f0f;
  --scrollbar-thumb: #2a2a2a;
  --preview-bg: #111;
  color-scheme: dark;
}

:root.light {
  --bg: #fafafa;
  --surface: #fff;
  --surface-2: #f0f0f0;
  --surface-3: #f5f5f5;
  --border: #e8e8e8;
  --border-2: #ddd;
  --border-3: #bbb;
  --text-1: #1a1a1a;
  --text-2: #1a1a1a;
  --text-muted: #333;
  --text-dim: #555;
  --text-faint: #888;
  --text-ghost: #aaa;
  --text-sep: #ccc;
  --accent: #1a6dd4;
  --accent-hover: #0d47a1;
  --accent-bg: #e8f0fe;
  --hover-bg: #f0f0f0;
  --pip-border: rgba(0, 0, 0, 0.1);
  --record-bg: #f0f0f0;
  --record-color: #555;
  --kbd-bg: #f4f4f4;
  --kbd-border: #ddd;
  --kbd-color: #666;
  --banner-bg: #1a6dd4;
  --banner-color: #fff;
  --scrollbar-thumb: #ddd;
  --preview-bg: #222;
  color-scheme: light;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-2);
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
}

/* ── Header ── */

.header-container {
  padding: 10px 16px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 0;
  position: relative;
  z-index: 40;
}

.header-row {
  display: flex;
  align-items: flex-start;
  width: 100%;
  gap: 8px;
}

.header-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
  align-self: flex-start;
}

.header-last-update {
  font-size: 0.58em;
  color: var(--text-ghost);
  line-height: 1.3;
}

.header-deck-count {
  font-size: 0.62em;
  color: var(--text-ghost);
  line-height: 1.2;
}

.header-container h1 {
  font-size: 1.2em;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent);
  white-space: nowrap;
}

.site-title {
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s ease;
}

.site-title:hover,
.site-title:focus-visible {
  opacity: 0.75;
  outline: none;
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  cursor: pointer;
  padding: 3px 7px;
  font-size: 1em;
  line-height: 1;
  color: var(--text-dim);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
  text-decoration: none;
}

.header-icon-btn:hover {
  background: var(--hover-bg);
  border-color: var(--text-ghost);
  color: var(--text-muted);
}

.header-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.contact-mail {
  font-size: 0.95em;
}

/* ── Breadcrumb ── */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-size: 0.76em;
  color: var(--text-faint);
  min-height: 1.4em;
}

.bc-trigger {
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.bc-trigger:hover {
  background: var(--surface);
  color: var(--text-muted);
}

.bc-trigger.bc-position {
  color: var(--accent);
  font-weight: 600;
}

.bc-trigger.bc-position:hover {
  background: var(--accent-bg);
  color: var(--accent-hover);
}

.bc-sep {
  color: var(--text-sep);
  font-size: 1.1em;
}

/* ── Breadcrumb dropdown ── */

.bc-dropdown {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  width: 240px;
  animation: dropIn 0.12s ease-out;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.bc-dropdown-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 0;
}

.bc-dropdown-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s;
}

.bc-dropdown-item:hover {
  background: var(--surface-3);
}

.bc-dropdown-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.bc-dropdown-sub {
  margin-left: auto;
  font-size: 0.8em;
  color: var(--text-ghost);
  font-weight: 400;
}

/* ── Main content ── */

.image-container {
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: stretch;
  position: relative;
  min-height: 0;
  height: 100%;
}

/* ── Player profile modal ── */

.player-modal {
  position: fixed;
  top: var(--header-height, 0px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  background: color-mix(in srgb, var(--bg) 40%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease-out;
}

.player-modal:not([hidden]) {
  pointer-events: auto;
}

.player-modal.open {
  opacity: 1;
}

.player-modal-panel {
  position: relative;
  width: min(100%, 380px);
  height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--border-2);
  box-shadow: -12px 0 40px color-mix(in srgb, var(--bg) 60%, transparent);
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-modal.open .player-modal-panel {
  transform: translateX(0);
}

.player-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.85em;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.player-modal-close:hover {
  background: var(--hover-bg);
  color: var(--text-muted);
  border-color: var(--text-ghost);
}

.player-modal-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 14px 16px 12px;
}

.player-modal-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.player-modal-header {
  padding-right: 32px;
  flex-shrink: 0;
}

.player-modal-title {
  font-size: 1.05em;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.player-modal-identity {
  margin-top: 4px;
  font-size: 0.72em;
  color: var(--text-dim);
  line-height: 1.35;
}

.player-modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}

.player-modal-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
}

.player-modal-stat-label {
  font-size: 0.62em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-ghost);
}

.player-modal-stat-value {
  font-size: 0.78em;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.player-modal-stat-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-weight: 500;
}

.player-modal-stat-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.28em;
}

.player-modal-stat-line--sub {
  font-size: 0.92em;
  color: var(--text-dim);
}

.player-modal-stat-num {
  font-weight: 700;
  color: var(--text-1);
}

.player-modal-stat-text {
  font-weight: 500;
  color: var(--text-muted);
}

.player-modal-stat-rank {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.player-modal-stat-rank + .player-modal-stat-rank {
  margin-top: 2px;
}

.player-modal-stat-rank-label {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-ghost);
  line-height: 1.25;
}

.player-modal-stat-rank-value {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.player-modal-decks {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-modal-heading {
  font-size: 0.62em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-ghost);
  flex-shrink: 0;
}

.player-modal-deck-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.player-modal-deck-item {
  display: grid;
  grid-template-columns: 1.2em 1fr auto;
  align-items: baseline;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.76em;
  line-height: 1.3;
}

.player-modal-deck-item:last-child {
  border-bottom: none;
}

.player-modal-deck-rank {
  color: var(--text-ghost);
  font-variant-numeric: tabular-nums;
}

.player-modal-deck-name {
  color: var(--text-muted);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-modal-deck-count {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.player-modal-hint {
  margin-top: auto;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.62em;
  color: var(--text-sep);
}

.player-modal-error {
  padding: 24px 8px;
  text-align: center;
  font-size: 0.82em;
  color: var(--text-dim);
}

/* ── Progress indicator ── */

.progress-track {
  position: absolute;
  right: 4px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--surface);
  border-radius: 2px;
  z-index: 10;
  pointer-events: none;
}

.progress-thumb {
  position: absolute;
  width: 100%;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.5;
  transition: top 0.2s ease-out, height 0.2s ease-out;
}

/* ── Deck view ── */

.deck-container {
  padding: 14px 24px 10px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.deck-container.slide-up {
  animation: slideUp 0.2s ease-out;
}

.deck-container.slide-down {
  animation: slideDown 0.2s ease-out;
}

.deck-container.slide-out-right {
  animation: slideOutRight 0.22s ease-in forwards;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-48px); }
}

.profile-wrap.slide-in-right {
  animation: slideInRight 0.22s ease-out;
}

.profile-wrap.slide-out-left {
  animation: slideOutLeft 0.22s ease-in forwards;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(48px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutLeft {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(48px); }
}

.deck-header {
  margin-bottom: 10px;
  flex-shrink: 0;
  text-align: center;
}

.deck-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.player-name {
  font-size: 1.15em;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.3px;
}

.player-record {
  font-weight: 700;
  font-size: 0.75em;
  color: var(--record-color);
  background: var(--record-bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* ── Deck archetype ── */

.deck-archetype {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  margin-top: 2px;
}

a.deck-archetype {
  display: block;
  text-align: center;
  text-decoration: none;
  transition: color 0.15s;
}

a.deck-archetype:hover {
  color: var(--accent);
}

.player-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.player-link:hover {
  color: var(--accent);
}

.deck-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.deck-link:hover {
  color: var(--accent);
}

button.player-modal-deck-name {
  text-align: left;
}

a.player-name {
  text-decoration: none;
  transition: color 0.15s;
}

a.player-name:hover {
  color: var(--accent);
}

/* ── Color pips ── */

.color-pips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.color-pip {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid var(--pip-border);
}

/* ── Tournament badge ── */

.tournament-badge {
  display: inline-block;
  font-size: 0.68em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  line-height: 1.4;
  vertical-align: middle;
}

/* ── Deck columns ── */

.decklist-columns {
  flex: 1;
  display: flex;
  gap: 28px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 6px;
}

.deck-actions {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  padding: 16px 0 8px;
  position: relative;
  z-index: 920;
}

.deck-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  min-height: 44px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.deck-action-btn:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-1px);
}

.deck-action-btn:active {
  transform: translateY(0);
}

.deck-action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.deck-container.visual-deck {
  max-width: 100%;
  padding-top: 8px;
  padding-bottom: 6px;
}

.deck-container.visual-deck .deck-header {
  margin-bottom: 6px;
}

.deck-container.visual-deck .deck-header .kbd-hint {
  display: none;
}

.decklist-columns.visual-mode {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  flex-direction: row;
  align-items: stretch;
  gap: 10px;
  padding-bottom: 0;
}

.decklist-columns.visual-mode .deck-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.decklist-columns.visual-mode .deck-col.sideboard-col {
  flex: 0 0 clamp(72px, 24vw, 108px);
}

.decklist-columns.visual-mode .col-title {
  flex-shrink: 0;
  font-size: 0.62em;
  letter-spacing: 1px;
  padding-bottom: 2px;
  margin-bottom: 0;
  border-bottom-width: 1px;
}

.deck-visual-grid {
  display: grid;
  align-content: start;
  justify-content: center;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.card-tile {
  position: relative;
  padding: 0;
  border: none;
  background: var(--surface-2);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  flex-shrink: 0;
}

.card-tile-loading {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: card-tile-shimmer 1.1s linear infinite;
}

@keyframes card-tile-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.card-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

@media (hover: none) {
  .card-tile:hover {
    transform: none;
    box-shadow: none;
  }
}

.card-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-tile img,
.card-tile-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.card-tile-loading .card-tile-img {
  opacity: 0;
}

.card-tile-qty {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.62em;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

.card-tile-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.card-tile-fallback-name {
  font-size: 0.62em;
  line-height: 1.25;
  color: var(--text-muted);
  text-align: center;
  word-break: break-word;
}

.deck-action-btn.download-btn {
  min-width: 160px;
}

.decklist-columns::-webkit-scrollbar {
  display: none;
}

.deck-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.deck-col.sideboard-col {
  flex: 0 0 28%;
}

.col-title {
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  padding-bottom: 4px;
  border-bottom: 2px solid var(--border-2);
}

.col-title.sideboard-title {
  border-bottom-color: var(--border-3);
}

/* ── Card categories ── */

.card-category {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.category-label {
  font-size: 0.68em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-ghost);
  padding-bottom: 2px;
  margin-bottom: 1px;
  border-bottom: 1px solid var(--border);
}

.card-row {
  display: flex;
  align-items: baseline;
  padding: 1.5px 4px;
  font-size: 0.82em;
  line-height: 1.5;
  border-radius: 3px;
  transition: background 0.1s;
}

.card-row:hover {
  background: var(--hover-bg);
}

.card-qty {
  width: 20px;
  text-align: right;
  margin-right: 8px;
  color: var(--text-ghost);
  font-size: 0.9em;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.card-name {
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.1s;
}

.card-name:hover {
  color: var(--accent);
}

/* ── Card preview popup ── */

#card-preview {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  display: none;
  border-radius: 12px;
  overflow: hidden;
  background: var(--preview-bg);
}

#card-preview-img {
  display: block;
  width: 244px;
  height: auto;
  border-radius: 12px;
}

/* ── New-data banner ── */

.new-data-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--banner-bg);
  color: var(--banner-color);
  font-size: 0.82em;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 24px;
  z-index: 900;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.new-data-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.new-data-banner #new-data-tap {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.action-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--border-3);
  font-size: 0.82em;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  z-index: 910;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: min(92vw, 360px);
  text-align: center;
  pointer-events: none;
}

.action-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.install-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--banner-bg);
  color: var(--banner-color);
  font-size: 0.82em;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 12px 10px 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  z-index: 900;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: min(92vw, 440px);
  display: flex;
  align-items: center;
  gap: 10px;
}

.install-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.install-banner-text {
  flex: 1;
  line-height: 1.35;
}

.install-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.install-banner-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.install-banner-btn:hover {
  background: var(--accent-hover);
}

.install-banner-dismiss {
  background: none;
  border: none;
  color: var(--banner-color);
  opacity: 0.7;
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
  padding: 4px;
}

.install-banner-dismiss:hover {
  opacity: 1;
}

.install-ios-hint {
  position: fixed;
  top: calc(var(--header-height, 60px) + 6px);
  right: 12px;
  max-width: min(88vw, 260px);
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border-3);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.78em;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 850;
}

.install-ios-hint strong {
  color: var(--text-1);
  font-weight: 600;
}

.install-app-btn {
  font-size: 1.05em;
  font-weight: 700;
}

/* ── Loader ── */

.loader {
  text-align: center;
  padding: 40px 20px;
  font-size: 0.9em;
  color: var(--text-ghost);
}

/* ── Keyboard hint ── */

.kbd-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.68em;
  color: var(--text-sep);
  margin-top: 2px;
}

.kbd-hint-part {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}

.kbd-hint-left {
  text-align: left;
}

.kbd-hint-center {
  text-align: center;
}

.kbd-hint-right {
  text-align: right;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 0.85em;
  font-family: inherit;
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  border-radius: 3px;
  color: var(--kbd-color);
}

/* ── Player profile page ── */

.profile-page {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
}

.site-link {
  color: var(--accent);
  text-decoration: none;
}

.site-link:hover {
  color: var(--accent-hover);
}

.profile-container {
  overflow-y: auto;
  padding: 20px 16px 32px;
}

.profile-wrap {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.profile-section {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 18px 20px;
}

.profile-title {
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.profile-heading {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 12px;
}

.profile-identity {
  font-size: 1.05em;
  color: var(--text-muted);
}

.profile-stat {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88em;
}

.profile-stat:last-child {
  border-bottom: none;
}

.profile-stat-label {
  color: var(--text-dim);
}

.profile-stat-value {
  color: var(--text-1);
  font-weight: 600;
  text-align: right;
}

.profile-deck-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-deck-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.9em;
}

.profile-deck-rank {
  color: var(--text-ghost);
  width: 1.5em;
}

.profile-deck-name {
  color: var(--text-1);
  font-weight: 600;
  flex: 1;
}

.profile-deck-count {
  color: var(--text-faint);
  font-size: 0.9em;
}

.profile-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-history-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-3);
  text-decoration: none;
  transition: background 0.15s;
}

.profile-history-row:hover {
  background: var(--hover-bg);
}

.profile-history-meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.profile-history-date {
  font-size: 0.78em;
  color: var(--text-faint);
}

.profile-history-type {
  font-size: 0.65em;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--accent);
}

.profile-history-tournament {
  font-size: 0.88em;
  color: var(--text-1);
  font-weight: 600;
}

.profile-history-detail {
  font-size: 0.82em;
  color: var(--text-dim);
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .header-container {
    padding: 8px 12px 5px;
  }

  .header-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .header-actions {
    margin-left: auto;
    align-self: flex-start;
    gap: 5px;
  }

  .header-container h1 {
    font-size: 1.1em;
  }

  .header-last-update {
    font-size: 0.54em;
    max-width: 14rem;
  }

  .header-deck-count {
    font-size: 0.56em;
  }

  .player-modal-panel {
    width: 100%;
  }

  .player-modal-body {
    padding: 12px 14px 10px;
  }

  .player-modal-title {
    font-size: 1em;
  }

  .player-modal-stats {
    gap: 6px;
  }

  .player-modal-stat {
    padding: 7px 8px;
  }

  .player-modal-stat-value {
    font-size: 0.72em;
  }

  .player-modal-deck-item {
    font-size: 0.72em;
  }

  .breadcrumb {
    font-size: 0.7em;
    gap: 4px;
  }

  .bc-dropdown {
    width: 200px;
  }

  .kbd-hint {
    display: none;
  }

  .deck-container {
    padding: 6px 10px 4px;
    height: 100%;
    max-height: 100%;
    margin-top: 0;
    margin-bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .deck-container.visual-deck {
    padding: 4px 8px 4px;
  }

  .decklist-columns {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 2px;
  }

  .decklist-columns.visual-mode {
    flex-direction: row;
    gap: 6px;
    overflow: hidden;
  }

  .deck-actions {
    position: sticky;
    bottom: 0;
    flex-shrink: 0;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px color-mix(in srgb, var(--bg) 85%, transparent);
  }

  .deck-action-btn {
    min-width: 0;
    flex: 1;
    max-width: 180px;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.68em;
  }

  .install-banner,
  .new-data-banner,
  .action-toast {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .deck-header {
    margin-bottom: 4px;
  }

  .deck-archetype {
    font-size: 0.78em;
  }

  .player-name {
    font-size: 1em;
  }

  .deck-title-row {
    gap: 6px;
  }

  .color-pip {
    width: 24px;
    height: 24px;
  }

  .color-pips {
    gap: 5px;
  }

  .player-record {
    font-size: 0.68em;
    padding: 1px 6px;
  }

  .tournament-badge {
    font-size: 0.6em;
    padding: 1px 5px;
  }

  .deck-col {
    gap: 4px;
    columns: 2;
    column-gap: 12px;
    display: block;
    flex: none;
  }

  .deck-col.sideboard-col {
    columns: 2;
    column-gap: 12px;
    flex: none;
  }

  .col-title {
    font-size: 0.65em;
    letter-spacing: 1px;
    padding-bottom: 2px;
    margin-bottom: 2px;
    column-span: all;
  }

  .card-category {
    break-inside: avoid;
    margin-bottom: 2px;
  }

  .category-label {
    font-size: 0.6em;
    letter-spacing: 1px;
    padding-bottom: 1px;
    margin-bottom: 0;
  }

  .card-row {
    font-size: 0.72em;
    line-height: 1.3;
    padding: 0.5px 2px;
  }

  .card-qty {
    width: 16px;
    margin-right: 4px;
    font-size: 0.85em;
  }

  #card-preview-img {
    width: 200px;
  }

  .progress-track {
    right: 2px;
    width: 2px;
  }

  .theme-toggle {
    padding: 2px 6px;
    font-size: 0.9em;
  }
}
