/* Global settings to include padding and borders in width and height calculations */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background-color: transparent;
    margin: 0;
    padding: 0;
    /* undo the flex-column hack: */
    display: block;
    height: auto;
    font-family: 'Arial', sans-serif;
}


.flex-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Positions the main container at the top */
    flex: 1; /* Allows the main container to grow and fill available space */
}

.main-container {
    width: auto;
    max-width: 600px;
    margin: 20px auto 0; /* Adds margin at the top and centers horizontally */
    padding-bottom: 50px; /* Adjust this padding to create space between puzzle and keyboard */
    padding-top: 100px; /* Add padding at the top to create space from the top */
}

#image-container img {
    width: 100%;
    max-width: 600px;
    height: auto;
    display: block;
    border-radius: 15px; 
    overflow: hidden;
    background-color: #c2c4c4;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0; /* ensures there is no space between the cells */
    background-color: #f0f0f0;
    margin-top:20px; /* Adds margin between image and grid */
    border-radius: 15px; 
    overflow: hidden;
    width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
}

.square {
  aspect-ratio: 1 / 1;
  width: 100%;
  max-height: 100%; /* NEW: ensures it won't grow vertically */
  overflow: hidden; /* Optional: hides oversize text if needed */
  background-color: #ddd; /* Will be overridden dynamically */
  color: #FA98E4;
  font-size: 2.5em;
  font-weight: none;
  text-align: center;
  border: none;
  outline: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  line-height: 1; /* 🔑 prevents vertical expansion */
  text-transform: uppercase;
}

.square:focus {
  outline: 2px solid #faf6d4;
}
/* Styles for the active square */
.square.active {
    position: relative;
    box-shadow: inset 0 0 0 4px #faf6d4;
    outline: none;
}

#keyboard-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #EAF6F0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    z-index: 100;
}

.key-wrapper {
    display: flex;
    flex-wrap: wrap; /* allows wrapping on smaller screens */
    justify-content: center;
    align-items: center;
    column-gap: 6px; /* horizontal gap */
    row-gap: 0px;    /* no vertical gap */
}

.key {
    flex: none;
    margin: 2 4px;
    padding: 4px;
    border: 2px solid #6DCFCF;
    color: #2AA894;
    background-color: #D9F3EA;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    width: 45px;
    border-radius: 8px;
    font-size: 1.4em;
    font-weight: none;
}

.key:hover {
    background-color: #ADE0C1;
  border: 2px solid #51B594;
    color: #0B919C;
}

.control {
    width: 90px;
    font-size: 1.4em;
}
.square.correct {
  background-color: #c8f7c5 !important; /* light green */
}


/* Keyframe animations for various effects */
@keyframes flashing {
    0%, 100% { background-color: initial; }
    50% { background-color: yellow; }
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}



.close-container {
    text-align: center;
    padding: 10px 0; /* Padding to create space around the close button */
    background-color: #fefefe; /* Same background color as the modal */
}

.close {
    color: #aaa;
    font-size: 2em;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
}

#rules-image {
    max-width: 100%;
    height: auto;
    flex-grow: 1;
}

@media (max-width: 768px) {
  #keyboard-container {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 4px;
    gap: 3px; /* adds consistent spacing between keys */
  }

  .key {
    width: 22px;
    height: 22px;
    font-size: 0.7em;
    padding: 0;
    margin: 2px;
  }

  .control {
    width: 40px;
    font-size: 0.7em;
    padding: 2px3px;
    margin: 2px;
  }

  .logo {
    height: 10px;
    margin-left: 5px;
    margin-top: 4px;
  }
}