@import url('https://fonts.googleapis.com/css2?family=Kosugi+Maru&display=swap');

/* ==========================================================================
   1. デザインシステム＆変数定義
   ========================================================================== */
:root {
  /* 配色：朝の空色×クリーム×山吹色。文字は焦げ茶 */
  --color-sky-light: #f0f8ff;   /* 空色ベースの極めて薄い背景 */
  --color-sky: #b3d9ff;         /* 空色 */
  --color-sky-dark: #0077e6;    /* 空色のアクセント・青 */
  --color-cream: #fdfbf7;       /* クリーム色（メインのカード/背景） */
  --color-yamabuki: #ffb800;    /* 山吹色（プライマリ・アクセント・ボタン） */
  --color-yamabuki-hover: #e0a200;
  --color-charcoal: #4a3e3d;    /* 焦げ茶色（文字・コントラスト確保） */
  --color-white: #ffffff;
  --color-success: #2e7d32;     /* 成功時の緑 */
  --color-bubble-rainbow: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
  --color-bubble-rainbow-active: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);

  /* タイポグラフィ */
  --font-family: 'Kosugi Maru', system-ui, -apple-system, sans-serif;
  --font-size-base: 18px; /* シニア向けに本文18px以上 */
  
  /* レイアウト */
  --max-width: 480px;
  --border-radius-lg: 24px;
  --border-radius-md: 16px;
  --shadow-sm: 0 4px 6px rgba(74, 62, 61, 0.08);
  --shadow-md: 0 8px 16px rgba(74, 62, 61, 0.12);
  --shadow-lg: 0 12px 24px rgba(74, 62, 61, 0.16);
  
  /* トランジション */
  --transition-normal: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. リセット＆グローバル設定
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-charcoal);
  background-color: var(--color-sky-light);
  line-height: 1.6;
}

/* ダブルタップズーム・ピンチズーム・長押し選択を無効化 */
body {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
}

/* アプリ容器 */
.app-container {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  background-color: var(--color-cream);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ヘッダー */
header {
  padding: 16px 20px;
  background-color: var(--color-sky);
  border-bottom: 4px solid var(--color-charcoal);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.logo-text {
  font-size: 20px;
  font-weight: bold;
  color: var(--color-charcoal);
}

.mute-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--color-charcoal);
  background-color: var(--color-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
}

.mute-btn:active {
  transform: scale(0.9);
}

/* ==========================================================================
   3. ビュー（画面）切り替え
   ========================================================================== */
.view {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 24px 20px 40px;
  animation: fadeIn 0.4s ease-out forwards;
}

.view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   4. シニア用コンポーネント (ボタン、カードなど)
   ========================================================================== */
/* メインボタン：高さ56px以上、押しやすい立体デザイン */
.btn-primary {
  width: 100%;
  min-height: 64px;
  padding: 12px 24px;
  font-family: var(--font-family);
  font-size: 22px;
  font-weight: bold;
  color: var(--color-charcoal);
  background-color: var(--color-yamabuki);
  border: 4px solid var(--color-charcoal);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  box-shadow: 0 6px 0 var(--color-charcoal);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--color-charcoal);
}

.btn-secondary {
  width: 100%;
  min-height: 58px;
  padding: 10px 20px;
  font-family: var(--font-family);
  font-size: 18px;
  font-weight: bold;
  color: var(--color-charcoal);
  background-color: var(--color-white);
  border: 3px solid var(--color-charcoal);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--color-charcoal);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--color-charcoal);
}

/* カードスタイル */
.card {
  background-color: var(--color-white);
  border: 3px solid var(--color-charcoal);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

/* 見出し */
h2 {
  font-size: 22px;
  margin-bottom: 16px;
  color: var(--color-charcoal);
  border-left: 6px solid var(--color-yamabuki);
  padding-left: 10px;
  line-height: 1.2;
}

h3 {
  font-size: 19px;
  margin-bottom: 12px;
  color: var(--color-charcoal);
}

/* ==========================================================================
   5. ホーム画面固有のスタイル
   ========================================================================== */
.catchphrase {
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: var(--color-sky-dark);
  margin-bottom: 8px;
}

.hero-title {
  text-align: center;
  font-size: 28px;
  line-height: 1.3;
  margin-bottom: 24px;
  color: var(--color-charcoal);
}

.streak-badge {
  text-align: center;
  font-size: 22px;
  font-weight: bold;
  background-color: #ffebeb;
  border: 3px solid #ff4d4d;
  border-radius: var(--border-radius-md);
  padding: 12px;
  margin-bottom: 20px;
}

/* カレンダー (ラジオ体操カード風) */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.calendar-day-label {
  text-align: center;
  font-size: 13px;
  font-weight: bold;
  color: #8a7e7d;
  padding-bottom: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  border: 2px solid var(--color-charcoal);
  border-radius: 8px;
  background-color: var(--color-sky-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: bold;
  position: relative;
}

.calendar-day.today {
  border-color: var(--color-yamabuki);
  box-shadow: 0 0 0 2px var(--color-yamabuki);
}

.calendar-day.stamped::after {
  content: "💮";
  font-size: 24px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.calendar-day.stamped span {
  opacity: 0.2;
}

/* グラフ (Canvas) */
.chart-container {
  position: relative;
  width: 100%;
  height: 180px;
  margin-bottom: 12px;
}

.chart-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* LP説明エリア */
.lp-section {
  margin-top: 20px;
}

.feature-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feature-item {
  display: flex;
  gap: 12px;
}

.feature-number {
  background-color: var(--color-sky-dark);
  color: var(--color-white);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

.feature-text strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.feature-text p {
  font-size: 16px;
  color: #6a5e5d;
}

/* FAQ / 免責 */
.faq-item {
  margin-bottom: 16px;
}

.faq-q {
  font-weight: bold;
  color: var(--color-sky-dark);
  margin-bottom: 4px;
}

.faq-a {
  font-size: 16px;
  color: #5a4e4d;
}

.disclaimer-text {
  font-size: 15px;
  color: #7a6e6d;
  line-height: 1.5;
}

/* フッター */
footer {
  margin-top: auto;
  padding: 24px 20px;
  background-color: #efeae2;
  border-top: 3px solid var(--color-charcoal);
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
  font-size: 16px;
}

.footer-links a {
  color: var(--color-charcoal);
  text-decoration: underline;
  font-weight: bold;
}

.footer-copy {
  font-size: 14px;
  color: #8a7e7d;
}

/* ==========================================================================
   6. マイク許可・エラー画面のスタイル
   ========================================================================== */
.mic-intro-title {
  text-align: center;
  font-size: 26px;
  margin-bottom: 24px;
}

.mic-card-highlight {
  border: 4px solid var(--color-sky-dark);
  background-color: #f7fbff;
  font-size: 20px;
}

.mic-icon-large {
  font-size: 64px;
  text-align: center;
  margin: 20px 0;
  animation: pulse 2s infinite ease-in-out;
}

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

.error-title {
  color: #d32f2f;
  font-size: 24px;
  text-align: center;
  margin-bottom: 16px;
}

/* ==========================================================================
   7. チャレンジ画面の共通＆個別スタイル
   ========================================================================== */
.challenge-header {
  text-align: center;
  margin-bottom: 20px;
}

.challenge-step-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.step-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--color-charcoal);
  background-color: var(--color-white);
}

.step-dot.active {
  background-color: var(--color-yamabuki);
}

.challenge-title {
  font-size: 24px;
  font-weight: bold;
}

.challenge-instruction {
  font-size: 20px;
  text-align: center;
  margin-bottom: 24px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.challenge-canvas-container {
  position: relative;
  width: 100%;
  height: 320px;
  border: 3px solid var(--color-charcoal);
  border-radius: var(--border-radius-lg);
  background-color: var(--color-white);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.challenge-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.challenge-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 20px;
  font-weight: bold;
  background-color: #f7f3eb;
  padding: 12px 20px;
  border-radius: var(--border-radius-md);
  border: 2px solid var(--color-charcoal);
}

/* カウントダウン・ノイズ計測オーバーレイ */
.overlay-countdown {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(253, 251, 247, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  text-align: center;
  padding: 20px;
}

.countdown-number {
  font-size: 80px;
  font-weight: bold;
  color: var(--color-yamabuki);
  text-shadow: 2px 2px 0 var(--color-charcoal);
  margin: 16px 0;
}

/* ==========================================================================
   8. 結果画面のスタイル
   ========================================================================== */
.result-header {
  text-align: center;
  margin-bottom: 24px;
}

.result-title {
  font-size: 26px;
  margin-bottom: 8px;
}

.result-main-card {
  text-align: center;
  padding: 30px 20px;
  background-color: #fffdec;
  border: 4px solid var(--color-charcoal);
}

.score-badge-large {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 4px solid var(--color-charcoal);
  background-color: var(--color-yamabuki);
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.score-num {
  font-size: 54px;
  font-weight: bold;
  line-height: 1.1;
}

.score-lbl {
  font-size: 16px;
  font-weight: bold;
}

.voice-age-label {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 12px;
}

.voice-age-num {
  font-size: 38px;
  color: #ff4d4d;
  text-shadow: 1px 1px 0 var(--color-charcoal);
}

.comparison-text {
  font-size: 18px;
  font-weight: bold;
  background-color: var(--color-sky-light);
  border: 2px solid var(--color-sky);
  border-radius: var(--border-radius-md);
  padding: 12px;
  margin: 16px 0;
  text-align: center;
}

/* 結果内訳 */
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  background-color: var(--color-white);
  border: 2px solid var(--color-charcoal);
}

.breakdown-name {
  font-weight: bold;
}

.breakdown-value {
  font-size: 20px;
  font-weight: bold;
}

.hidden-canvas {
  display: none;
}
