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

html, body {
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;   /* lock both horizontal and vertical scrolling */
  position: fixed;    /* freeze the viewport */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

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

.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;
  font-size: 2.5em;
  margin: 0;
}

/* ---------- TOP BAR, GAME, FEEDBACK ---------- */
.top-bar,
.game-container,
.feedback-area {
  width: 400px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

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

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

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

#play-btn.new-game {
  animation: popIn 0.5s ease, wiggleLoop 3.6s infinite ease-in-out;
}

.score-container {
  background: #fff;
}

#score {
  margin: 0;
}

/* ---------- GAME CONTAINER ---------- */
.game-container {
  background-color: #333;
  border: 2px solid #1D929A;
  border-radius: 10px;
  padding: 15px;
  width: 400px;
  margin-top: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: auto; /* adapt to square buttons */
}

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

/* Buttons: three in a row, perfect squares */
.button-container.three-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.button-container.three-row button {
  aspect-ratio: 1 / 1;
  background-color: #1D929A;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  font-size: 1em;
}

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

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

/* ---------- FEEDBACK ---------- */
.feedback-area {
  position: relative;
  height: 0;
}

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

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

/* Wiggle animation */
@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); }
}

@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) {
  .top-bar,
  .game-container,
  .feedback-area {
    width: 80%;
    max-width: 400px;
  }

  /* Feedback smaller on mobile */
  #inline-feedback {
    font-size: 0.9em;
  }
}

/* ---------- OVERLAY ---------- */
.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;
}
