body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #f5f5f5;
  padding: 20px;
  box-sizing: border-box;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.scratch-container {
  position: relative;
  width: 90vw;
  max-width: 400px;
  height: 60vw;
  max-height: 267px;
  border: 2px solid #333;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  background: white;
}

.retry-button {
  padding: 12px 30px;
  font-size: 18px;
  font-weight: bold;
  color: white;
  background: #4CAF50;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  display: none;
}

.retry-button.show {
  display: block;
}

.retry-button:hover {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
}

.retry-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

canvas#scratch {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border-radius: 6px;
  touch-action: none;
}

.result {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1.5rem, 8vw, 2.5rem);
  font-weight: bold;
  color: #333;
  user-select: none;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
}

.money-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.money {
  position: absolute;
  font-size: 2rem;
  animation: fall 3s linear forwards;
  pointer-events: none;
}

@keyframes fall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(calc(100vh + 100px)) rotate(720deg);
    opacity: 0;
  }
}

@keyframes sway {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-20px);
  }
  75% {
    transform: translateX(20px);
  }
}

.money.sway {
  animation: fall 3s linear forwards, sway 0.5s ease-in-out infinite;
}

/* テトリスゲーム */
.tetris-game {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.tetris-game.active {
  display: flex;
}

.tetris-container {
  background: #222;
  border: 3px solid #444;
  border-radius: 10px;
  padding: 20px;
  position: relative;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#tetris-canvas {
  border: 2px solid #666;
  background: #111;
  display: block;
}

.tetris-info {
  position: absolute;
  right: -180px;
  top: 20px;
  color: white;
  font-family: monospace;
  font-size: 16px;
  background: #333;
  padding: 20px;
  border-radius: 8px;
  border: 2px solid #555;
  min-width: 140px;
}

.tetris-info div {
  margin-bottom: 10px;
}

.close-button {
  position: absolute;
  top: -40px;
  right: -40px;
  width: 40px;
  height: 40px;
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.close-button:hover {
  background: #ff6666;
}

@media (max-width: 768px) {
  .tetris-info {
    position: static;
    margin-top: 20px;
    text-align: center;
  }
  
  .tetris-container {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .close-button {
    position: fixed;
    top: 20px;
    right: 20px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }
  
  .scratch-container {
    width: 95vw;
    height: 63.33vw;
  }
  
  .money {
    font-size: 1.5rem;
  }
  
  .tetris-container {
    padding: 10px;
  }
  
  #tetris-canvas {
    width: 200px;
    height: 400px;
  }
}