/* ===================================
   たしざんれんしゅう — スタイル
   =================================== */

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

:root {
  --pink:     #FFB3C6;
  --pink-lt:  #FFEEF3;
  --mint:     #B5EAD7;
  --mint-lt:  #E8FAF3;
  --yellow:   #FFF3B0;
  --lavender: #C7B8EA;
  --lav-lt:   #F0ECFC;
  --peach:    #FFD9B3;
  --text:     #3D3250;
  --white:    #FFFFFF;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: linear-gradient(135deg, #FFEEF3 0%, #F0ECFC 50%, #E8FAF3 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-x: hidden;
}

/* ===================================
   流れ星
   =================================== */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.star {
  position: absolute;
  font-size: 1.2rem;
  animation: twinkle 3s ease-in-out infinite;
  opacity: 0.4;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(1.3); }
}

/* ===================================
   アプリ全体
   =================================== */
.app {
  width: 100%;
  max-width: 520px;
  position: relative;
  z-index: 1;
}

/* ===================================
   ヘッダー
   =================================== */
.header {
  text-align: center;
  margin-bottom: 1.2rem;
  position: relative;
}

.header h1 {
  font-size: clamp(1.2rem, 5vw, 1.6rem);
  font-weight: 900;
  color: var(--text);
  line-height: 1.4;
}

.back-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--white);
  border: 2px solid var(--lavender);
  color: var(--text);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(140,100,200,0.1);
  transition: transform 0.15s;
}
.back-btn:hover { transform: translateY(-50%) translateX(-2px); }

/* ===================================
   スコアバー
   =================================== */
.score-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.score-item {
  background: var(--white);
  border-radius: 16px;
  padding: 0.6rem 1rem;
  text-align: center;
  box-shadow: 0 3px 12px rgba(140,100,200,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 80px;
}

.score-icon { font-size: 1.3rem; }
.score-label { font-size: 0.68rem; color: #9B8BB0; font-weight: 700; }
.score-num { font-size: 1.6rem; font-weight: 900; color: var(--text); line-height: 1; }

/* ===================================
   問題カード
   =================================== */
.question-area { margin-bottom: 1rem; }

.question-card {
  background: var(--white);
  border-radius: 28px;
  padding: 2rem 1.5rem;
  box-shadow: 0 8px 32px rgba(140,100,200,0.13);
  text-align: center;
}

.question-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.num {
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 900;
  color: #9333EA;
  background: var(--lav-lt);
  width: clamp(70px, 18vw, 90px);
  height: clamp(70px, 18vw, 90px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  border: 3px solid var(--lavender);
}

.plus, .equals {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  color: var(--text);
}

.answer-box {
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 900;
  color: #D97706;
  background: var(--yellow);
  width: clamp(70px, 18vw, 90px);
  height: clamp(70px, 18vw, 90px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  border: 3px dashed #F59E0B;
  transition: all 0.2s;
}

.answer-box.correct {
  background: var(--mint-lt);
  border-color: #10B981;
  color: #059669;
  animation: pop 0.35s ease;
}

.answer-box.wrong {
  background: #FEE2E2;
  border-color: #F87171;
  color: #DC2626;
  animation: shake 0.35s ease;
}

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

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

/* ===================================
   視覚的なヒント（絵文字）
   =================================== */
.visual-hint {
  font-size: 1.5rem;
  line-height: 1.8;
  min-height: 3rem;
  margin-bottom: 1rem;
  letter-spacing: 0.1em;
  word-break: break-all;
}

/* ===================================
   数字ボタン
   =================================== */
.num-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.num-btn {
  background: var(--lav-lt);
  border: 2.5px solid var(--lavender);
  border-radius: 14px;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 900;
  color: var(--text);
  padding: 0.7rem 0;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  font-family: 'Noto Sans JP', sans-serif;
}

.num-btn:hover {
  background: var(--lavender);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(140,100,200,0.25);
}

.num-btn:active { transform: scale(0.93); }

.num-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ===================================
   フィードバック
   =================================== */
.feedback {
  font-size: 1.3rem;
  font-weight: 900;
  min-height: 2rem;
  transition: opacity 0.3s;
}

.feedback.correct { color: #059669; }
.feedback.wrong   { color: #DC2626; }

/* ===================================
   スタート・結果画面
   =================================== */
.start-screen,
.result-screen {
  position: fixed;
  inset: 0;
  background: rgba(240, 236, 252, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.start-card,
.result-card {
  background: var(--white);
  border-radius: 28px;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 12px 40px rgba(140,100,200,0.18);
  max-width: 360px;
  width: 100%;
}

.start-emoji,
.result-emoji {
  font-size: 4rem;
  margin-bottom: 0.8rem;
  display: block;
  animation: float 2.5s ease-in-out infinite;
}

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

.start-card h2,
.result-card h2 {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 0.8rem;
}

.start-card p,
.result-card p {
  color: #7E7597;
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.result-score {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
  background: var(--yellow);
  border-radius: 16px;
  padding: 0.8rem 1.5rem;
  margin-bottom: 1.5rem;
}

.result-score span { color: #9333EA; font-size: 2rem; }

.start-btn {
  background: linear-gradient(135deg, #C084FC, #F472B6);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.9rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(192,132,252,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: 'Noto Sans JP', sans-serif;
}

.start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(192,132,252,0.45);
}

.hidden { display: none !important; }

/* ===================================
   紙吹雪
   =================================== */
.confetti {
  position: fixed;
  top: -10px;
  font-size: 1.5rem;
  animation: fall linear forwards;
  pointer-events: none;
  z-index: 100;
}

@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
