/* =========================
   RESET & BAS
========================= */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  background: #f2f7ff; /* var #fff0f5 */
  color: #1f2a44;      /* var #333 */
  margin: 0;
  padding: 16px;
}

/* =========================
   RUBRIKER
========================= */
h1, h2, h3 {
  color: #1d4ed8; /* var #c71585 */
  text-align: center;
  margin: 0 0 12px;
}

/* =========================
   HEADER / MENY
========================= */
header { text-align: center; margin-bottom: 12px; }

.menu a {
  color: #2563eb; /* var #d63384 */
  font-weight: bold;
  text-decoration: none;
  margin: 0 8px;
}
.menu a:hover { text-decoration: underline; }

/* =========================
   BAKGRUNDSBILD
========================= */
.background-image {
  position: fixed;
  inset: 0;
  background: url('../images/matchamera.png') no-repeat center center;
  background-size: 95%;
  opacity: 0.08; /* lite lugnare mot blått */
  z-index: -1;
  pointer-events: none;
}

/* =========================
   LOADER
========================= */
#page-loader {
  position: fixed;
  inset: 0;
  background: #eef5ff; /* var #fff4f8 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: #1d4ed8; /* var #c71585 */
}
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #93c5fd;   /* var #f2a1c4 */
  border-top-color: #1d4ed8;   /* var #c71585 */
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   GAME MATCHES – TABELL
========================================================= */
.table-viewport {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.match-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  table-layout: fixed;
  font-size: 0.9rem;
}

.match-table th,
.match-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #c7ddff; /* var #f4a1c0 */
  text-align: center;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
}

.match-table th {
  background: #eaf2ff; /* var #ffe4e1 */
  color: #1d4ed8;      /* var #c71585 */
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.mm-row.row-even { background:#ffffff; }
.mm-row.row-odd  { background:#f1f6ff; } /* var #ffe6f2 */

/* =========================
   SORTERING
========================= */
.sort-indicator {
  font-size: 0.7em;
  margin-left: 4px;
}

/* =========================
   NY / 24H BADGES
========================= */
.badge-new-user { margin-right: 4px; }

.badge-new-24h {
  background: #3b82f6; /* var #ff5ca8 */
  color: #fff;
  font-size: 0.65em;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 4px;
}

.mm-row.new-since-last {
  background: #eef5ff;        /* var #fff3f8 */
  border-left: 4px solid #3b82f6; /* var #ff5ca8 */
}

/* =========================================================
   REAKTIONER – STABIL SLUTVERSION
========================================================= */

/* 🔑 Reaktionskolumn */
.match-table th:nth-child(6),
.match-table td:nth-child(6) {
  width: 88px;
  min-width: 88px;
  max-width: 88px;
  padding: 4px 2px;
  text-align: center;
  vertical-align: top;
}

/* Visade reaktioner (namn) */
.match-table td:nth-child(6) > div[id^="reactions_"] {
  font-size: 9px;
  line-height: 1.05;
  margin-bottom: 3px;
  overflow: hidden;
}

/* Emoji-grid: 2 × 3 */
.reaction-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 14px;
  gap: 2px;
  justify-items: center;
}

/* Emoji-knappar */
.reaction-btn {
  all: unset;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reaction-btn:hover { transform: scale(1.15); }

.emoji-users {
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
}

/* =========================================================
   MOBIL – TABELL
========================================================= */
@media (max-width: 700px) {

  .match-table { font-size: 0.75rem; line-height: 1.15; }

  .match-table th,
  .match-table td { padding: 4px 5px; }

  /* Kategori */
  .match-table th:nth-child(1),
  .match-table td:nth-child(1) { width: 70px; }

  /* Din fråga */
  .match-table th:nth-child(2),
  .match-table td:nth-child(2) { width: 120px; }

  /* Ditt svar */
  .match-table th:nth-child(3),
  .match-table td:nth-child(3) {
    width: 64px;
    white-space: nowrap;
  }

  /* Motfråga */
  .match-table th:nth-child(4),
  .match-table td:nth-child(4) { width: 120px; }

  /* Partnerns svar */
  .match-table th:nth-child(5),
  .match-table td:nth-child(5) {
    width: 64px;
    white-space: nowrap;
  }

  /* Reaktioner */
  .match-table th:nth-child(6),
  .match-table td:nth-child(6) {
    width: 82px;
    min-width: 82px;
    max-width: 82px;
    font-size: 9px;
  }

  /* Dölj */
  .match-table th:last-child,
  .match-table td:last-child { width: 60px; }
}

/* =========================================================
   QUESTIONS – ÅTERSTÄLLT (ANDRA SIDOR)
========================================================= */
.question-block {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  padding-top: 24px;
}
.question-title { font-size: 1.6rem; margin-bottom: 8px; }
.question-text {
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto 28px;
  line-height: 1.35;
}

.answer-options {
  display: flex;
  justify-content: center;
  gap: 28px;
}

.answer-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.answer-option:hover { transform: scale(1.12); }

.answer-image {
  width: 80px;
  max-width: 80px;
  height: auto;
}

.answer-label {
  margin-top: 4px;
  font-weight: bold;
  font-size: 0.95rem;
}

/* MOBIL – FOOTER */
@media (max-width: 768px) {
  body { padding-bottom: 140px; }

  .answer-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(
      180deg,
      rgba(242,247,255,0.95),
      rgba(242,247,255,1)
    ); /* var rgba(255,240,245,...) */
    border-top: 1px solid #c7ddff; /* var #f4a1c0 */
    padding: 14px 10px 18px;
    z-index: 100;
  }

  .answer-options { justify-content: space-around; gap: 0; }

  .answer-image { width: 64px; max-width: 64px; }
  .answer-label { font-size: 0.85rem; }
}

/* =========================
   KATEGORI-FILTER
========================= */

/* Desktop: grid som fyller bra */
#category-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 12px;
}

/* Kort */
.category-filter-card {
  position: relative;
  padding: 10px 12px;
  border-radius: 10px;
  background: #ffffffcc;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
  min-width: 0;
  overflow: hidden;
}

.category-filter-card:hover { transform: translateY(-1px); }

.category-filter-card.inactive {
  opacity: 0.35;
  filter: grayscale(1);
}

/* Header: namn + total */
.cat-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.cat-name {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.15;
  word-break: break-word;
}

.cat-total {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Stats: 2×2 */
.cat-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
  margin-top: 6px;
  text-align: center;
}

.cat-stats .stat {
  font-size: 0.7rem;
  line-height: 1.15;
  padding: 3px 0;
  border-radius: 6px;
  white-space: nowrap;
}

/* Färger */
.stat.perfect  { background: #eaf2ff; } /* var #ffe6ea */
.stat.maybe    { background: #fff7d6; } /* behåller "varm" maybe */
.stat.silent   { background: #dbeafe; } /* var #e6f0ff */
.stat.conflict { background: #eef2f7; } /* var #f0f0f0 */
.stat.locked  { background: #bfdbfe; }  /* var #ffd0d0 */

/* ✅ MOBIL: alltid 2 kort per rad */
@media (max-width: 600px) {
  #category-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px;
  }

  .category-filter-card {
    padding: 8px 10px;
  }

  .cat-name {
    font-size: 0.9rem;
  }

  .cat-stats .stat {
    font-size: 0.68rem;
  }

  .cat-stats .stat span {
    display: none;
  }
}

.mm-row.is-hidden-row td {
  font-style: italic;
}
.mm-row.is-hidden-row {
  opacity: 0.5;
  background: #eef2f7; /* var #f3f3f3 */
}
.stat.locked {
  opacity: 0.9;
  font-weight: 600;
}

.stat.locked.dimmed {
  opacity: 0.3;
}

.match-thumb {
  width: 60px;
  margin-top: 6px;
  border-radius: 6px;
  cursor: pointer;
}

#image-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

#image-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
}

#image-modal-img {
  position: absolute;
  max-width: 90%;
  max-height: 90%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 12px;
}

#tabs {
  display: flex;
  flex-wrap: wrap;
  overflow-x: auto;
  gap: 6px;
}

#tabs .tab {
  white-space: nowrap;
  flex-shrink: 0;
}