/* =========================
   GAME BOARD & CELLS
   ========================= */

#game-board-container {
  background: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  margin: 0;
  padding: 0;
}

#game-board-wrapper {
    background-color: transparent;
}

#gameBoard {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
  width: min(90vw, 90vh, 420px);
  height: min(90vw, 90vh, 420px);
  margin: 30px auto 25px auto;
  padding: 0;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background-color: #fff;
  border: 2px solid #d6c8f7;
  border-radius: 22px;
}

.container.game-active {
  border: none;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100dvh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  gap: 0;
  overflow: hidden;
  position: fixed;
  background: linear-gradient(180deg, #f6f6fa 0%, #ede0ff 60%, #e8deff 100%);
}

/* Hide home elements when game is active */
.container.game-active .home-top,
.container.game-active .home-bottom {
  display: none;
}

.cell {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  font-size: clamp(16px, 3vw, 24px);
  touch-action: none;
  cursor: pointer;
  border-radius: 16px;
  background-color: #fff;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

@media (hover: hover) {
  .cell:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 10px rgba(108, 92, 231, 0.25);
    z-index: 1;
  }
}

.cell:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(108, 92, 231, 0.3);
}

/* Subtle, accessible symbol backgrounds */
.cell-violin {
  background: #ffe5ec;
}
.cell-piano {
  background: #e5f0ff;
}
.cell-trumpet {
  background: #fff9e5;
}
.cell-drum {
  background: #e5fff0;
}
.cell-saxophone {
  background: #f3e5ff;
}
.cell-musicalnote {
  background: #f0f0ff;
}

.cell.selected {
  background-color: #f6c453;
  border: 2px solid #e29a1f;
  transform: scale(1.05);
}

.cell.matched {
  background-color: #8fd3a8;
  transform: scale(1.15);
  transition: transform 0.2s, background-color 0.2s;
}

.cell:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  z-index: 2;
  box-shadow: 0 0 0 3px #ede7fa;
}

/* =========================
   SCORE POPUP
   ========================= */

.score-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(34, 197, 94, 0.95);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.28);
  pointer-events: none;
  z-index: 5;
  animation: scorePopupFloat 0.7s ease-out forwards;
}

.combo-popup {
  background: rgba(245, 158, 11, 0.96);
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.3);
}

@keyframes scorePopupFloat {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
  20%  { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1.05); }
}

/* =========================
   HUD / TOP BAR
   ========================= */

#score-moves-wrapper {
  width: 100%;
  padding: 10px 10px 8px;
  box-sizing: border-box;
  background: linear-gradient(135deg, var(--color-primary) 0%, #8f5cff 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex-shrink: 0;
  height: auto;
  min-height: unset;
}

.top-bar-custom {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
  box-sizing: border-box;
}

.top-bar-custom > * {
  min-width: 0;
}

.level-center {
  flex: 0 1 auto;
  text-align: left;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 14px;
  letter-spacing: 0.6px;
  margin: 0 auto 0 0;
  color: white;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

#livesDisplay,
#livesCount {
  color: white;
}

#livesDisplay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  font-size: 0.98rem;
  font-weight: 700;
  white-space: nowrap;
}

#totalScoreDisplay {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  text-align: center;
  padding: 6px 16px;
  background: linear-gradient(135deg, #f3f3fa 0%, #e6eaff 100%);
  border: 2px solid #d0d0f0;
  border-radius: 16px;
  margin: 6px auto 4px;
  max-width: 200px;
  box-shadow: 0 2px 6px rgba(108, 92, 231, 0.1);
}

.home-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: white;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  margin: 0;
  width: fit-content;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(30, 30, 80, 0.12);
}

.home-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(30, 30, 80, 0.18);
}

.home-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(30, 30, 80, 0.14);
}

/* =========================
   INFO BAR: MOVES, SCORE & TIMER
   ========================= */

.moves-score-timer-row {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
}

.moves-score-timer-row > * {
  min-width: 0;
}

.moves-horizontal,
.score-horizontal,
.timer-horizontal {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95em;
  font-weight: 600;
  flex: 1 1 0;
  border-radius: 14px;
  border: 2px solid #e0e0f7;
  background: linear-gradient(90deg, #f3f3fa 80%, #e6eaff 100%);
  padding: 6px 8px;
  box-sizing: border-box;
}

#timerDisplay.low-time {
  background: linear-gradient(135deg, #ff6b6b 0%, #e03131 100%);
  color: #fff;
  border-color: #ff6b6b;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.18), 0 6px 14px rgba(224, 49, 49, 0.28);
  animation: timerWarningPulse 1s ease-in-out infinite;
}

@keyframes timerWarningPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.04); }
}

/* =========================
   OBJECTIVE COUNTERS
   ========================= */

#objective-counters {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, #eef1ff 0%, #e4e9ff 100%);
  border: 1px solid #c8cff5;
  box-shadow: 0 2px 10px rgba(60, 60, 120, 0.08);
  border-radius: 18px;
  padding: 8px 12px;
  margin: 0 auto 8px;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
}

#objective-counters span {
  color: #2f335c;
  padding: 2px 4px;
  font-size: 0.95em;
  font-weight: 700;
  flex: 0 1 auto;
  box-sizing: border-box;
  text-align: center;
  white-space: nowrap;
}

/* =========================
   RESPONSIVE — TABLET & DESKTOP
   min-width: 768px
   ========================= */

@media (min-width: 768px) {
  .moves-score-timer-row {
    gap: 16px;
  }

  .moves-horizontal,
  .score-horizontal,
  .timer-horizontal {
    font-size: 1.1em;
    min-width: 90px;
    flex: 0 1 auto;
    padding: 8px 12px;
  }

  #objective-counters {
    gap: 16px;
    padding: 12px 20px;
  }

  #objective-counters span {
    font-size: 1.05em;
    padding: 2px 6px;
  }
}