*,
*::after,
*::before {
  box-sizing: border-box;
  font-family: "Comic Sans MS", "Chalkboard SE", "Arial Rounded MT Bold";
  touch-action: manipulation;
  overscroll-behavior: none;
}

html,
body {
  position: relative;
  background: linear-gradient(135deg, 
  #ffb8e7 0%, 
  #a6d1ff 25%, 
  #ffd6e7 50%, 
  #c5a8ff 75%, 
  #ffcfe5 100%);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  padding: 1em;
  font-size: clamp(0.9rem, 2.5vmin, 1.5rem);
  overflow-x: hidden;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body::before{
  content: "";
  position: fixed;
  inset: 0;

  background-image: 
  url(./images/bakgrund.jpg),
  url(./images/bakgrund2.jpg);

  background-size: 
  cover,
  cover;

  background-position: 
  center,
  center;
  
  background-repeat: 
  no-repeat,
  no-repeat;

  background-blend-mode: multiply;

  opacity: 12%;
}



h1 {
  text-align: center;
  color: white;
  font-size: clamp(1.5rem, 5vw, 3rem);
  margin: 0.5em 0;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
}

.keyboard {
  position: relative;
  display: grid;
  grid-template-columns: repeat(20, minmax(auto, 1.25em));
  grid-auto-rows: 3em;
  gap: 0.25em;
  justify-content: center;
  touch-action: none;

  z-index: 1;
}

.key {
  font-size: 1.3rem;
  grid-column: span 2;
  border: none;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(
    145deg,
    hsl(
      var(--hue, 330),
      var(--saturation, 85%),
      calc(var(--lightness-offset, 0%) + var(--lightness, 75%))
    ),
    hsl(
      var(--hue, 330),
      var(--saturation, 85%),
      calc(var(--lightness-offset, 0%) + var(--lightness, 65%))
    )
  );
  color: white;
  fill: white;
  text-transform: uppercase;
  border-radius: 0.25em;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  touch-action: none;
}


.key.large {
  grid-column: span 3;
}

.key:hover,
.key:focus {
  --lightness-offset: 5%;
  transform: translateY(-3px);
  box-shadow: 0 8px 0 #ffb8e7,
              0 12px 20px rgba(255, 105, 180, 0.4);
}

.key:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #ffb8e7,
              0 4px 10px rgba(255, 105, 180, 0.2);
}

.key.wrong {
  --hue: 0;
  --saturation: 10%;
  --lightness: 65%;
  border-color: #ffccd5;
}

.key.wrong-location {
  --hue: 45;
  --saturation: 90%;
  --lightness: 65%;
  border-color: #ffd6a5;
}

.key.correct {
  --hue: 140;
  --saturation: 70%;
  --lightness: 65%;
  border-color: #b5e6b5;
}

.guess-grid {
  display: grid;
  justify-content: center;
  align-content: center;
  flex-grow: 1;
  grid-template-columns: repeat(5, 4em);
  grid-template-rows: repeat(6, 4em);
  gap: 0.25em;
  margin-bottom: 1em;
}

.tile {
  font-size: 2em;
  color: #ff66b2;
  border: 4px solid #ffd1e6;
  text-transform: uppercase;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  transition: transform 250ms linear;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(5px);
  box-shadow: 0 8px 20px rgba(255, 182, 193, 0.4);
  text-shadow: 2px 2px 0 rgba(255, 182, 193, 0.3);
}

.tile[data-state="active"] {
  border-color: #ff8ac6;
  background: white;
}

.tile[data-state="wrong"] {
  border: none;
  background-color: #AE9D9D ;
  color: white;
  text-shadow: none;
}

.tile[data-state="wrong-location"] {
  border: none;
  background: linear-gradient(145deg, #FFF8BA, #ffd166); /*#FFF8BA*/
  color: #ff6b9d;
}

.tile[data-state="correct"] {
  border: none;
  background: linear-gradient(145deg, #a8e6cf, #27ca7c);
  color: white;
  text-shadow: none;
}

.tile.shake {
  animation: shake 250ms ease-in-out;
}

.tile.dance {
  animation: dance 500ms ease-in-out;
}

.tile.flip {
  transform: rotateX(90deg);
}

@keyframes shake {
  10% {
    transform: translateX(-5%);
  }
  30% {
    transform: translateX(5%);
  }
  50% {
    transform: translateX(-7.5%);
  }
  70% {
    transform: translateX(7.5%);
  }
  90% {
    transform: translateX(-5%);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes dance {
  20% {
    transform: translateY(-50%);
  }
  40% {
    transform: translateY(5%);
  }
  60% {
    transform: translateY(-25%);
  }
  80% {
    transform: translateY(2.5%);
  }
  90% {
    transform: translateY(-5%);
  }
  100% {
    transform: translateY(0);
  }
}

.alert-container {
  position: fixed;
  top: 10vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90%;
}

.alert {
  pointer-events: none;
  background: linear-gradient(145deg, #ff9ed8, #ff6bc1);
  padding: 0.75em 1.5em;
  border-radius: 2em;
  opacity: 1;
  transition: opacity 500ms ease-in-out;
  margin-bottom: 0.5em;
  box-shadow: 0 10px 20px rgba(255, 105, 180, 0.3), 0 6px 0 #ff8ac6;
  color: white;
  font-weight: bold;
}

.alert:last-child {
  margin-bottom: 0;
}

.alert.hide {
  opacity: 0;
}

#retry-button {
  position: fixed;
  display: none;
  align-items: center;
  justify-content: center;
  height: 50px;
  width: 150px;
  border-radius: 25px;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(145deg, #ff9ed8, #ff6bc1);
  color: white;
  border: none;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 15px 30px rgba(255, 105, 180, 0.4), 0 8px 0 #ff8ac6;
  transition: all 0.3s ease;

  z-index: 2;
}

#retry-button:hover {
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

#retry-button:active {
  transform: translate(-50%, -50%) scale(0.98);
}

@media (max-width: 768px) {
  .keyboard {
    grid-template-columns: repeat(20, minmax(auto, 2em));
    grid-auto-rows: 2.5em;
    gap: 0.2em;
  }
}

@media (max-width: 480px) {
  .keyboard {
    grid-template-columns: repeat(20, minmax(auto, 1.6em));
    grid-auto-rows: 6em;
    gap: 0.15em;
  }
}

@media (max-width: 390px) {
  .keyboard {
    grid-template-columns: repeat(20, minmax(auto, 1.4em));
    grid-auto-rows: 6em;
    gap: 0.15em;
  }
}

@media (max-width: 768px) {
  .guess-grid {
    grid-template-columns: repeat(5, 7em);
    grid-template-rows: repeat(6, 7em);
    gap: 0.3em;
  }
}

@media (max-width: 480px) {
  .guess-grid {
    grid-template-columns: repeat(5, 6em);
    grid-template-rows: repeat(6, 6em);
    gap: 0.25em;
  }
}

@media (max-width: 390px) {
  .guess-grid {
    grid-template-columns: repeat(5, 5em);
    grid-template-rows: repeat(6, 5em);
    gap: 0.25em;
  }
}

@media (max-width: 480px) {
  #retry-button {
    width: 120px;
    height: 45px;
    font-size: 15px;
  }
}
