/* =========================
   FONT & VARIABLER
========================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --primary-light: #06b6d4;
  --accent: #f59e0b;

  --text: #0f172a;
  --text-muted: #475569;

  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --border: rgba(14, 116, 144, 0.18);

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.18);
  --shadow-primary: 0 10px 28px rgba(8, 145, 178, 0.30);

  --easy: #10b981;
  --med: #f59e0b;
  --hard: #ef4444;
}

* {
  box-sizing: border-box;
}

/* =========================
   GRUNN / BAKGRUNN
========================= */

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  margin: 0;
  padding: 24px 20px 32px;
  text-align: center;
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  letter-spacing: -0.01em;
}

body::before {
  content: "";
  position: fixed;
  inset: -20px;
  background: url("img/java-reisen.png") center/cover no-repeat;
  filter: brightness(0.45) saturate(1.05) blur(12px);
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.45) 50%,
    rgba(0, 0, 0, 0.60) 100%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: -1;
}

/* =========================
   TITLER
========================= */

h1 {
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  font-weight: 800;
  margin: 4px 0 6px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #ea580c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.site-title {
  background: none;
  margin: 0 auto 10px;
  padding: 0;
  text-shadow: none;
  line-height: 0;
}

.site-logo {
  display: inline-block;
  max-width: min(280px, 80vw);
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35));
}

body > p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  margin: 0 auto 20px;
  max-width: 500px;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* =========================
   VANSKELIGHETSGRAD
========================= */

.difficulty-section {
  max-width: 520px;
  margin: 0 auto 18px;
  padding: 16px 20px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.difficulty-section p {
  margin: 0 0 12px !important;
  color: var(--text-muted) !important;
  font-size: 0.75rem !important;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700 !important;
}

.difficulty-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.difficulty-btn {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
  min-width: 85px;
}

.difficulty-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.difficulty-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.difficulty-btn.active {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  border-color: transparent;
  box-shadow: 0 12px 30px rgba(8, 145, 178, 0.4);
}

.difficulty-btn[onclick*="ez"] {
  border-color: #86efac;
  color: #047857;
  background: #f0fdf4;
}

.difficulty-btn[onclick*="ez"]:hover {
  border-color: #22c55e;
  color: #047857;
  background: #dcfce7;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
}

.difficulty-btn[onclick*="ez"].active {
  background: linear-gradient(135deg, #4ade80, #16a34a);
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 28px rgba(34, 197, 94, 0.35);
}

.difficulty-btn[onclick*="med"] {
  border-color: #fcd34d;
  color: #b45309;
  background: #fffbeb;
}

.difficulty-btn[onclick*="med"]:hover {
  border-color: #f59e0b;
  color: #b45309;
  background: #fef3c7;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
}

.difficulty-btn[onclick*="med"].active {
  background: linear-gradient(135deg, #fbbf24, #ea580c);
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.35);
}

.difficulty-btn[onclick*="hard"] {
  border-color: #fca5a5;
  color: #b91c1c;
  background: #fef2f2;
}

.difficulty-btn[onclick*="hard"]:hover {
  border-color: var(--hard);
  color: var(--hard);
  background: #fef2f2;
  box-shadow:
    0 0 0 4px rgba(239, 68, 68, 0.15),
    0 0 20px rgba(239, 68, 68, 0.55);
  animation: scary-shake 0.3s infinite;
}

.difficulty-btn[onclick*="hard"].active {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 28px rgba(239, 68, 68, 0.40);
}

@keyframes scary-shake {
  0%   { transform: translate(0, 0) rotate(0deg); }
  20%  { transform: translate(-2px, 1px) rotate(-1deg); }
  40%  { transform: translate(2px, -1px) rotate(1deg); }
  60%  { transform: translate(-1px, -2px) rotate(-1deg); }
  80%  { transform: translate(1px, 2px) rotate(1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* =========================
   ØY-KNAPPER (GRID)
========================= */

.islands {
  max-width: 720px;
  margin: 0 auto 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 4px;
  justify-content: center;
  justify-items: center;
}

.islands button {
  width: 100%;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  line-height: 1.3;
  min-height: 56px;
}

.islands button:hover {
  transform: translateY(-4px);
  background: white;
  border-color: var(--primary);
  color: var(--primary-dark);
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(8, 145, 178, 0.12);
}

.islands button:hover .island-badge {
  transform: rotate(-6deg) scale(1.08);
  filter: drop-shadow(0 8px 14px rgba(8, 145, 178, 0.35));
}

.island-badge {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.22));
  transition: transform 0.25s ease, filter 0.25s ease;
  pointer-events: none;
}

.island-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
}

.island-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

/* =========================
   BADGE-TRACKER
========================= */

.badge-tracker {
  max-width: 980px;
  margin: 18px auto 24px;
  padding: 22px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  box-shadow: 0 16px 34px rgba(2, 8, 23, 0.24);
  text-align: left;
}

.badge-tracker-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-label {
  margin: 0 0 6px;
  color: rgba(186, 230, 253, 0.88);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 800;
}

.badge-tracker h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  color: #f8fafc;
}

.badge-tracker-intro {
  margin: 0;
  color: rgba(226, 232, 240, 0.72);
  line-height: 1.5;
}

.player-form {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.player-form input {
  flex: 1 1 240px;
  min-width: 220px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.98rem;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.player-form input:focus {
  outline: none;
  border-color: rgba(125, 211, 252, 0.4);
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.1);
}

.player-form input::placeholder {
  color: rgba(226, 232, 240, 0.55);
}

.primary-btn,
.secondary-btn,
.remove-player-btn {
  border: none;
  border-radius: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.primary-btn {
  padding: 12px 18px;
  background: linear-gradient(135deg, #0ea5e9, #0369a1);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(14, 165, 233, 0.18);
}

.primary-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn {
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 0.92rem;
  font-weight: 700;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.badge-table-wrapper {
  overflow-x: auto;
}

.badge-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  overflow: hidden;
}

.badge-table th,
.badge-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: center;
}

.badge-table th {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(226, 232, 240, 0.82);
  font-size: 0.82rem;
  font-weight: 800;
}

.badge-th {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.badge-th-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.badge-table td {
  color: #e2e8f0;
}

.badge-table td:first-child,
.badge-table th:first-child {
  text-align: left;
  min-width: 160px;
}

.player-name {
  font-weight: 700;
  color: #f8fafc;
}

.badge-checkbox {
  width: 20px;
  height: 20px;
  accent-color: #22d3ee;
  cursor: pointer;
}

.badge-total {
  font-weight: 800;
  color: #bae6fd;
}

.remove-player-btn {
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid rgba(248, 113, 113, 0.12);
}

.remove-player-btn:hover {
  background: rgba(239, 68, 68, 0.18);
}

.empty-state {
  margin: 0;
  padding: 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(226, 232, 240, 0.76);
  text-align: center;
  border: 1px dashed rgba(148, 163, 184, 0.22);
}

/* =========================
   SPØRSMÅLSKORT
========================= */

#questionBox {
  background: var(--surface-solid);
  max-width: 520px;
  width: 100%;
  margin: 8px auto 0;
  padding: 24px 26px;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: fadeSlideIn 0.4s ease;
  text-align: left;
}

#questionBox h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.45;
}

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

/* =========================
   SVAR-KNAPPER
========================= */

#answers {
  margin-top: 16px;
}

#answers button {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px 18px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

#answers button:hover {
  background: #ecfeff;
  border-color: var(--primary);
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

/* =========================
   TILBAKEMELDINGS-IKON
========================= */

.answer-btn {
  position: relative;
  overflow: hidden;
}

.feedback-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  opacity: 0;
  animation: fadeIcon 3s ease forwards;
}

.correct-icon { color: var(--easy); }
.wrong-icon   { color: var(--hard); }

@keyframes fadeIcon {
  0%   { opacity: 0; transform: translateY(-50%) scale(0.8); }
  10%  { opacity: 1; transform: translateY(-50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* =========================
   SJANSEKORT
========================= */

.chance-card-section {
  margin: 20px auto 12px;
}

.chance-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
  pointer-events: none;
}

.chance-icon-lg {
  width: 36px;
  height: 36px;
  vertical-align: middle;
  margin-right: 6px;
}

.chance-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 34px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: white;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  letter-spacing: 0.02em;
  box-shadow:
    0 10px 24px rgba(245, 158, 11, 0.40),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.25s ease;
}

.chance-btn:hover {
  transform: translateY(-3px);
  box-shadow:
    0 16px 34px rgba(245, 158, 11, 0.50),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

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

#chanceCardBox {
  background: linear-gradient(135deg, #fef3c7, #fed7aa);
  border: 2px solid #f59e0b;
  border-radius: 20px;
  padding: 32px;
  margin: 24px auto;
  max-width: 500px;
  box-shadow: 0 20px 44px rgba(245, 158, 11, 0.28);
  animation: slideIn 0.4s ease;
  position: relative;
  z-index: 100;
}

#chanceCardBox.hidden {
  display: none !important;
}

#chanceCardBox h2 {
  color: #92400e;
  margin-top: 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

#chanceCardText {
  font-size: 1.1rem;
  color: #78350f;
  line-height: 1.6;
  margin: 20px 0;
  font-weight: 500;
}

#chanceCardBox button {
  padding: 12px 30px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  background: #92400e;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#chanceCardBox button:hover {
  background: #78350f;
  transform: translateY(-2px);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================
   SKJULT
========================= */

.hidden {
  display: none !important;
}

/* =========================
   RESPONSIV
========================= */

@media (max-width: 640px) {
  body {
    padding: 28px 16px 56px;
  }

  .badge-tracker {
    padding: 18px 16px;
  }

  .badge-tracker-header {
    flex-direction: column;
    align-items: stretch;
  }

  .secondary-btn,
  .primary-btn {
    width: 100%;
  }

  .difficulty-section {
    padding: 20px 16px;
  }

  .difficulty-btn {
    padding: 10px 20px;
    min-width: 75px;
  }

  .islands {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  #questionBox {
    padding: 28px 24px;
  }

  .chance-btn {
    width: 100%;
    max-width: 400px;
  }

  #chanceCardBox {
    margin: 15px;
    padding: 24px;
  }

  #chanceCardText {
    font-size: 1.15rem;
  }
}

@media (max-width: 420px) {
  .islands {
    grid-template-columns: 1fr;
  }
}

/* =========================
   RANKED MULTIPLAYER
========================= */

.ranked-header {
  max-width: 900px;
  margin: 16px auto 0;
  padding: 0 16px;
  display: flex;
  justify-content: flex-end;
}

#authArea {
  display: flex;
  align-items: center;
  gap: 12px;
}

#userInfo {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 8px 16px;
  font-weight: 600;
}

#userInfo.hidden {
  display: none;
}

.elo-badge {
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.elo-badge strong {
  font-weight: 800;
}

.ranked-section {
  max-width: 900px;
  margin: 24px auto;
  padding: 24px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.ranked-section h2 {
  margin-top: 0;
}

.ranked-section.hidden {
  display: none;
}

.match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: #f0f9ff;
  border-radius: 12px;
  margin-bottom: 12px;
}

.match-player {
  flex: 1;
  text-align: center;
}

.match-vs {
  font-weight: 800;
  color: var(--primary);
  font-size: 1.2rem;
}

/* Lobby (vente-rom) */
.lobby-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.lobby-player-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
}

.lobby-player-list li {
  padding: 6px 10px;
  border-radius: 6px;
  background: #f1f5f9;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.lobby-count {
  font-size: 0.85rem;
  color: #64748b;
  margin: 4px 0;
}

.lobby-msg {
  font-size: 0.9rem;
  color: #475569;
  margin: 6px 0 12px;
}

/* N-spiller match — spillerkort */
.match-players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.match-player-card {
  flex: 1 1 120px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  text-align: center;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.match-player-card.is-me {
  border-color: var(--primary);
}

.match-player-card.is-current-turn {
  border-color: #16a34a;
  background: #dcfce7;
}

.match-player-card.is-me.is-current-turn {
  border-color: var(--primary);
  background: #ecfdf5;
}

.mpc-name {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mpc-badges {
  display: block;
  font-size: 0.85rem;
  color: #475569;
}

.turn-indicator {
  text-align: center;
  font-weight: 700;
  padding: 10px;
  border-radius: 8px;
  margin: 12px 0;
}

.turn-indicator.my-turn {
  background: #dcfce7;
  color: #166534;
}

.turn-indicator.their-turn {
  background: #fef3c7;
  color: #92400e;
}

#lobbyLeaderboard {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

#leaderboardList {
  list-style: decimal;
  padding-left: 24px;
}

#leaderboardList li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed #e5e7eb;
}

.lb-name {
  font-weight: 600;
}

.lb-elo {
  color: var(--primary);
  font-weight: 700;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 6px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

.queue-message {
  margin-top: 10px;
  color: #b45309;
  font-size: 0.9rem;
  text-align: center;
}
