/* Tre gäddor och en sill – gemensam stil för värdskärm och telefon */
:root {
  --bg: #061a2e;
  --bg2: #0b2b47;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.14);
  --text: #eef5fb;
  --muted: #9db4c8;
  --gold: #f5c542;
  --gold-dark: #b8891a;
  --green: #2ecc71;
  --red: #e74c3c;
  --blue: #3498db;
  --yellow: #f1c40f;
  --opt-a: #d64541;
  --opt-b: #2f7dd1;
  --opt-c: #d9a406;
  --opt-d: #27a35a;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #12406a 0%, var(--bg2) 40%, var(--bg) 100%);
  color: var(--text);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,.15), transparent 60%),
    radial-gradient(2px 2px at 70% 60%, rgba(255,255,255,.12), transparent 60%),
    radial-gradient(3px 3px at 40% 80%, rgba(255,255,255,.08), transparent 60%);
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 4vw, 3rem); }
p { margin: .3em 0; }
a { color: var(--gold); }
button, input, select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: .75em 1.2em;
  background: var(--panel-strong);
  color: var(--text);
  transition: transform .08s ease, background .15s ease, opacity .15s;
}
button:hover { background: rgba(255,255,255,.18); }
button:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button.primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
  color: #2b1d02;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(245, 197, 66, .3);
}
button.primary:hover { filter: brightness(1.06); background: linear-gradient(180deg, var(--gold), var(--gold-dark)); }
button.danger { background: rgba(231, 76, 60, .25); }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.big { font-size: 1.25rem; padding: .9em 1.6em; border-radius: 16px; }
input[type=text], input[type=number], select {
  width: 100%;
  padding: .8em 1em;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  color: var(--text);
  outline: none;
}
input[type=text]:focus, input[type=number]:focus { border-color: var(--gold); }
input[type=range] { width: 100%; accent-color: var(--gold); }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.center { text-align: center; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  backdrop-filter: blur(6px);
}
.chip {
  display: inline-flex; align-items: center; gap: .35em;
  padding: .3em .8em; border-radius: 999px;
  background: var(--panel-strong); font-size: .85rem; font-weight: 600;
  white-space: nowrap;
}
.chip.gold { background: var(--gold); color: #2b1d02; }
.chip.green { background: var(--green); color: #05270f; }
.chip.red { background: var(--red); color: #fff; }
.avatar { font-size: 1.4em; line-height: 1; }
.hidden, [hidden] { display: none !important; }
.fade-in { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop .4s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.pulse { animation: pulse 1.2s ease-in-out infinite; }

/* Timer */
.timer {
  position: relative; height: 12px; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,.35);
}
.timer > .bar {
  position: absolute; inset: 0; transform-origin: left;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: transform .25s linear;
}
.timer.low > .bar { background: linear-gradient(90deg, var(--red), #ff8a65); }
.timer-num { font-variant-numeric: tabular-nums; font-weight: 800; }

/* Svarsalternativ */
.options { display: grid; gap: .8rem; grid-template-columns: 1fr 1fr; }
.option {
  display: flex; align-items: center; gap: .8rem;
  padding: 1rem 1.1rem; border-radius: 14px; min-height: 4.2rem;
  font-size: 1.15rem; font-weight: 600; text-align: left; color: #fff;
  box-shadow: var(--shadow);
}
.option .sym { font-size: 1.3em; width: 1.4em; text-align: center; flex: 0 0 auto; }
.option.a { background: var(--opt-a); }
.option.b { background: var(--opt-b); }
.option.c { background: var(--opt-c); }
.option.d { background: var(--opt-d); }
.option.dim { opacity: .35; filter: grayscale(.5); }
.option.correct { outline: 4px solid #fff; box-shadow: 0 0 0 8px rgba(46, 204, 113, .45); }
.option.mine { outline: 3px dashed rgba(255,255,255,.9); }
.option:hover { filter: brightness(1.08); }
.option:disabled { opacity: .7; }
@media (max-width: 520px) { .options { grid-template-columns: 1fr; } .option { font-size: 1.05rem; min-height: 3.6rem; } }

/* Media */
.media { display: flex; justify-content: center; margin: .6rem 0; }
.media img, .media video { max-width: 100%; max-height: 46vh; border-radius: 14px; box-shadow: var(--shadow); background: #000; }
.media audio { width: min(100%, 520px); }
.media iframe { width: min(100%, 720px); aspect-ratio: 16/9; border: 0; border-radius: 14px; box-shadow: var(--shadow); }
.media .audio-box {
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  padding: 1.2rem 2rem; border-radius: 14px; background: rgba(0,0,0,.3);
}
.media .audio-box .note { font-size: 3rem; }

/* Listor */
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.plist li {
  display: flex; align-items: center; gap: .8rem;
  padding: .6rem .9rem; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line);
}
.plist .name { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .score { font-variant-numeric: tabular-nums; font-weight: 800; }
.plist li.me { border-color: var(--gold); background: rgba(245,197,66,.12); }
.plist li.off { opacity: .5; }
.plist .rank { width: 2em; text-align: center; font-weight: 800; color: var(--muted); }
.plist .rank.r1 { color: var(--gold); }
.plist .bar { height: 6px; border-radius: 999px; background: var(--gold); opacity: .8; }
.delta { color: var(--green); font-weight: 700; font-variant-numeric: tabular-nums; }
.tag-correct { color: var(--green); font-weight: 800; }
.tag-wrong { color: var(--red); font-weight: 800; }
.answer-value { color: var(--muted); font-size: .9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }

/* Podium */
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem; align-items: end; margin: 1rem auto; max-width: 760px; }
.podium .spot { text-align: center; border-radius: 16px 16px 0 0; padding: 1rem .5rem; background: var(--panel-strong); }
.podium .spot .av { font-size: 2.6rem; }
.podium .spot .nm { font-weight: 800; font-size: 1.1rem; }
.podium .spot .sc { color: var(--muted); font-variant-numeric: tabular-nums; }
.podium .p1 { background: linear-gradient(180deg, rgba(245,197,66,.55), rgba(245,197,66,.2)); min-height: 200px; }
.podium .p2 { background: linear-gradient(180deg, rgba(200,200,210,.45), rgba(200,200,210,.15)); min-height: 150px; }
.podium .p3 { background: linear-gradient(180deg, rgba(205,127,50,.45), rgba(205,127,50,.15)); min-height: 120px; }
.trophy { font-size: clamp(3rem, 10vw, 6rem); animation: pulse 2s ease-in-out infinite; }

/* Frågestorlekar */
.qtext { font-size: clamp(1.3rem, 3.2vw, 2.4rem); font-weight: 700; text-wrap: balance; }
.qsmall { font-size: 1.05rem; font-weight: 600; }
.bigscore { font-size: clamp(2.5rem, 12vw, 5rem); font-weight: 900; line-height: 1; }
.feedback { border-radius: 20px; padding: 1.5rem 1rem; text-align: center; }
.feedback.ok { background: rgba(46,204,113,.2); border: 2px solid var(--green); }
.feedback.bad { background: rgba(231,76,60,.18); border: 2px solid var(--red); }
.feedback.neutral { background: var(--panel); border: 2px solid var(--line); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: #1c1c1c; color: #fff; padding: .7em 1.2em; border-radius: 999px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50;
}
.toast.show { opacity: 1; }
.conn { position: fixed; top: .6rem; right: .8rem; font-size: .75rem; color: var(--muted); z-index: 40; }
.conn.bad { color: var(--red); font-weight: 700; }
