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

:root {
  --card-color: #FFB3BA;
}

body {
  font-family: 'Hiragino Maru Gothic ProN', 'M PLUS Rounded 1c', sans-serif;
  background: linear-gradient(135deg, #fff9f0 0%, #f0f4ff 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  user-select: none;
}

.hidden { display: none !important; }

/* ===== ヘッダー ===== */
header {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-shrink: 0;
}

h1 {
  font-size: 1rem;
  color: #555;
  font-weight: bold;
  white-space: nowrap;
}

/* ===== モードタブ ===== */
.mode-tabs {
  display: flex;
  background: #efe8ff;
  border-radius: 14px;
  padding: 3px;
  gap: 3px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: 11px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  color: #888;
  font-family: inherit;
  font-weight: bold;
  transition: background 0.2s, color 0.2s;
}

.tab-btn.active {
  background: white;
  color: #555;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* ===== フラッシュカードセクション ===== */
#flashcard-section {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.fc-top {
  margin-bottom: 12px;
}

.fc-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  justify-content: flex-end;
}

.icon-btn {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  color: #555;
  transition: transform 0.1s, background 0.1s;
  font-family: inherit;
}

.icon-btn:active { transform: scale(0.93); background: #f5f5f5; }

.icon-btn.spin { animation: spin 0.5s ease; }

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 進捗 */
.progress-wrap { width: 100%; }

.progress-info {
  display: flex;
  justify-content: flex-end;
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 5px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: #e8e8e8;
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #ff8c42, #ff6b6b);
  border-radius: 99px;
  transition: width 0.3s ease;
}

/* カードコンテナ */
.card-container {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
  margin-bottom: 16px;
  min-height: 280px;
  max-height: 400px;
}

.card {
  width: 100%;
  height: 100%;
  min-height: 280px;
  max-height: 400px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.card.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.card-front {
  background: white;
  border: 4px solid var(--card-color);
}

.row-label {
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: 0.8rem;
  color: #aaa;
  font-weight: bold;
}

.katakana-main {
  font-size: clamp(90px, 25vw, 160px);
  color: #333;
  line-height: 1;
  font-weight: 900;
  text-shadow: 2px 4px 8px rgba(0,0,0,0.08);
}

.tap-hint { margin-top: 18px; font-size: 0.9rem; color: #bbb; }

.card-back {
  background: var(--card-color);
  transform: rotateY(180deg);
  gap: 10px;
}

.katakana-small {
  font-size: clamp(40px, 10vw, 64px);
  color: rgba(0,0,0,0.3);
  line-height: 1;
  font-weight: 900;
}

.divider {
  width: 60%;
  height: 3px;
  background: rgba(255,255,255,0.7);
  border-radius: 99px;
}

.hiragana-text {
  font-size: clamp(56px, 16vw, 100px);
  color: #333;
  font-weight: 900;
  line-height: 1;
}

.romaji-text {
  font-size: clamp(20px, 4.5vw, 30px);
  color: rgba(0,0,0,0.5);
  font-weight: bold;
  letter-spacing: 0.05em;
}

#speak-btn {
  margin-top: 6px;
  background: white;
  border: 3px solid rgba(255,255,255,0.9);
  border-radius: 50px;
  padding: 9px 22px;
  font-size: 0.95rem;
  cursor: pointer;
  color: #555;
  font-family: inherit;
  font-weight: bold;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
}

#speak-btn:active, #speak-btn.speaking { transform: scale(0.93); }

.nav-buttons {
  width: 100%;
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  max-width: 200px;
  background: white;
  border: 3px solid #e0e0e0;
  border-radius: 20px;
  padding: 16px 0;
  font-size: 1.2rem;
  cursor: pointer;
  color: #444;
  font-family: inherit;
  font-weight: bold;
  transition: transform 0.1s, border-color 0.1s, color 0.1s;
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
}

.nav-btn:active { transform: scale(0.95); }
.nav-btn:hover  { border-color: #ff8c42; color: #ff8c42; }

/* ===== クイズセクション ===== */
#quiz-section {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
}

/* 卵エリア */
.egg-area {
  display: flex;
  align-items: center;
  gap: 16px;
  background: white;
  border-radius: 20px;
  padding: 12px 16px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.egg-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.egg-container {
  width: 64px;
  height: 76px;
  position: relative;
}

.egg-svg {
  width: 100%;
  height: 100%;
}

/* 卵のひび */
.crack {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.egg-stage-1 #c1 { opacity: 1; }
.egg-stage-2 #c1, .egg-stage-2 #c2 { opacity: 1; }
.egg-stage-3 #c1, .egg-stage-3 #c2, .egg-stage-3 #c3 { opacity: 1; }
.egg-stage-4 #c1, .egg-stage-4 #c2, .egg-stage-4 #c3, .egg-stage-4 #c4 { opacity: 1; }

.egg-stage-4 .egg-svg {
  animation: egg-wobble 1.2s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes egg-wobble {
  0%, 100% { transform: rotate(-6deg); }
  50%       { transform: rotate(6deg); }
}

.egg-crack-flash {
  animation: crack-flash 0.3s ease;
}

@keyframes crack-flash {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* 卵プログレスバー */
.egg-progress-track {
  width: 64px;
  height: 7px;
  background: #eee;
  border-radius: 99px;
  overflow: hidden;
}

.egg-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FFD700, #FF8C42);
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s ease;
}

.egg-label {
  font-size: 0.75rem;
  color: #999;
  font-weight: bold;
}

/* 恐竜カウント */
.dino-tally {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.dino-tally-icon {
  font-size: 2rem;
  line-height: 1;
}

.dino-tally #dino-count {
  font-size: 1.6rem;
  font-weight: 900;
  color: #555;
  line-height: 1;
}

.dino-tally-unit {
  font-size: 0.7rem;
  color: #aaa;
}

/* 問題エリア */
.quiz-question-area {
  background: white;
  border-radius: 24px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  flex-shrink: 0;
}

.quiz-prompt {
  font-size: 1rem;
  color: #999;
  margin-bottom: 6px;
}

.quiz-katakana-display {
  font-size: clamp(72px, 20vw, 120px);
  font-weight: 900;
  color: #333;
  line-height: 1;
}

/* 選択肢グリッド */
.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
}

.choice-btn {
  background: white;
  border: 3px solid #e8e8e8;
  border-radius: 20px;
  font-size: clamp(36px, 10vw, 56px);
  font-weight: 900;
  color: #333;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choice-btn:active:not(:disabled) { transform: scale(0.94); }

.choice-btn.correct {
  background: #4CAF50;
  border-color: #4CAF50;
  color: white;
  animation: correct-pop 0.35s cubic-bezier(0.2, 0.8, 0.3, 1.4);
}

.choice-btn.wrong {
  background: #F44336;
  border-color: #F44336;
  color: white;
  animation: wrong-shake 0.4s ease;
}

.choice-btn:disabled { cursor: default; }

@keyframes correct-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

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

/* ===== 孵化オーバーレイ ===== */
.hatch-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: overlay-in 0.35s ease;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.confetti-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 3px;
  animation: confetti-fall linear forwards;
}

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

.dino-reveal-box {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 1;
  animation: reveal-pop 0.6s cubic-bezier(0.2, 0.8, 0.3, 1.2);
  padding: 32px 24px;
}

@keyframes reveal-pop {
  0%   { transform: scale(0.3); opacity: 0; }
  70%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.dino-big {
  font-size: clamp(160px, 50vw, 300px);
  line-height: 1;
  animation: dino-bounce 0.7s ease infinite alternate;
  filter: drop-shadow(0 12px 32px rgba(0,0,0,0.3));
}

@keyframes dino-bounce {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-16px) scale(1.04); }
}

.dino-reveal-box h2 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  color: white;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.dino-got-text {
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 6px rgba(0,0,0,0.3);
}

.dino-total-text {
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  color: rgba(255,255,255,0.75);
}

.dino-total-text strong {
  color: #FFD700;
  font-size: 1.3em;
}

.hatch-close-btn {
  margin-top: 16px;
  background: white;
  border: none;
  border-radius: 50px;
  padding: 16px 36px;
  font-size: clamp(1rem, 3vw, 1.2rem);
  color: #ff6b6b;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.1s;
}

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

/* ===== レスポンシブ ===== */
@media (max-height: 680px) {
  .katakana-main { font-size: clamp(70px, 20vw, 120px); }
  .hiragana-text { font-size: clamp(48px, 13vw, 80px); }
  .quiz-katakana-display { font-size: clamp(56px, 15vw, 90px); }
  .choice-btn { min-height: 64px; font-size: clamp(28px, 8vw, 44px); }
  .dino-big { font-size: 72px; }
}
