:root {
    --base-font-size: 16px;
    --scale-factor: 1;
    --max-width: 1200px;
  }
  
body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-top: 50px;
    height: 100vh;
    font-size: var(--base-font-size);
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    background-color: #f0f0f0;
}

.container {
    text-align: center;
}

#gameBoard {
    position: relative;
    margin: 20px auto;
    background-color: #f0f0f0;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    padding: 5px;
    box-sizing: border-box;
    width: 76.5vmin;
    height: 76.5vmin;
    max-width: 600px;
    max-height: 600px;
}

#gameBoard.puzzle-8 {
    width: 57.375vmin;  /* 75% of 76.5vmin */
    height: 57.375vmin;
    max-width: 450px;   /* 75% of 600px */
    max-height: 450px;
}

#gameBoard.puzzle-15 {
    width: 76.5vmin;
    height: 76.5vmin;
}

.tile {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: calc(4vmin + 8px);
    font-weight: bold;
    background-color: #3498db;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    position: absolute;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    width: calc((76.5vmin - 30px) / 4);
    height: calc((76.5vmin - 30px) / 4);
    max-width: calc((600px - 30px) / 4);
    max-height: calc((600px - 30px) / 4);
}

.puzzle-8 .tile {
    width: calc((57.375vmin - 18px) / 3);
    height: calc((57.375vmin - 18px) / 3);
    font-size: calc(5vmin + 8px);
    max-width: calc((450px - 18px) / 3);
    max-height: calc((450px - 18px) / 3);
}

.puzzle-15 .tile {
    width: calc((76.5vmin - 30px) / 4);
    height: calc((76.5vmin - 30px) / 4);
    font-size: calc(4vmin + 8px);
}

.tile:hover {
    background-color: #2980b9;
    transform: scale(1.05);
}

.empty {
    background-color: transparent;
    box-shadow: none;
}

.controls {
    margin-top: 20px;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    margin: 0 10px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #27ae60;
}

#moves {
    margin-top: 20px;
    font-size: 18px;
}

.congratulations {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

#shuffleResetBtn {
    transition: background-color 0.3s;
}

#shuffleResetBtn:active {
    background-color: #27ae60;
}

#puzzleType {
    padding: 10px;
    font-size: 16px;
    cursor: pointer;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    margin: 0 10px;
    transition: background-color 0.3s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#puzzleType:hover {
    background-color: #27ae60;
}

#puzzleType:after {
    content: '\25BC';
    position: absolute;
    top: 0;
    right: 0;
    padding: 10px;
    background-color: #2ecc71;
    pointer-events: none;
}

#puzzleType::-ms-expand {
    display: none;
}

#puzzleType option {
    background-color: white;
    color: #333;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.overlay, .alert-box {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay .message, .alert-box .message {
    background: white;
    padding: 20px;
    border-radius: 5px;
    text-align: center;
}

.alert-box .message {
    display: flex;
    flex-direction: column;
}

.alert-box button {
    margin-top: 10px;
    padding: 5px 10px;
}

.alert-box {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.alert-box .message {
    background: white;
    padding: 20px;
    border-radius: 5px;
    text-align: center;
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.alert-box button {
    margin-top: 10px;
    padding: 5px 10px;
    cursor: pointer;
}

.alert-box .yes {
    background-color: #4CAF50;
    color: white;
}

.alert-box .no {
    background-color: #f44336;
    color: white;
}

button:disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
}

#stats {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    margin-right: 1rem;
}

#stats {
    justify-content: space-between;
}

#stats {
    padding: 1rem;
}

h1 {
    font-size: calc(2.5rem * var(--scale-factor));
    max-font-size: 3.5rem;
  }
  
  h2 {
    font-size: calc(2rem * var(--scale-factor));
    max-font-size: 2.75rem;
  }
  
  h3 {
    font-size: calc(1.75rem * var(--scale-factor));
    max-font-size: 2.25rem;
  }
  
  p, li {
    font-size: calc(1rem * var(--scale-factor));
    max-font-size: 1.25rem;
  }
  
  @media (max-width: 768px) {
    :root {
      --scale-factor: 0.9;
    }
  }
  
  @media (max-width: 480px) {
    :root {
      --scale-factor: 0.8;
    }
  }
  
  @media (min-width: 1201px) {
    body {
      font-size: calc(var(--base-font-size) * 1.1);
    }
  }