/* Base styles for the mini‑game */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Arial', sans-serif;
  color: #f5f5f5;
  overflow-x: hidden;
}

/* Utility classes */
.hidden {
  display: none !important;
}

/* Overlays for start and finish screens */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.4);
}

.start-content, .finish-content {
  max-width: 500px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2rem 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.start-character {
  width: 140px;
  height: auto;
  margin-bottom: 1rem;
}

.start-title, .finish-title {
  font-size: 1.4rem;
  color: #f5e6c6;
  margin: 0;
}

.finish-text {
  font-size: 1rem;
  color: #f5e6c6;
  margin: 0.5rem 0 1rem;
}

.start-btn, .cta-btn {
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.5rem;
  color: #1e1e1e;
  background: linear-gradient(90deg, #f7c84d 0%, #a07c4a 100%);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.1s;
}

/* Container for multiple CTA buttons on the finish screen */
.cta-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  align-items: center;
}

.start-btn:hover, .cta-btn:hover {
  transform: scale(1.05);
}

/* Adjust positioning of mini progress bar */
.mini-progress {
  width: 80%;
  max-width: 320px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin: 2rem auto 0;
}

/* Background image and subtle animation */
#background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background-image: url('background.png');
  background-size: cover;
  background-position: center;
  filter: brightness(0.7);
  animation: bgMove 40s linear infinite alternate;
  overflow: hidden;
}

@keyframes bgMove {
  from { background-position: 50% 0%; }
  to   { background-position: 50% 100%; }
}

/* Twinkling stars overlay */
#stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: -1;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
  animation: twinkle 2s infinite ease-in-out;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.8; transform: scale(0.8); }
  50%      { opacity: 0.2; transform: scale(1.2); }
}

/* Main container styling */
.container {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1rem;
  box-sizing: border-box;
  z-index: 1;
}

header {
  text-align: center;
  margin-bottom: 1rem;
}

h1 {
  margin: 0.5rem 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffd27f;
}

#description {
  margin: 0.5rem 0;
  font-size: 1rem;
  color: #f5e6c6;
}

/* General progress bar (for all 9 mini‑games) */
.general-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.general-progress-bar {
  position: relative;
  width: 180px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.general-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f7c84d 0%, #a07c4a 100%);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.general-progress-text {
  font-size: 0.9rem;
  color: #f5e6c6;
  min-width: 50px;
  text-align: left;
}

/* Shelves */
.shelves {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  width: 100%;
  margin-top: 1rem;
  gap: 1.5rem;
}

.shelf {
  position: relative;
  flex: 1 1 40%;
  min-width: 140px;
  max-width: 220px;
  height: 100px;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  transition: background 0.3s, transform 0.3s;
}

.shelf.active {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-4px) scale(1.02);
}

.shelf.correct {
  border-color: #3aca8f;
  box-shadow: 0 0 12px #3aca8f;
}

.shelf.incorrect {
  border-color: #e55a5a;
  box-shadow: 0 0 12px #e55a5a;
}

.shelf-icon {
  margin-bottom: 0.2rem;
}

/* Half icon: a glowing half circle */
.half-icon {
  width: 24px;
  height: 12px;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  /* gradient from gold to amber, vivid enough to be visible on dark background */
  background: linear-gradient(to top, #f7c84d, #c49a3e);
  box-shadow: 0 0 6px #f7c84d;
}

/* Whole icon: a glowing full circle */
.whole-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  /* smooth golden gradient for visibility */
  background: radial-gradient(circle at center, #f7c84d 0%, #c49a3e 70%, rgba(0,0,0,0) 100%);
  box-shadow: 0 0 6px #f7c84d;
}

.shelf-label {
  font-size: 0.9rem;
  color: #f5e6c6;
  text-align: center;
  user-select: none;
}

/* Card styling */
#card-container {
  position: relative;
  width: 100%;
  height: 120px;
  margin-top: 2.5rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  /* pointer-events intentionally left enabled so that cards receive pointer events */
  /* Prevent default scroll and pinch behaviours when dragging on touch screens */
  touch-action: none;
}

.card {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  color: #2a2a2a;
  padding: 0.8rem 1.2rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: grab;
  user-select: none;
  transition: transform 0.2s ease;
  z-index: 10;
  pointer-events: auto;
  /* Prevent browser touch actions such as scrolling and zooming when dragging */
  touch-action: none;
}

.card.dragging {
  cursor: grabbing;
  box-shadow: 0 8px 16px rgba(0,0,0,0.4), 0 0 15px rgba(247, 200, 77, 0.7);
  transform: translateX(-50%) scale(1.05);
}

.card.correct {
  background: #e1f5ea;
  border: 2px solid #3aca8f;
  box-shadow: 0 0 12px #3aca8f;
}

.card.incorrect {
  background: #ffe8e8;
  border: 2px solid #e55a5a;
  box-shadow: 0 0 12px #e55a5a;
}

/* Mini game progress bar */
.mini-progress {
  width: 100%;
  max-width: 320px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 2rem;
}

.mini-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f7c84d 0%, #a07c4a 100%);
  transition: width 0.4s ease;
}

/* Explanation box */
.explanation {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: #f5e6c6;
  min-height: 2rem;
  text-align: center;
  transition: opacity 0.3s;
  opacity: 0;
}

.explanation.show {
  opacity: 1;
}

/* Responsiveness */
@media (max-width: 600px) {
  /* Keep shelves in a single row on small screens */
  .shelves {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 1rem;
  }
  .shelf {
    flex: 0 0 48%;
    max-width: none;
    min-width: 140px;
    height: 110px;
  }
  /* Card should not wrap text; increase its size on small screens */
  .card {
    font-size: 1rem;
    white-space: nowrap;
    max-width: 90%;
    text-align: center;
  }

  /* Increase the height of the card container on small screens to provide
     more space for dragging cards */
  #card-container {
    height: 160px;
  }

  /* Adapt start and finish screen content on small screens */
  .start-content, .finish-content {
    width: 100%;
    padding: 1.5rem;
  }
  .start-character {
    width: 100px;
  }
  .start-title, .finish-title {
    font-size: 1.2rem;
  }
  .finish-text {
    font-size: 0.9rem;
  }
  .start-btn, .cta-btn {
    width: 100%;
  }
}