* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  color: black;
  touch-action: manipulation;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.container {
  background: white;
  max-width: 600px;
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
}

.puzzle-image {
  flex: 0 0 auto;
  padding: 0.5rem;
  text-align: center;
}

.puzzle-image img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 40vh;
  object-fit: contain;
}

/* クリック可能な画像 */
.clickable-image {
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 8px;
}

/* 画像フルスクリーンモーダル */
.image-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  box-sizing: border-box;
  cursor: pointer;
}

.image-modal-overlay.show {
  display: flex;
}

.image-modal-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.image-modal-content img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.modal-instructions {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  margin-top: 15px;
  text-align: center;
  pointer-events: none;
}

/* アニメーション */
.image-modal-overlay {
  animation: fadeIn 0.3s ease-out;
}

.image-modal-content img {
  animation: zoomIn 0.3s ease-out;
}

@keyframes zoomIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.answer-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  min-height: 60vh;
  border-top: 1px solid #ddd;
}

.input-group {
  margin-bottom: 1.5rem;
}

#answerInput {
  width: 100%;
  padding: 1rem;
  border: 1px solid #ddd;
  font-size: 1rem;
  background: white;
  max-width: 600px;
}

#answerInput:focus {
  outline: 1px solid black;
  background: white;
}

/* 答え表示エリア */
.answer-display {
  flex: 0 0 auto;
  margin-bottom: 0.5rem;
}

.answer-text {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.6rem;
  border: 2px solid #ddd;
  font-size: 1rem;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: bold;
  border-radius: 8px;
  color: #333;
}

/* Wordle風の文字スタイル */
.answer-text.wordle-mode {
  display: flex;
  justify-content: center;
  gap: 0.15rem;
  font-family: "Courier New", monospace;
}

.wordle-char {
  display: inline-block;
  width: 1.8rem;
  height: 1.8rem;
  line-height: 1.8rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: bold;
  text-align: center;
  background: white;
  transition: all 0.3s ease;
}

.wordle-char.correct {
  background: #6aaa64;
  color: white;
  border-color: #6aaa64;
}

.wordle-char.partial {
  background: #c9b458;
  color: white;
  border-color: #c9b458;
}

.wordle-char.wrong {
  background: #787c7e;
  color: white;
  border-color: #787c7e;
}

/* 結果メッセージ */
.result-message {
  flex: 0 0 auto;
  text-align: center;
  margin: 0.3rem 0;
  font-size: 0.9rem;
  font-weight: bold;
  min-height: 1.2rem;
}

.result-message.success {
  color: #6aaa64;
  animation: successBounce 0.6s ease-in-out;
}

.result-message.try-again {
  color: #787c7e;
}

/* アニメーション */
@keyframes successBounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.wordle-char.animate {
  animation: colorReveal 0.3s ease-in-out;
}

@keyframes colorReveal {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* カタカナキーボード */
.katakana-keyboard {
  display: flex;
  flex-direction: column;
  padding: 0.2rem 0;
}

/* 縦並びキーボードグリッド */
.keyboard-grid {
  display: flex;
  justify-content: center;
  gap: 0.1rem;
  margin: 0.2rem 0;
}

.keyboard-column {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  max-width: 3rem;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 0.15rem;
  margin: 0.1rem 0;
  flex-wrap: wrap;
}

.kana-btn {
  background: #f8f9fa;
  border: 1px solid #ddd;
  padding: 0.3rem 0.2rem;
  font-size: 0.75rem;
  cursor: pointer;
  width: 100%;
  font-weight: 600;
  border-radius: 4px;
  transition: all 0.2s ease;
  min-height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.kana-btn.empty-btn {
  background: transparent;
  border: none;
  cursor: default;
  pointer-events: none;
}

.kana-btn:hover:not(.empty-btn) {
  background: #e9ecef;
  border-color: #999;
  transform: translateY(-1px);
}

.kana-btn:active:not(.empty-btn) {
  background: #dee2e6;
  transform: translateY(0);
}

.function-row {
  margin: 0.2rem 0;
}

.function-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
  font-weight: 600;
  transition: all 0.2s ease;
  min-width: 2rem;
  touch-action: manipulation;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.function-btn:hover {
  background: #0056b3;
  transform: translateY(-1px);
}

.function-btn:active {
  background: #004085;
  transform: translateY(0);
}

.function-btn.delete {
  background: #dc3545;
}

.function-btn.delete:hover {
  background: #c82333;
}

.function-btn.delete:active {
  background: #bd2130;
}

.submit-row {
  flex: 0 0 auto;
  margin: 0.3rem 0;
  text-align: center;
}

.submit-btn {
  background: black;
  color: white;
  width: 100%;
  border-radius: 25px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ポップアップ背景 */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.popup-overlay.show {
  display: flex;
}

/* ポップアップコンテンツ */
.popup-content {
  background: white;
  border: 2px solid #ddd;
  padding: 2rem;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.popup-content h2 {
  color: black;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.popup-content p {
  color: black;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

.popup-close {
  background: black;
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
}

/* アニメーション効果 */
.success-celebration {
  animation: successCelebration 0.8s ease-in-out;
}

.bounce-effect {
  animation: bounceEffect 0.6s ease-in-out;
}

.shake-effect {
  animation: shakeEffect 0.5s ease-in-out;
}

.fade-in {
  animation: fadeIn 0.4s ease-in;
}

.pulse-effect {
  animation: pulseEffect 0.8s ease-in-out;
}

.vibrate-effect {
  animation: vibrateEffect 0.4s ease-in-out;
}

.slide-down {
  animation: slideDown 0.5s ease-out;
}

/* アニメーションキーフレーム */
@keyframes successCelebration {
  0% {
    transform: scale(0.5) rotate(-10deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.1) rotate(5deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes bounceEffect {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-15px);
  }
  60% {
    transform: translateY(-8px);
  }
}

@keyframes shakeEffect {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(5px);
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulseEffect {
  0%,
  100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.05);
  }
  50% {
    transform: scale(1.1);
  }
  75% {
    transform: scale(1.05);
  }
}

@keyframes vibrateEffect {
  0%,
  100% {
    transform: translateX(0);
  }
  10% {
    transform: translateX(-2px) rotate(-0.5deg);
  }
  20% {
    transform: translateX(2px) rotate(0.5deg);
  }
  30% {
    transform: translateX(-2px) rotate(-0.5deg);
  }
  40% {
    transform: translateX(2px) rotate(0.5deg);
  }
  50% {
    transform: translateX(-1px) rotate(-0.25deg);
  }
  60% {
    transform: translateX(1px) rotate(0.25deg);
  }
  70% {
    transform: translateX(-1px) rotate(-0.25deg);
  }
  80% {
    transform: translateX(1px) rotate(0.25deg);
  }
  90% {
    transform: translateX(0) rotate(0deg);
  }
}

@keyframes slideDown {
  0% {
    transform: translateY(-50px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}
