:root {
  --paper: #eef0e9;
  --paper-raised: #e4e7db;
  --ink: #1b241c;
  --ink-muted: #55604f;
  --rule: #c7ccbb;
  --brand: #1f6f6b;
  --brand-strong: #14504d;
  --surplus: #a3701a;
  --needed: #1f6f6b;
  --tag-surplus-bg: #e6d7bd;
  --tag-needed-bg: #d2e3dd;
  --danger: #a8432b;
  --danger-bg: #ecdcd3;

  /* "poster" oficial Panini World Cup: rosu-bordo (nu mov) + auriu, cartonas turcoaz-deschis */
  --hero-bg: #6b0f1f;
  --hero-bg-2: #9c1a2a;
  --hero-ink: #fff8f0;
  --hero-gold: #ffcb3d;
  --sticker-bg: #d7f1f3;
  --sticker-border: #8fd0d4;
  --sticker-ink: #0d3b3e;
  --owned-border: #2f8f4e;
  --watermark: rgba(13, 59, 62, .1);

  /* pill-ul de navigare e mereu negru, indiferent de tema */
  --pill-bg: #14100f;
  --pill-ink: #f4ede4;
  --pill-ink-muted: #a89f95;

  --team-hue: 172;
  --team-l: 91%;
  --team-l-text: 24%;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121a13;
    --paper-raised: #1a231b;
    --ink: #e9ebe0;
    --ink-muted: #a1ab94;
    --rule: #333f2e;
    --brand: #52b6ab;
    --brand-strong: #7ed0c5;
    --surplus: #dba748;
    --needed: #52b6ab;
    --tag-surplus-bg: #3c3018;
    --tag-needed-bg: #17322c;
    --danger: #e08a68;
    --danger-bg: #3a2519;

    --hero-bg: #400a14;
    --hero-bg-2: #6b1520;
    --hero-ink: #fff8f0;
    --hero-gold: #ffd666;
    --sticker-bg: #123638;
    --sticker-border: #1f5457;
    --sticker-ink: #d7f1f3;
    --owned-border: #4fbf72;
    --watermark: rgba(215, 241, 243, .08);

    --team-l: 22%;
    --team-l-text: 86%;

    color-scheme: dark;
  }
}

/* comutare explicita (buton), indiferent de tema sistemului */
:root[data-theme="dark"] {
  --paper: #121a13;
  --paper-raised: #1a231b;
  --ink: #e9ebe0;
  --ink-muted: #a1ab94;
  --rule: #333f2e;
  --brand: #52b6ab;
  --brand-strong: #7ed0c5;
  --surplus: #dba748;
  --needed: #52b6ab;
  --tag-surplus-bg: #3c3018;
  --tag-needed-bg: #17322c;
  --danger: #e08a68;
  --danger-bg: #3a2519;

  --hero-bg: #400a14;
  --hero-bg-2: #6b1520;
  --hero-ink: #fff8f0;
  --hero-gold: #ffd666;
  --sticker-bg: #123638;
  --sticker-border: #1f5457;
  --sticker-ink: #d7f1f3;
  --owned-border: #4fbf72;
  --watermark: rgba(215, 241, 243, .08);

  --team-l: 22%;
  --team-l-text: 86%;

  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.menu-wrap {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
}
.menu-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(0, 0, 0, .3);
  color: var(--hero-ink);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(2px);
}
.menu-btn:hover { background: rgba(0, 0, 0, .45); }
.menu-btn:focus-visible { outline: 2px solid var(--hero-gold); outline-offset: 2px; }

.menu-panel {
  position: absolute;
  top: 48px;
  right: 0;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: .4rem;
  border-radius: 10px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  padding: .6rem .7rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font-family: "Public Sans", sans-serif;
  font-weight: 600;
  font-size: .88rem;
  text-align: left;
  cursor: pointer;
}
button.menu-item:hover { background: var(--paper); }
.menu-item--icon { width: auto; font-size: 1.05rem; padding: .55rem .7rem; }
.menu-account {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: .78rem;
  color: var(--ink-muted);
  cursor: default;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  margin-block: 2px;
  padding-block: .55rem;
}
.menu-danger { color: var(--danger); }
button.menu-item.menu-danger:hover { background: var(--danger-bg); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .5);
}
.modal-card {
  width: 100%;
  max-width: 380px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1.6rem;
  border-radius: 14px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
}
.modal-card h2 { font-size: 1.3rem; margin-bottom: .2rem; }
.modal-card h3 {
  font-family: "Baloo 2", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 1.1rem;
  margin-bottom: .1rem;
}
.modal-card h3:first-of-type { margin-top: .4rem; }
.modal-card label { font-size: .84rem; font-weight: 600; margin-top: .6rem; }
.link-inline {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: .88rem;
  color: var(--brand-strong);
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}
.modal-card input[type="text"],
.modal-card select {
  font-size: 1rem;
  padding: .6rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Public Sans", sans-serif;
}
.modal-card input[type="text"]:focus-visible,
.modal-card select:focus-visible { outline: 2px solid var(--brand); }
.modal-actions { display: flex; gap: .7rem; margin-top: 1rem; }
.modal-actions .btn-primary { margin-top: 0; flex: 1; }
.modal-actions .btn-secondary { flex: 1; text-align: center; }

h1, h2 {
  font-family: "Baloo 2", "Public Sans", sans-serif;
  margin: 0;
  text-wrap: balance;
}

.eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.hero-eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--hero-gold);
}
.hero-wordmark {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  color: var(--hero-ink);
  text-transform: uppercase;
  line-height: .95;
  letter-spacing: -.01em;
  margin-top: .4rem;
}

/* ---- login ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.login-hero {
  position: relative;
  overflow: hidden;
  background-image: url("/images/hero-collage.jpg");
  background-size: 220px auto;
  background-repeat: repeat;
  background-color: var(--hero-bg);
  padding: 3rem 20px 4rem;
  text-align: center;
}
.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 140% at 15% 0%, var(--hero-bg-2), var(--hero-bg) 70%);
  opacity: .72;
}
.login-hero > * { position: relative; z-index: 1; }
.login-hero::after {
  content: "";
  position: absolute;
  right: -10%;
  bottom: -60%;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.login-hero .hero-wordmark { font-size: clamp(2.2rem, 9vw, 3.4rem); }

.login-screen form.login-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: 100%;
  max-width: 380px;
  margin: -2rem auto 0;
  padding: 1.8rem;
  border-radius: 16px 16px 0 0;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-bottom: none;
  position: relative;
  z-index: 1;
}
.login-card label { font-size: .84rem; font-weight: 600; margin-top: .6rem; }
.login-card input[type="text"],
.login-card select {
  font-size: 1rem;
  padding: .6rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Public Sans", sans-serif;
}
.login-card input[type="text"]:focus-visible,
.login-card select:focus-visible { outline: 2px solid var(--brand); }
.login-card .btn-primary { margin-top: .8rem; width: 100%; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Public Sans", system-ui, sans-serif;
  line-height: 1.6;
}

main, footer.app-foot, nav.tabs {
  max-width: 760px;
  margin-inline: auto;
  padding-inline: 20px;
}

/* ---- header ---- */
header.app-head {
  position: relative;
  overflow: hidden;
  background-image: url("/images/hero-collage.jpg");
  background-size: 190px auto;
  background-repeat: repeat;
  background-color: var(--hero-bg);
  margin-bottom: 1.2rem;
}
header.app-head::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--hero-bg-2), var(--hero-bg) 75%);
  opacity: .68;
}
header.app-head::after {
  content: "";
  position: absolute;
  right: -8%;
  top: -120%;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
.head-row {
  position: relative;
  max-width: 760px;
  margin-inline: auto;
  padding: 1rem 20px .9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}
.head-row .hero-wordmark { font-size: clamp(1.15rem, 3.4vw, 1.5rem); margin-top: 0; }
.whoami {
  margin: .25rem 0 0;
  font-size: .78rem;
  color: var(--hero-ink);
  opacity: .85;
}
.album-box { min-width: 220px; flex: 1 1 240px; max-width: 320px; }
.album-name {
  display: block;
  font-family: "Baloo 2", sans-serif;
  font-weight: 600;
  font-size: .82rem;
  color: var(--hero-ink);
  margin-bottom: .3rem;
}
.progress { height: 5px; background: rgba(255, 255, 255, .25); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--hero-gold); width: 0%; transition: width .3s ease; }
.progress-label {
  display: block;
  margin-top: .28rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: .68rem;
  color: var(--hero-ink);
  opacity: .8;
}

/* ---- tab pill (stil bara "INDEX" din album) ---- */
nav.tabs {
  display: flex;
  justify-content: center;
  gap: .25rem;
  width: fit-content;
  background: var(--pill-bg);
  border-radius: 999px;
  padding: .35rem;
  margin: 0 auto 1.8rem;
}
.tab {
  font-family: "Baloo 2", sans-serif;
  font-weight: 600;
  font-size: .92rem;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--pill-ink-muted);
  padding: .6rem 1.2rem;
  cursor: pointer;
}
.tab:hover { color: var(--pill-ink); }
.tab.active { color: var(--pill-bg); background: var(--hero-gold); }
.tab-badge,
.card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 .3rem;
  margin-left: .35rem;
  border-radius: 999px;
  background: #d64545;
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: .68rem;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
}

main { padding-block: 0 2rem; }
.view { display: none; }
.view.active { display: block; }

.hint { color: var(--ink-muted); font-size: .92rem; max-width: 58ch; margin: 0 0 1.1rem; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  font-family: "IBM Plex Mono", monospace;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .2em .6em;
  border-radius: 3px;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.tag-have { background: var(--paper-raised); color: var(--ink); }
.tag-have::before { background: var(--ink); }
.tag-surplus { background: var(--tag-surplus-bg); color: var(--surplus); }
.tag-surplus::before { background: var(--surplus); }
.tag-needed { background: var(--tag-needed-bg); color: var(--needed); }
.tag-needed::before { background: var(--needed); }

/* ---- inventar: grupe Cupa Mondiala + pagini de tara ---- */
.wc-group {
  margin-bottom: 2.4rem;
}
.wc-group-head {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  background: var(--hero-bg);
  color: var(--hero-ink);
  padding: .5rem 1.1rem;
  border-radius: 10px;
  margin-bottom: 1.1rem;
}
.wc-group-head .eyebrow { color: var(--hero-gold); }
.wc-group-head .badge-title {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 1rem;
}
.wc-group-head .flags { font-size: .95rem; letter-spacing: .1em; }

.country-group { margin-bottom: 1.7rem; }
.country-head {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: .6rem;
  padding: .5rem .75rem;
  border-radius: 8px;
  background: hsl(var(--team-hue) 55% var(--team-l));
  cursor: pointer;
  list-style: none;
}
.country-head::-webkit-details-marker { display: none; }
.country-head-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .3rem .6rem;
}
.country-head-row::before {
  content: "▾";
  font-size: .8rem;
  transition: transform .15s ease;
  color: hsl(var(--team-hue) 25% var(--team-l-text));
}
.country-progress { margin-left: auto; }
.country-group:not([open]) .country-head-row::before { transform: rotate(-90deg); }
.country-bar {
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: hsl(var(--team-hue) 30% var(--team-l-text) / .2);
}
.country-bar-fill {
  height: 100%;
  background: var(--owned-border);
  transition: width .2s ease;
}
.country-name {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: hsl(var(--team-hue) 45% var(--team-l-text));
}
.country-progress {
  font-family: "IBM Plex Mono", monospace;
  font-size: .76rem;
  color: hsl(var(--team-hue) 25% var(--team-l-text));
}

.inventory-groups { display: flex; flex-direction: column; }

.stk-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.stk {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .55rem;
  border: 2px solid var(--owned-border);
  border-radius: 12px;
  padding: .6rem .6rem .7rem;
  background: var(--sticker-bg);
  color: var(--sticker-ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: .72rem;
  cursor: pointer;
}
.stk:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.stk-img {
  width: 100%;
  aspect-ratio: 226 / 300;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, .15);
  background: rgba(255, 255, 255, .4);
}
.stk-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.stk-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.stk .code { font-family: "Baloo 2", sans-serif; font-weight: 700; color: inherit; font-size: .95rem; }
.stk-player {
  font-family: "Public Sans", sans-serif;
  font-size: .84rem;
  font-weight: 600;
  color: inherit;
  line-height: 1.25;
}
.stk-dup {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  flex-shrink: 0;
  cursor: pointer;
  color: inherit;
  opacity: .85;
}
.stk-dup input { width: 17px; height: 17px; cursor: pointer; accent-color: var(--surplus); }
.stk-dup:has(input:disabled) { opacity: .35; cursor: default; }
.stk-dup input:disabled { cursor: default; }

.stk[data-status="dublura"] {
  border-color: var(--hero-gold);
  box-shadow: 0 0 0 2px var(--hero-gold) inset;
}
.stk[data-status="lipsa"] {
  background: var(--paper-raised);
  border-style: dashed;
  border-color: var(--rule);
  color: var(--ink-muted);
}
.stk[data-status="lipsa"]::before {
  content: "26";
  position: absolute;
  right: -.1rem;
  bottom: -1rem;
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 3.4rem;
  line-height: 1;
  color: var(--watermark);
  pointer-events: none;
  z-index: 0;
}
.stk-top, .stk-player { position: relative; z-index: 1; }

/* ---- matching ---- */
.matchlist { display: flex; flex-direction: column; gap: .6rem; }
.match-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .7rem .9rem;
  padding: .9rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-raised);
}
.match-main { display: flex; align-items: center; gap: .7rem; flex: 1 1 200px; min-width: 0; }
.match-side { display: flex; align-items: center; gap: .7rem; flex-shrink: 0; }
.avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: .72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
}
.match-info { flex: 1; min-width: 0; }
.match-name { font-weight: 600; font-size: .96rem; }
.handle-tag { font-family: "IBM Plex Mono", monospace; font-weight: 400; color: var(--ink-muted); font-size: .85em; }
.match-sub { font-size: .8rem; color: var(--ink-muted); }
.match-count { font-family: "IBM Plex Mono", monospace; font-size: .78rem; color: var(--needed); white-space: nowrap; }
.btn-secondary {
  font-family: "Baloo 2", sans-serif;
  font-weight: 600;
  font-size: .86rem;
  color: var(--brand-strong);
  background: transparent;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: .6rem .9rem;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--tag-needed-bg); }

/* ---- schimb ---- */
#schimbWith { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.2rem; }
.swap-cols { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.swap-col { flex: 1 1 200px; min-width: 0; }
.swap-list {
  list-style: none;
  margin: .7rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.swap-list li {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: .5rem .7rem;
  font-size: .88rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .2rem .5rem;
}
.swap-list li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.swap-list li .num { font-family: "IBM Plex Mono", monospace; color: var(--ink-muted); }

.chat-box {
  margin-top: 1.8rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.1rem;
  max-width: 60ch;
}
.chat-box h3 {
  margin: 0 0 .7rem;
  font-family: "Baloo 2", sans-serif;
  font-size: 1.02rem;
}
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: .8rem;
}
.chat-messages .hint { margin: 0; }
.chat-msg {
  max-width: 80%;
  padding: .45rem .7rem;
  border-radius: 10px;
  font-size: .88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  background: var(--paper-raised);
  color: var(--ink);
}
.chat-msg--me {
  align-self: flex-end;
  background: var(--owned-border);
  color: #fff;
}
.chat-msg time {
  display: block;
  margin-top: .2rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: .68rem;
  opacity: .7;
}
.chat-form { display: flex; gap: .5rem; }
.chat-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: .5rem .7rem;
  font-size: .88rem;
  background: var(--paper);
  color: var(--ink);
}
.chat-form .btn-secondary { padding: .5rem 1rem; }

.btn-primary {
  margin-top: 1.4rem;
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: .96rem;
  color: var(--hero-bg);
  background: var(--hero-gold);
  border: none;
  border-radius: 8px;
  padding: .75rem 1.3rem;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(.95); }
.btn-primary:disabled { opacity: .5; cursor: default; }

.feedback { margin-top: .8rem; font-size: .88rem; }
.feedback:empty { display: none; }
.feedback.ok { color: var(--brand-strong); }
.feedback.warn { color: var(--surplus); }
.feedback.err { color: var(--danger); }

footer.app-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding-block: 1.4rem 2rem;
  border-top: 1px solid var(--rule);
  font-family: "IBM Plex Mono", monospace;
  font-size: .78rem;
  color: var(--ink-muted);
}
.foot-name { font-weight: 500; color: var(--ink); }
.foot-sep { opacity: .5; }
footer.app-foot a { color: var(--brand-strong); text-decoration: underline; }
footer.app-foot a:hover { color: var(--brand); }

@media (max-width: 560px) {
  .head-row { flex-direction: column; align-items: flex-start; padding-block: .9rem .8rem; gap: .6rem; }
  .album-box { max-width: none; width: 100%; flex-basis: auto; }
  .match-side { width: 100%; justify-content: space-between; }
  .btn-primary { width: 100%; }
}
