/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #74abe2 0%, #5563de 100%);
  transition: background 0.5s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  color: #333;
  overflow: hidden;
}
#info {
  display: flex;
  gap: 20px;
  margin: 20px 0;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 2;
}
#game {
  display: grid;
  gap: 6px;
  background: white;
  padding: 10px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  z-index: 1;
}
.tile {
  width: 60px;
  height: 60px;
  font-size: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  z-index: 1;
}
.locked {
  cursor: default;
}
.tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}
.selected {
  outline: 3px solid #ffce00;
  outline-offset: -4px;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 206, 0, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 206, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 206, 0, 0);
  }
}
.hint {
  animation: hintFlash 5s ease-in-out infinite;
}
@keyframes hintFlash {
  0%,
  100% {
    background: white;
  }
  50% {
    background: gold;
  }
}
.fading {
  animation: fadeOut 0.4s forwards;
}
@keyframes fadeOut {
  to {
    opacity: 0;
    transform: scale(0.5);
  }
}
.falling {
  transition: transform 0.3s ease-out;
  will-change: transform;
}
.shake {
  animation: shake 0.4s ease;
}
@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-5px);
  }
  100% {
    transform: translateX(0);
  }
}
/* Overlays */
.overlay {
  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;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 20;
}
.overlay.visible {
  visibility: visible;
  opacity: 1;
}
.panel {
  background: white;
  padding: 30px 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.panel h1 {
  margin-bottom: 20px;
  font-size: 32px;
  color: #5563de;
}
.scores-note {
  font-size: 16px;
  margin-top: -10px;
  margin-bottom: 10px;
  color: #333;
}
.scores-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 20px;
  text-align: left;
}
.scores-list li {
  background: #f5f5f5;
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 18px;
}
.panel p {
  margin-bottom: 20px;
  font-size: 18px;
  line-height: 1.4;
}
.panel button {
  font-size: 18px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: #5563de;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
}
.panel button:hover {
  background: #4350b3;
}

.example {
  display: block;
  font-size: 24px;
  margin-bottom: 8px;
}

.help-panel {
  max-width: 500px;
  background: linear-gradient(135deg, #ffffff 0%, #f0f8ff 100%);
}


.help-list {
  list-style: none;
  padding: 0;
  margin: 20px 0;
  text-align: center;
}

.help-list li {
  margin-bottom: 12px;
  font-size: 18px;
  line-height: 1.4;
  text-align: center;
}

.actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

#player-name {
  padding: 8px 12px;
  font-size: 18px;
  border-radius: 8px;
  border: 2px solid #5563de;
  margin-bottom: 15px;
  width: 100%;
}

#scores-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffce00;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 11;
}

#scores-btn:hover {
  background: #e0b700;
}

#sound-toggle {
  position: fixed;
  bottom: 20px;
  right: 90px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffce00;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 11;
}

#sound-toggle:hover {
  background: #e0b700;
}

#help-btn {
  position: fixed;
  bottom: 20px;
  right: 160px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffce00;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 11;
}

#help-btn:hover {
  background: #e0b700;
}
/* Confetti */
#confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 9;
}
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  opacity: 1;
  transform-origin: center;
  animation: confetti-fall 1.5s linear forwards;
}
@keyframes confetti-fall {
  to {
    transform: translateY(100vh) rotateZ(360deg);
    opacity: 0;
  }
}

/* Level progress bar */
#progress {
  width: 80%;
  max-width: 400px;
  height: 14px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 7px;
  margin: 10px 0 20px;
  overflow: hidden;
}
#progress .bar {
  height: 100%;
  width: 0%;
  background: #ffce00;
  transition: width 0.3s ease;
}

/* Version info */
#version-info {
  margin-top: 10px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.8);
  padding: 6px 12px;
  border-radius: 8px;
  color: #333;
}
#version-info a {
  color: #333;
}
