/* ---------------------------------------------------------------------------
   Lugn, tydlig och touch-vänlig design.
   Stora knappar, mjuka färger, inga blinkande effekter (skön för autism/fokus).
--------------------------------------------------------------------------- */

* { box-sizing: border-box; }

:root {
  --bg: #f3f7fb;
  --kort: #ffffff;
  --bla: #5b9bd5;
  --bla-mork: #3f7cb5;
  --gron: #6cc070;
  --gron-mork: #4ca152;
  --gul: #ffd166;
  --amber: #f0a64a;
  --text: #2c3e50;
  --skugga: 0 6px 16px rgba(60, 90, 130, 0.15);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Skärmar */
.skarm {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
}
.skarm.aktiv { display: flex; }

/* ---------- HEM ---------- */
.hem-innehall {
  margin: auto;
  text-align: center;
  padding: 24px;
}
.hem-figur { font-size: 96px; line-height: 1; margin-bottom: 8px; }
#hem-hej { font-size: clamp(32px, 8vw, 56px); margin: 0 0 28px; }
.stjarn-rad { font-size: 28px; margin-top: 22px; font-weight: 700; color: var(--bla-mork); }

.klistermarken {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 420px;
  font-size: 34px;
}

/* Profilväljare (enkel inloggning) */
.profil-val {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}
.profil-knapp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 4px solid #d9e4ef;
  background: #fff;
  border-radius: 26px;
  padding: 26px 30px;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  box-shadow: var(--skugga);
  min-width: 140px;
}
.profil-knapp:active { transform: scale(0.96); }
.profil-avatar { font-size: 80px; line-height: 1; }

.byt-barn { right: auto; left: 14px; }

/* Barnets nivåväljare på startsidan */
.niva-val {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 4px 0 26px;
}
.niva-val button {
  border: 4px solid #d9e4ef;
  background: #fff;
  border-radius: 18px;
  padding: 14px 20px;
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  box-shadow: var(--skugga);
}
.niva-val button.vald { border-color: var(--gron); background: #eafaf0; }

.testa-rost-hem {
  margin-top: 20px;
  border: 3px solid var(--bla);
  background: #fff;
  color: var(--bla-mork);
  border-radius: 16px;
  padding: 12px 22px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: var(--skugga);
}
.version {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 12px;
  opacity: 0.4;
}

.vuxen-knapp {
  position: absolute;
  top: 14px; right: 14px;
  width: 52px; height: 52px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.7);
  font-size: 24px;
  box-shadow: var(--skugga);
}

/* ---------- Stora knappar ---------- */
.stor-knapp {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 12px auto;
  padding: 22px 28px;
  font-size: 28px;
  font-weight: 700;
  border: none;
  border-radius: 22px;
  color: #fff;
  box-shadow: var(--skugga);
  transition: transform 0.08s ease;
}
.stor-knapp:active { transform: scale(0.96); }
.stor-knapp.spela { background: var(--gron); }
.stor-knapp.lugn { background: var(--bla); }

/* ---------- SPEL ---------- */
.spel-topp {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.topp-knapp {
  width: 52px; height: 52px;
  border: none; border-radius: 16px;
  background: var(--kort);
  font-size: 24px;
  box-shadow: var(--skugga);
  flex: 0 0 auto;
}
.progress {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.prick {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #d9e4ef;
  transition: background 0.25s, transform 0.25s;
}
.prick.klar { background: var(--gul); transform: scale(1.1); }

.spelyta {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 18px 28px;
  gap: 22px;
  overflow: auto;
}

/* Frågedel */
.fraga {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.hogtalare {
  width: 64px; height: 64px;
  border: none; border-radius: 50%;
  background: var(--bla);
  color: #fff; font-size: 30px;
  box-shadow: var(--skugga);
  flex: 0 0 auto;
}
.hogtalare:active { transform: scale(0.94); }
.fraga-bild { font-size: clamp(90px, 26vw, 150px); line-height: 1; }
.fraga-ord {
  font-size: clamp(52px, 14vw, 90px);
  font-weight: 800;
  letter-spacing: 4px;
}
.fraga-text { font-size: 24px; font-weight: 600; opacity: 0.85; }

/* Svarsalternativ */
.alternativ {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  width: 100%;
  max-width: 640px;
}
.alt {
  border: 4px solid transparent;
  border-radius: 26px;
  background: var(--kort);
  box-shadow: var(--skugga);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s, border-color 0.2s, background 0.2s;
}
.alt:active { transform: scale(0.95); }
.alt.bild { width: 150px; height: 150px; font-size: 84px; }
.alt.bokstav {
  width: 120px; height: 120px;
  font-size: 64px; font-weight: 800;
  text-transform: lowercase;
}
.alt.ratt { border-color: var(--gron); background: #e7f7e8; }
.alt.fel { animation: skaka 0.35s; border-color: var(--amber); }

@keyframes skaka {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Bygg ordet */
.slots {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.slot {
  width: 76px; height: 92px;
  border: 4px dashed #c5d4e3;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; font-weight: 800;
  background: #fff;
  color: var(--text);
}
.slot.fylld { border-style: solid; border-color: var(--gron); background: #eafaf0; }
.slot.mall { color: #c5d4e3; } /* "härma"-mall – svag bokstav att kopiera */

.brickor {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.bricka {
  width: 86px; height: 86px;
  border: none; border-radius: 18px;
  background: var(--bla);
  color: #fff;
  font-size: 48px; font-weight: 800;
  box-shadow: var(--skugga);
}
.bricka:active { transform: scale(0.94); }
.bricka.anvand { opacity: 0.25; pointer-events: none; }

.harma-knapp {
  border: none;
  border-radius: 16px;
  background: var(--gul);
  color: var(--text);
  font-size: 20px; font-weight: 700;
  padding: 12px 22px;
  box-shadow: var(--skugga);
}

/* Ord med lucka (Vilken bokstav saknas) */
.ord-lucka {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: clamp(44px, 13vw, 76px);
  font-weight: 800;
  letter-spacing: 2px;
}
.ord-lucka .lucka {
  min-width: 0.7em;
  text-align: center;
  border-bottom: 6px solid var(--bla);
  color: var(--gron-mork);
}
.ord-lucka .lucka.fylld { border-bottom-color: var(--gron); }

/* Bokstavschips (Ljuda och läs) */
.chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.chip {
  border: none;
  border-radius: 14px;
  background: #eaf2fb;
  color: var(--bla-mork);
  font-size: 38px;
  font-weight: 800;
  width: 64px;
  height: 74px;
  box-shadow: var(--skugga);
}
.chip:active { transform: scale(0.94); }

/* Skriv bokstaven (rita-yta) */
.rita-wrap { width: 100%; display: flex; justify-content: center; }
.rita {
  width: min(86vw, 320px);
  height: 300px;
  background: #fff;
  border-radius: 22px;
  box-shadow: var(--skugga);
  touch-action: none;
}
.rita-knappar { display: flex; gap: 14px; justify-content: center; }
.klar-rita {
  border: none;
  border-radius: 16px;
  background: #cfe8d4;
  color: #82a98a;
  font-size: 20px;
  font-weight: 700;
  padding: 12px 26px;
  box-shadow: var(--skugga);
  transition: background 0.2s, color 0.2s;
}
.klar-rita.redo { background: var(--gron); color: #fff; }

/* Meningar-läget */
.mening-slots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.mening-slot {
  min-width: 92px;
  height: 62px;
  border: 3px dashed #c5d4e3;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  background: #fff;
  padding: 0 12px;
}
.mening-slot.fylld { border-style: solid; border-color: var(--gron); background: #eafaf0; }

.ord-brickor {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.ord-bricka {
  border: none;
  border-radius: 14px;
  background: var(--bla);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  padding: 14px 18px;
  box-shadow: var(--skugga);
}
.ord-bricka:active { transform: scale(0.95); }
.ord-bricka.anvand { opacity: 0.25; pointer-events: none; }
.ord-kort {
  border-radius: 14px;
  background: #eaf2fb;
  color: var(--bla-mork);
  font-size: 26px;
  font-weight: 700;
  padding: 14px 18px;
  box-shadow: var(--skugga);
}

/* Matte */
.stor-knapp.matte { background: var(--amber); }
.alt.tal {
  width: 110px; height: 110px;
  font-size: 60px; font-weight: 800;
}
.rakna-grid {
  display: flex; flex-wrap: wrap;
  gap: 12px; justify-content: center;
  max-width: 540px;
  font-size: clamp(40px, 11vw, 60px);
}
.tarning {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 190px; height: 190px;
  background: #fff; border-radius: 22px;
  box-shadow: var(--skugga); padding: 18px;
}
.tarn-cell { display: flex; align-items: center; justify-content: center; }
.pip { width: 36px; height: 36px; border-radius: 50%; background: var(--bla-mork); }
.plus-rad { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.plus-tecken { font-size: 56px; font-weight: 800; color: var(--text); }
.plus-grupp { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.plus-tal { font-size: 44px; font-weight: 800; }
.plus-tal.bla { color: var(--bla-mork); }
.plus-tal.gron { color: var(--gron-mork); }
.prick-grupp {
  display: grid;
  grid-template-columns: repeat(5, 1fr); /* tioram-struktur: 5 per rad */
  gap: 9px;
  justify-content: center;
  padding: 16px; background: #fff;
  border-radius: 18px; box-shadow: var(--skugga);
}
.prick-stor { width: 32px; height: 32px; border-radius: 50%; position: relative; }
.prick-stor.bla { background: var(--bla); }
.prick-stor.gron { background: var(--gron); }
.prick-stor.tom { background: transparent; border: 3px dashed #c5d4e3; }
.prick-stor.borta { opacity: 0.35; }
.prick-stor.borta::after {
  content: '✕';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #c0392b; font-size: 22px; font-weight: 800;
}

/* Minus-ekvation (5 − 2) */
.ekvation { display: flex; gap: 14px; align-items: center; font-size: 46px; font-weight: 800; }
.ekvation .op { color: var(--text); }
.ekvation .bort { color: #c0392b; }
.ekvation .fraga-ruta {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; height: 52px;
  border: 3px dashed var(--bla); border-radius: 12px;
  color: var(--bla-mork);
}

/* Textuppgift */
.uppg-text { font-size: 22px; line-height: 1.5; max-width: 520px; }
.uppg-bild {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; max-width: 540px;
  font-size: clamp(36px, 10vw, 54px);
}
.uppg-bild .aten {
  opacity: 0.35;
  text-decoration: line-through;
  text-decoration-color: #c0392b;
  text-decoration-thickness: 3px;
}

/* Stjärna som dyker upp vid rätt svar */
.belon {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 180px;
  pointer-events: none;
  animation: poff 0.9s ease;
}
@keyframes poff {
  0% { transform: scale(0.2); opacity: 0; }
  30% { transform: scale(1.1); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.2); opacity: 0; }
}

/* ---------- KLAR ---------- */
.klar-innehall { margin: auto; text-align: center; padding: 24px; }
.klar-figur { font-size: 110px; }
.klar-innehall h1 { font-size: 48px; margin: 8px 0; }
#klar-text { font-size: 24px; margin-bottom: 12px; }
.klar-klistermarke { font-size: 96px; margin: 10px 0 24px; }

/* ---------- STATISTIK ---------- */
.stats-rubrik { margin: 0; font-size: 24px; }
.stats-yta {
  flex: 1;
  overflow: auto;
  padding: 8px 18px 40px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}
.stat-kort {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat-ruta {
  background: var(--kort);
  border-radius: 18px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--skugga);
}
.stat-emoji { font-size: 28px; }
.stat-varde { font-size: 30px; font-weight: 800; color: var(--bla-mork); }
.stat-text { font-size: 14px; opacity: 0.75; }

.stat-sektion { margin-bottom: 26px; }
.stat-sektion h3 { margin: 0 0 10px; font-size: 19px; }
.stat-tomt { opacity: 0.6; font-size: 15px; margin: 4px 0; }

.stat-rad {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--kort);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 6px rgba(60, 90, 130, 0.08);
}
.stat-rad-bild { font-size: 30px; width: 38px; text-align: center; }
.stat-rad-namn { font-size: 22px; font-weight: 700; flex: 1; }
.stat-rad-siffror { font-size: 17px; font-weight: 700; white-space: nowrap; }
.stat-rad-siffror .ratt { color: var(--gron-mork); }
.stat-rad-siffror .fel { color: #c0392b; }

/* ---------- Overlays (vuxen) ---------- */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(40, 60, 90, 0.45);
  align-items: center; justify-content: center;
  padding: 20px;
  z-index: 10;
}
.overlay.aktiv { display: flex; }
.ruta {
  background: #fff;
  border-radius: 24px;
  padding: 26px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--skugga);
}
.ruta.brett { max-width: 520px; max-height: 90vh; overflow: auto; }
.ruta h2 { margin: 0 0 16px; }
.grind-input {
  width: 100%;
  font-size: 30px;
  padding: 14px;
  border: 2px solid #c5d4e3;
  border-radius: 14px;
  text-align: center;
  margin: 10px 0 4px;
}
.ruta-knappar { display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px; }
.liten-knapp {
  border: none; border-radius: 14px;
  padding: 14px 22px;
  font-size: 18px; font-weight: 700;
  color: #fff;
}
.liten-knapp.spela { background: var(--gron); }
.liten-knapp.lugn { background: #9bb0c4; }

.installning { margin-bottom: 18px; }
.installning > label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--bla-mork);
}
.val-rad { display: flex; gap: 10px; flex-wrap: wrap; }
.val-rad.kolumn { flex-direction: column; }
.val-rad button {
  flex: 1;
  min-width: 80px;
  border: 3px solid #d9e4ef;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}
.val-rad button.vald { border-color: var(--gron); background: #eafaf0; }
.val-rad button.neutral { border-color: #d9e4ef; }
.val-rad button.fara { color: #c0392b; }
