:root {
  /* Vår egen palett: midnattsblå vinternatt + varm gull */
  --bg-1: #16212f;
  --bg-2: #0e1721;
  --bg-3: #090f16;
  --surface: #131d2b;
  --holly: #243447;
  --gold-hi: #eccb85;
  --gold: #cfa757;
  --gold-dark: #8a6c2c;
  --cream: #f1ebdd;
  --cream-dim: rgba(241, 235, 221, .62);
  --ink: #0b1119;
  --red: #c24938;
  --green: #4a9e74;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: #090f16; /* mørk overscroll-bakgrunn (bounce-effekten på mobil) */
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: radial-gradient(120% 80% at 50% -10%, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  color: var(--cream);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
header { text-align: center; padding: 2.4rem 1rem 1.2rem; }

h1 {
  font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
  font-size: clamp(2.8rem, 9vw, 4.4rem);
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--cream);
  line-height: .95;
  text-shadow: 0 4px 24px rgba(0, 0, 0, .4);
}

.tagline { color: var(--cream-dim); margin-top: .5rem; font-size: 1.05rem; }
.tagline em { color: var(--gold-hi); font-style: normal; font-weight: 700; }

/* Nedtelling */
.banner { display: block; text-align: center; margin-top: 1rem; }
.count-caption {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--cream-dim);
}
.countdown {
  display: flex;
  justify-content: center;
  gap: .8rem;
  margin-top: .6rem;
}
header .header-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1rem;
}
header .header-buttons .notify-btn { margin: 0; }
.countdown span {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  color: var(--gold);
  background: rgba(207, 167, 87, .07);
  border: 1px solid rgba(207, 167, 87, .22);
  border-radius: 12px;
  padding: .6rem .9rem .3rem;
  min-width: 3.6rem;
  line-height: 1;
}
.countdown small {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--cream-dim);
  text-shadow: none;
  margin-top: .3rem;
}

/* Varsel/install-knapper */
header .notify-btn { margin: .4rem .2rem 0; }

.notify-btn {
  font-weight: 600;
  font-size: .95rem;
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 10px;
  padding: .6rem 1.2rem;
  cursor: pointer;
  transition: opacity .12s ease;
}
.notify-btn:hover { opacity: .9; }
.notify-btn:disabled {
  background: var(--surface);
  color: var(--cream-dim);
  box-shadow: none;
  cursor: default;
  filter: none;
  transform: none;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  justify-content: center;
  gap: .45rem;
  padding: 1.1rem .8rem;
}

.tab {
  background: var(--surface);
  color: var(--cream-dim);
  border: 1px solid var(--holly);
  border-radius: 10px;
  padding: .6rem .9rem;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  flex: 1 1 0;
  max-width: 150px;
}
.tab:hover { border-color: rgba(207, 167, 87, .38); color: var(--cream); }
.tab.active {
  background: rgba(207, 167, 87, .15);
  border-color: rgba(207, 167, 87, .42);
  color: var(--gold);
}

/* ---------- Layout ---------- */
main {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 0 1rem 2.5rem;
  flex: 1;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }

h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  letter-spacing: .05em;
  font-weight: 400;
  margin: 1.6rem 0 .7rem;
  color: var(--cream);
}
h3 { margin: 1rem 0 .5rem; }

/* ---------- Dager-siden-wham ---------- */
.days-without {
  text-align: center;
  background: rgba(207, 167, 87, .07);
  border: 1px solid rgba(207, 167, 87, .22);
  border-radius: var(--radius);
  padding: .9rem;
  font-size: 1.1rem;
  font-weight: 700;
}
.days-without small { display: block; color: var(--cream-dim); font-weight: 400; font-size: .8rem; }

/* ---------- Deltakerkort ---------- */
.card-list { display: flex; flex-direction: column; gap: .55rem; }

.person {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--surface);
  border: 1px solid var(--holly);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  padding: .75rem .95rem;
  transition: transform .12s ease;
}
.person:hover { transform: translateY(-1px); }

.person.out { border-left-color: var(--red); }
.person.out .info { opacity: .6; }
.person.out img.avatar { filter: grayscale(90%); }

.person.self { border-left-color: var(--gold); box-shadow: 0 0 0 1px rgba(207, 167, 87, .45); }

.person img.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-3);
  border: 2px solid var(--holly);
  flex-shrink: 0;
}

.person .info { flex: 1; min-width: 0; }
.person .name { font-weight: 700; font-size: 1.02rem; }
.person .details { font-size: .83rem; color: var(--cream-dim); margin-top: .1rem; }

.person .badge {
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: rgba(63, 155, 109, .14);
  color: var(--green);
  border: 1px solid rgba(63, 155, 109, .4);
  border-radius: 999px;
  padding: .28rem .7rem;
  white-space: nowrap;
}
.person.out .badge {
  background: rgba(194, 73, 56, .14);
  color: var(--red);
  border-color: rgba(194, 73, 56, .4);
}

.person img.proof-thumb {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  cursor: zoom-in;
  flex-shrink: 0;
}

.rank { font-weight: 800; color: var(--gold); width: 1.8rem; text-align: center; flex-shrink: 0; }

/* Wham-fanen i menyen får rød aksent */
.tab[data-tab="wham"] {
  border-color: rgba(194, 73, 56, .5);
  color: #e8a39a;
}
.tab[data-tab="wham"].active {
  background: rgba(194, 73, 56, .18);
  border-color: rgba(194, 73, 56, .6);
  color: #fff;
}

/* ---------- Bobler (deltakere i live) ---------- */
.bubble-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.bubble {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  background: var(--surface);
  border: 1px solid var(--holly);
  border-radius: 999px;
  padding: .35rem .95rem .35rem .35rem;
  transition: transform .12s ease, border-color .12s ease;
}
.bubble:hover { transform: translateY(-1px); border-color: rgba(207, 167, 87, .35); }
.bubble.self { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(207, 167, 87, .3); }
.bubble-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-3);
  flex-shrink: 0;
}
.bubble-avatar.avatar-fallback {
  width: 36px;
  height: 36px;
  font-size: .85rem;
}
.bubble-name { font-weight: 700; font-size: .95rem; }

/* ---------- Skillelinje ---------- */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0 .9rem;
  color: var(--cream-dim);
  font-weight: 800;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .14em;
}
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--holly); }

/* ---------- Identitetskort ---------- */
.identity-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--surface);
  border: 1px solid rgba(207, 167, 87, .38);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
}
.identity-card img {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-3);
}
.identity-card .who { flex: 1; }
.identity-card .who strong { display: block; font-size: 1.05rem; }
.identity-card .who small { color: var(--cream-dim); }
.identity-card button {
  background: none;
  border: 1px solid var(--holly);
  border-radius: 999px;
  color: var(--cream-dim);
  padding: .4rem .8rem;
  font-size: .8rem;
  cursor: pointer;
}

/* Genererte initial-avatarer */
.avatar-fallback {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, .95);
  flex-shrink: 0;
}
.identity-avatar.avatar-fallback { width: 52px; height: 52px; font-size: 1rem; }
.person.out .avatar-fallback { filter: grayscale(70%); opacity: .8; }

/* ---------- Trofé & Hall of Fame ---------- */
.trophy {
  background: var(--surface);
  border: 1px solid rgba(207, 167, 87, .3);
  border-radius: var(--radius);
  padding: 1.2rem;
  text-align: center;
}
.trophy h2 { margin-top: 0; }
.trophy-photos { display: flex; gap: .9rem; justify-content: center; margin-top: 1rem; }
.trophy-photos img {
  width: 44%;
  max-width: 240px;
  border-radius: 12px;
  border: 1px solid var(--holly);
  cursor: zoom-in;
  transition: transform .15s ease;
}
.trophy-photos img:hover { transform: scale(1.03); }

.hall-of-fame { display: flex; flex-direction: column; gap: .5rem; }
.hof-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid rgba(207, 167, 87, .3);
  border-radius: var(--radius);
  padding: .8rem 1rem;
}
.hof-year { color: var(--gold); font-weight: 800; font-size: .95rem; font-family: 'Bebas Neue', sans-serif; font-size: 1.15rem; letter-spacing: .05em; }
.hof-name { flex: 1; font-weight: 600; }
.hof-emoji { font-size: 1.1rem; }

/* ---------- Regler ---------- */
.rules-list { list-style: none; display: flex; flex-direction: column; }
.rules-list li {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: 1rem 0;
  border-top: 1px solid var(--holly);
  line-height: 1.55;
}
.rules-list li:first-child { border-top: none; }
.regel-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.4rem;
  color: var(--gold);
  line-height: 1;
  min-width: 3rem;
  flex-shrink: 0;
}
.regel-text { flex: 1; }

/* ---------- Sudden Death ---------- */
.sd-panel {
  background: linear-gradient(160deg, rgba(194, 73, 56, .18), transparent 55%), var(--surface);
  border: 1px solid rgba(194, 73, 56, .55);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  margin: .8rem 0 1rem;
  text-align: center;
}
.sd-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  letter-spacing: .08em;
  color: var(--red);
}
.sd-sub { color: var(--cream-dim); font-size: .9rem; margin-top: .3rem; }
.sd-alive { color: var(--gold); font-weight: 700; margin-top: .55rem; font-size: .95rem; }
.sd-draw {
  margin-top: .9rem;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: .9rem 2rem;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
  transition: transform .1s ease, opacity .12s ease;
}
.sd-draw:hover { opacity: .92; }
.sd-draw:active { transform: scale(.97); }
.sd-login {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  max-width: 320px;
  margin: .9rem auto 0;
}
.sd-log {
  margin-top: 1rem;
  text-align: left;
  background: var(--bg-3);
  border: 1px solid var(--holly);
  border-radius: 10px;
  padding: .7rem .9rem;
  max-height: 180px;
  overflow-y: auto;
}
.sd-log-row { font-size: .82rem; color: var(--cream-dim); padding: .15rem 0; }
.sd-log-row.sd-lc { color: var(--red); font-weight: 700; }

/* Avsløringskortet */
.sd-card {
  background: var(--bg-3);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.4rem 1rem;
  text-align: center;
  animation: sd-flip .5s ease;
}
.sd-card.sd-card-lc { border-color: var(--red); background: rgba(194, 73, 56, .12); }
@keyframes sd-flip { from { transform: scale(.9) rotateX(40deg); opacity: 0; } to { transform: none; opacity: 1; } }
.sd-card-artist { color: var(--cream-dim); font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; }
.sd-card-title { font-family: 'Bebas Neue', sans-serif; font-size: 2rem; margin-top: .25rem; }
.sd-card-result { color: var(--red); font-weight: 800; margin-top: .6rem; font-size: 1.1rem; }
.sd-card-safe { color: var(--green); font-weight: 700; margin-top: .6rem; }
.sd-winner {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.7rem;
  color: var(--gold);
}

/* ---------- Statistikk ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--holly);
  border-radius: var(--radius);
  padding: .9rem .5rem;
  text-align: center;
}
.stat-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.1rem;
  color: var(--gold);
  line-height: 1;
}
.stat-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--cream-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: .25rem;
}
.stat-bar-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: .5rem;
}
.stat-bar-label { min-width: 7.5rem; font-weight: 600; font-size: .9rem; }
.stat-bar-track {
  flex: 1;
  height: 22px;
  background: var(--surface);
  border: 1px solid var(--holly);
  border-radius: 999px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  border-radius: 999px;
}
.stat-bar-count { min-width: 2rem; text-align: right; font-weight: 800; color: var(--gold); }
.quirk-card {
  background: var(--surface);
  border: 1px solid var(--holly);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin-top: .6rem;
  font-size: .92rem;
}

/* ---------- Når-valg (chips) ---------- */
.when-options { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip {
  background: var(--surface);
  border: 1px solid var(--holly);
  border-radius: 999px;
  padding: .5rem 1rem;
  font-size: .9rem;
  font-weight: 700;
  color: var(--cream-dim);
  cursor: pointer;
  flex-direction: row;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.chip:has(input:checked) {
  background: rgba(207, 167, 87, .15);
  border-color: rgba(207, 167, 87, .45);
  color: var(--gold);
}
#when-custom { display: flex; gap: .5rem; }
#when-custom.hidden { display: none; }
#when-custom input { flex: 1; }

/* ---------- Snarvei til innlogging ---------- */
.shortcut {
  font-family: 'Inter', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--cream-dim);
  text-decoration: none;
  border-bottom: 1px dashed var(--holly);
}
.shortcut:hover { color: var(--gold); border-color: var(--gold); }

/* ---------- Skjema ---------- */
form { display: flex; flex-direction: column; gap: 1rem; margin-top: .5rem; }

label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: var(--cream-dim); }

input, textarea, select {
  background: var(--bg-3);
  color: var(--cream);
  border: 1px solid var(--holly);
  border-radius: 10px;
  padding: .8rem .9rem;
  font-size: 16px;
  font-family: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(207, 167, 87, .15);
}
select { cursor: pointer; }

button[type="submit"] {
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink);
  border: none;
  border-radius: 12px;
  padding: .95rem;
  cursor: pointer;
  transition: opacity .12s ease;
}
button[type="submit"]:hover { opacity: .9; }
button[type="submit"]:active { transform: scale(.98); }
button.danger {
  background: var(--red);
  color: #fff;
}

.form-message { min-height: 1.2rem; font-weight: 700; font-size: .95rem; }
.form-message.error { color: #ff9d94; }
.form-message.success { color: #a5e3be; }

.admin-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

.winner-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.winner-form input { flex: 1 1 110px; }
.winner-form button {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .7rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
}
.hof-del {
  background: none;
  border: 1px solid rgba(194, 73, 56, .45);
  border-radius: 8px;
  color: var(--red);
  padding: .3rem .6rem;
  font-size: .8rem;
  cursor: pointer;
}
.admin-actions button {
  border: 1px solid rgba(194, 73, 56, .45);
  border-radius: 8px;
  padding: .4rem .7rem;
  font-size: .8rem;
  cursor: pointer;
  background: rgba(194, 73, 56, .14);
  color: var(--red);
}

/* ---------- Konfetti ---------- */
.confetti {
  position: fixed;
  top: -12px;
  z-index: 9999;
  pointer-events: none;
  width: 10px;
  height: 14px;
  animation: confetti-fall 3s ease-in forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ---------- Diverse ---------- */
.hidden { display: none !important; }
.muted { color: var(--cream-dim); }

footer {
  text-align: center;
  padding: 1.2rem 1rem;
  color: var(--cream-dim);
  font-size: .78rem;
  opacity: .6;
  margin-top: auto;
}

/* ---------- Hall of Fame-bilde ---------- */
.hof-img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-3);
  flex-shrink: 0;
}
.hof-img.avatar-fallback { font-size: .85rem; width: 42px; height: 42px; }

.tab, button { touch-action: manipulation; }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  html { font-size: 18px; }
  main { max-width: 920px; }
  h1 { font-size: 5rem; }
  .countdown { gap: 1rem; }
  .countdown span { font-size: 3rem; padding: .8rem 1.3rem .55rem; min-width: 4.6rem; }
  .tab { font-size: 1rem; max-width: 190px; padding: .8rem 1.2rem; }
  .person { padding: 1rem 1.2rem; }
  .person img.avatar, .avatar-fallback { width: 64px; height: 64px; }
  .avatar-fallback { font-size: 1.3rem; }
  .bubble { padding: .5rem 1.2rem .5rem .5rem; }
  .bubble-avatar, .bubble-avatar.avatar-fallback { width: 42px; height: 42px; font-size: .95rem; }
  .bubble-name { font-size: 1.05rem; }
  button[type="submit"] { padding: 1.1rem; }
  input, textarea, select { padding: 1rem; font-size: 17px; }
  .panic-btn { padding: .9rem 2.4rem; font-size: 1.1rem; }
}

/* ---------- Mobil – responsiv tilpasning ---------- */
@media (max-width: 520px) {
  header { padding: 1.6rem .8rem .8rem; }

  /* Bunnmeny som en ekte app */
  .tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-3);
    border-top: 1px solid var(--holly);
    padding: .45rem .25rem calc(.45rem + env(safe-area-inset-bottom));
    gap: .15rem;
    z-index: 100;
    flex-wrap: nowrap;
  }
  .tab {
    flex: 1 1 0;
    max-width: none;
    font-size: .6rem;
    padding: .5rem .1rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
  }
  .tab.active { background: rgba(207, 167, 87, .15); border-color: rgba(207, 167, 87, .42); }
  main { padding-bottom: 5rem; }

  button[type="submit"] { padding: .95rem; }
  .person { padding: .75rem .8rem; }
  .person img.avatar, .avatar-fallback { width: 48px; height: 48px; }

  /* Nedtelling tilpasses */
  .countdown { gap: .45rem; }
  .countdown span { padding: .45rem .55rem .3rem; min-width: 2.7rem; font-size: 1.5rem; }

  h2 { font-size: 1.25rem; }

  /* Stat-kort tilpasser seg antall */
  .stat-cards { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: .4rem; }
  .stat-card { padding: .7rem .3rem; }
  .stat-num { font-size: 1.6rem; }
  .stat-label { font-size: .62rem; letter-spacing: .05em; }

  /* Bobler kompakt */
  .bubble { padding: .3rem .8rem .3rem .3rem; }
  .bubble-avatar, .bubble-avatar.avatar-fallback { width: 30px; height: 30px; font-size: .75rem; }
  .bubble-name { font-size: .88rem; }

  /* Stat-barer: label over baren på smale skjermer */
  .stat-bar-label { min-width: 5.2rem; font-size: .8rem; }

  .sd-title { font-size: 1.6rem; }
  .sd-card-title { font-size: 1.6rem; }
  .winner-form input { flex: 1 1 100%; }
}

/* Veldig smale (< 360px) */
@media (max-width: 360px) {
  .countdown span { min-width: 2.4rem; padding: .4rem .45rem .25rem; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
}
