/* =========================================================================
   Einars Pussel- och Talspel – Färgglad & Lekfull Design
   ========================================================================= */

:root {
  --bg-top: #74d0fc;
  --bg-mid: #d0f4ff;
  --bg-bottom: #fff9db;
  --ink: #1e293b;
  --muted: #475569;
  --card-bg: rgba(255, 255, 255, 0.94);
  --primary: #ff6b35;
  --primary-dark: #d9480f;
  --green: #2ecc71;
  --green-dark: #219653;
  --blue: #339af0;
  --blue-dark: #1c7ed6;
  --yellow: #ffd43b;
  --yellow-dark: #f08c00;
  --purple: #9775fa;
  --danger: #ff4d6d;
  --shadow-soft: 0 10px 28px rgba(30, 41, 59, 0.12);
  --shadow-pop: 0 8px 0 rgba(0, 0, 0, 0.16);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 45%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

/* Dekorativa moln i bakgrunden */
.sky-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  font-size: 4rem;
  opacity: 0.55;
  animation: cloudDrift 28s linear infinite;
}

.cloud.c1 { top: 8%; left: -10%; font-size: 5rem; animation-duration: 36s; }
.cloud.c2 { top: 18%; left: 40%; font-size: 3.5rem; animation-duration: 46s; animation-delay: -12s; }
.cloud.c3 { top: 4%; right: 6%; left: auto; font-size: 4.5rem; opacity: 0.75; animation: sunSpin 24s linear infinite; }

@keyframes cloudDrift {
  0% { transform: translateX(-12vw); }
  100% { transform: translateX(115vw); }
}

@keyframes sunSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.08); }
  100% { transform: rotate(360deg) scale(1); }
}

/* =========================================================================
   Toppbar
   ========================================================================= */
.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  gap: 12px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill-btn, .star-badge, .timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1rem;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.star-badge {
  background: linear-gradient(135deg, #ffe066, #fcc419);
  color: #5c3c00;
}

.timer-pill {
  background: linear-gradient(135deg, #a5d8ff, #74c0fc);
  color: #0b4a6f;
  transition: transform 0.25s, background 0.3s;
}

.timer-pill.warning {
  background: linear-gradient(135deg, #ffc078, #ff922b);
  color: #5c2800;
  animation: pulseWarn 1.2s ease-in-out infinite;
}

.timer-pill.expired {
  background: linear-gradient(135deg, #ffa8a8, #ff6b6b);
  color: #fff;
}

@keyframes pulseWarn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.pill-btn {
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  transition: transform 0.15s, box-shadow 0.15s;
}

.pill-btn:hover { transform: translateY(-2px); }
.pill-btn:active { transform: translateY(1px); }

.adult-btn {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  color: #334155;
}

.home-btn {
  background: linear-gradient(135deg, #fff, #e7f5ff);
  color: #1864ab;
}

/* Varningsbanner för speltid */
.toast-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: linear-gradient(135deg, #ff922b, #ff6b35);
  color: #fff;
  padding: 14px 26px;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 800;
  border: 4px solid #fff;
  box-shadow: 0 12px 30px rgba(217, 72, 15, 0.35);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================================================
   Startskärm
   ========================================================================= */
.screen {
  position: relative;
  z-index: 10;
  max-width: 1120px;
  margin: 0 auto;
  padding: 4px 18px 36px;
}

.hero-header {
  text-align: center;
  margin-bottom: 18px;
}

.game-title {
  margin: 0;
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  font-weight: 900;
  color: #ffffff;
  text-shadow:
    0 4px 0 #1c7ed6,
    0 7px 18px rgba(28, 126, 214, 0.35);
  letter-spacing: 0.5px;
}

.game-subtitle {
  margin: 6px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e3a5f;
}

.card-section {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 18px 20px 22px;
  box-shadow: var(--shadow-soft);
  border: 4px solid rgba(255, 255, 255, 0.9);
  margin-bottom: 18px;
}

.section-heading {
  margin: 0 0 14px;
  font-size: 1.3rem;
  color: #1864ab;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 16px;
}

.char-card {
  position: relative;
  border: 5px solid transparent;
  border-radius: 22px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s, box-shadow 0.2s;
}

.char-card:hover {
  transform: translateY(-5px) scale(1.02);
}

.char-card.selected {
  border-color: #ff6b35;
  box-shadow: 0 0 0 5px rgba(255, 107, 53, 0.28), 0 12px 24px rgba(255, 107, 53, 0.25);
  transform: translateY(-4px) scale(1.03);
}

.char-card.selected::after {
  content: '✓';
  position: absolute;
  top: -10px;
  right: -10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #2ecc71;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.char-thumb-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: #f1f5f9;
  margin-bottom: 8px;
}

.char-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.char-card-name {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--ink);
}

/* Snabbval innan start */
.pregame-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.control-box {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-label {
  font-size: 1.1rem;
  font-weight: 900;
  color: #1864ab;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  flex: 1 1 auto;
  min-width: 72px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 3px solid #dbeafe;
  background: #f8fafc;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

.chip small {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.75;
}

.chip:hover {
  transform: translateY(-2px);
}

.chip.active {
  background: linear-gradient(135deg, #339af0, #228be6);
  color: #fff;
  border-color: #1864ab;
  box-shadow: 0 4px 10px rgba(34, 139, 230, 0.32);
}

.mic-toggle-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 3px solid #cbd5e1;
  background: #f1f5f9;
  color: #334155;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.mic-toggle-btn.active {
  background: linear-gradient(135deg, #d3f9d8, #b2f2bb);
  border-color: #2f9e44;
  color: #14532d;
}

.mic-toggle-icon {
  font-size: 1.9rem;
  flex-shrink: 0;
}

.mic-toggle-text {
  display: flex;
  flex-direction: column;
  font-size: 0.96rem;
}

.mic-toggle-text small {
  font-size: 0.78rem;
  opacity: 0.85;
}

.word-preview-pill {
  font-size: 0.88rem;
  background: #fff3bf;
  color: #5c3c00;
  padding: 7px 12px;
  border-radius: 12px;
  font-weight: 700;
}

.tiny-hint {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.start-action-wrap {
  display: flex;
  justify-content: center;
}

.mega-play-btn {
  border: 5px solid #fff;
  background: linear-gradient(180deg, #40c057 0%, #2b8a3e 100%);
  color: #fff;
  font-size: clamp(1.3rem, 2.6vw, 1.75rem);
  font-weight: 900;
  padding: 18px 44px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 9px 0 #1e6b2e, 0 14px 28px rgba(43, 138, 62, 0.38);
  transition: transform 0.14s, box-shadow 0.14s;
  letter-spacing: 0.5px;
}

.mega-play-btn:hover {
  transform: translateY(-3px) scale(1.03);
}

.mega-play-btn:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #1e6b2e, 0 6px 14px rgba(43, 138, 62, 0.3);
}

body.in-puzzle-mode {
  height: 100vh;
  overflow: hidden;
}

/* =========================================================================
   Pusselskärm (Anpassad för 100% synlighet utan scroll!)
   ========================================================================= */
#screen-puzzle {
  max-width: 1220px;
  height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  padding: 2px 16px 12px;
  overflow: hidden;
}

.puzzle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  background: var(--card-bg);
  padding: 8px 16px;
  border-radius: var(--radius-lg);
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.puzzle-char-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 900;
  color: #1864ab;
  white-space: nowrap;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 180px;
  max-width: 340px;
}

.progress-track {
  flex: 1;
  height: 16px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid #cbd5e1;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd43b, #ff922b, #40c057);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-text {
  font-weight: 900;
  font-size: 0.95rem;
  color: #334155;
  white-space: nowrap;
}

.puzzle-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.board-frame {
  flex-shrink: 0;
  background: linear-gradient(135deg, #fff9db, #ffffff);
  padding: 12px;
  border-radius: 24px;
  border: 5px solid #ffd43b;
  box-shadow: 0 12px 30px rgba(30, 41, 59, 0.16);
}

.puzzle-board {
  position: relative;
  background: #f8fafc;
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px #e2e8f0;
  touch-action: none;
}

.puzzle-ghost-canvas {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  pointer-events: none;
}

.puzzle-placed-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tray-frame {
  flex: 1 1 320px;
  max-width: 540px;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: 24px;
  padding: 12px 14px;
  border: 4px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.tray-title {
  text-align: center;
  font-weight: 900;
  color: #1864ab;
  margin-bottom: 8px;
  font-size: 1rem;
  flex-shrink: 0;
}

.puzzle-tray {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  align-content: center;
  gap: 8px;
  padding: 4px;
  overflow: hidden;
}

@media (max-width: 760px) {
  .puzzle-workspace {
    flex-direction: column;
    gap: 10px;
  }
  .tray-frame {
    width: 100%;
    max-width: 100%;
    flex: 1;
  }
}

.tray-piece-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: opacity 0.25s, transform 0.25s;
}

.tray-piece-slot.slot-empty {
  opacity: 0.12;
  pointer-events: none;
}

.puzzle-piece {
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.22));
  transition: filter 0.15s;
}

.puzzle-piece.in-tray {
  transform: scale(var(--tray-scale, 0.8));
  transform-origin: center;
}

.puzzle-piece.in-tray:hover {
  transform: scale(calc(var(--tray-scale, 0.8) * 1.08));
}

.puzzle-piece.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.35));
  transform: scale(1.06);
}

.puzzle-piece.placed {
  cursor: default;
  filter: none;
}

/* BELÖNING VID VARJE RÄTT PLACERAD BIT: Hoppar snabbt upp och dansar lite! */
.piece-hop-dance {
  animation: pieceHopDance 0.82s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  filter: drop-shadow(0 12px 18px rgba(255, 180, 0, 0.55)) !important;
}

@keyframes pieceHopDance {
  0%   { transform: translateY(0) scale(1) rotate(0deg); }
  20%  { transform: translateY(-28px) scale(1.16) rotate(-7deg); }
  42%  { transform: translateY(-16px) scale(1.12) rotate(8deg); }
  62%  { transform: translateY(-22px) scale(1.10) rotate(-5deg); }
  82%  { transform: translateY(-6px) scale(1.04) rotate(3deg); }
  100% { transform: translateY(0) scale(1) rotate(0deg); }
}

.piece-sparkle {
  position: absolute;
  font-size: 1.55rem;
  pointer-events: none;
  z-index: 60;
  animation: sparkleBurst 0.72s ease-out forwards;
}

@keyframes sparkleBurst {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.25) rotate(25deg);
    opacity: 0;
  }
}

/* =========================================================================
   Overlays (Tal-utmaning, Belöning, Tiden är slut)
   ========================================================================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.speech-card {
  position: relative;
  background: linear-gradient(180deg, #ffffff 0%, #fff9db 100%);
  border: 6px solid #ffd43b;
  border-radius: 32px;
  max-width: 540px;
  width: 100%;
  padding: 24px 24px 18px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.speech-character-spotlight {
  position: relative;
  width: 190px;
  height: 190px;
  margin: 0 auto 16px;
}

.speech-character-spotlight img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 26px;
  border: 6px solid #ff922b;
  box-shadow: 0 12px 28px rgba(255, 146, 43, 0.35);
  position: relative;
  z-index: 2;
  animation: gentleBounce 2.2s ease-in-out infinite;
}

.spotlight-ring {
  position: absolute;
  inset: -12px;
  border-radius: 34px;
  border: 5px dashed #ffd43b;
  animation: spinSlow 14s linear infinite;
}

@keyframes gentleBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.03); }
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.speech-bubble {
  background: #e7f5ff;
  border: 4px solid #339af0;
  border-radius: 22px;
  padding: 12px 18px;
  margin-bottom: 16px;
}

.speech-bubble p {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  color: #1864ab;
}

.speech-bubble strong {
  color: #e8590c;
  font-size: 1.65rem;
}

.mic-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.mic-orb {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd43b, #fab005);
  border: 5px solid #fff;
  box-shadow: 0 8px 20px rgba(240, 140, 0, 0.28);
  display: grid;
  place-items: center;
  font-size: 2.3rem;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s;
}

.mic-orb.preparing {
  background: linear-gradient(135deg, #ffe066, #fcc419);
  transform: scale(0.94);
}

.mic-orb.listening {
  background: linear-gradient(135deg, #40c057, #2b8a3e);
  transform: scale(1.06);
  animation: micPulse 1.4s ease-out infinite;
}

.mic-orb.error {
  background: linear-gradient(135deg, #ff6b6b, #e03131);
  transform: scale(0.96);
}

.diag-level-wrap {
  width: 100%;
  height: 16px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
  border: 2px solid #cbd5e1;
}

.diag-level-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #40c057, #ffd43b, #ff6b6b);
  transition: width 0.06s linear;
}

.diag-log {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
}

@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(64, 192, 87, 0.65), 0 10px 24px rgba(43, 138, 62, 0.38); }
  70% { box-shadow: 0 0 0 24px rgba(64, 192, 87, 0), 0 10px 24px rgba(43, 138, 62, 0.38); }
  100% { box-shadow: 0 0 0 0 rgba(64, 192, 87, 0), 0 10px 24px rgba(43, 138, 62, 0.38); }
}

.volume-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  height: 36px;
}

.volume-bars span {
  width: 10px;
  height: 8px;
  border-radius: 999px;
  background: #339af0;
  transition: height 0.08s ease-out;
}

.volume-bars span:nth-child(1) { background: #ff4d6d; }
.volume-bars span:nth-child(2) { background: #ff9f1c; }
.volume-bars span:nth-child(3) { background: #ffd60a; }
.volume-bars span:nth-child(4) { background: #2ecc71; }
.volume-bars span:nth-child(5) { background: #339af0; }
.volume-bars span:nth-child(6) { background: #845ef7; }
.volume-bars span:nth-child(7) { background: #f06595; }

.speech-feedback {
  font-size: 1.05rem;
  font-weight: 800;
  color: #334155;
  min-height: 28px;
  margin-bottom: 14px;
}

.speech-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.adult-assist-bar {
  border-top: 2px dashed #e2e8f0;
  padding-top: 10px;
}

.subtle-approve-btn {
  background: #fff3bf;
  color: #7c4a03;
  border: 2px solid #fcc419;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
}

.subtle-approve-btn:hover {
  background: #ffe066;
}

/* =========================================================================
   Belöningsskärm (Ballonger, Konfetti & Dansande figur)
   ========================================================================= */
.celebration-overlay {
  background: radial-gradient(circle at center, rgba(255, 224, 102, 0.92) 0%, rgba(51, 154, 240, 0.94) 65%, rgba(132, 94, 247, 0.96) 100%);
  overflow: hidden;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 501;
}

.balloons-container {
  position: fixed;
  inset: 0;
  z-index: 505;
  pointer-events: none;
  overflow: hidden;
}

.celebration-balloon {
  position: absolute;
  bottom: -155px;
  border: none;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.55), var(--balloon-color) 55%);
  box-shadow: inset -8px -12px 18px rgba(0, 0, 0, 0.14), 0 8px 16px rgba(0, 0, 0, 0.16);
  /* Söt knappnål istället för liten hand, så det ser ut som att man sticker hål i ballongen! */
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cline x1='3' y1='29' x2='19' y2='13' stroke='%23334155' stroke-width='3.2' stroke-linecap='round'/%3E%3Cline x1='3' y1='29' x2='19' y2='13' stroke='%23e2e8f0' stroke-width='1.4' stroke-linecap='round'/%3E%3Ccircle cx='22' cy='10' r='7.5' fill='%23ff4d6d' stroke='%23ffffff' stroke-width='2'/%3E%3Ccircle cx='20' cy='8' r='2.2' fill='%23ffffff' opacity='0.7'/%3E%3C/svg%3E") 3 29, crosshair;
  pointer-events: auto;
  animation: balloonFloat linear forwards;
}

.celebration-balloon.popping {
  transform: scale(1.38) !important;
  opacity: 0;
  transition: transform 0.16s, opacity 0.16s;
}

.balloon-shine {
  position: absolute;
  top: 16%;
  left: 20%;
  width: 22%;
  height: 28%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: rotate(-20deg);
}

.balloon-knot {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 8px;
  background: var(--balloon-color);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.balloon-string {
  position: absolute;
  bottom: -58px;
  left: 50%;
  width: 2px;
  height: 54px;
  background: rgba(255, 255, 255, 0.8);
}

@keyframes balloonFloat {
  0%   { transform: translateY(0) translateX(0) rotate(-3deg); }
  25%  { transform: translateY(-30vh) translateX(10px) rotate(4deg); }
  50%  { transform: translateY(-60vh) translateX(-10px) rotate(-4deg); }
  75%  { transform: translateY(-90vh) translateX(8px) rotate(3deg); }
  100% { transform: translateY(-128vh) translateX(0) rotate(0deg); }
}

.pop-ring {
  position: fixed;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 5px solid #fff;
  transform: translate(-50%, -50%) scale(0.4);
  pointer-events: none;
  z-index: 520;
  animation: popRingExpand 0.36s ease-out forwards;
}

@keyframes popRingExpand {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(3.4); opacity: 0; }
}

/* Små, små miniballonger som flyger ut när man spränger en ballong! */
.mini-balloon {
  position: fixed;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.65), var(--mini-color) 58%);
  box-shadow: inset -2px -3px 5px rgba(0, 0, 0, 0.14), 0 3px 8px rgba(0, 0, 0, 0.16);
  pointer-events: none;
  z-index: 522;
  animation: miniBalloonFly 1.2s cubic-bezier(0.22, 0.8, 0.36, 1) forwards;
}

.mini-balloon-shine {
  position: absolute;
  top: 18%;
  left: 22%;
  width: 26%;
  height: 30%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
}

.mini-balloon-string {
  position: absolute;
  bottom: -14px;
  left: 50%;
  width: 1.5px;
  height: 14px;
  background: rgba(255, 255, 255, 0.85);
}

@keyframes miniBalloonFly {
  0% {
    transform: translate(-50%, -50%) scale(0.35) rotate(0deg);
    opacity: 1;
  }
  25% {
    opacity: 1;
  }
  75% {
    opacity: 0.95;
  }
  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.05) rotate(var(--rot));
    opacity: 0;
  }
}

.celebration-content {
  position: relative;
  z-index: 515;
  text-align: center;
  max-width: 560px;
  width: 100%;
  pointer-events: none;
}

.celebration-content button {
  pointer-events: auto;
}

.celebration-banner h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 5px 0 #d9480f, 0 12px 24px rgba(0, 0, 0, 0.3);
  animation: bannerBounce 0.9s ease-in-out infinite alternate;
}

@keyframes bannerBounce {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.celebration-banner p {
  margin: 8px 0 18px;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.dancing-character-stage {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto 14px;
}

.dance-glow {
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(255, 212, 59, 0) 70%);
  animation: pulseWarn 1s ease-in-out infinite;
}

.dancing-character-img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 32px;
  border: 7px solid #fff;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.3);
  animation: characterPartyDance 0.95s ease-in-out infinite;
}

@keyframes characterPartyDance {
  0%   { transform: translateY(0) rotate(-6deg) scale(1); }
  25%  { transform: translateY(-22px) rotate(7deg) scale(1.08); }
  50%  { transform: translateY(0) rotate(-7deg) scale(0.97, 1.04); }
  75%  { transform: translateY(-18px) rotate(6deg) scale(1.07); }
  100% { transform: translateY(0) rotate(-6deg) scale(1); }
}

.pop-tip {
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  margin: 0 0 18px;
}

.celebration-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Tiden är slut-skärm */
.timeup-overlay {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(49, 46, 129, 0.95));
}

.timeup-card {
  background: #fff;
  border-radius: 32px;
  border: 6px solid #ffd43b;
  max-width: 480px;
  width: 100%;
  padding: 32px 26px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.timeup-emoji {
  font-size: 3.5rem;
  margin-bottom: 10px;
}

.timeup-card h2 {
  margin: 0 0 10px;
  font-size: 2rem;
  color: #1e293b;
}

.timeup-card p {
  font-size: 1.15rem;
  color: #475569;
  margin: 0 0 16px;
}

.timeup-stars {
  background: #fff3bf;
  color: #5c3c00;
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 1.15rem;
  margin-bottom: 22px;
}

/* =========================================================================
   Knappar & Modaler (Vuxenpanel)
   ========================================================================= */
.action-btn {
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.14s, filter 0.14s;
}

.action-btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.04); }
.action-btn:active:not(:disabled) { transform: translateY(1px); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.small-btn { padding: 9px 16px; font-size: 0.92rem; }
.blue-btn { background: linear-gradient(135deg, #339af0, #1c7ed6); }
.green-btn { background: linear-gradient(135deg, #40c057, #2b8a3e); }
.yellow-btn { background: linear-gradient(135deg, #ffd43b, #f08c00); color: #3d2400; }
.danger-btn { background: linear-gradient(135deg, #ff6b6b, #e03131); }
.subtle-btn { background: #e2e8f0; color: #334155; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 24px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: popIn 0.25s ease-out;
}

.small-modal { max-width: 420px; }
.large-modal { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: linear-gradient(135deg, #e7f5ff, #d0ebff);
  border-bottom: 2px solid #bae6fd;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #0c4a6e;
}

.icon-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #334155;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  user-select: text;
}

.modal-desc {
  margin: 0 0 10px;
  color: #475569;
}

.hint-badge {
  background: #fff3bf;
  color: #5c3c00;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.adult-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 6px;
  gap: 6px;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.92rem;
  color: #475569;
  cursor: pointer;
}

.tab-btn.active {
  background: #fff;
  color: #1864ab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #e2e8f0;
}

.compact-row {
  border-bottom: none;
  padding-bottom: 0;
  margin-top: 8px;
}

.setting-desc {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: #64748b;
}

.setting-block {
  margin-bottom: 16px;
}

.block-label {
  display: block;
  margin-bottom: 6px;
}

.text-input, .select-input, .file-input {
  padding: 10px 14px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  font-size: 0.98rem;
  font-family: inherit;
  width: 100%;
  background: #fff;
}

.short-input { width: 90px; }
.full-width { width: 100%; }

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.add-card h4 {
  margin: 0 0 10px;
  color: #1864ab;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
}

.list-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.list-item-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
}

.list-item-meta small {
  display: block;
  color: #64748b;
  font-size: 0.8rem;
}

.voice-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.error-text { color: #e03131; font-weight: 800; font-size: 0.9rem; margin-top: 8px; }
.success-text { color: #2b8a3e; font-weight: 800; font-size: 0.9rem; margin-top: 8px; }

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 30px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: 0.25s;
}

.slider::before {
  content: '';
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.25s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider { background: #40c057; }
.switch input:checked + .slider::before { transform: translateX(24px); }

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.86); }
  100% { opacity: 1; transform: scale(1); }
}

@media (max-width: 720px) {
  .character-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .board-frame {
    padding: 10px;
  }
}
