@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;700;900&display=swap');

/*
:root {
  --font-family: 'M PLUS Rounded 1c', sans-serif;
  --color-bg-primary: #e6f7ff;
  --color-bg-secondary: #f0f5ff;
  --color-text-main: #333333;
  --color-primary: #1890ff;
  --color-primary-hover: #40a9ff;
  --color-success: #52c41a;
  --color-warning: #faad14;
  --color-danger: #f5222d;
  --color-mushibarasu: #722ed1;
  --color-mushibarasu-bg: #f9f0ff;
  --border-radius-large: 24px;
  --border-radius-medium: 16px;
  --border-radius-small: 12px;
  --shadow-pop: 0 8px 0px rgba(0, 0, 0, 0.15);
  --shadow-flat: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition-smooth: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
  font-family: var(--font-family);
  background: radial-gradient(circle, #e6f7ff 0%, #bae7ff 100%);
  color: var(--color-text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

html {
  height: 100%;
}
*/

/* アプリコンテナ */
#app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  background: white;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
	margin: 1em auto;
}

/* 共通画面スタイル */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  opacity: 0;
  pointer-events: none;
  transform: translateX(50px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

/* ヘッダー/コントロール */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sound-toggle-btn {
  background: #f0f0f0;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 0 #d9d9d9;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

.sound-toggle-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

/* 1. タイトル画面 */
#title-screen {
  background: radial-gradient(circle, #fffbe6 0%, #ffe58f 100%);
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 24px;
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.logo-sub {
  font-size: 1.2rem;
  font-weight: 700;
  color: #d46b08;
  background: rgba(255,255,255,0.8);
  padding: 6px 16px;
  border-radius: 20px;
  border: 2px solid #ffe58f;
  animation: bounce 2s infinite;
}

.logo-title {
  font-size: 2.4rem;
  font-weight: 900;
  color: #ad2102;
  text-shadow: 3px 3px 0px #fff, -3px -3px 0px #fff, 3px -3px 0px #fff, -3px 3px 0px #fff, 0px 4px 6px rgba(0,0,0,0.2);
  line-height: 1.2;
}

.title-illustration {
  width: 75%;
  max-width: 280px;
  position: relative;
  margin: 10px 0;
}

.title-illustration img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0px 8px 12px rgba(0,0,0,0.15));
}

.pulse-animation {
  animation: pulse 1.8s infinite alternate;
}

.start-btn {
  background: linear-gradient(135deg, #ff7a45 0%, #ff4d4f 100%);
  color: white;
  border: none;
  font-family: var(--font-family);
  font-size: 1.5rem;
  font-weight: 900;
  padding: 16px 48px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 0px #cf1322, 0 12px 20px rgba(255, 77, 79, 0.4);
  transition: var(--transition-smooth);
}

.start-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0px #cf1322, 0 4px 10px rgba(255, 77, 79, 0.4);
}

/* 2. 難易度選択画面 */
#difficulty-screen {
  background: radial-gradient(circle, #e6f7ff 0%, #bae7ff 100%);
}

.screen-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: #0050b3;
  text-align: center;
  margin-top: 16px;
  text-shadow: 2px 2px 0px #fff;
}

.difficulty-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: auto 0;
}

.diff-btn {
  border: none;
  border-radius: var(--border-radius-large);
  padding: 20px;
  font-family: var(--font-family);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  transition: var(--transition-smooth);
}

.diff-btn .icon {
  font-size: 2.5rem;
  background: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}

.diff-btn .info {
  display: flex;
  flex-direction: column;
}

.diff-name {
  font-size: 1.4rem;
  font-weight: 900;
}

.diff-desc {
  font-size: 0.9rem;
  opacity: 0.9;
}

.diff-easy {
  background: linear-gradient(135deg, #f6ffed 0%, #d9f7be 100%);
  color: #389e0d;
  box-shadow: 0 8px 0px #73d13d;
}

.diff-easy:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0px #73d13d;
}

.diff-normal {
  background: linear-gradient(135deg, #fffbe6 0%, #ffe58f 100%);
  color: #d46b08;
  box-shadow: 0 8px 0px #ffc53d;
}

.diff-normal:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0px #ffc53d;
}

.diff-hard {
  background: linear-gradient(135deg, #fff1f0 0%, #ffccc7 100%);
  color: #cf1322;
  box-shadow: 0 8px 0px #ff7875;
}

.diff-hard:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0px #ff7875;
}

/* 3. クイズバトル画面 */
#battle-screen {
  background: #f0f5ff;
  padding: 16px;
}

/* バトルアリーナ（はぴかちゃん VS ムシバラス） */
.battle-arena {
  background: white;
  border-radius: var(--border-radius-large);
  border: 4px solid #bae7ff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-flat);
  position: relative;
  background-image: radial-gradient(#e6f7ff 1.5px, transparent 1.5px);
  background-size: 16px 16px;
}

.boss-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-mushibarasu-bg);
  padding: 12px;
  border-radius: var(--border-radius-medium);
  border: 2px dashed var(--color-mushibarasu);
}

.boss-avatar-wrapper {
  position: relative;
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}

.boss-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
}

.hp-bar-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hp-label {
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--color-mushibarasu);
  display: flex;
  justify-content: space-between;
}

.hp-bar-bg {
  background: #d9d9d9;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

.hp-bar-fill {
  background: linear-gradient(90deg, #b37feb 0%, #722ed1 100%);
  width: 100%;
  height: 100%;
  border-radius: 7px;
  transition: width 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

/* プレイヤー側（はぴかちゃん） */
.player-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 12px;
}

.player-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.player-name {
  font-size: 0.95rem;
  font-weight: 900;
  color: #0050b3;
}

.combo-badge {
  background: var(--color-warning);
  color: white;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
  animation: bounce 0.8s infinite alternate;
  display: none;
}

.player-avatar-wrapper {
  position: relative;
  width: 70px;
  height: 70px;
}

.player-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
}

/* クイズエリア */
.quiz-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  justify-content: space-between;
  margin-top: 12px;
  gap: 12px;
}

.progress-bar {
  background: #f0f0f0;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  background: var(--color-primary);
  width: 0%;
  height: 100%;
  transition: width 0.3s;
}

.question-card {
  background: white;
  border-radius: var(--border-radius-medium);
  padding: 16px;
  box-shadow: var(--shadow-flat);
  border: 3px solid #1890ff;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text-main);
  text-align: center;
  line-height: 1.4;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  background: white;
  border: 3px solid #d9d9d9;
  border-radius: var(--border-radius-medium);
  padding: 16px 20px;
  font-family: var(--font-family);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-main);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 0px #d9d9d9;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.option-btn .number {
  background: #f0f0f0;
  color: #666;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 900;
  flex-shrink: 0;
}

/* 正解・不正解時のオプションスタイル */
.option-btn.correct {
  border-color: var(--color-success);
  background: #f6ffed;
  color: #389e0d;
  box-shadow: 0 4px 0px #73d13d;
}

.option-btn.incorrect {
  border-color: var(--color-danger);
  background: #fff1f0;
  color: #cf1322;
  box-shadow: 0 4px 0px #ff7875;
}

/* 攻撃時のアニメーション */
@keyframes playerAttack {
  0% { transform: scale(1); }
  30% { transform: translateX(-15px) scale(1.1); }
  60% { transform: translateX(25px) scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes bossHit {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(0.9) rotate(-10deg) translateX(10px); filter: brightness(1.5) sepia(1) hue-rotate(-50deg); }
  75% { transform: scale(0.9) rotate(10deg) translateX(-10px); filter: brightness(1.5) sepia(1) hue-rotate(-50deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-4px, -2px); }
  20%, 40%, 60%, 80% { transform: translate(4px, 2px); }
}

.animate-attack {
  animation: playerAttack 0.6s ease;
}

.animate-hit {
  animation: bossHit 0.6s ease;
}

.animate-shake {
  animation: shake 0.5s ease;
}

/* 判定レイヤー (まる・ばつ) */
.judgment-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
  border-radius: var(--border-radius-large);
}

.judgment-mark {
  font-size: 10rem;
  font-weight: 900;
  transform: scale(0.5);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.5);
}

.judgment-overlay.show {
  opacity: 1;
}

.judgment-overlay.show .judgment-mark {
  transform: scale(1);
}

.judgment-correct {
  color: rgba(82, 196, 26, 0.95);
  text-shadow: 0 0 20px rgba(255,255,255,1);
}

.judgment-incorrect {
  color: rgba(245, 34, 45, 0.95);
  text-shadow: 0 0 20px rgba(255,255,255,1);
}

/* 4. リザルト（結果）画面 */
#result-screen {
  background: radial-gradient(circle, #fffbe6 0%, #ffe58f 100%);
  align-items: center;
  text-align: center;
}

.result-card {
  background: white;
  width: 100%;
  border-radius: var(--border-radius-large);
  padding: 24px;
  box-shadow: var(--shadow-flat);
  border: 4px solid #ffd666;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.result-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: #ad2102;
}

.badge-display {
  width: 120px;
  height: 120px;
  margin: 10px 0;
  position: relative;
}

.badge-display img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0px 6px 8px rgba(0,0,0,0.15));
  animation: float 3s ease-in-out infinite;
}

.result-score {
  font-size: 2.2rem;
  font-weight: 900;
  color: #fa8c16;
}

.result-message {
  font-size: 1.1rem;
  font-weight: 700;
  color: #555;
  line-height: 1.4;
}

.fact-box {
  background: #fffbe6;
  border-left: 6px solid #ffc53d;
  padding: 12px 16px;
  border-radius: 0 var(--border-radius-medium) var(--border-radius-medium) 0;
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.4;
}

.fact-title {
  font-weight: 900;
  color: #d46b08;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-group {
  display: flex;
  gap: 16px;
  width: 100%;
}

.action-btn {
  flex: 1;
  font-family: var(--font-family);
  font-size: 1.1rem;
  font-weight: 900;
  padding: 14px 20px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-restart {
  background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  color: white;
  box-shadow: 0 6px 0px #0050b3;
}

.btn-restart:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0px #0050b3;
}

.btn-home {
  background: linear-gradient(135deg, #8c8c8c 0%, #595959 100%);
  color: white;
  box-shadow: 0 6px 0px #434343;
}

.btn-home:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0px #434343;
}

/* キラキラ用紙吹雪用のキャンバス */
#effects-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* キーフレームアニメーション */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}

/* メディアクエリ */
@media (max-height: 600px) {
  #app-container {
    height: 100%;
  }
  .logo-title {
    font-size: 1.8rem;
  }
  .title-illustration {
    width: 50%;
  }
  .diff-btn {
    padding: 12px;
  }
  .diff-btn .icon {
    width: 44px;
    height: 44px;
    font-size: 1.8rem;
  }
  .options-container {
    gap: 8px;
  }
  .option-btn {
    padding: 10px 14px;
    font-size: 0.95rem;
  }
}
