html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

/* -------------------------
   GENERAL PAGE
------------------------- */
body {
  position: relative;
  font-family: Arial, sans-serif;
  color: black;
  text-align: center;
  background: url("background.jpg") no-repeat center center fixed;
  background-size: cover;
}

/* pink overlay when frozen */
body.frozen-background::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(233, 187, 196, 0.35);
  pointer-events: none;
  z-index: 0;
}

/* -------------------------
   GAME CONTAINER
------------------------- */
#gameContainer {
  padding-top: 0;
  position: relative;
  z-index: 1;
}

/* -------------------------
   TOP BAR (score + timer)
------------------------- */
#topBar {
  display: flex;
  justify-content: space-around;
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 15px;
  position: relative;
  z-index: 1;
}

/* -------------------------
   BOARD (5x5 grid)
------------------------- */
#board {
  display: grid;
  grid-template-columns: repeat(5, 65px);
  grid-template-rows: repeat(5, 65px);
  gap: 8px;
  justify-content: center;
  margin: 20px auto;
  position: relative;
  z-index: 1;
}

/* -------------------------
   TILE STYLE (3D GREY)
------------------------- */
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  color: black;
  background: linear-gradient(145deg, #d3d3d3, #bfbfbf);
  border-radius: 8px;
  box-shadow:
    4px 4px 8px rgba(0,0,0,0.3),
    -2px -2px 4px rgba(255,255,255,0.7);
  user-select: none;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* -------------------------
   BLANK TILE
------------------------- */
.blank {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

/* -------------------------
   SELECTED TILE (WORD SWIPE)
------------------------- */
.selected {
  background: #90ee90;
}

/* -------------------------
   BUTTONS
------------------------- */
button {
  margin-top: 10px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: bold;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

button:active {
  transform: scale(0.97);
}

.freeze-active {
  background: red !important;
  color: white !important;
}

/* -------------------------
   MESSAGE TEXT
------------------------- */
#message {
  margin-top: 10px;
  font-size: 16px;
  min-height: 20px;
  position: relative;
  z-index: 1;
}

/* -------------------------
   END SCREEN
------------------------- */
#endScreen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 2;
}

#endContent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 30px;
  border-radius: 10px;
  text-align: center;
}

#endContent h2 {
  margin-bottom: 20px;
}

/* -------------------------
   SCREEN SETUP
------------------------- */
.screen {
  display: none;
  position: relative;
  width: 100%;
  height: 100vh;
}

.screen.active {
  display: block;
}

/* -------------------------
   BACKGROUND IMAGES
------------------------- */
.bg-image {
  width: 100%;
  height: 100vh;
  object-fit: contain;
  background-color: grey;
}

/* -------------------------
   HOME SCREEN
------------------------- */
#home-screen {
  background: url("background.jpg") no-repeat center center;
  background-size: cover;
}

.home-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: 100vh;
  padding-top: 0;
  position: relative;
}

.home-image {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* -------------------------
   INVISIBLE PLAY BUTTON
------------------------- */
.play-btn {
  position: absolute;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%);
  width: 55%;
  height: 80px;
  background: transparent;
  border: none;
  border-radius: 20px;
  z-index: 10;
}

/* -------------------------
   RULES BOX
------------------------- */
.rules-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.95);
  padding: 20px;
  border-radius: 12px;
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
}

.rules-box h2 {
  text-align: center;
  margin-bottom: 10px;
}

.rules-box ul {
  padding-left: 18px;
}

.rules-box button {
  display: block;
  margin: 15px auto 0;
}
#comboPopup {
  position: fixed;
  left: 50%;
  top: 55%;
  transform: translateX(-50%);
  font-size: 28px;
  font-weight: bold;
  color: #ff2d55;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}

#comboPopup.show {
  animation: comboFloat 1s ease-out forwards;
}

@keyframes comboFloat {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(0);
  }
  15% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-140px) translateY(-180px);
  }
}
/* -------------------------
   MOBILE
------------------------- */
@media (max-width: 768px) {
  .play-btn {
    bottom: 32%;
    width: 58%;
    height: 75px;
  }
}
/* CHAIN BONUS POPUP */
.chain-bonus {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);

  font-size: 28px;
  font-weight: bold;
  color: red;

  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  text-shadow: 2px 2px 4px black;

  animation: flashChain 0.8s ease-out forwards;
}

/* Flash animation */
@keyframes flashChain {
  0% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.9);
  }
}