body {
  font-family: sans-serif;
  padding: 20px;
  margin: 0;
}

#grid {
  display: grid;
  grid-template-columns: repeat(4, 60px);
  grid-template-rows: repeat(4, 60px);
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eee;
  border: 2px solid #888;
  font-size: 24px;
  font-weight: bold;
  height: 60px;
  width: 60px;
  visibility: visible;
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s ease;
}

.tile-letter {
  font-size: 24px;
}

.tile-points {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 12px;
  color: #444;
}

.highlight {
  background: #ffdf7f;
  border-color: #f90;
}

#inputRack,
#inputRack1 {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 60px;
  flex-wrap: wrap;
  justify-content: center;
}

.input-tile {
  position: relative;
  width: 60px;
  height: 60px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #339;
  font-size: 24px;
  font-weight: bold;
}

button {
  font-size: 16px;
  padding: 5px 10px;
  margin: 5px;
}

@keyframes fadeOutMoveUp {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}

@keyframes fadeInMoveDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.tile.played {
  animation: fadeOutMoveUp 0.4s forwards;
}

.tile.new {
  animation: fadeInMoveDown 0.4s forwards;
}

@keyframes shuffleWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(5deg); }
  50% { transform: rotate(-5deg); }
  75% { transform: rotate(3deg); }
}

.tile.animate-move {
  transition: transform 0.3s ease;
  will-change: transform;
}

.input-tile.optional {
  border-style: dashed;
}

.input-tile:empty {
  background: #f0f0f0;
}

.input-tile.fixed {
  background: #ccc;
  border-color: #666;
  color: #222;
  font-style: italic;
  pointer-events: none;
}

.tile-modifier {
  position: absolute;
  bottom: 2px;
  left: 4px;
  font-size: 12px;
  color: #b00;
  font-weight: bold;
  pointer-events: none;
}

.input-tile.filled {
  background: #f1e7d7;
}

.tile.boosted {
  animation: wiggle 0.5s ease-in-out;
}

@keyframes wiggle {
  0% { transform: rotate(0); }
  25% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
  75% { transform: rotate(-5deg); }
  100% { transform: rotate(0); }
}

.tile-popup {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: #ff0;
  color: #000;
  padding: 2px 6px;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid #aa0;
  border-radius: 6px;
  opacity: 0;
  animation: popupFade 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 2;
}

@keyframes popupFade {
  0% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
  }
}

.points-buffed {
  color: green;
  font-size: 14px;
  font-weight: bold;
}

.input-tile.rack-a {
  background-color: #d0eaff;
}

.input-tile.rack-b {
  background-color: #ffe7cc;
}

.input-tile.inactive {
  opacity: 0.6;
}

/* Rack 0 */
.tile.rack-0.rack-active {
  border: 2px solid #4db8ff;
  background-color: rgba(77, 184, 255, 0.2);
}

.tile.rack-0.rack-inactive {
  border: 2px solid #4db8ff;
  opacity: 0.5;
}

/* Rack 1 */
.tile.rack-1.rack-active {
  border: 2px solid #ffa640;
  background-color: rgba(255, 166, 64, 0.2);
}

.tile.rack-1.rack-inactive {
  border: 2px solid #ffa640;
  opacity: 0.5;
}

#gridRow {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  position: relative;
}

/* These containers match the full height of the grid */
#leftColumn, #rightColumn {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: calc(4 * 80px + 3 * 10px); /* 4 tiles tall + 3 gaps of 10px */
}

/* Spacer to push the button to the bottom */
.spacer {
  flex: 1;
}

.square-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  font-size: 2rem;
  font-weight: bold;
  background-color: #fff;
  border: 3px solid #888;
  border-radius: 10px;
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  user-select: none;
  padding: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}


.square-button:hover {
  background-color: #f0f0f0;
}

.square-button:active {
  transform: scale(0.98);
}

/* 📱 Mobile layout */
@media (max-width: 768px) {
  #grid {
    grid-template-columns: repeat(4, 10vw);
    grid-template-rows: repeat(4, 10vw);
    gap: 2vw;
  }

  .tile,
  .input-tile
  {
    width: 10vw;
    height: 10vw;
    font-size: 7vw;
  }
  .square-button {
    width: 12vw;
    height: 12vw;
    font-size: 7vw;
  }

  .tile-letter {
    font-size: 6vw;
  }

  .tile-points,
  .tile-modifier {
    font-size: 2.8vw;
  }

  #inputRack,
  #inputRack1 {
    gap: 0.5vw;
    min-height: 10vw;
  }

  button {
    font-size: 4vw;
    padding: 1vw 2vw;
  }

  .tile-popup {
    font-size: 4vw;
    padding: 0.5vw 1vw;
  }

  #leftColumn,
  #rightColumn {
    gap: 2vw;
  }
}
#leftColumn,
#rightColumn {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%; /* Allow the columns to match the grid's height */
}

#gridRow {
  align-items: flex-end;
  height: calc(3 * 80px + 3 * 10px); /* 4 tiles + 3 gaps of 10px */
}

@media (max-width: 768px) {
  #gridRow {
    height: calc(4 * 10vw + 3 * 2vw); /* 4 tiles + 3 gaps of 2vw */
  }

  #leftColumn,
  #rightColumn {
    height: 100%;
  }
}
@keyframes levelUpPulse {
  0% { transform: scale(1); color: #a8d0ff; }   /* soft icy blue */
  50% { transform: scale(1.3); color: #58c4ff; } /* vibrant cool blue */
  100% { transform: scale(1); color: inherit; }
}

.level-up-animate {
  animation: levelUpPulse 0.6s ease-in-out;
}
