:root {
  --bg: #f5efe6;
  --ink: #1f2933;
  --card: #fffaf3;
  --accent: #ff5a36;
  --accent-2: #0f9d58;
  --line: #e6dac7;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #ffe8c2 0%, transparent 35%),
    radial-gradient(circle at 90% 20%, #ffd1c4 0%, transparent 30%),
    var(--bg);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.4rem;
  border-bottom: 2px solid var(--line);
  background: #fff7eb;
  position: sticky;
  top: 0;
  z-index: 900;
}

.topbar a {
  color: var(--ink);
  text-decoration: none;
  margin-left: 1rem;
  font-weight: 600;
}

.brand {
  font-size: 1.2rem;
  font-weight: 800;
}

.container {
  width: min(1120px, 95%);
  margin: 1.5rem auto;
}

.hero,
.panel,
.team-card,
.match-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.hero {
  text-align: center;
  padding: 2rem;
}

.button,
button {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

.cep-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.cep-form input {
  border: 1px solid var(--line);
  padding: 0.45rem;
  border-radius: 8px;
}


.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}

.sticker {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  background: #fff;
}

.sticker.special {
  border-color: var(--accent-2);
  background: #f1fff6;
}

.sticker.repeated {
  border-color: #f0b429;
  background: #fffbea;
}

.sticker p {
  margin: 0.3rem 0;
}

.qty {
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 0.4rem;
}

.actions form {
  margin: 0;
}

.actions button {
  width: 34px;
  height: 34px;
  padding: 0;
}

/* ── Painel de localização ── */
.loc-status {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.8rem;
}
.loc-ok   { color: var(--accent-2); }
.loc-cep  { color: #666; }
.loc-none { color: #999; }

.btn-geo {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-radius: 12px;
  background: var(--accent);
  margin-bottom: 0.5rem;
}

.loc-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0 0.8rem;
  color: #999;
  font-size: 0.82rem;
}
.loc-divider::before,
.loc-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Grade de times ── */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.team-thumb {
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.1s;
}
.team-thumb::before {
  content: '';
  position: absolute;
  inset: -10%;
  background-image: var(--flag-bg);
  background-size: cover;
  background-position: center;
  filter: blur(7px) brightness(1.15) saturate(0.9);
  opacity: 0.28;
  z-index: 0;
  pointer-events: none;
}
.team-thumb > * {
  position: relative;
  z-index: 1;
}
.team-thumb:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.team-thumb:hover::before {
  opacity: 0.42;
}
.team-name { font-weight: 800; font-size: 0.95rem; }
.team-conf { font-size: 0.75rem; color: #4f5b66; }
.team-stats { font-size: 0.82rem; color: var(--accent); font-weight: 700; margin-top: 0.3rem; }
.repeated-badge { color: var(--accent-2); }
.special-badge  { color: #f4c430; margin-right: 0.25rem; }

/* ── Time Especiais (FWC) ── */
.team-thumb[data-conf="FWC"] {
  border-color: #f4c430;
  background: linear-gradient(135deg, #1c1600 0%, #2e2200 100%);
  color: #f4c430;
}
.team-thumb[data-conf="FWC"] .team-conf { color: #b8960c; }
.team-thumb[data-conf="FWC"]::before {
  content: '★';
  font-size: 7rem;
  line-height: 1;
  background-image: none;
  filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f4c430;
  opacity: 0.18;
}
.team-thumb[data-conf="FWC"]:hover { border-color: #ffe066; }
.team-thumb[data-conf="FWC"]:hover::before { opacity: 0.28; }

/* ── Progresso do álbum ── */
.album-progress { margin: 0.8rem 0 1rem; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.82rem; margin-bottom: 0.35rem; color: #4f5b66; }
.progress-label strong { color: var(--ink); }
.progress-bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), #0acf83); border-radius: 99px; transition: width .6s ease; }

/* ── Filtro de times ── */
.team-filters { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.team-search-input {
  width: 100%; padding: 0.55rem 0.9rem; border: 1.5px solid var(--line);
  border-radius: 10px; font-size: 0.9rem; background: #fff; color: var(--ink);
}
.team-search-input:focus { outline: none; border-color: var(--accent); }
.conf-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.conf-btn {
  padding: 0.3rem 0.75rem; border: 1.5px solid var(--line); border-radius: 99px;
  background: #fff; color: #4f5b66; font-size: 0.78rem; cursor: pointer; transition: all .15s;
}
.conf-btn.active, .conf-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--card);
  border-radius: 16px;
  width: min(740px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.2rem;
  box-shadow: 0 24px 60px rgba(0,0,0,0.2);
  animation: modal-in 0.22s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Alça visual do bottom-sheet (só aparece no mobile via media query) */
.modal-handle {
  display: none;
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  margin: 0 auto 1rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.modal-header h3 { margin: 0 0 0.2rem; }
.modal-header small { color: #4f5b66; }
.modal-close {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
}

.match-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.messages {
  margin-bottom: 1rem;
}

.message {
  padding: 0.6rem;
  border-radius: 8px;
  background: #fff5cf;
  border: 1px solid #f2d981;
}

.hint {
  color: #4f5b66;
}

/* ── Badge de mensagens ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Match card: distância ── */
.dist-badge {
  font-weight: 700;
  color: var(--accent-2);
  margin: 0.2rem 0 0.6rem;
}
.dist-unknown {
  color: #888;
  font-weight: 400;
}
.match-card .button {
  display: inline-block;
  text-decoration: none;
  white-space: nowrap;
}
.match-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.6rem;
}
.match-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}
.score-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  background: var(--line);
  color: var(--ink);
  font-weight: 600;
}
.score-pill.offer  { background: #d4edda; color: #155724; }
.score-pill.receive{ background: #ffe8d4; color: #7a3100; }
.score-pill.common { background: #d1e7ff; color: #0a3872; }

.match-preview-details summary {
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  margin-bottom: 0.5rem;
}
.match-preview-body { padding-top: 0.5rem; display: flex; flex-direction: column; gap: 0.7rem; }
.preview-section strong { font-size: 0.78rem; display: block; margin-bottom: 0.35rem; }
.preview-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.preview-chip {
  font-size: 0.73rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--line);
  color: var(--ink);
}
.preview-chip.more { background: transparent; border: 1px dashed var(--line); color: #888; }

/* ── Typing indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  color: #888;
}
.typing-dots span {
  animation: blink 1.2s infinite;
  font-size: 1.2rem;
  line-height: 0;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0; } 40% { opacity: 1; } }

/* ── Onboarding ── */
.onboarding-banner {
  position: relative;
  background: linear-gradient(135deg, #fff9f0, #fff3e0);
  border: 2px solid #ffd580;
  border-radius: 14px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
}
.onboarding-banner h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.onboarding-banner p  { font-size: 0.85rem; color: #555; margin-bottom: 0.6rem; }
.onboarding-steps {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.onboarding-close {
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 0.5rem;
}
.page-btn {
  padding: 0.4rem 1rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.page-info { font-size: 0.82rem; color: #888; }

/* ── Avatar img ── */
.avatar-img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }

/* ── QR Code ── */
.qr-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}
.btn-qr {
  flex: 1;
  min-width: 140px;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}
.btn-show-qr    { background: var(--accent-2); color: #fff; }
.btn-scan-qr    { background: var(--accent);   color: #fff; }
.btn-copy-direct{ background: #4a6fa5;         color: #fff; }

.qr-modal-box { max-width: 360px; text-align: center; }
.qr-display { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 0.5rem 0; }
.qr-img { width: 220px; height: 220px; border-radius: 12px; border: 4px solid var(--line); }
.qr-hint { font-size: 0.82rem; color: #4f5b66; max-width: 280px; line-height: 1.5; }

.qr-scanner-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }
#qr-reader { width: 100% !important; border-radius: 12px; overflow: hidden; }
#qr-reader video { border-radius: 10px; }

.share-link-row {
  display: flex;
  width: 100%;
  max-width: 320px;
  gap: 0.4rem;
  margin: 0.4rem 0 0.6rem;
}
.share-link-input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.7rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--ink);
  background: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.btn-copy-link {
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
}
.btn-copy-link:active { background: #d44a2a; }
/* Remove botões extras do html5-qrcode */
#qr-reader__dashboard_section_csr button { background: var(--accent) !important; border-radius: 8px !important; }
#qr-reader__dashboard_section_swaplink { display: none !important; }

/* ── Inbox ── */
.inbox-list {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.inbox-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s;
}
.inbox-item:hover { border-color: var(--accent); }
.inbox-unread { border-color: var(--accent-2); }
.inbox-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.inbox-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.inbox-preview {
  font-size: 0.85rem;
  color: #4f5b66;
}

/* ── Trade Preview ── */
.trade-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.trade-row {}

.trade-row-label {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.4rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.offer-label   { color: #0f9d58; }
.receive-label { color: #e67e22; }
.common-label  { color: #2980b9; }

.trade-count {
  background: currentColor;
  color: #fff;
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 1px 6px;
  opacity: 0.9;
}

.trade-carousel {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.4rem;
  scrollbar-width: none;
}
.trade-carousel::-webkit-scrollbar { display: none; }

.trade-card {
  flex-shrink: 0;
  scroll-snap-align: start;
  width: 100px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.offer-card   { border-color: #b7e8cc; background: #f3fff8; }
.receive-card { border-color: #fdd9b5; background: #fff8f0; }
.common-card  { border-color: #b3d4f0; background: #f0f7ff; }
.trade-card.special { border-style: dashed; }

.tc-team {
  font-size: 0.65rem;
  color: #4f5b66;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-num  { font-size: 1rem; font-weight: 800; line-height: 1; }
.tc-name { font-size: 0.68rem; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Chat / Conversa ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.chat-header h2 { margin: 0; }
.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
}
.chat-bubble {
  max-width: 70%;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  line-height: 1.4;
}
.chat-bubble p { margin: 0 0 0.2rem; }
.chat-bubble time { font-size: 0.72rem; color: #888; }

.bubble-me {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble-me time { color: rgba(255,255,255,0.75); }
.bubble-other {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.chat-form {
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.chat-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  font-family: inherit;
  resize: vertical;
}
.chat-form button { align-self: flex-end; }

/* ── Responsividade mobile ── */
@media (max-width: 768px) {

  /* Topbar */
  .topbar {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }
  .topbar nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }
  .topbar nav a {
    margin-left: 0;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    background: rgba(0,0,0,0.04);
    font-size: 0.9rem;
  }

  /* Container */
  .container { width: 100%; padding: 0 0.75rem; margin: 1rem auto; }

  /* Grade de times: 2 colunas fixas */
  .team-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }
  .team-thumb { padding: 0.8rem; }
  .team-name { font-size: 0.88rem; }

  /* Modal vira bottom-sheet */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal-box {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    width: 100%;
    padding: 1rem 0.9rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    animation: sheet-in 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes sheet-in {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .modal-handle { display: block; }

  /* Grade de figurinhas no modal: 3 colunas */
  .sticker-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
  .sticker { padding: 0.5rem; }
  .sticker p { font-size: 0.78rem; }

  /* Touch targets maiores para +/- */
  .actions button {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
  }

  /* Match list 1 coluna */
  .match-list { grid-template-columns: 1fr; }

  /* Chat */
  .chat-bubble { max-width: 88%; }
  .chat-window { max-height: 42vh; min-height: 200px; }
}
