:root {
  --phos: #39ff88;
  --dim: #8fe0b0; /* secondary text: 12.7:1 on --bg (the old 50 % green was 4.3:1) */
  --bg: #060b08;
  --panel: #0e1512;
  --line: #1e2a22;
  --amber: #ffb03a;
  --red: #ff4d4d;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--phos);
  font: 15px/1.6 var(--mono);
  -webkit-text-size-adjust: 100%;
}

body {
  padding: max(1rem, env(safe-area-inset-top)) 1rem
           max(1rem, env(safe-area-inset-bottom));
  max-width: 60rem;
  margin: 0 auto;
}

h1, h2, h3 {
  margin: 0 0 .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 { font-size: 1.4rem; }
h2 { font-size: .95rem; color: var(--dim); margin-top: 1.8rem;
     border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
h3 { font-size: .8rem; }

a { color: var(--phos); }
.sub { color: var(--dim); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; }
.hint { color: var(--dim); font-size: .75rem; line-height: 1.6; }
.err { color: var(--red); font-size: .8rem; min-height: 1.2em; }
.ok { color: var(--phos); }

nav { display: flex; gap: .5rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
nav a {
  padding: .45rem .8rem; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .08em; text-decoration: none;
  border: 1px solid var(--line); border-radius: 3px;
}
nav a.active { background: var(--phos); color: var(--bg); border-color: var(--phos); }

label { display: block; font-size: .7rem; text-transform: uppercase;
        letter-spacing: .08em; color: var(--dim); margin-top: .7rem; }
input, select {
  width: 100%; margin-top: .25rem; padding: .7rem;
  font: inherit; font-size: 1rem; color: var(--phos);
  background: #0a100d; border: 1px solid var(--line); border-radius: 3px;
}
input:focus, select:focus { outline: none; border-color: var(--phos); }

button {
  padding: .7rem 1rem; font: inherit; font-size: .85rem;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--bg); background: var(--phos);
  border: none; border-radius: 3px; cursor: pointer;
}
button.ghost { color: var(--phos); background: transparent; border: 1px solid var(--line); }
button.danger { color: var(--red); background: transparent; border: 1px solid var(--red); }
button.small { padding: .35rem .6rem; font-size: .7rem; }
button:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; }

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

/* leaderboard */
.standings { display: flex; flex-direction: column; gap: .5rem; }
.standing {
  display: grid; grid-template-columns: 2.5rem 1fr auto;
  gap: .8rem; align-items: center;
  padding: .9rem 1rem; border-left: 4px solid; border-radius: 3px;
  background: var(--panel);
}
.standing .pos { font-size: 1.4rem; font-weight: 700; text-align: center; color: var(--dim); }
.standing.first .pos { color: var(--amber); }
.standing .who { min-width: 0; }
.standing .tname { font-weight: 700; letter-spacing: .05em; }
.standing .roster { color: var(--dim); font-size: .7rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing .pts { text-align: right; }
.standing .pts b { font-size: 1.5rem; }
.standing .pts span { display: block; color: var(--dim); font-size: .65rem;
  text-transform: uppercase; letter-spacing: .08em; }

table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--dim); font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: .1rem .45rem; border-radius: 10px;
        font-size: .65rem; border: 1px solid currentColor; }
.pwd { font-family: var(--mono); background: #0a100d; padding: .15rem .4rem;
       border-radius: 3px; border: 1px solid var(--line); user-select: all; }

.games { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.game-card { display: block; padding: 1rem; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.game-card.live { border-color: var(--phos); }
.game-card .gname { font-weight: 700; letter-spacing: .05em; }
.game-card .gmeta { color: var(--dim); font-size: .7rem; margin-top: .2rem; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--phos); color: var(--bg); padding: .6rem 1rem;
  border-radius: 3px; font-size: .8rem; z-index: 50; max-width: 90vw;
}

/* --- herd --- */
.question { background: var(--panel); border: 1px solid var(--line);
  border-radius: 4px; padding: 1rem; margin-bottom: .8rem; }
.question.done { border-color: var(--dim); }
.question h3 { text-transform: none; letter-spacing: .02em; font-size: .95rem; }
.question .qn { color: var(--dim); margin-right: .4rem; }

.options { display: grid; gap: .35rem; }
.options label {
  display: flex; align-items: center; gap: .6rem; margin: 0;
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 3px;
  font-size: .9rem; text-transform: none; letter-spacing: 0; color: var(--phos);
  cursor: pointer;
}
.options input { width: auto; margin: 0; accent-color: var(--phos); }
.options label:has(input:checked) { border-color: var(--phos); background: #0f2118; }
/* A sent answer is locked: make the pick unmistakable and fade the rest. */
.options.locked label { cursor: default; }
.options.locked label:not(:has(input:checked)) { opacity: .4; }
.options.locked label:has(input:checked) {
  border-color: var(--amber); background: #221c0a; color: var(--amber); font-weight: 700; }
.options.locked input { accent-color: var(--amber); }
.options.locked label:has(input:checked)::after {
  content: '✓ ditt svar'; margin-left: auto; font-size: .75rem; white-space: nowrap; }

.sticky { position: sticky; bottom: 0; padding: .8rem 0;
  background: linear-gradient(transparent, var(--bg) 35%); }
.sticky button { width: 100%; padding: 1rem; font-size: 1rem; }

.big { font-size: 2.4rem; font-weight: 700; line-height: 1.1; }
.meter { height: .6rem; background: var(--line); border-radius: 3px; overflow: hidden; margin: .4rem 0; }
.meter > div { height: 100%; background: var(--phos); transition: width .4s; }

.bar { position: relative; display: grid; grid-template-columns: 1fr 2.2rem 2.4rem;
  gap: .4rem; align-items: center; padding: .3rem .5rem; margin-bottom: .2rem;
  border-radius: 3px; font-size: .8rem; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: #123522; z-index: 0; }
.bar > span { position: relative; z-index: 1; }
.bar .n, .bar .pts { text-align: right; font-variant-numeric: tabular-nums; }
.bar .pts.plus { color: var(--phos); font-weight: 700; }
.bar .pts.minus { color: var(--red); }
.bar.empty { color: var(--dim); opacity: .6; }
.bar.mine { outline: 1px solid var(--amber); }
.bar.mine .opt::after { content: '  ← du'; color: var(--amber); }

.team-row { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem;
  padding: .6rem .8rem; border-left: 4px solid; background: var(--panel);
  border-radius: 3px; margin-bottom: .4rem; }
.team-row .tname { font-weight: 700; }
.team-row .who { grid-column: 1 / -1; font-size: .7rem; color: var(--dim); }
.team-row .who .yes { color: var(--phos); }
.admin-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0; }
.cols { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); }
