/* ============================================================
   TROLLPENNAN — magisk natthimmel-estetik för barn 7–12 år
   ============================================================ */

:root {
  --night-1: #0b0a22;
  --night-2: #181445;
  --night-3: #241c63;
  --gold: #ffd84d;
  --pink: #ff6fb5;
  --cyan: #4de3ff;
  --green: #7dff6f;
  --ink: #fffdf5;
  --shadow-pop: 0 8px 0 rgba(0, 0, 0, .35);
  --font-display: "Baloo 2", system-ui, sans-serif;
  --font-hand: "Gochi Hand", cursive;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--night-1);
  font-family: var(--font-display);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ---------- Kamera + rityta ---------- */

#cam {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);            /* spegelvänd som en spegel */
  filter: brightness(.62) saturate(.8) contrast(1.05);
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 45%, rgba(11, 10, 34, .55) 85%, rgba(11, 10, 34, .9) 100%),
    linear-gradient(to bottom, rgba(11, 10, 34, .55), transparent 18%, transparent 85%, rgba(11, 10, 34, .55));
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
  z-index: 10;
  pointer-events: none;
}

.hud-group {
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: auto;
}

.bubble-btn {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  border: 3px solid rgba(255, 255, 255, .25);
  background: rgba(24, 20, 69, .85);
  font-size: 26px;
  cursor: pointer;
  box-shadow: var(--shadow-pop);
  transition: transform .12s ease, background .12s ease;
}
.bubble-btn:hover { transform: translateY(-3px) rotate(-4deg); background: var(--night-3); }
.bubble-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }

/* Färgpalett */
#palette {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(24, 20, 69, .85);
  border: 3px solid rgba(255, 255, 255, .25);
  border-radius: 20px;
  box-shadow: var(--shadow-pop);
}

.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .35);
  cursor: pointer;
  transition: transform .12s ease;
}
.swatch:hover { transform: scale(1.18) rotate(8deg); }
.swatch.active {
  border-color: #fff;
  transform: scale(1.22);
  box-shadow: 0 0 14px currentColor;
}
.swatch.rainbow {
  background: conic-gradient(#ff6fb5, #ffd84d, #7dff6f, #4de3ff, #b48bff, #ff6fb5);
}

/* Ordpanel i mall-läget */
#wordPanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  background: rgba(24, 20, 69, .85);
  border: 3px solid rgba(255, 255, 255, .25);
  border-radius: 26px;
  padding: 12px 26px 14px;
  box-shadow: var(--shadow-pop);
}

#wordEmoji { font-size: 38px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-6px) rotate(4deg); }
}

#wordChips { display: flex; gap: 7px; }

.chip {
  min-width: 44px;
  height: 50px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  font-size: 30px;
  font-weight: 800;
  border-radius: 14px;
  border: 3px dashed rgba(255, 255, 255, .3);
  color: rgba(255, 255, 255, .35);
  transition: all .25s ease;
}
.chip.current {
  border-style: solid;
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 216, 77, .12);
  animation: pulse 1.2s ease-in-out infinite;
}
.chip.done {
  border-style: solid;
  border-color: var(--green);
  color: var(--green);
  background: rgba(125, 255, 111, .14);
  text-shadow: 0 0 12px var(--green);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(255, 216, 77, 0); }
  50% { transform: scale(1.08); box-shadow: 0 0 18px rgba(255, 216, 77, .55); }
}

#letterProgress {
  width: 100%;
  height: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .14);
  overflow: hidden;
}
#letterProgressFill {
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--gold), var(--pink));
  box-shadow: 0 0 10px var(--gold);
  transition: width .15s ease;
}

/* ---------- Tips & kalibrering ---------- */

.banner {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-hand);
  font-size: 30px;
  background: rgba(24, 20, 69, .9);
  border: 3px solid rgba(255, 255, 255, .25);
  padding: 12px 28px;
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  animation: hintWiggle 1.6s ease-in-out infinite;
  z-index: 10;
}

.banner.gold {
  border-color: rgba(255, 216, 77, .6);
  color: var(--gold);
  box-shadow: var(--shadow-pop), 0 0 26px rgba(255, 216, 77, .35);
}

@keyframes hintWiggle {
  0%, 100% { transform: translateX(-50%) rotate(-1.5deg); }
  50% { transform: translateX(-50%) rotate(1.5deg); }
}

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  overflow-y: auto;
  gap: 22px;
  background:
    radial-gradient(ellipse 90% 70% at 50% -10%, var(--night-3), transparent),
    radial-gradient(ellipse 70% 60% at 80% 110%, #2a1a52, transparent),
    var(--night-1);
  padding: 24px;
  text-align: center;
}

/* Stjärnhimmel */
.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20% 30%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 70% 18%, #ffd84d, transparent),
    radial-gradient(2px 2px at 85% 55%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 75%, #4de3ff, transparent),
    radial-gradient(2px 2px at 10% 80%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 55% 45%, #ff6fb5, transparent),
    radial-gradient(2px 2px at 92% 85%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 30% 10%, #fff, transparent);
  background-size: 600px 600px;
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle { from { opacity: .5; } to { opacity: 1; } }

.float-deco {
  position: absolute;
  font-size: 44px;
  animation: floatAround 7s ease-in-out infinite;
  pointer-events: none;
}
.d1 { top: 12%; left: 12%; animation-delay: 0s; }
.d2 { top: 18%; right: 14%; animation-delay: -2s; font-size: 34px; }
.d3 { bottom: 16%; left: 16%; animation-delay: -4s; font-size: 52px; }
.d4 { bottom: 22%; right: 12%; animation-delay: -1s; }

@keyframes floatAround {
  0%, 100% { transform: translate(0, 0) rotate(-8deg); }
  33% { transform: translate(12px, -18px) rotate(6deg); }
  66% { transform: translate(-10px, -8px) rotate(-4deg); }
}

/* Titel */
.title {
  font-size: clamp(48px, 9vh, 110px);
  font-weight: 800;
  line-height: .9;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff 10%, var(--gold) 55%, #ff9c3f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .4)) drop-shadow(0 0 30px rgba(255, 216, 77, .35));
  transform: rotate(-2deg);
  animation: titlePop .7s cubic-bezier(.2, 1.6, .4, 1) both;
}
.title span {
  background: linear-gradient(180deg, #fff 10%, var(--cyan) 55%, #5f7bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@keyframes titlePop {
  from { transform: rotate(-2deg) scale(.4); opacity: 0; }
  to { transform: rotate(-2deg) scale(1); opacity: 1; }
}

.subtitle {
  font-family: var(--font-hand);
  font-size: clamp(22px, 3.4vw, 34px);
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 111, 181, .5);
  animation: titlePop .7s .15s cubic-bezier(.2, 1.6, .4, 1) both;
}

/* Instruktioner */
.howto {
  display: flex;
  align-items: center;
  gap: 18px;
  animation: titlePop .7s .3s cubic-bezier(.2, 1.6, .4, 1) both;
}

.howto-step {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.25;
  opacity: .9;
}

.howto-icon {
  font-size: 42px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, .08);
  border: 3px solid rgba(255, 255, 255, .18);
  border-radius: 22px;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin-inline: auto;
}

.howto-arrow { font-size: 28px; opacity: .5; font-weight: 800; }

/* Åldersväljare */
.age-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  animation: titlePop .7s .4s cubic-bezier(.2, 1.6, .4, 1) both;
}

.age-label {
  font-family: var(--font-hand);
  font-size: 24px;
  color: rgba(255, 255, 255, .75);
  margin-right: 4px;
}

.age-pill {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  padding: 9px 22px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .08);
  color: var(--ink);
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.age-pill:hover { transform: translateY(-2px) scale(1.06); }
.age-pill.active {
  background: linear-gradient(160deg, #ffe98a, var(--gold) 60%, #ffab3f);
  color: var(--night-1);
  border-color: #fff;
  box-shadow: 0 0 18px rgba(255, 216, 77, .5), 0 5px 0 rgba(0, 0, 0, .3);
}

/* Lägesknappar */
.mode-buttons {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 1040px;
  animation: titlePop .7s .5s cubic-bezier(.2, 1.6, .4, 1) both;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 225px;
  padding: 20px 16px 18px;
  border-radius: 28px;
  border: 4px solid rgba(255, 255, 255, .35);
  cursor: pointer;
  font-family: var(--font-display);
  color: var(--night-1);
  box-shadow: 0 9px 0 rgba(0, 0, 0, .35);
  transition: transform .15s cubic-bezier(.2, 1.6, .4, 1);
}
.mode-btn:hover { transform: translateY(-6px) rotate(-1.5deg) scale(1.04); }
.mode-btn:active { transform: translateY(3px); box-shadow: 0 4px 0 rgba(0, 0, 0, .35); }

.mode-btn.free   { background: linear-gradient(160deg, #ffe98a, var(--gold) 55%, #ffab3f); }
.mode-btn.words  { background: linear-gradient(160deg, #9af0ff, var(--cyan) 55%, #4d9bff); }
.mode-btn.catch  { background: linear-gradient(160deg, #ffb3d4, var(--pink) 55%, #f4438f); }
.mode-btn.build  { background: linear-gradient(160deg, #b8ffae, var(--green) 55%, #3fd166); }
.mode-btn.listen { background: linear-gradient(160deg, #d9c2ff, #b48bff 55%, #8b5cf6); }
.mode-btn.duel   { background: linear-gradient(160deg, #ffc89a, #ff9c3f 55%, #f4622f); }

.mode-emoji { font-size: 46px; }
.mode-name { font-size: 27px; font-weight: 800; }
.mode-desc { font-size: 14px; font-weight: 700; opacity: .75; }

#wordCount {
  font-size: 14px;
  font-weight: 700;
  opacity: .6;
  letter-spacing: .5px;
}

/* ---------- Paketväljare ---------- */

.packs-title {
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 800;
  background: linear-gradient(180deg, #fff 10%, var(--gold) 60%, #ff9c3f);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, .4));
  transform: rotate(-1.5deg);
  animation: titlePop .6s cubic-bezier(.2, 1.6, .4, 1) both;
}

.total-stars {
  font-size: 24px;
  font-weight: 800;
  background: rgba(255, 216, 77, .12);
  border: 3px solid rgba(255, 216, 77, .4);
  border-radius: 999px;
  padding: 8px 26px;
  color: var(--gold);
  animation: titlePop .6s .1s cubic-bezier(.2, 1.6, .4, 1) both;
}

#packGrid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 1100px;
  animation: titlePop .6s .2s cubic-bezier(.2, 1.6, .4, 1) both;
}

.pack-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 210px;
  padding: 22px 16px 18px;
  border-radius: 28px;
  border: 4px solid rgba(255, 255, 255, .35);
  cursor: pointer;
  font-family: var(--font-display);
  color: var(--night-1);
  box-shadow: 0 9px 0 rgba(0, 0, 0, .35);
  transition: transform .15s cubic-bezier(.2, 1.6, .4, 1);
}
.pack-card:hover { transform: translateY(-6px) rotate(-1.5deg) scale(1.04); }
.pack-card:active { transform: translateY(3px); box-shadow: 0 4px 0 rgba(0, 0, 0, .35); }

.pack-emoji { font-size: 56px; }
.pack-name { font-size: 27px; font-weight: 800; }
.pack-stars { font-size: 16px; font-weight: 800; opacity: .8; }

.pack-card.locked {
  cursor: default;
  filter: grayscale(.85) brightness(.6);
}
.pack-card.locked:hover { transform: none; }

.pack-lock {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 24px;
  background: rgba(11, 10, 34, .55);
  color: #fff;
  font-size: 34px;
  font-weight: 800;
}
.pack-lock small { font-size: 16px; font-weight: 700; }

/* ---------- Stjärnbetyg ---------- */

#starRow { display: flex; gap: 12px; font-size: 56px; line-height: 1; }

#starRow .star { opacity: .22; filter: grayscale(1); }
#starRow .star.earned {
  opacity: 1;
  filter: drop-shadow(0 0 14px rgba(255, 216, 77, .8));
  animation: starPop .5s cubic-bezier(.2, 1.8, .4, 1) both;
}
#starRow .star.earned:nth-child(2) { animation-delay: .18s; }
#starRow .star.earned:nth-child(3) { animation-delay: .36s; }

@keyframes starPop {
  from { transform: scale(0) rotate(-120deg); }
  to { transform: scale(1) rotate(0deg); }
}

/* ---------- Peppande poppar ---------- */

.praise {
  position: fixed;
  left: 50%;
  top: 38%;
  font-family: var(--font-hand);
  font-size: clamp(44px, 8vw, 76px);
  color: var(--gold);
  text-shadow: 0 4px 0 rgba(0, 0, 0, .4), 0 0 30px rgba(255, 216, 77, .7);
  pointer-events: none;
  z-index: 15;
  white-space: nowrap;
  animation: praiseUp 1.15s ease-out forwards;
}

@keyframes praiseUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.4) rotate(-8deg); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1.15) rotate(-3deg); }
}

/* Laddar */
.loading-wand { font-size: 80px; animation: wandSpin 1.2s ease-in-out infinite; }

@keyframes wandSpin {
  0%, 100% { transform: rotate(-20deg) scale(1); }
  50% { transform: rotate(25deg) scale(1.15); }
}

.loading-text {
  font-family: var(--font-hand);
  font-size: 32px;
  color: var(--gold);
}

/* Firande */
#celebrate { background: rgba(11, 10, 34, .72); backdrop-filter: blur(6px); }
#error { background: rgba(11, 10, 34, .9); }

.celebrate-card {
  background: linear-gradient(170deg, var(--night-3), var(--night-2));
  border: 4px solid rgba(255, 255, 255, .3);
  border-radius: 36px;
  padding: 40px 56px;
  box-shadow: 0 14px 0 rgba(0, 0, 0, .4), 0 0 60px rgba(255, 216, 77, .25);
  animation: titlePop .55s cubic-bezier(.2, 1.6, .4, 1) both;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.celebrate-big { font-size: 84px; animation: bob 1.6s ease-in-out infinite; }

.celebrate-card h2 {
  font-size: 54px;
  font-weight: 800;
  background: linear-gradient(180deg, #fff, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.celebrate-card p { font-family: var(--font-hand); font-size: 30px; color: var(--cyan); }

.celebrate-buttons { display: flex; gap: 14px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }

.cta {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  padding: 14px 30px;
  border-radius: 999px;
  border: 4px solid rgba(255, 255, 255, .35);
  background: linear-gradient(160deg, #ffe98a, var(--gold) 60%, #ffab3f);
  color: var(--night-1);
  cursor: pointer;
  box-shadow: 0 7px 0 rgba(0, 0, 0, .35);
  transition: transform .14s cubic-bezier(.2, 1.6, .4, 1);
}
.cta:hover { transform: translateY(-4px) scale(1.05); }
.cta:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.cta.ghost { background: rgba(255, 255, 255, .1); color: var(--ink); }

/* ---------- Kamerablixt ---------- */

#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 30;
  pointer-events: none;
  animation: flashFade .35s ease-out forwards;
}

@keyframes flashFade { from { opacity: .9; } to { opacity: 0; } }

/* ---------- Profilchip & svit på startskärmen ---------- */

.profile-chip {
  position: absolute;
  top: 22px;
  right: 24px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  padding: 10px 22px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .08);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-pop);
  transition: transform .12s ease;
  z-index: 2;
}
.profile-chip:hover { transform: translateY(-2px) scale(1.05); }

.streak-badge {
  position: absolute;
  top: 22px;
  left: 24px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: 999px;
  border: 3px solid rgba(255, 155, 63, .55);
  background: rgba(255, 155, 63, .14);
  color: #ffb13f;
  box-shadow: 0 0 18px rgba(255, 155, 63, .3);
  z-index: 2;
  animation: bob 2.2s ease-in-out infinite;
}

/* Extra-knappar (daglig utmaning + samlarbok) */
.extra-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  animation: titlePop .7s .6s cubic-bezier(.2, 1.6, .4, 1) both;
}

.extra-btn {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  padding: 12px 26px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .1);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-pop);
  transition: transform .13s cubic-bezier(.2, 1.6, .4, 1);
}
.extra-btn:hover { transform: translateY(-3px) scale(1.05); }
.extra-btn:active { transform: translateY(2px); }

/* ---------- Profilväljare ---------- */

#profileGrid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 800px;
}

.profile-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 170px;
  padding: 20px 28px;
  border-radius: 24px;
  border: 4px solid rgba(255, 255, 255, .3);
  background: linear-gradient(160deg, var(--night-3), var(--night-2));
  color: var(--ink);
  font-family: var(--font-display);
  cursor: pointer;
  box-shadow: var(--shadow-pop);
  transition: transform .14s cubic-bezier(.2, 1.6, .4, 1);
}
.profile-card:hover { transform: translateY(-4px) scale(1.05); }
.profile-card.active { border-color: var(--gold); box-shadow: 0 0 22px rgba(255, 216, 77, .4), var(--shadow-pop); }

.profile-name { font-size: 24px; font-weight: 800; }
.profile-stars { font-size: 17px; font-weight: 700; color: var(--gold); }

.profile-del {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 82, 82, .9);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  border: 2px solid #fff;
  opacity: 0;
  transition: opacity .15s ease;
}
.profile-card:hover .profile-del { opacity: 1; }

.profile-add {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

#newProfileName {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  padding: 13px 22px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .1);
  color: var(--ink);
  outline: none;
  width: 240px;
}
#newProfileName:focus { border-color: var(--cyan); box-shadow: 0 0 16px rgba(77, 227, 255, .35); }
#newProfileName::placeholder { color: rgba(255, 255, 255, .4); }

/* ---------- Samlarbok ---------- */

#bookGrid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 6px 18px;
}

.book-section h3 {
  font-size: 23px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--cyan);
  text-align: left;
}

.book-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.book-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 92px;
  padding: 12px 6px 10px;
  border-radius: 18px;
  border: 3px solid rgba(255, 255, 255, .2);
  background: rgba(24, 20, 69, .7);
}

.book-emoji { font-size: 36px; }
.book-word { font-size: 13px; font-weight: 800; letter-spacing: .5px; }

.book-card.full {
  border-color: var(--gold);
  background: rgba(255, 216, 77, .12);
  box-shadow: 0 0 16px rgba(255, 216, 77, .3);
}
.book-card.full .book-emoji { animation: bob 2.4s ease-in-out infinite; }
.book-card.partial { opacity: .75; }
.book-card.partial .book-emoji { filter: grayscale(.7); }
.book-card.empty { opacity: .45; }

/* ---------- Fingerläge ---------- */

.touch-link {
  font-family: var(--font-hand);
  font-size: 22px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, .55);
  cursor: pointer;
  text-decoration: underline dotted;
  transition: color .15s ease;
}
.touch-link:hover { color: var(--cyan); }
.touch-link.on { color: var(--green); text-decoration: none; }

body.touch #cam, body.touch #vignette { display: none; }
body.touch {
  background:
    radial-gradient(ellipse 90% 70% at 50% -10%, var(--night-3), transparent),
    radial-gradient(ellipse 70% 60% at 80% 110%, #2a1a52, transparent),
    var(--night-1);
}

/* Musikknapp avstängd */
#btnMusic.off { opacity: .35; }

/* Klickbar emoji i ordpanelen (läs upp igen) */
#wordEmoji { cursor: pointer; }

/* ---------- Statistik ---------- */

#statsGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 16px;
  max-width: 860px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 12px 16px;
  border-radius: 24px;
  border: 3px solid rgba(255, 255, 255, .22);
  background: rgba(24, 20, 69, .75);
  box-shadow: var(--shadow-pop);
}

.stat-icon { font-size: 34px; }
.stat-val { font-size: 30px; font-weight: 800; color: var(--gold); }
.stat-label { font-size: 14px; font-weight: 700; opacity: .7; text-align: center; }

/* ---------- Egna ord ---------- */

.custom-help {
  font-family: var(--font-hand);
  font-size: 22px;
  color: rgba(255, 255, 255, .65);
  max-width: 520px;
}

#customList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 34vh;
  overflow-y: auto;
  min-width: 320px;
  padding: 4px 10px;
}

.custom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 23px;
  font-weight: 800;
  padding: 8px 18px;
  border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, .2);
  background: rgba(24, 20, 69, .75);
}

.custom-del {
  background: rgba(255, 82, 82, .85);
  border: 2px solid #fff;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
  cursor: pointer;
  font-size: 13px;
}

.custom-empty { font-family: var(--font-hand); font-size: 22px; opacity: .5; }

.emoji-input { width: 90px !important; text-align: center; }

#customWord {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  padding: 13px 22px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .1);
  color: var(--ink);
  outline: none;
  width: 200px;
  text-transform: uppercase;
}
#customEmoji {
  font-size: 21px;
  padding: 13px 10px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .1);
  color: var(--ink);
  outline: none;
}
#customWord:focus, #customEmoji:focus { border-color: var(--cyan); }

/* ---------- Nivåkarta ---------- */

#mapWrap {
  position: relative;
  width: min(88vw, 1000px);
  height: min(48vh, 420px);
}

#mapPath {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#mapNodes { position: absolute; inset: 0; }

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  color: var(--ink);
}

.node-face {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-size: 32px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .35);
  background: rgba(24, 20, 69, .85);
  box-shadow: var(--shadow-pop);
  transition: transform .14s cubic-bezier(.2, 1.6, .4, 1);
}
.map-node:hover .node-face { transform: scale(1.15) rotate(-5deg); }

.node-label {
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .6);
}

.map-node.done .node-face {
  border-color: var(--gold);
  background: rgba(255, 216, 77, .18);
  box-shadow: 0 0 18px rgba(255, 216, 77, .45), var(--shadow-pop);
}
.map-node.current .node-face {
  border-color: var(--green);
  animation: pulse 1.2s ease-in-out infinite;
}
.map-node.locked { cursor: default; }
.map-node.locked .node-face { filter: grayscale(1) brightness(.55); }
.map-node.locked:hover .node-face { transform: none; }
.map-node.boss .node-face {
  width: 80px;
  height: 80px;
  font-size: 40px;
  border-color: #ff9c3f;
  box-shadow: 0 0 22px rgba(255, 156, 63, .5), var(--shadow-pop);
}

/* Mobilanpassning */
@media (max-width: 640px) {
  .howto { gap: 8px; }
  .howto-icon { width: 60px; height: 60px; font-size: 32px; }
  .howto-step { font-size: 13px; }
  .bubble-btn { width: 48px; height: 48px; font-size: 21px; }
  .chip { min-width: 34px; height: 40px; font-size: 23px; }
  #wordEmoji { font-size: 28px; }
  .celebrate-card { padding: 28px 26px; }
}
