/* ==========================================================================
   TOUCH-FIRST BARNSPEL – CSS STYLESHEET
   Optimerat för surfplattor, pekskärmar och barn ca 4–8 år.
   Alla kontroller baseras på Pointer Events, stora touchytor och direkt respons.
   ========================================================================== */

/* 1. Global Reset & Touch Lock */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

:root {
  --primary-blue: #3b82f6;
  --primary-dark: #1d4ed8;
  --accent-yellow: #fbbf24;
  --accent-orange: #f97316;
  --accent-green: #22c55e;
  --accent-pink: #ec4899;
  --accent-purple: #8b5cf6;
  --bg-sky: #e0f2fe;
  --card-bg: #ffffff;
  --text-dark: #1e293b;
  --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.15);
  --font-family: 'Fredoka', 'Nunito', system-ui, -apple-system, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--font-family);
  background: #38bdf8;
  color: var(--text-dark);
}

/* Huvudcontainer med 16:9 max ratio på desktop/platta */
.touch-game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, #7dd3fc 0%, #bae6fd 60%, #86efac 100%);
}

/* ==========================================================================
   ÖVRE LIST / HEADER (Stora, tydliga ikoner och knappar)
   ========================================================================== */
.touch-game-header {
  height: 76px;
  min-height: 76px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: center;
}

/* Stora header-knappar (minst 64-80px breda/höga för enkel touch) */
.btn-touch-nav {
  min-height: 56px;
  min-width: 56px;
  height: 56px;
  padding: 0 18px;
  border-radius: 28px;
  border: 3px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-family: var(--font-family);
  font-size: 1.15rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  text-decoration: none;
  transition: transform 0.1s ease;
}

.btn-touch-nav:active {
  transform: scale(0.92);
  background: #f1f5f9;
}

.btn-touch-sound {
  background: #fef08a;
  border-color: #fde047;
  color: #854d0e;
}

.btn-touch-fs {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

.btn-touch-menu {
  background: #fbcfe8;
  border-color: #f472b6;
  color: #9d174d;
}

.star-counter-pill {
  height: 56px;
  background: #fef9c3;
  border: 3px solid #facc15;
  color: #713f12;
  border-radius: 28px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 1.35rem;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.current-game-badge {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  padding: 8px 20px;
  border-radius: 24px;
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* ==========================================================================
   SPELOMRÅDE & CANVAS VIEWPORT (16:9 ratio)
   ========================================================================== */
.touch-game-viewport {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
  height: calc(100% - 76px);
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Visuell instruktionsbanner / Uppmaning över canvas */
.game-prompt-banner {
  position: absolute;
  top: 16px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 4px solid var(--primary-blue);
  border-radius: 36px;
  padding: 12px 32px;
  font-size: 1.6rem;
  font-weight: 800;
  color: #1e3a8a;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  transform: translateY(0);
  transition: transform 0.3s ease, opacity 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.btn-speak-again {
  pointer-events: auto;
  min-height: 48px;
  min-width: 48px;
  border-radius: 24px;
  border: none;
  background: #3b82f6;
  color: #ffffff;
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 8px;
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
}

.btn-speak-again:active {
  transform: scale(0.92);
}

/* ==========================================================================
   DOM OVERLAYS (För meny, start, vinst och UI-knappar)
   ========================================================================== */

/* Stora touchknappar */
.btn-touch-giant {
  min-height: 90px;
  height: 96px;
  min-width: 240px;
  padding: 0 36px;
  border-radius: 48px;
  border: 4px solid #ffffff;
  background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
  color: #ffffff;
  font-family: var(--font-family);
  font-size: 2rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(22, 163, 74, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-touch-giant:active {
  transform: scale(0.94);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

/* Startskärm / Overlay */
.touch-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.touch-modal-overlay.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Modal-kort */
.touch-modal-card {
  background: #ffffff;
  border-radius: 36px;
  border: 6px solid #e0f2fe;
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 32px 24px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Start-hero styling */
.hero-animal-icons {
  font-size: 4rem;
  margin-bottom: 8px;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
  animation: gentleBounce 2s infinite ease-in-out;
}

@keyframes gentleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.touch-modal-title {
  font-size: 2.4rem;
  font-weight: 900;
  color: #1e3a8a;
  margin-bottom: 6px;
}

.touch-modal-subtitle {
  font-size: 1.25rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 24px;
}

/* Rutnät av 10 spel för snabb touch-navigation */
.games-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  width: 100%;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .games-picker-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.game-select-card {
  min-height: 120px;
  background: #f8fafc;
  border: 3px solid #e2e8f0;
  border-radius: 24px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.game-select-card:active {
  transform: scale(0.92);
  background: #eff6ff;
  border-color: #3b82f6;
}

.game-select-card.active-game {
  border-color: #2563eb;
  background: #dbeafe;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.game-card-emoji {
  font-size: 2.8rem;
  line-height: 1;
  margin-bottom: 6px;
}

.game-card-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.2;
}

.game-card-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  margin-top: 2px;
}

/* Vinstskärm / Belöning */
.celebrate-badge {
  font-size: 5rem;
  margin-bottom: 8px;
  animation: celebratePop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes celebratePop {
  0% { transform: scale(0.2) rotate(-20deg); opacity: 0; }
  70% { transform: scale(1.15) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.win-stars-row {
  font-size: 2.8rem;
  margin: 14px 0 20px;
}

.win-actions-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.btn-win-action {
  min-height: 72px;
  height: 76px;
  min-width: 180px;
  padding: 0 28px;
  border-radius: 38px;
  font-family: var(--font-family);
  font-size: 1.4rem;
  font-weight: 800;
  border: 4px solid #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn-win-action:active {
  transform: scale(0.94);
}

.btn-win-next {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
}

.btn-win-replay {
  background: linear-gradient(135deg, #10b981, #047857);
  color: #ffffff;
}

.btn-win-menu {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

/* ==========================================================================
   TRYCK-FEEDBACK & EFFEKTER
   ========================================================================== */
.touch-ripple-effect {
  position: absolute;
  width: 90px;
  height: 90px;
  margin-left: -45px;
  margin-top: -45px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(254, 240, 138, 0.8) 0%, rgba(251, 191, 36, 0.4) 60%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
  animation: ripplePop 0.45s ease-out forwards;
  z-index: 999;
}

@keyframes ripplePop {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Stor feedback-popup vid rätt svar (🎉 BRA!) */
.feedback-floating-tag {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: #ffffff;
  border: 5px solid #22c55e;
  border-radius: 40px;
  padding: 16px 40px;
  color: #15803d;
  font-size: 2.6rem;
  font-weight: 900;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 150;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 16px;
}

.feedback-floating-tag.show {
  transform: translate(-50%, -50%) scale(1);
}

/* Stora svarsknappar (120x120px på surfplatta) */
.dom-touch-options {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  z-index: 80;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 95%;
}

.dom-touch-card {
  min-width: 110px;
  min-height: 110px;
  width: 120px;
  height: 120px;
  border-radius: 30px;
  border: 4px solid #ffffff;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.dom-touch-card:active {
  transform: scale(0.92);
}

@media (min-width: 768px) {
  .dom-touch-card {
    min-width: 130px;
    min-height: 130px;
    width: 140px;
    height: 140px;
    font-size: 4.2rem;
  }
}

/* Anpassning för mindre skärmar */
@media (max-width: 576px) {
  .touch-game-header {
    height: 64px;
    min-height: 64px;
    padding: 0 8px;
  }
  .btn-touch-nav {
    min-height: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0 12px;
    font-size: 0.95rem;
  }
  .star-counter-pill {
    height: 48px;
    padding: 0 12px;
    font-size: 1.1rem;
  }
  .current-game-badge {
    padding: 6px 12px;
    font-size: 1rem;
  }
  .game-prompt-banner {
    font-size: 1.25rem;
    padding: 8px 18px;
    top: 10px;
  }
  .btn-touch-giant {
    height: 80px;
    min-height: 80px;
    min-width: 200px;
    font-size: 1.6rem;
  }
}

/* ==========================================================================
   ÄMNESFILTER & KATEGORIKNAPPAR (Matte, Svenska, Engelska, SO, NO, Bild, Hem)
   ========================================================================== */
.subject-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
  margin-bottom: 20px;
}

.btn-subject-tab {
  min-height: 48px;
  padding: 8px 16px;
  border-radius: 24px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-subject-tab:active {
  transform: scale(0.94);
}

.btn-subject-tab.active {
  background: #3b82f6;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Ämnesmärken på spelkorten */
.game-card-subject-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
  margin-top: 4px;
  text-transform: uppercase;
}

.tag-matte { background: #dbeafe; color: #1e40af; }
.tag-svenska { background: #fce7f3; color: #9d174d; }
.tag-engelska { background: #ede9fe; color: #5b21b6; }
.tag-so { background: #e0e7ff; color: #3730a3; }
.tag-no { background: #dcfce7; color: #166534; }
.tag-bild { background: #fef3c7; color: #92400e; }
.tag-hem { background: #fee2e2; color: #991b1b; }
.tag-lek { background: #e0f2fe; color: #0369a1; }

/* ==========================================================================
   STJÄRNRESAN & MASKOTAR
   ========================================================================== */
.btn-touch-star-journey {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #fef3c7;
  color: #ffffff;
  font-weight: 900;
}

.mascot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  width: 100%;
  margin-bottom: 20px;
}

.mascot-card {
  background: #f8fafc;
  border: 3px solid #cbd5e1;
  border-radius: 20px;
  padding: 12px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mascot-card.unlocked {
  border-color: #22c55e;
  background: #f0fdf4;
  box-shadow: 0 4px 10px rgba(34, 197, 94, 0.2);
}

.mascot-card.locked {
  opacity: 0.55;
  filter: grayscale(0.8);
}

.mascot-emoji {
  font-size: 2.8rem;
  line-height: 1;
  margin-bottom: 4px;
}

.mascot-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1e293b;
}

.mascot-stars-needed {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
}

/* Dagens utmaning HUD */
.daily-challenge-badge {
  background: linear-gradient(135deg, #ec4899, #be185d);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

