* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Arial', sans-serif;
  background: linear-gradient(to bottom, #87CEEB 0%, #98D98E 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.game-container {
  width: 100%;
  max-width: 500px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Game Header */
.game-header {
  text-align: center;
  margin-bottom: 10px;
  position: relative;
  width: 100%;
}

.game-title {
  font-size: 32px;
  color: #2D5016;
  text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
  margin-bottom: 5px;
  font-weight: bold;
}

.game-subtitle {
  font-size: 16px;
  color: #4A7C2C;
  font-weight: 600;
}

.trap-counter {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  color: #FF6B6B;
  font-size: 18px;
  font-weight: bold;
  padding: 8px 15px;
  border-radius: 20px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  border: 2px solid #FF6B6B;
}

.trap-counter.flash {
  animation: trapFlash 0.5s ease-out;
}

@keyframes trapFlash {
  0%, 100% { background: rgba(255, 255, 255, 0.9); }
  50% { background: rgba(255, 107, 107, 0.3); transform: scale(1.1); }
}

/* 3x3 Grid */
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 360px;
  padding: 15px;
  background: rgba(139, 69, 19, 0.3);
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.grid-cell {
  aspect-ratio: 1;
  background: #6B8E23;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.grid-cell:active {
  transform: scale(0.95);
}

.grid-cell.disabled {
  pointer-events: none;
}

.potato-leaf {
  font-size: 40px;
  margin-bottom: 5px;
}

.potato-number {
  font-size: 28px;
  font-weight: bold;
  color: #FFFFFF;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Animation Effects */
.grid-cell.correct {
  animation: correctAnim 0.5s ease-out;
}

.grid-cell.wrong {
  animation: wrongAnim 0.5s ease-out;
}

@keyframes correctAnim {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); background: #FFD700; }
  100% { transform: scale(1); }
}

@keyframes wrongAnim {
  0% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  50% { transform: translateX(10px); }
  75% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}

.revealed-potato {
  font-size: 50px;
  animation: potatoAppear 0.5s ease-out;
}

.revealed-trap {
  font-size: 50px;
  animation: trapAppear 0.5s ease-out;
}

@keyframes potatoAppear {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes trapAppear {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* Rabbit Container */
.rabbit-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.rabbit-number {
  font-size: 36px;
  font-weight: bold;
  color: #FF6B6B;
  background: white;
  padding: 8px 20px;
  border-radius: 20px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  border: 3px solid #FF6B6B;
}

.rabbit {
  font-size: 60px;
  animation: rabbitBounce 1s ease-in-out infinite;
}

@keyframes rabbitBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.rabbit.sad {
  animation: rabbitSad 0.5s ease-out;
}

@keyframes rabbitSad {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-15px) rotate(-10deg); }
  75% { transform: translateY(-15px) rotate(10deg); }
}

.rabbit.surrender {
  animation: rabbitSurrender 0.8s ease-out;
}

@keyframes rabbitSurrender {
  0% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(0.9) rotate(-15deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.help-icon {
  font-size: 24px;
  cursor: pointer;
  background: white;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.help-icon:hover {
  transform: scale(1.1);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 20px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-content h3 {
  color: #2D5016;
  margin-bottom: 15px;
  font-size: 24px;
}

.modal-content p {
  color: #555;
  margin: 10px 0;
  font-size: 16px;
  line-height: 1.5;
}

.modal-btn {
  margin-top: 20px;
  padding: 12px 30px;
  font-size: 18px;
  font-weight: bold;
  color: white;
  background: #4CAF50;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, background 0.2s;
}

.modal-btn:active {
  transform: scale(0.95);
}

.next-btn {
  background: #FF6B6B;
  font-size: 20px;
  padding: 15px 40px;
}

.win-content h2 {
  color: #FF6B6B;
  font-size: 28px;
  margin-bottom: 20px;
}

.win-info {
  font-size: 18px;
  color: #333;
  margin: 10px 0;
}

.win-info span {
  color: #FF6B6B;
  font-weight: bold;
  font-size: 22px;
}

/* Lose Modal Styles */
.lose-content h2 {
  color: #FF6B6B;
  font-size: 28px;
  margin-bottom: 15px;
}

.lose-info {
  font-size: 18px;
  color: #555;
  margin-bottom: 20px;
}

.farmer-catch-animation {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  font-size: 50px;
  animation: farmerCatch 0.8s ease-out;
}

@keyframes farmerCatch {
  0% { transform: translateX(-100px); opacity: 0; }
  60% { transform: translateX(10px); }
  100% { transform: translateX(0); opacity: 1; }
}

.farmer {
  animation: farmerRun 0.5s ease-out;
}

@keyframes farmerRun {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.caught-rabbit {
  animation: caughtAnimation 0.8s ease-out;
}

@keyframes caughtAnimation {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-15deg); }
  75% { transform: rotate(15deg); }
  100% { transform: rotate(0deg); }
}

.restart-btn {
  background: #4CAF50;
  font-size: 18px;
  padding: 12px 35px;
  margin: 5px;
}

.quit-btn {
  background: #999;
  font-size: 16px;
  padding: 10px 30px;
  margin: 5px;
}
