/* Reset some basic styles */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: #2f3f55;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  /* manipulation: reliable taps on buttons/titles; avoid body { touch-action: none } breaking clicks on iOS */
  touch-action: manipulation;
}

/* Game container styling */
#game-container {
  text-align: center;
  width: 90%;
  max-width: 600px;
  background: #2f3f55;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 20px;
}

/* Title row: undo (left) + centered title — h1 first in DOM (below), button second (on top for touch) */
.title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  margin-bottom: 20px;
  touch-action: manipulation;
  position: relative;
}

.title-row h1 {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  text-align: center;
  position: relative;
  z-index: 0;
  min-width: 0;
}

.title-row #undo-button {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  position: relative;
  z-index: 10;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.15);
}

/* Title */
h1 {
  color: #edad6d;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s;
}

h1:hover {
  opacity: 0.8;
}

h1:active {
  opacity: 0.6;
}

/* Board and tray: block scrolling / keep drag behavior without disabling taps elsewhere */
#game-board,
#pieces-container {
  touch-action: none;
}

/* Game board */
#game-board {
  background-color: #e8d7bb;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 1px;
  padding: 1px;
  border: 4px solid #a4825f;
  width: 300px;
  height: 300px;
  margin: 0 auto;
}

/* Individual cells (initial styles) */
#game-board div {
  background-color: #e8d7bb;
  border: 1px solid #a4825f;
  width: 100%;
  height: 100%;
}

/* Pieces container */
#undo-button {
  padding: 10px 20px;
  font-size: 16px;
  font-family: Arial, sans-serif;
  color: #2f3f55;
  background: #edad6d;
  border: 2px solid #a4825f;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}

/* Avoid native disabled — it drops pointer-events on some mobile WebKits and taps hit the h1 behind */
#undo-button[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
}

#pieces-container {
  margin-top: 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  min-height: 120px;  /* Reduced from 200px to give space for version info */
  gap: 50px;
  margin-bottom: 40px;  /* Add bottom margin to ensure space for version info */
}

.piece-wrapper {
  display: inline-block;
  cursor: grab;
  background: none;
  margin: 10px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.piece-wrapper>div {
  position: absolute;
  width: 37.5px;
  height: 37.5px;
  border: 1px solid #5c3b1a;
  border-radius: 2px;
  min-width: 30px;
  min-height: 30px;
}

.piece-wrapper.dragging {
  opacity: 0.6;
}

.game-cell.preview {
  transition: background-color 0.1s ease;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  #pieces-container {
    gap: 20px;
    padding: 10px;
  }
}

.game-cell {
  background-color: transparent;
  border: 1px solid #ccc;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  transition: background-color 0.2s;
}

.game-cell.filled {
  opacity: 1 !important;
  z-index: 1;
}

/* Ensure filled cells are fully colored */
.game-cell.filled {
  border: none;
  margin: 0;
  padding: 0;
}

/* Preview styling */
.game-cell.preview {
  border: none;
}

@keyframes bonusFloat {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }

  20% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -100%) scale(1);
    opacity: 0;
  }
}

#score-display {
  font-weight: bold;
  color: #f77912;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.no-scroll {
  overflow: hidden;
  /* Prevent scrolling */
  height: 100%;
  /* Ensure the body takes full height */
}

.version-info {
  position: relative;  /* Add position relative */
  margin-top: 20px;
  padding-top: 20px;  /* Add padding to ensure separation */
  font-size: 12px;
  color: #edad6d;
  opacity: 0.7;
  text-align: center;
  font-family: monospace;
  clear: both;  /* Ensure it clears any floating elements */
  width: 100%;  /* Make it full width */
}