body {
  font-family: Arial, sans-serif;
  text-align: center;
  background-color: #f0f0f0;
  margin: 0;
  color: #1c1c1c;
}

.main-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100dvh; /* dynamic viewport height for mobile */
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  width: 100%;
}

.subtitle {
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 0;
}

h1 {
  font-family: 'Dancing Script', cursive; /* decorative font only for title */
  font-size: 2.5em;
  margin: 0;
}

/* ---------- TOP BAR, GAME, FEEDBACK SHARED ---------- */
.top-bar,
.game-container,
.feedback-area {
  width: 80%;           /* ~80% of screen */
  max-width: 400px;     /* cap at desktop design size */
  margin-left: auto;    /* keep centered */
  margin-right: auto;
}

/* ---------- TOP BAR ---------- */
.top-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr; /* 3 equal blocks */
  align-items: center;
  margin: 10px auto;
  gap: 8px;
}

#learn-btn,
#play-btn,
.score-container {
  font-size: 14px;       
  font-weight: bold;     
  height: 42px;          
  line-height: 42px;     
  padding: 0;            
  border-radius: 5px;
  text-align: center;
  border: 1px solid #ccc; /* unify borders */
}

/* Buttons */
#learn-btn,
#play-btn {
  background-color: #e36f46;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Animate when New Game appears */
#play-btn.new-game {
  animation: popIn 0.5s ease, wiggleLoop 3.6s infinite ease-in-out;
}

/* Score box */
.score-container {
  background: #fff;
}

#score {
  margin: 0;
}

/* ---------- GAME CONTAINER ---------- */
.game-container {
  background-color: #333;
  border: 2px solid #1D929A;
  border-radius: 10px;
  padding: 15px;
  height: 480px; /* desktop look preserved */
  margin-top: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
}

.game-container.dimmed {
  opacity: 0.4;
  pointer-events: none;
}

/* Button grid fills container */
.button-container {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(6, 1fr);
  gap: 10px;
}

.button-container button {
  background-color: #1D929A;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.button-container button:hover:not(:disabled) {
  background-color: #29b4c1;
}

.button-container button:disabled {
  background-color: #888;
  cursor: not-allowed;
}

/* ---------- FEEDBACK ---------- */
.feedback-area {
  position: relative;
  margin: 0 auto;
  height: 0; /* float only */
}

#inline-feedback {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%); /* always center */
  margin-top: 8px;
  font-size: 1em;
  font-weight: bold;
  text-align: center;
  white-space: nowrap;
}

#inline-feedback.correct {
  color: green;
}

#inline-feedback.wrong {
  color: red;
}

/* Wiggle animation with centering preserved */
@keyframes wiggle {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  15% { transform: translateX(-50%) rotate(-5deg); }
  30% { transform: translateX(-50%) rotate(5deg); }
  45% { transform: translateX(-50%) rotate(-5deg); }
  60% { transform: translateX(-50%) rotate(5deg); }
  75% { transform: translateX(-50%) rotate(-5deg); }
  90% { transform: translateX(-50%) rotate(5deg); }
}

.wiggle {
  animation: wiggle 0.5s ease;
}

/* ---------- NEW GAME ANIMATIONS ---------- */
@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  80% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

/* wiggle every 3s with pause */
@keyframes wiggleLoop {
  0%, 90%, 100% { transform: rotate(0deg); }
  5% { transform: rotate(-5deg); }
  10% { transform: rotate(5deg); }
  15% { transform: rotate(-5deg); }
  20% { transform: rotate(5deg); }
  25% { transform: rotate(0deg); }
}

/* ---------- MOBILE ADJUSTMENTS ---------- */
@media (max-width: 500px) {
  .game-container {
    height: auto;            /* no fixed height */
    aspect-ratio: 5 / 6;     /* scale like original proportions */
  }

  .button-container {
    gap: 6px; /* slightly smaller gaps */
  }

  .button-container button {
    font-size: 0.8em; /* smaller text so it fits */
  }

  h1 {
    font-size: 2em; /* smaller title on phones */
  }

  #score {
    font-size: 14px;
  }
}

/* ---------- OVERLAY LEARN ---------- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.overlay.hidden {
  display: none;
}

.learn-box {
  background: #fff;
  padding: 20px 25px;
  border-radius: 10px;
  text-align: center;
  max-width: 350px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.learn-box h2 {
  margin-top: 0;
  font-size: 1.5em;
}

.learn-box p {
  font-size: 14px;
  margin: 10px 0 20px;
}

#close-learn {
  background-color: #e36f46;
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
