* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #071827;
  color: white;
  font-family: Arial, sans-serif;
  touch-action: manipulation;
  user-select: none;
}

.game-page {
  max-width: 430px;
  margin: 0 auto;
  padding: 14px;
  min-height: 100vh;
  text-align: center;
  position: relative;
}

.top-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
  justify-content: space-between;
  margin-bottom: 16px;
}

.top-bar button,
.stat {
  flex: 1;
  background: #102f4a;
  border: 2px solid #2b90d9;
  color: white;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 14px;
}

#backBtn {
  background: #15803d;
  border-color: #22c55e;
  font-weight: bold;
}

.stat span {
  display: block;
  font-size: 12px;
  opacity: 0.8;
}

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.title-area h1 {
  margin: 10px 0 6px;
  font-size: 28px;
}

.title-area p {
  margin: 0 0 18px;
  color: #dbeafe;
  font-size: 15px;
}

.grid {
  width: min(92vw, 380px);
  height: min(92vw, 380px);
  margin: 0 auto 20px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.square {
  background: #050505;
  border: 2px solid #333;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.square.flash {
  background: red;
  box-shadow: 0 0 22px red;
  transform: scale(1.08);
}

.square.player-tap {
  background: #2563eb;
  box-shadow: 0 0 18px #60a5fa;
  transform: scale(1.05);
}

.square.disabled {
  pointer-events: none;
}

.controls {
  margin-top: 10px;
}

.controls button {
  background: #16a34a;
  color: white;
  border: 2px solid #22c55e;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 18px;
  font-weight: bold;
}

#restartBtn {
  background: #2563eb;
  border-color: #60a5fa;
}

.message {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: bold;
  text-align: center;
  z-index: 10;
  pointer-events: none;
  padding: 20px;
}

.message.red {
  color: #ff3333;
  text-shadow: 0 0 18px red;
}

.message.green {
  color: #22c55e;
  text-shadow: 0 0 18px #22c55e;
}

.message.gold {
  color: gold;
  text-shadow: 0 0 22px gold;
}

.hidden {
  display: none !important;
}

.shake {
  animation: shake 0.3s ease;
}

.confetti-piece {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 16px;
  z-index: 20;
  animation: confettiFall 2.4s linear forwards;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-8px); }
  100% { transform: translateX(0); }
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}