:root {
  --bg: #0f1320;
  --panel: #171c2e;
  --panel-2: #1f2740;
  --accent: #e4002b;      /* classic sticker red */
  --accent-dark: #8a0019; /* darker shade of accent (topbar gradient end) */
  --spread-navy: #1d2a52; /* navy used in .we-are and .spread-progress */
  --gold: #f2c14e;
  --green: #2ecc71;
  --text: #e9ecf5;
  --muted: #8b93ad;
  --slot: #232b45;
  --slot-edge: #313c5e;

  /* paper / album board tones */
  --paper: #f6f1e6;
  --paper-edge: #d8cfb8;
  --paper-ink: #2a2622;
  --paper-muted: #8a7f6b;
  --gutter: #c9bfa6;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

/* ---- Swaps / Repeats theme: recolor the whole UI blue ---- */
body.swaps-mode {
  --accent: #0a66c2;
  --accent-dark: #053a73;
  --spread-navy: #103a73;   /* replaces the #1d2a52 navy literals */
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---- Topbar ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  position: sticky;
  top: 0;
  z-index: 10;
}
#topbar h1 { font-size: 1.25rem; margin: 0; letter-spacing: 0.3px; }
#view-tabs { display: flex; gap: 8px; margin-left: 8px; }
.tab-btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tab-btn:hover { background: rgba(0, 0, 0, 0.4); }
.tab-btn.active {
  background: #fff;
  color: var(--accent);
  border-color: #fff;
}
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.overall {
  font-weight: 700;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 16px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.icon-btn {
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.25);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.45); }

/* ---- User menu (topbar) ---- */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
}
.user-menu[hidden] { display: none; }
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}
.user-avatar[hidden] { display: none; }
.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-logout {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  white-space: nowrap;
  transition: background 0.15s ease;
}
.user-logout:hover { background: rgba(0, 0, 0, 0.4); }

#layout { display: flex; height: calc(100vh - 66px); }
#layout[hidden] { display: none; }

/* ---- Login screen ----
   Full-bleed white landing themed to the official 2026 logo (black/gold/white).
   Fixed + high z-index so it covers the dark app chrome (topbar) when logged out. */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 28%, #ffffff 0%, #eef0f5 62%, #e2e6ef 100%);
}
.login-screen[hidden] { display: none; }
.login-card {
  background: #fff;
  border: 1px solid #e6e8ee;
  border-top: 4px solid #c9a227; /* gold accent echoing the trophy */
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(16, 19, 28, 0.18);
  padding: 36px 44px 34px;
  text-align: center;
  max-width: 440px;
  width: 100%;
}
.login-logo {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
  margin: 4px auto 14px;
}
.login-title {
  margin: 0 0 6px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #10131c;
}
.login-sub {
  margin: 0 0 26px;
  color: #5b6170;
  font-size: 0.95rem;
}
.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font: inherit;
  font-weight: 600;
  font-size: 0.98rem;
  color: #1f2330;
  text-decoration: none;
  background: #fff;
  border: 1px solid #dadce0;
  padding: 11px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.16);
  border-color: #c7c9cf;
}
.login-btn .g-icon {
  width: 20px;
  height: 20px;
  flex: none;
}

/* ---- Left nav (collapsible) ---- */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--panel);
  overflow: hidden;
  border-right: 1px solid #000;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, margin-left 0.25s ease, opacity 0.2s ease;
}
.sidebar-section { flex: 1; padding: 8px 0; min-height: 0; overflow-y: auto; }
.sidebar-title {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 16px 6px;
}
.sidebar-hint { color: var(--muted); padding: 16px; font-size: 0.9rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 0.92rem;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--panel-2); border-left-color: var(--gold); }
.nav-flag { font-size: 1.05rem; flex-shrink: 0; }
.nav-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-size: 0.72rem;
  background: var(--slot);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.badge.complete { background: var(--green); color: #06371b; font-weight: 700; }

/* collapsed state */
body.sidebar-collapsed #sidebar {
  width: 0;
  margin-left: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  border-right: none;
}

/* ---- Album area ---- */
#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 26px;
  background: var(--panel);
  border-bottom: 1px solid #000;
}
#search-box {
  position: relative;
  flex: 1;
  max-width: 1100px;
}
#search-box[hidden] { display: none; }

.dl-btn {
  flex-shrink: 0;
  margin-left: auto;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  background: var(--panel-2);
  border: 1px solid var(--slot-edge);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.dl-btn:hover { background: var(--slot); border-color: var(--gold); }
#section-search {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--slot-edge);
  border-radius: 10px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
#section-search:focus { border-color: var(--gold); }
#section-search::placeholder { color: var(--muted); }

#search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--slot-edge);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
#search-suggestions[hidden] { display: none; }
.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
}
.suggestion:hover,
.suggestion.active { background: var(--slot); }
.suggestion .sg-flag { font-size: 1.1rem; flex-shrink: 0; }
.suggestion .sg-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion .sg-code { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.suggestion mark { background: transparent; color: var(--gold); font-weight: 700; }
.suggestion-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

#album, #repeats {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px 60px;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 20% 10%, #141a2c, var(--bg));
}

.search-hidden { display: none !important; }

/* ---- A 2-page spread ---- */
.spread {
  max-width: 1100px;
  margin: 0 auto 40px;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 14px;
  border: 1px solid var(--paper-edge);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  scroll-margin-top: 12px;
}

.spread-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  background: linear-gradient(180deg, #ffffff, var(--paper));
  border-bottom: 3px solid var(--accent);
}
.spread-flag {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}
.spread-titles { flex: 1; }
.we-are {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--spread-navy);
}
.country-name {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--accent);
}
.assoc {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-muted);
  margin-top: 4px;
}
.spread-progress {
  font-weight: 800;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  background: var(--spread-navy);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
}

/* two pages with centre gutter/fold */
.pages {
  display: grid;
  grid-template-columns: 1fr 18px 1fr;
  align-items: stretch;
  padding: 22px;
  gap: 0;
}
.page { padding: 4px 18px; }
.page-left { padding-left: 4px; }
.page-right { padding-right: 4px; }
.gutter {
  background:
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.16),
      rgba(0, 0, 0, 0.04) 45%,
      rgba(255, 255, 255, 0.5) 50%,
      rgba(0, 0, 0, 0.04) 55%,
      rgba(0, 0, 0, 0.16));
  border-radius: 2px;
}

.spread-foot {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--paper-muted);
  padding: 10px 0 16px;
  border-top: 1px dashed var(--paper-edge);
}

/* ---- Slot grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}
.card {
  aspect-ratio: 3 / 4;
  background: #ece5d4;
  border: 2px dashed #b9ad90;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 6px;
  user-select: none;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
  position: relative;
}
.card:hover { transform: translateY(-2px); }
.card .num {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #8a7f6b;
}
.card .name {
  font-size: 0.74rem;
  line-height: 1.15;
  color: #6f6552;
  margin-top: 8px;
  padding: 0 2px;
}
.card .mark { font-size: 1.5rem; color: #b9ad90; }

/* spare badge (copies >= 2) */
.card .spare {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 0.66rem;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  padding: 1px 6px;
  border-radius: 999px;
  display: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.card .spare.show { display: inline-block; }

/* owned state — looks like a stuck-in sticker */
.card.owned {
  background: linear-gradient(160deg, var(--gold), #d99b1c);
  border: 2px solid #b9810f;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.card.owned .num { color: #5b3d00; }
.card.owned .name { color: #3a2700; font-weight: 700; }
.card.owned .mark { color: #2c5e1a; }

/* ---- Swap card with +/- repeat counter ---- */
.swap-card {
  /* num pinned top-left, name centred, counter pinned bottom */
  justify-content: flex-start;
  padding-top: 22px;
  padding-bottom: 8px;
}
.swap-card .name {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}
.rep-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: auto;
  width: 100%;
}
.rep-btn {
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  background: var(--accent);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: filter 0.12s ease, transform 0.08s ease;
}
.rep-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.rep-btn:active { transform: translateY(0); }
.rep-count {
  font-weight: 800;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: #6f6552;
  min-width: 16px;
  text-align: center;
}
/* this player has spares — highlight similar in spirit to .card.owned */
.swap-card.has-repeats {
  background: linear-gradient(160deg, var(--gold), #d99b1c);
  border: 2px solid #b9810f;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.swap-card.has-repeats .num { color: #5b3d00; }
.swap-card.has-repeats .name { color: #3a2700; font-weight: 700; }
.swap-card.has-repeats .rep-count { color: #3a2700; }

/* ---- Repeats view ---- */
.repeats-wrap { max-width: 900px; margin: 0 auto; }
.repeats-hint, .repeats-empty {
  max-width: 900px;
  margin: 0 auto;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}
.repeats-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--slot-edge);
}
.repeats-head h2 { margin: 0; font-size: 1.3rem; flex: 1; }
.repeats-total {
  font-size: 0.95rem;
  color: var(--muted);
  background: var(--panel);
  padding: 8px 16px;
  border-radius: 999px;
}
.repeats-total strong { color: var(--gold); }

.repeats-group {
  background: var(--panel);
  border: 1px solid var(--slot-edge);
  border-radius: 12px;
  margin-bottom: 18px;
  overflow: hidden;
}
.repeats-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--panel-2);
  font-weight: 700;
}
.rg-flag { font-size: 1.3rem; }
.repeats-list { list-style: none; margin: 0; padding: 6px 0; }
.repeats-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.ri-num {
  font-weight: 800;
  color: var(--gold);
  min-width: 64px;
  font-variant-numeric: tabular-nums;
}
.ri-name { flex: 1; }
.ri-copies { color: var(--muted); font-variant-numeric: tabular-nums; }
.ri-spares {
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
}

/* ---- Responsive: stack the two pages ---- */
@media (max-width: 760px) {
  .pages {
    grid-template-columns: 1fr;
  }
  .gutter {
    height: 14px;
    margin: 6px 0;
    background:
      linear-gradient(180deg,
        rgba(0, 0, 0, 0.16),
        rgba(255, 255, 255, 0.5) 50%,
        rgba(0, 0, 0, 0.16));
  }
  .page { padding: 4px 2px; }
  .country-name { font-size: 1.4rem; }
}
