html, body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: url("../img/body-bg.png");
  background-repeat: repeat;
  background-position: center;
  background-size: cover;
}

.chakra-petch-regular {
  font-family: "Chakra Petch", sans-serif;
  font-weight: 400;
  font-style: normal;
}

.chakra-petch-bold-italic {
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  font-style: italic;
}

.chakra-petch-semibold-italic {
  font-family: "Chakra Petch", sans-serif;
  font-weight: 600;
  font-style: italic;
}

.chakra-petch-light-italic {
  font-family: "Chakra Petch", sans-serif;
  font-weight: 300;
  font-style: italic;
}

header {
  background: url("../img/header-footer-bg.png") repeat center center;
  background-size: cover;
  color: #fff;
  box-shadow: 0 15px 6px -2px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.logo {
  max-height: 80px;
}

@media (max-width: 768px) {
  .logo {
    max-height: 50px;
  }
}

@media (max-width: 576px) {
  .logo {
    max-height: 40px;
  }
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin-top: 4%;
  overflow: hidden;
}

#grid-container {
  flex: 1;
  width: 90vw;
  max-width: 1000px;
  overflow-y: auto;
  border: 3px solid #434343;
  background: #f7f7f7;
  box-shadow: 
    inset 0 4px 10px rgba(0, 0, 0, 0.6),
    inset 0 -4px 10px rgba(0, 0, 0, 0.6),
    inset 4px 0 10px rgba(0, 0, 0, 0.6),
    inset -4px 0 10px rgba(0, 0, 0, 0.6),
    0 6px 12px rgba(0, 0, 0, 0.4);
  margin: 0 auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 7px;
}

#grid-container::-webkit-scrollbar {
  display: none;
}

#grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0;
}

.cell {
  position: relative;
  box-shadow: inset 0 0 0 0.3px rgba(0,0,0,0.2);
  aspect-ratio: 1;
  background: #f7f7f7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell.selected {
  border: 2px solid #34B0F2;
  box-sizing: border-box;
}

.cell.new {
  opacity: 0;
  transform: translateY(20px);
  animation: appear 0.4s forwards;
}

@keyframes appear {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#fab-container {
  text-align: center;
  padding: 15px 0;
  flex-shrink: 0;
}

#fab {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  font-size: 1.5rem;
  font-family: "Chakra Petch", sans-serif;
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
  background-color: #34B0F2;
  color: #074415;
}

#fab:hover {
  background-color: #2a8bc4;
  transform: translateX(-5%) scale(1.02);
  transition: 0.2s ease;
}

.number {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 1.4rem;
  color: #222;
  animation: fall 0.5s forwards;
}

@keyframes fall {
  to {
    top: 50%;
    transform: translate(-50%, -50%);
  }
}

.number.explode {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  animation: explodeBig 0.8s forwards;
}

@keyframes explodeBig {
  0%   { transform: scale(1) rotate(0deg);   opacity: 1;   filter: brightness(1); }
  20%  { transform: scale(1.8) rotate(10deg); opacity: 1;   filter: brightness(1.5); }
  40%  { transform: scale(2.5) rotate(-10deg); opacity: 0.9; filter: brightness(2); }
  60%  { transform: scale(3) rotate(15deg);  opacity: 0.7; filter: blur(2px) brightness(2); }
  80%  { transform: scale(2) rotate(-15deg); opacity: 0.5; }
  100% { transform: scale(0); opacity: 0; }
}

.row-collapse {
  animation: rowExplode 0.6s forwards;
}

@keyframes rowExplode {
  0%   { opacity: 1; transform: scale(1); background-color: #f7f7f7; }
  25%  { background-color: #34b0f2; filter: brightness(1.5); }
  50%  { background-color: #8fd8ff; }
  75%  { background-color: #d4f0ff; opacity: 0.7; transform: scale(1.05); }
  100% { opacity: 0; transform: scaleY(0); }
}

.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup-box {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  max-width: 80%;
  width: 400px;
  text-align: center;
  border: 3px solid #08521B;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  animation: popup-appear 0.3s ease-out;
}

.popup-box h2 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  color: #4F1702;
}

.popup-box p {
  font-size: 1rem;
  margin-bottom: 20px;
  color: #444;
}

.popup-buttons {
  display: flex;
  gap: 10px;
}

.popup-buttons button {
  flex: 1;
  padding: 10px 0;
  font-size: 1rem;
  font-family: "Chakra Petch", sans-serif;
  background: #08521B;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.popup-buttons button:hover {
  background: #056021;
}

#menuOverlay .popup-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

#menuOverlay #menuStartButton {
  width: 100%;
  font-size: 1.2rem;
  font-weight: bold;
}


@keyframes popup-appear {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

footer {
  background: url("../img/header-footer-bg.png") repeat center center;
  background-size: cover;
  color: #fff;
  box-shadow: 0 0 6px 15px rgba(0,0,0,0.3);
  flex-shrink: 0;
}