/* Grundlayout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-touch-callout: none; /* Tar bort long-press meny på iOS */
  -webkit-user-select: none;   /* Safari */
  -moz-user-select: none;      /* Firefox */
  -ms-user-select: none;       /* IE/Edge */
  user-select: none;           /* Standard */
  -webkit-tap-highlight-color: transparent;
}

/* img, button, div, span {
  -webkit-user-drag: none;
  user-drag: none;
} */

:root {
  --avatar-border-color: transparent;
}

body {
  font-family: "Nunito", "Fluent Emoji Color", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI Emoji", sans-serif;
  /* font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; */
  background: linear-gradient(135deg, #3b82f6, #a855f7);
  color: #0f172a;
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
}

/* Header */
.header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  background: #f9fafb;
  background: linear-gradient(180deg, #f6fbff, #eaf4ff);
  border: 4px solid rgba(50, 50, 50, 0.08);
  outline: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 3px 3px rgba(50, 50, 50, 0.2);
  margin-bottom: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 220px;
}

.logo-icon {
  font-size: 40px;
}

.logo-icon img {
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  display: flex;
}

.logo h1 {
  font-size: 1.4rem;
  margin-bottom: 2px;
}

.logo p {
  font-size: 0.85rem;
  color: #6b7280;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1 1 260px;
  justify-content: flex-end;
}

.profile-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* .profile-avatar {
  font-size: 34px;
  background: #e5e7eb;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--avatar-border-color);
} */

.profile-avatar {
  font-size: 34px;
  background: #e5e7eb;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;

  /* 🔑 NYA STYLAR FÖR GRADIENT-RAM */

  /* 1. Definiera de två bakgrundslagren (vitt inre lager & kantlinjelager) */
  background-image:
    linear-gradient(90deg, #e5e7eb, #e5e7eb), /* Det inre (vita) lagret */
    var(--avatar-border-gradient);         /* Variabeln som vi sätter i JS */

  /* 2. Klipp det vita lagret så att gradienten syns i kantlinje-området */
  background-clip: padding-box, border-box;
  background-origin: border-box;

  /* 3. Gör den riktiga kantlinjen transparent för att ge plats */
  border: 3px solid transparent;
}

.profile-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.profile-title {
  font-size: 0.8rem;
  color: #6b7280;
}

.profile-prestige {
  font-size: 0.75rem;
  font-weight: 700;
  color: #92400e;
  background: linear-gradient(90deg, #fde68a, #fbbf24);
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  margin-top: 2px;
}

.profile-prestige:empty {
  display: none;
}

.profile-progress {
  min-width: 170px;
}

.level-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.8rem;
}

.stars {
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* XP-bar */
.xp-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 4px;
}

.xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #a3e635);
  transition: width 0.3s ease;
}

.xp-text {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Main layout */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 12px;
  /* min-height: calc(100vh - 200px); */
}

/* Worlds / områden */
.worlds {
  background: rgba(249, 250, 251, 0.95);
  background: linear-gradient(180deg, #f6fbff, #eaf4ff);
  border: 4px solid rgba(50, 50, 50, 0.08);
  outline: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 3px 3px rgba(50, 50, 50, 0.2);
}

.worlds h2 {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.worlds-subtitle {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 10px;
}

/* Dagens uppdrag */
.daily-card {
  background: #f1f5f9;
  border: 2px solid rgba(0,0,0,0.05);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 8px 10px;
  margin-top: 12px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.daily-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.daily-title {
  font-weight: 600;
}

.daily-progress {
  font-size: 0.85rem;
  color: #374151;
}

.daily-completed {
  margin-top: 5px;
  color: #16a34a;
  font-weight: 600;
}

/* Grund (om du inte redan har nåt liknande) */
#daily-mission {
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* När uppdraget är klart – kort “pop” */
.daily-mission-complete {
  animation: missionCompletePop 0.5s ease;
}

@keyframes missionCompletePop {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* (valfritt) lite grön feeling för klart-läge */
/*
.daily-mission-complete-box {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.5);
  border-radius: 4px;
  padding: 5px;
}
*/

@media (min-width: 700px) {
  #daily-mission {
    max-width: 550px;
  }
}

/* Worlds grid */
.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.world-card {
  position: relative;
  /* background: #e5e7eb; */
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(15, 30, 50, 0.06);
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition:
    transform 260ms cubic-bezier(0.2, 0.9, 0.3, 1),
    box-shadow 260ms;
  will-change: transform;
}
.world-card:hover{
  transform: translateY(-8px) rotate(-1deg);
  box-shadow: 0 14px 40px rgba(74, 160, 247, 0.12);
}

/* Aktiv värld */
.world-card.active {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  transform: scale(102%);
  transition: transform 0.05s ease;
}

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

.world-icon {
  font-size: 1.6rem;
}

.world-name {
  font-weight: 600;
  font-size: 1rem;
}

.world-progress {
  font-size: 0.8rem;
  color: #111827;
  margin-top: 4px;
}

/* Låsta världar */
.world-card.locked {
  opacity: 0.55;
  cursor: default;
}

.world-lock {
  margin-left: auto;
  font-size: 1rem;
}

/* Mastered / “krans” */
.world-card.mastered {
  border: 1px solid #fbbf24;
}

.world-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 1.1rem;
}

/* Game area */
.game-area {
  display: flex;
  flex-direction: column;
}

.game-card {
  background: rgba(249, 250, 251, 0.98);
  background: linear-gradient(180deg, #f6fbff, #eaf4ff);
  border-radius: 20px;
  border: 2px dashed rgba(50, 50, 50, 0.2);
  outline: 4px solid rgba(249, 250, 251, 0.98);
  padding: 14px;
  box-shadow: 5px 5px rgba(50, 50, 50, 0.2);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  margin-top: 4px;
  transition: transform .35s ease, opacity .35s ease;
  /* transition: transform 0.2s ease, box-shadow 0.2s ease; */
}

/* Pop-out */
.card-pop-out {
  transform: scale(0.9);
  opacity: 0;
}

/* Pop-in */
.card-pop-in {
  transform: scale(1.1);
  opacity: 0;
}

.card-pop-in-active {
  transform: scale(1);
  opacity: 1;
}

/*
.game-card.card-pop {
  animation: cardPop 0.22s ease;
}

@keyframes cardPop {
  0% {
    transform: scale(0.96);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
  }
  60% {
    transform: scale(1.02);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
  }
}
*/

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#category-icon {
  font-size: 1.6rem;
}

#category-title {
  font-size: 1.2rem;
}

/* Fråga + svar */
.question-container {
  flex: 1;
  margin-bottom: 10px;
}

.question-text {
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.helper-text {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 8px;
}

.answer-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-btn {
  color: #333;
  flex: 1 1 calc(50% - 8px);
  min-width: 120px;
  border-radius: 12px;
  padding: 14px;
  background: #e5e7eb;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.1s ease;
  font-family: "Nunito", sans-serif;

  background: linear-gradient(180deg, #fff, #f4fbff);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-weight: 800;
}

.answer-btn:hover {
  transform: translateY(-0.5px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

.answer-btn.correct {
  background: #22c55e;
  background: linear-gradient(120deg, #d4fc79 0%, #96e6a1 100%);
  color: white;
}

/* Pop-animation när man trycker på en knapp */
.answer-btn:active {
  transform: scale(0.95);
}

/* När svaret är rätt */
/* .answer-btn.correct {
  animation: correctPop 0.4s ease;
  background: #6bd66b !important;
  color: #fff !important;
} */

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* När svaret är fel */
.answer-btn.incorrect {
  animation: shake 0.4s ease;
  background: #ff6b6b;
  background: linear-gradient(to right, #f78ca0 0%, #f9748f 19%, #fd868c 60%, #fe9a8b 100%);
  color: #fff !important;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-6px); }
  100% { transform: translateX(0); }
}

.free-input {
  width: 80%;
  max-width: 200px;
  padding: 10px 14px;
  font-size: 1.2rem;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  margin: 12px 0;
  text-align: center;
}

.drag-choices {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.drag-tile {
  padding: 0.6rem 1rem;
  background: white;
  border: 3px solid #cbd5e1;
  border-radius: 12px;
  font-size: 1.2rem;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s;
}

.drag-tile:active {
  transform: scale(0.95);
}

.drop-zone {
  width: 160px;
  height: 60px;
  margin: 1rem auto;
  border: 3px dashed #94a3b8;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #64748b;
  background: rgba(255,255,255,0.4);
  user-select: none;
  pointer-events: auto;
  -webkit-user-select: none; /* WebKit/Chrome/Safari/iOS */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* Edge/IE */
}

.drop-correct {
  border-color: #4ade80 !important;
  background: #bbf7d0 !important;
  color: #065f46 !important;
}

.drop-incorrect {
  border-color: #f87171 !important;
  background: #fecaca !important;
  color: #7f1d1d !important;
}

/* Feedback */
.feedback {
  min-height: 24px;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

/* Buttons */
.btn {
  border-radius: 12px;
  border: none;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.05s ease, box-shadow 0.1s ease, background 0.2s ease;
  font-family: "Nunito", sans-serif;
}

.btn.primary {
  background: #2563eb;
  color: white;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
}

.btn.primary:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.btn.secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn.small {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

/* Game actions */
.game-actions {
  display: flex;
  justify-content: flex-end;
}

/* Introtext */
.intro-text {
  font-size: 1rem;
  line-height: 1.5;
}

/* Overlay (profiler + shop) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 20;
}

.overlay.show {
  display: flex;
}

.overlay-content {
  background: #f9fafb;
  border-radius: 20px;
  padding: 16px;
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.4);
}

.overlay-content h2 {
  margin-bottom: 8px;
}

.overlay-content h3 {
  margin: 12px 0 6px;
}

/* question image */
.question-image {
  display: block;
  max-width: 220px;      /* lagom för iPad/mobil */
  width: 100%;
  height: auto;
  margin: 0 auto 0.75rem;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25);
  background: rgba(15, 23, 42, 0.05);
  object-fit: contain;
}

/* Profillista */
.profile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.profile-card {
  border-radius: 16px;
  padding: 8px 10px;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 200px;
  justify-content: space-between;
}

.profile-card-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-card-avatar {
  font-size: 1.5rem;
}

.profile-card-info {
  display: flex;
  flex-direction: column;
}

.profile-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.profile-card-meta {
  font-size: 0.7rem;
  color: #6b7280;
}

.profile-delete-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  color: #9ca3af;
}

/* Emoji-val */
.emoji-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.emoji-option {
  font-size: 1.4rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
  background: #e5e7eb;
}

.emoji-option.selected {
  outline: 2px solid #2563eb;
  background: #dbeafe;
}

/* Form */
#profile-name {
  width: 100%;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  margin-top: 4px;
  margin-bottom: 6px;
}

/* Footer */
.footer {
  margin-top: 10px;
  text-align: center;
  color: #e5e7eb;
  font-size: 0.8rem;
}

/* Flygande stjärna-animation */
.flying-star {
  position: fixed;
  font-size: 2.2rem;
  pointer-events: none;
  animation: starFly 1s ease-out forwards;
  z-index: 999999;
}

@keyframes starFly {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  50% { transform: translateY(-80px) scale(1.5); opacity: 1; }
  100% { transform: translateY(-160px) scale(0.5); opacity: 0; }
}

/* Confetti */
#confettiWrap {
  overflow: hidden;
}
.confetti {
  position: absolute;
  border-radius: 2px;
}

/* PRESTIGE */
.prestige-window {
  max-width: 420px;
  text-align: center;
}

.prestige-window #prestige-info {
  line-height: 1.5;
  margin-bottom: 14px;
}

.prestige-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* SHOP */
.shop-window {
  max-width: 500px;
}

.shop-stars {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.shop-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.shop-tab {
  flex: 1;
  padding: 6px 8px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #e5e7eb;
  font-size: 0.85rem;
}

.shop-tab.active {
  background: #2563eb;
  color: #fff;
}

#shop-item-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.shop-item {
  background: #f4f4f4;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.shop-item:hover {
  transform: scale(1.05);
}

.shop-item-main {
  font-size: 2rem;
}

.shop-item-main.skin-preview {
  width: 100%;
  height: 40px;
  border-radius: 10px;
}

/* .shop-item-main.border-preview {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 4px solid transparent;
  background: #fff;
} */

.shop-item-main.border-preview {
  width: 32px;
  height: 32px;
  border-radius: 999px;

  /* 🔑 NY Gradient-Ram Logik */

  /* 1. Skapa utrymmet för ramen */
  border: 4px solid transparent;

  /* 2. Definiera de två bakgrundslagren (vitt inre lager & kantlinjelager) */
  background-image:
    linear-gradient(90deg, #fff, #fff), /* Vitt inre lager (som var din gamla bakgrund) */
    var(--shop-border-gradient);         /* Variabeln för den specifika ramen */

  /* 3. Klipper det vita lagret så att gradienten syns i kantlinje-området */
  background-clip: padding-box, border-box;
  background-origin: border-box;
}

.shop-label {
  font-size: 0.8rem;
}

.shop-cost {
  font-size: 0.75rem;
  color: #333;
}

.shop-item.owned {
  border: 2px solid #fbbf24;
}

.shop-item.equipped {
  box-shadow: 0 0 0 2px #2563eb;
}

@media (max-width: 899px) {
  .main {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 599px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-summary {
    width: 100%;
    justify-content: space-between;
  }

  .answer-btn {
    flex: 1 1 100%;
  }

  #shop-item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header-actions {
    flex-direction: row;
  }
}

/* --- Coachfigur nere i hörnet --- */
/* === Coach Figur === */
#coach-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  z-index: 9999;
}

/* Pratbubblan till vänster */
#coach-bubble {
  background: white;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid #ddd;
  max-width: 220px;
  font-size: 0.9rem;
  line-height: 1.3;
  display: none;                /* dold tills coachen pratar */
  animation: bubblePop 0.25s ease;
  position: relative;
}

/* Litet "triangel"-tal till bubblan */
#coach-bubble::after {
  content: "";
  position: absolute;
  right: -16px;
  bottom: 12px;
  border-width: 8px;
  border-style: solid;
  border-color: transparent transparent transparent white;
}

/* Själva coach-karaktären */
#coach-character {
  border-radius: 50%;
  background: #f9fafb;
  border: 3px solid rgba(148, 163, 184, 0.7);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.25);
  font-size: 2rem;
  cursor: pointer;
  transition: transform 0.15s ease;
  width: 48px;
  height: 48px;
  text-align: center;
}

#coach-character:hover {
  transform: scale(1.12);
}

@keyframes bubblePop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Göm coachen på väldigt små skärmar om du vill */
@media (max-width: 640px) {
  #coach-container {
    display: none;
  }
}

@media (max-width: 768px) {
  #world-grid {
    max-height: 20vh;   /* justera 50–65vh efter smak */
    overflow-y: auto;
    padding-right: 4px; /* liten marginal så scrollen inte gömmer text */
  }

  /* gör så att scrollbaren ser snygg ut (valfritt) */
  #world-grid::-webkit-scrollbar {
    width: 6px;
  }
  #world-grid::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
  }

  .header {
    /* gör headern kompakt */
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;   /* viktigt: INTE space-between */
    padding: 10px 14px;
    gap: 8px;
  }

  .logo {
    display: none;
  }

  .profile-summary {
    flex: 0 0 auto;
    width: 100%;
    justify-content: space-between;
  }

  .profile-progress {
    display: none;
  }
}
