/* コード・クオリティ当てトレーニング。配色・配置はコード辞典(chord-dictionary.css)に合わせる */
#cet-root {
  --cet-paper: #F7F6F2;
  --cet-card: #FFFFFF;
  --cet-ink: #232730;
  --cet-sub: #7A7E89;
  --cet-line: #DDDBD3;
  --cet-accent: #2E6E8E;
  --cet-accent-soft: #E8F0F3;
  --cet-danger: #C24B4B;
  --cet-radius: 14px;
  --cet-radius-sm: 8px;
  --cet-radius-pill: 999px;

  background: var(--cet-paper);
  color: var(--cet-ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#cet-root * { box-sizing: border-box; }

/* --- ページ本体(コード辞典と同じく、記事内に並ぶ通常のカード) --- */
#cet-root .cet-wrap {
  max-width: 640px;
  margin: 0 auto;
}

#cet-root .cet-screen {
  display: flex;
  flex-direction: column;
  position: relative;
}

#cet-root .cet-content { padding: 20px 16px 40px; flex: 1; }

#cet-root .cet-card {
  background: var(--cet-card); border: 1px solid var(--cet-line); border-radius: var(--cet-radius);
  padding: 18px; margin-bottom: 14px;
}
#cet-root .cet-card h3 { font-size: 13px; color: var(--cet-sub); margin: 0 0 10px; font-weight: 700; }

/* 自己ベスト */
#cet-root .cet-best-row { display: flex; justify-content: space-between; align-items: baseline; }
#cet-root .cet-best-level {
  font-size: 12px; background: var(--cet-accent); color: #fff;
  padding: 3px 10px; border-radius: var(--cet-radius-pill); font-weight: 700;
}
#cet-root .cet-best-score { font-size: 28px; font-weight: 800; color: var(--cet-accent); }
#cet-root .cet-best-score span { font-size: 13px; font-weight: 600; color: var(--cet-sub); margin-left: 4px; }

/* サイト記録 */
#cet-root .cet-record-list { display: flex; flex-direction: column; gap: 8px; }
#cet-root .cet-record-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; background: var(--cet-paper); border-radius: var(--cet-radius-sm); font-size: 13px;
}
#cet-root .cet-record-item .tag { color: var(--cet-sub); font-weight: 600; }
#cet-root .cet-record-item .val { font-weight: 800; color: var(--cet-accent); }

/* アコーディオン */
#cet-root .cet-accordion-row {
  border: 1px solid var(--cet-line); border-radius: var(--cet-radius-sm);
  margin-bottom: 8px; overflow: hidden; background: var(--cet-card);
}
#cet-root .cet-accordion-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 14px; cursor: pointer; font-size: 13px; font-weight: 700;
}
#cet-root .cet-accordion-head .chev { color: var(--cet-sub); transition: transform 0.15s; font-size: 11px; }
#cet-root .cet-accordion-row.open .chev { transform: rotate(180deg); }
#cet-root .cet-accordion-body {
  max-height: 0; overflow: hidden; transition: max-height 0.2s ease;
  font-size: 12.5px; color: var(--cet-sub); line-height: 1.6;
}
#cet-root .cet-accordion-row.open .cet-accordion-body { max-height: 280px; }
#cet-root .cet-accordion-body-inner { padding: 0 14px 14px; }

/* モード選択 */
#cet-root .cet-mode-grid { display: flex; flex-direction: column; gap: 10px; }
#cet-root .cet-mode-pill {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-radius: var(--cet-radius-sm); border: 1.5px solid var(--cet-line);
  background: var(--cet-card); cursor: pointer;
}
#cet-root .cet-mode-pill.selected { border-color: var(--cet-accent); background: var(--cet-accent-soft); }
#cet-root .cet-mode-pill .mode-name { font-weight: 700; font-size: 14px; }
#cet-root .cet-mode-pill .mode-desc { font-size: 11px; color: var(--cet-sub); margin-top: 2px; }
#cet-root .cet-mode-pill .check {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--cet-line);
  display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff;
  flex-shrink: 0;
}
#cet-root .cet-mode-pill.selected .check { background: var(--cet-accent); border-color: var(--cet-accent); }

/* 練習モード: 級複数選択(チェックボックス) */
#cet-root .cet-practice-level-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#cet-root .cet-practice-level-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--cet-radius-pill); border: 1.5px solid var(--cet-line);
  background: var(--cet-card); cursor: pointer; font-size: 13px; font-weight: 700;
}
#cet-root .cet-practice-level-pill.selected { border-color: var(--cet-accent); background: var(--cet-accent-soft); color: var(--cet-accent); }
#cet-root .cet-practice-level-pill .check { font-size: 12px; color: var(--cet-accent); font-weight: 800; }

#cet-root .cet-btn-primary {
  width: 100%; background: var(--cet-accent); color: #fff; border: none;
  padding: 16px; border-radius: var(--cet-radius-pill); font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
#cet-root .cet-btn-primary:active { background: var(--cet-ink); }
#cet-root .cet-btn-primary:disabled { background: var(--cet-line); color: var(--cet-sub); cursor: default; }
#cet-root .cet-loading-note { text-align: center; font-size: 12px; color: var(--cet-sub); margin-bottom: 10px; }
#cet-root .cet-btn-secondary {
  width: 100%; background: transparent; color: var(--cet-accent);
  border: 1.5px solid var(--cet-accent); padding: 14px; border-radius: var(--cet-radius-pill);
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; margin-top: 8px;
}

/* --- プレイ画面 --- */
#cet-root .cet-play-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; }
#cet-root .cet-lives { display: flex; gap: 4px; font-size: 18px; }
#cet-root .cet-life-lost { opacity: 0.25; }
#cet-root .cet-level-badge {
  background: var(--cet-accent); color: #fff; font-size: 12px; font-weight: 700;
  padding: 4px 12px; border-radius: var(--cet-radius-pill); white-space: nowrap;
}
#cet-root .cet-timer-chip {
  display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 800;
  color: var(--cet-accent); background: var(--cet-accent-soft); padding: 4px 12px;
  border-radius: var(--cet-radius-pill); font-variant-numeric: tabular-nums; white-space: nowrap;
}

#cet-root .cet-progress-track {
  height: 6px; background: var(--cet-line); border-radius: var(--cet-radius-pill);
  margin: 0 20px 8px; overflow: hidden;
}
#cet-root .cet-progress-fill { height: 100%; background: var(--cet-accent); border-radius: var(--cet-radius-pill); transition: width 0.2s ease; }

#cet-root .cet-play-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 20px 20px;
}
#cet-root .cet-play-button {
  width: 108px; height: 108px; border-radius: 50%; background: var(--cet-accent); border: none;
  color: #fff; font-size: 40px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 10px 24px rgba(46, 110, 142, 0.35); margin-bottom: 14px;
}
#cet-root .cet-play-hint { font-size: 12px; color: var(--cet-sub); margin-bottom: 26px; }

#cet-root .cet-radio-row { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 20px; font-size: 13px; }
#cet-root .cet-radio-option { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#cet-root .cet-radio-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--cet-line); display: flex; align-items: center; justify-content: center; }
#cet-root .cet-radio-option.selected .cet-radio-dot { border-color: var(--cet-accent); }
#cet-root .cet-radio-option.selected .cet-radio-dot::after { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--cet-accent); }
#cet-root .cet-radio-option.selected .label { font-weight: 700; color: var(--cet-accent); }

#cet-root .cet-choices { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#cet-root .cet-choice-btn {
  padding: 18px 10px; border-radius: var(--cet-radius-sm); border: 1.5px solid var(--cet-line);
  background: var(--cet-card); font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
}
#cet-root .cet-choice-btn:disabled { cursor: default; }
#cet-root .cet-choice-btn.correct { border-color: var(--cet-accent); background: var(--cet-accent); color: #fff; }
#cet-root .cet-choice-btn.wrong { border-color: var(--cet-danger); background: #FBEAEA; color: var(--cet-danger); }

#cet-root .cet-next-btn {
  margin-top: 16px; padding: 12px 32px; border-radius: var(--cet-radius-pill); border: none;
  background: var(--cet-accent); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  font-family: inherit; opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
#cet-root .cet-next-btn.show { opacity: 1; pointer-events: auto; }

#cet-root .cet-quit-link {
  text-align: center; padding: 8px 0 14px; font-size: 11.5px; color: var(--cet-sub);
  text-decoration: underline; cursor: pointer;
}

#cet-root .cet-confirm-overlay {
  position: absolute; inset: 0; background: rgba(35, 39, 48, 0.45);
  display: none; align-items: center; justify-content: center; z-index: 80;
}
#cet-root .cet-confirm-overlay.show { display: flex; }
#cet-root .cet-confirm-box { width: 82%; background: var(--cet-card); border-radius: var(--cet-radius); padding: 22px 18px; text-align: center; }
#cet-root .cet-confirm-box .msg { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
#cet-root .cet-confirm-box .sub { font-size: 12px; color: var(--cet-sub); margin-bottom: 16px; }
#cet-root .cet-confirm-box .row { display: flex; gap: 8px; }
#cet-root .cet-confirm-box button { flex: 1; padding: 11px 0; border-radius: var(--cet-radius-pill); border: none; font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit; }
#cet-root .cet-confirm-cancel { background: var(--cet-paper); color: var(--cet-ink); }
#cet-root .cet-confirm-quit { background: var(--cet-danger); color: #fff; }

/* 昇格インタースティシャル */
#cet-root .cet-interstitial {
  position: absolute; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center;
  color: #fff; background: var(--cet-accent); transform: translateX(100%); transition: transform 0.35s ease;
}
#cet-root .cet-interstitial.show { display: flex; transform: translateX(0); }
#cet-root .cet-interstitial .inner { text-align: center; }
#cet-root .cet-interstitial .label { font-size: 13px; opacity: 0.85; letter-spacing: 0.08em; }
#cet-root .cet-interstitial .name { font-size: 34px; font-weight: 800; margin: 10px 0; }
#cet-root .cet-interstitial .sub { font-size: 13px; opacity: 0.9; }

/* 正解/不正解トースト */
#cet-root .cet-feedback-toast {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(0.85);
  padding: 18px 36px; border-radius: 20px; font-size: 22px; font-weight: 800; color: #fff;
  opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}
#cet-root .cet-feedback-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#cet-root .cet-feedback-toast.correct { background: var(--cet-accent); border: 2.5px solid #fff; }
#cet-root .cet-feedback-toast.wrong { background: var(--cet-danger); border: 2.5px solid #fff; }
/* .show時のみクリックを通す(非表示中に裏の選択肢ボタン等のクリックを妨げないため) */
#cet-root .cet-feedback-toast.wrong.show { pointer-events: auto; cursor: pointer; }

/* --- 結果画面 --- */
#cet-root .cet-result-hero { text-align: center; padding: 30px 20px 10px; }
#cet-root .cet-result-badge {
  display: inline-block; background: var(--cet-accent); color: #fff; font-size: 12px; font-weight: 700;
  padding: 5px 14px; border-radius: var(--cet-radius-pill); margin-bottom: 12px;
}
#cet-root .cet-result-score { font-size: 44px; font-weight: 800; color: var(--cet-accent); line-height: 1; }
#cet-root .cet-result-score-label { font-size: 12px; color: var(--cet-sub); margin-top: 6px; }

#cet-root .cet-record-banner {
  margin: 18px 20px; padding: 16px; text-align: center; border-radius: var(--cet-radius);
  background: var(--cet-accent-soft);
}
#cet-root .cet-record-banner .title { font-weight: 800; font-size: 15px; color: var(--cet-accent); }
#cet-root .cet-record-banner .diff { font-size: 12px; color: var(--cet-sub); margin-top: 4px; }

#cet-root .cet-thumb-preview { margin: 18px 20px; border-radius: var(--cet-radius-sm); overflow: hidden; border: 1px solid var(--cet-line); background: var(--cet-accent); }
#cet-root .cet-thumb-preview img { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; }
#cet-root .cet-thumb-preview .thumb-foot { background: var(--cet-card); padding: 8px 14px; font-size: 11px; color: var(--cet-sub); }

#cet-root .cet-share-row { display: flex; gap: 10px; padding: 0 20px; margin-bottom: 14px; }
#cet-root .cet-share-btn { flex: 1; padding: 12px 0; border-radius: var(--cet-radius-sm); border: none; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; }
#cet-root .cet-share-line { background: #06C755; }
#cet-root .cet-share-x { background: #111; }
#cet-root .cet-share-ig { background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af, #515bd4); }

#cet-root .cet-share-hint { margin: 0 20px 14px; padding: 10px 14px; border-radius: var(--cet-radius); background: var(--cet-accent-soft); color: var(--cet-accent); font-size: 12px; text-align: center; }

#cet-root .cet-result-actions { padding: 0 20px; margin-top: auto; padding-bottom: 20px; }

/* 「結果」画面の小見出し(cet-topbar)。ホーム画面のブランド表示は撤去済みだが、
   結果画面は状態の区切りを示す見出しとして残す */
#cet-root .cet-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; background: var(--cet-card); border-bottom: 1px solid var(--cet-line);
}
#cet-root .cet-topbar .brand { font-weight: 700; font-size: 15px; }

@media (max-width: 480px) {
  #cet-root .cet-content { padding: 16px 12px 32px; }
}
