/* ==========================================================
   令和8年度 ケアマネ試験対策アプリ スタイル
   方針：文字大きめ・高コントラスト・目に優しい配色
   ========================================================== */

:root {
  --bg: #faf6ee;            /* クリーム系の落ち着いた背景 */
  --text: #1d3145;          /* 濃紺（高コントラスト） */
  --text-sub: #51606f;
  --card: #ffffff;
  --primary: #0e7c6b;       /* 深い緑（メインボタン） */
  --primary-dark: #0a5f52;
  --secondary: #e8772e;     /* オレンジ（アクセント） */
  --danger: #c0392b;
  --line: #dfd8c8;
  --correct: #1e8e3e;
  --correct-bg: #e6f4ea;
  --wrong: #c0392b;
  --wrong-bg: #fdecea;
  --gold: #f5b301;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(29, 49, 69, 0.10);
}

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

html { font-size: 17px; }

body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  transition: filter 0.3s ease;
}

/* 不正解時：画面全体を白黒に */
#app.grayscale {
  filter: grayscale(1) brightness(0.75);
}

.hidden { display: none !important; }

.screen { animation: screen-in 0.25s ease; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 共通パーツ ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 12px;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
  min-height: 52px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-text { background: none; color: var(--text-sub); text-decoration: underline; min-height: auto; padding: 6px; font-weight: 500; }
.btn-big { font-size: 1.2rem; padding: 18px 16px; }

.icon-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 1.3rem;
  width: 48px;
  height: 48px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}

/* ---------- ホーム画面 ---------- */

.home-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin: 8px 0 12px;
}

.title-block { flex: 1; }

.app-title {
  font-size: 1.55rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.app-org {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
  letter-spacing: 0.08em;
}

.screen-header-title {
  font-weight: 800;
  font-size: 1.15rem;
  flex: 1;
}

.settings-header h2 { flex: 1; }

.daily-message {
  background: #fff7e0;
  border: 1px solid #f0dfa8;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.streak-card {
  text-align: center;
  padding: 24px 20px;
}

.streak-flames {
  font-size: 2.6rem;
  line-height: 1.2;
  animation: flame-sway 1.6s ease-in-out infinite;
}
@keyframes flame-sway {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

.streak-main {
  font-size: 1.7rem;
  font-weight: 800;
  margin-top: 6px;
}

.streak-sub {
  color: var(--text-sub);
  font-size: 0.95rem;
  margin-top: 4px;
}

.streak-best {
  color: var(--text-sub);
  font-size: 0.85rem;
  margin-top: 10px;
}

.countdown-card {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 14px;
  background: #eef6f5;
  border: 1px solid #cfe5e2;
}

.stats-card { margin-top: 8px; }

.stats-note {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 14px;
}

.cat-row { margin-bottom: 14px; }
.cat-row:last-child { margin-bottom: 0; }

.cat-name {
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.cat-name .cat-detail {
  font-weight: 500;
  color: var(--text-sub);
  font-size: 0.82rem;
  white-space: nowrap;
}

.cat-bar {
  background: #ece6d8;
  border-radius: 8px;
  height: 14px;
  margin-top: 5px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--primary), #2fae8f);
  width: 0;
  transition: width 0.6s ease;
}

.cat-bar-fill.low  { background: linear-gradient(90deg, #e8772e, #f0a35e); }
.cat-bar-fill.master { background: linear-gradient(90deg, var(--gold), #ffd95e); }

.home-footer {
  text-align: center;
  color: var(--text-sub);
  font-size: 0.8rem;
  margin-top: 20px;
}

/* ---------- マイルストーン（10日ごと）演出 ---------- */

.milestone-banner {
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 16px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
  background: linear-gradient(120deg, #ff5e62, #f5b301, #2fae8f, #4f74e3, #ff5e62);
  background-size: 400% 400%;
  animation: milestone-gradient 5s ease infinite;
  box-shadow: 0 4px 16px rgba(245, 179, 1, 0.45);
}
@keyframes milestone-gradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

body.celebrating {
  background: linear-gradient(160deg, #fff8e1, #ffe9f0, #e5f7f1, #fff8e1);
  background-size: 300% 300%;
  animation: milestone-gradient 8s ease infinite;
}

/* ---------- 出題画面 ---------- */

.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 14px;
}

.quiz-progress-wrap { flex: 1; }

.quiz-progress-text {
  font-weight: 700;
  font-size: 0.95rem;
}

.quiz-progress-bar {
  background: #ece6d8;
  height: 10px;
  border-radius: 6px;
  margin-top: 4px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 6px;
  width: 0;
  transition: width 0.3s ease;
}

.quiz-category {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 14px;
  margin-bottom: 10px;
}

.question-card { padding: 22px 20px; }

.question-text {
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.75;
}

.choices { margin-bottom: 16px; }

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 1.02rem;
  line-height: 1.6;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice input[type="radio"] {
  width: 22px;
  height: 22px;
  margin-top: 3px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.choice.selected {
  border-color: var(--primary);
  background: #eef6f5;
}

.choice.reveal-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  font-weight: 700;
}

.choice.reveal-wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

.choice.disabled { cursor: default; opacity: 0.92; }
.choice.disabled.dimmed { opacity: 0.55; }

/* ---------- 解説 ---------- */

.explanation-box { animation: screen-in 0.3s ease; }

.explanation-verdict {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.explanation-verdict.ok { color: var(--correct); }
.explanation-verdict.ng { color: var(--wrong); }

.explanation-comment {
  font-size: 0.95rem;
  background: #fff7e0;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.explanation-answer {
  font-weight: 700;
  background: var(--correct-bg);
  border-left: 5px solid var(--correct);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.explanation-title { font-size: 1rem; margin-bottom: 6px; }

.explanation-text {
  font-size: 1rem;
  margin-bottom: 18px;
  white-space: pre-line;
}

/* ---------- 結果画面 ---------- */

.result-card {
  text-align: center;
  padding: 34px 20px;
  margin-top: 24px;
}

.result-emoji { font-size: 3.2rem; line-height: 1.2; }

.result-score {
  font-size: 1.9rem;
  font-weight: 800;
  margin-top: 10px;
}

.result-rate {
  color: var(--text-sub);
  font-size: 1.05rem;
  margin-bottom: 14px;
}

.result-comment {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.8;
}

/* ---------- 設定画面 ---------- */

.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
}

.settings-desc {
  font-size: 0.92rem;
  color: var(--text-sub);
  margin-bottom: 12px;
}

.settings-desc strong { color: var(--danger); }

.date-input {
  display: block;
  width: 100%;
  font-size: 1.1rem;
  font-family: inherit;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  background: #fff;
  color: var(--text);
}

.settings-saved { color: var(--correct); font-weight: 700; }

/* ---------- オーバーレイ（正解・不正解演出） ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.overlay-inner {
  text-align: center;
  padding: 24px;
  position: relative;
}

.overlay-skip {
  margin-top: 26px;
  font-size: 0.8rem;
  opacity: 0.75;
}

/* 正解：金色の輝き＋大きな文字 */
.overlay-correct {
  background: radial-gradient(circle at center, rgba(255, 240, 180, 0.97), rgba(255, 215, 64, 0.93));
  animation: overlay-in 0.2s ease;
}

.correct-glow {
  position: absolute;
  inset: -60px;
  background: radial-gradient(circle, rgba(255,255,255,0.9) 0%, rgba(255,215,64,0) 60%);
  animation: glow-pulse 1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes glow-pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50%      { transform: scale(1.25); opacity: 1; }
}

.correct-text {
  position: relative;
  font-size: 3.4rem;
  font-weight: 900;
  color: #8a5a00;
  text-shadow: 0 2px 0 #fff, 0 4px 14px rgba(138, 90, 0, 0.35);
  animation: correct-pop 0.45s cubic-bezier(0.2, 2.2, 0.4, 1);
}
@keyframes correct-pop {
  0%   { transform: scale(0.2) rotate(-6deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.correct-comment {
  position: relative;
  margin-top: 14px;
  font-size: 1.25rem;
  font-weight: 800;
  color: #5c3d00;
}

.combo-badge {
  position: relative;
  display: inline-block;
  margin-top: 12px;
  background: #c2410c;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  border-radius: 999px;
  padding: 7px 20px;
  box-shadow: 0 3px 12px rgba(194, 65, 12, 0.45);
  animation: correct-pop 0.5s cubic-bezier(0.2, 2.2, 0.4, 1);
}

/* 不正解：鬼の登場 */
.overlay-wrong {
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  animation: overlay-in 0.2s ease, oni-shake 0.5s ease 0.15s;
}

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

@keyframes oni-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

.oni-face {
  font-size: 6.5rem;
  line-height: 1.1;
  animation: oni-jump 0.6s cubic-bezier(0.2, 2, 0.4, 1);
  filter: drop-shadow(0 0 24px rgba(255, 60, 60, 0.8));
}
@keyframes oni-jump {
  0%   { transform: translateY(80px) scale(0.3); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.oni-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #ffd0c0;
  margin-top: 4px;
}

.wrong-text {
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 6px;
  color: #ff8a80;
}

.oni-comment {
  margin-top: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  padding: 12px 18px;
  max-width: 480px;
}

/* ---------- 紙吹雪 ---------- */

#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -24px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(112vh) rotate(680deg); opacity: 0.6; }
}

/* ---------- レスポンシブ ---------- */

@media (max-width: 420px) {
  html { font-size: 16px; }
  .app-title { font-size: 1.35rem; }
  .correct-text { font-size: 2.6rem; }
  .oni-face { font-size: 5rem; }
}

@media (min-width: 700px) {
  #app { padding-top: 32px; }
}
