:root {
  --bg: #2b0f5c;
  --bg-2: #46178f;
  --card: #ffffff;
  --ink: #1b0b3a;
  --muted: #6b6280;
  --line: #e6e1f0;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --pending: #d6d0e2;
  --radius: 14px;
  --shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: #fff;
  background: radial-gradient(circle at 20% 0%, var(--bg-2), var(--bg) 60%) fixed;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}

button, input, select { font: inherit; }

.hidden { display: none !important; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
}

.center { justify-content: center; }

.logo {
  font-weight: 900;
  font-size: clamp(28px, 7vw, 56px);
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 24px;
  line-height: 1.05;
}
.logo small {
  display: block;
  font-size: 0.35em;
  font-weight: 700;
  opacity: 0.75;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 6px;
}

.panel {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.panel input {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  color: var(--ink);
}
.panel input:focus { outline: none; border-color: var(--bg-2); }

.btn {
  display: inline-block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 14px 18px;
  font-weight: 800;
  font-size: 18px;
  cursor: pointer;
  color: #fff;
  background: #333;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.05s;
  text-decoration: none;
  text-align: center;
}
.btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-dark { background: var(--ink); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-blue { background: var(--blue); }
.btn-ghost { background: rgba(255, 255, 255, 0.15); box-shadow: none; }
.btn-sm { padding: 10px 14px; font-size: 15px; width: auto; }

.error { color: var(--red); font-weight: 700; min-height: 1.2em; margin: 8px 0 0; text-align: center; }

.link { color: #fff; opacity: 0.8; margin-top: 20px; font-weight: 600; }

.muted { opacity: 0.75; }

/* ---------- Leikmaður ---------- */

.wait-name {
  font-size: 32px;
  font-weight: 900;
  margin: 8px 0;
  text-align: center;
  word-break: break-word;
}

.spinner {
  width: 44px; height: 44px;
  border: 5px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.topbar {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar .me { font-weight: 800; font-size: 18px; }
.score-pill {
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 18px;
  white-space: nowrap;
}

.progress {
  width: 100%;
  max-width: 560px;
  height: 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress > div { height: 100%; background: #3ddc84; transition: width 0.4s; }

.missions {
  width: 100%;
  max-width: 560px;
  display: grid;
  gap: 12px;
}

.mission {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-left: 10px solid var(--c, var(--blue));
}
.mission:nth-child(4n + 1) { --c: var(--red); }
.mission:nth-child(4n + 2) { --c: var(--blue); }
.mission:nth-child(4n + 3) { --c: var(--yellow); }
.mission:nth-child(4n + 4) { --c: var(--green); }

.mission-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
  user-select: none;
}
.mission-num {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-weight: 900;
  display: grid;
  place-items: center;
}
.mission-text { font-weight: 700; font-size: 17px; line-height: 1.35; flex: 1; }
.mission-text.secret { filter: blur(7px); }
.mission-hint { font-size: 12px; color: var(--muted); font-weight: 600; }

.mission-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 16px;
}
.mission-actions .btn { font-size: 16px; padding: 12px 8px; }

.mission.done { border-left-color: var(--green); }
.mission.got { border-left-color: var(--red); opacity: 0.7; }
.mission.done .mission-num { background: var(--green); }
.mission.got .mission-num { background: var(--red); }
.mission.got .mission-text { text-decoration: line-through; }
.badge {
  flex: none;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
}
.badge.done { background: var(--green); }
.badge.got { background: var(--red); }

.section-title {
  width: 100%;
  max-width: 560px;
  font-weight: 800;
  margin: 26px 0 10px;
  opacity: 0.85;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.mini-board {
  width: 100%;
  max-width: 560px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  padding: 8px 14px;
}
.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 700;
}
.mini-row:last-child { border-bottom: 0; }
.mini-row.me { color: #ffe066; }
.mini-row.out { opacity: 0.45; }

.dots { display: flex; gap: 4px; flex: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }
.dot.done { background: #3ddc84; }
.dot.got { background: #ff5d73; }

/* ---------- Gluggi (staðfesting) ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 0, 30, 0.7);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 10;
}
.modal .panel { max-width: 420px; text-align: center; }
.modal h3 { margin: 0 0 8px; font-size: 22px; }
.modal p { margin: 0 0 18px; color: var(--muted); font-weight: 600; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- Úrslit ---------- */

.trophy { font-size: 84px; line-height: 1; margin: 10px 0; animation: pop 0.6s ease-out; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.winner-name {
  font-size: clamp(32px, 9vw, 80px);
  font-weight: 900;
  text-align: center;
  margin: 4px 0 16px;
  word-break: break-word;
}

/* ---------- Hýsill ---------- */

.host { max-width: 1200px; margin: 0 auto; padding: 24px; }

.join-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 20px 28px;
  box-shadow: var(--shadow);
}
.join-bar .label { font-weight: 700; color: var(--muted); font-size: 18px; }
.join-bar .url { font-weight: 900; font-size: clamp(20px, 3vw, 34px); word-break: break-all; }
.join-bar .pin { font-weight: 900; font-size: clamp(48px, 8vw, 96px); letter-spacing: 0.06em; line-height: 1; }
.join-bar img { width: 180px; height: 180px; display: block; }

.lobby-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 16px;
  flex-wrap: wrap;
}
.count {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 900;
  font-size: 22px;
}
.settings { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-weight: 700; }
.settings select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 0;
  font-weight: 800;
  color: var(--ink);
}

.chips { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 12px; }
.chip {
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  font-size: 22px;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  animation: pop 0.35s ease-out;
  border: 0;
}
.chip:hover { text-decoration: line-through; }
.chip.off { opacity: 0.5; }

.empty { text-align: center; opacity: 0.7; font-weight: 700; font-size: 22px; margin-top: 48px; }

.game-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-top: 20px; }
@media (max-width: 800px) {
  .game-grid { grid-template-columns: 1fr; }
  .join-bar { grid-template-columns: 1fr; text-align: center; }
  .join-bar img { margin: 0 auto; }
}

.board { display: grid; gap: 10px; }
.board-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  gap: 14px;
  align-items: center;
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 20px;
}
.board-row .rank { font-weight: 900; color: var(--muted); }
.board-row .score { font-size: 24px; font-weight: 900; min-width: 56px; text-align: right; }
.board-row.out { opacity: 0.5; }
.board-row .dots .dot { width: 18px; height: 18px; background: var(--pending); }
.board-row .dots .dot.done { background: var(--green); }
.board-row .dots .dot.got { background: var(--red); }
.board-row .offline { font-size: 13px; color: var(--muted); font-weight: 700; margin-left: 6px; }

.feed { background: rgba(0, 0, 0, 0.25); border-radius: var(--radius); padding: 14px; max-height: 70vh; overflow: auto; }
.feed h3 { margin: 0 0 10px; }
.feed-item { padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.1); font-weight: 700; animation: pop 0.3s ease-out; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .m { font-weight: 500; opacity: 0.8; font-size: 14px; margin-top: 4px; }
.feed-item.done::before { content: '✅ '; }
.feed-item.got::before { content: '😬 '; }

.host-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.host-actions .btn { width: auto; min-width: 180px; }

.rules { max-width: 560px; width: 100%; margin-top: 20px; }
.rules summary { cursor: pointer; font-weight: 800; }
.rules ol { padding-left: 20px; line-height: 1.5; }
