:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7280;
  --line: #e2ddd2;
  --accent: #1f4fd8;
  --accent-ink: #ffffff;
  --win: #14804a;
  --win-bg: #e3f5ea;
  --danger: #b42318;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 16px; text-wrap: balance; }
h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  font-weight: 600;
  touch-action: manipulation;
}
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--danger); }
button.small { min-height: 38px; padding: 6px 10px; font-size: .9rem; }

input[type="text"], input[type="password"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
input:focus-visible, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .grow { flex: 1 1 auto; }

/* ---------- Deltager ---------- */

.voter main { display: flex; flex-direction: column; min-height: 100dvh; justify-content: center; }

.options { display: grid; gap: 12px; }

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 14px 16px;
  text-align: left;
  font-size: 1.1rem;
  border-width: 2px;
  border-radius: var(--radius);
}
.option .badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  font-weight: 700;
}
.option .label { flex: 1; overflow-wrap: anywhere; }
.option .tag { flex: none; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.option.mine { border-color: var(--accent); }
.option.mine .badge { background: var(--accent); color: var(--accent-ink); }
.option.mine .tag { color: var(--accent); }
.option.winner { border-color: var(--win); background: var(--win-bg); opacity: 1; }
.option.winner .badge { background: var(--win); color: #fff; }
.option.winner .tag { color: var(--win); }
.option.dim { opacity: .4; }

.status { margin-top: 18px; text-align: center; color: var(--muted); min-height: 1.4em; }

.waiting { text-align: center; }
.pulse {
  width: 14px; height: 14px; margin: 0 auto 18px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.8); opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* ---------- Admin ---------- */

.phase {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
  background: var(--bg);
  margin-bottom: 10px;
}
.phase.voting { background: #e2eafc; color: var(--accent); }
.phase.results { background: var(--win-bg); color: var(--win); }

.tally { display: grid; gap: 8px; margin: 12px 0 14px; }
.tally-row { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tally-row .bar { position: absolute; inset: 0 auto 0 0; background: #e2eafc; transition: width .3s; }
.tally-row.winner .bar { background: var(--win-bg); }
.tally-row .text { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; }
.tally-row .text span:first-child { overflow-wrap: anywhere; }
.tally-row .text b { font-variant-numeric: tabular-nums; }

.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.queue li { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.title { font-weight: 600; }
.queue .title { font-weight: 600; overflow-wrap: anywhere; }
.queue .opts { color: var(--muted); font-size: .9rem; margin: 2px 0 10px; overflow-wrap: anywhere; }

.editor { display: grid; gap: 8px; }
.editor label { font-size: .85rem; color: var(--muted); }

.warn { background: #fff4e5; border-color: #f5c98a; }
.error { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; }

.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; align-content: center; gap: 16px;
  padding: 24px; background: #fff; text-align: center;
}
#qr img, #qr canvas { width: min(78vw, 360px); height: auto; }
.url { overflow-wrap: anywhere; font-weight: 600; }
