/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", "Meiryo", "Hiragino Kaku Gothic ProN", sans-serif;
  background: #f8fafc;
  color: #1e293b;
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== Site Header ===== */
.site-header {
  background: #0f172a;
  padding: 14px 24px;
}

.site-header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header-logo {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.site-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.3px;
  transition: opacity 0.2s;
}

.site-logo:hover { opacity: 0.7; }

.logo-dot { color: #60a5fa; }

.site-brand {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #60a5fa;
  letter-spacing: 0.5px;
}

.header-nav a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.2s;
}

.header-nav a:hover { color: #ffffff; }

/* ===== App Shell ===== */
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

/* ===== Screen Transitions ===== */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

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

/* ===== Loading Screen ===== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
  color: #64748b;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== App Header ===== */
.app-header {
  text-align: center;
  padding: 32px 0 16px;
}

.app-header h1 {
  font-size: 1.6rem;
  color: #1e293b;
}

.app-subtitle {
  color: #64748b;
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ===== Cards ===== */
.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px;
  margin: 16px 0;
}

/* ===== Start Screen ===== */
.start-card h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: #1e293b;
}

.start-card h3 {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 10px;
}

/* Category Filter Header */
.category-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.category-filter-header h3 {
  margin-bottom: 0;
}

.category-toggle-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-text {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.2s;
}

.btn-text:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.toggle-sep {
  color: #cbd5e1;
  font-size: 0.75rem;
}

/* Category Group Headers */
.category-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 8px;
}

.category-group-header:first-child {
  margin-top: 0;
}

.category-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #2563eb;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.category-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.category-checkbox:hover {
  border-color: #2563eb;
}

.category-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  cursor: pointer;
}

.category-name {
  flex: 1;
  font-size: 0.9rem;
}

.category-count {
  color: #94a3b8;
  font-size: 0.8rem;
}

.options {
  margin: 16px 0;
}

.option-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: #475569;
  cursor: pointer;
}

.option-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  cursor: pointer;
}

.question-count {
  text-align: center;
  font-size: 0.95rem;
  color: #64748b;
  margin: 16px 0;
}

.question-count strong {
  color: #2563eb;
  font-size: 1.2rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-lg {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.05rem;
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-outline {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #475569;
}

.btn-outline:hover {
  border-color: #2563eb;
  color: #2563eb;
}

/* ===== Progress Bar ===== */
.quiz-header {
  margin-bottom: 16px;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-count {
  font-size: 0.85rem;
  color: #64748b;
  white-space: nowrap;
  min-width: 60px;
}

.btn-quit {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: transparent;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-quit:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.progress-bar-bg {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
  margin-right: 6px;
}

.badge-category {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-basic {
  background: #dcfce7;
  color: #15803d;
}

.badge-intermediate {
  background: #fef3c7;
  color: #b45309;
}

.badge-advanced {
  background: #fee2e2;
  color: #dc2626;
}

.badge-type {
  background: #e0e7ff;
  color: #4338ca;
}

/* ===== Question Card ===== */
.question-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 16px;
}

.question-meta {
  margin-bottom: 16px;
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: #1e293b;
}

/* ===== Choice Buttons ===== */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  color: #1e293b;
  font-size: 0.95rem;
  line-height: 1.6;
  cursor: pointer;
  transition: all 0.2s;
}

.choice-btn:hover:not(.disabled) {
  border-color: #2563eb;
  background: #eff6ff;
}

.choice-btn.correct {
  border-color: #22c55e;
  background: #f0fdf4;
}

.choice-btn.incorrect {
  border-color: #ef4444;
  background: #fef2f2;
}

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

.choice-btn.disabled:not(.correct):not(.incorrect) {
  opacity: 0.5;
}

.choice-label {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.choice-btn.correct .choice-label {
  background: #22c55e;
  color: #fff;
}

.choice-btn.incorrect .choice-label {
  background: #ef4444;
  color: #fff;
}

/* ===== Explanation Card ===== */
.explanation-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  margin: 16px 0;
  animation: fadeIn 0.4s ease;
}

.explanation-card.result-correct {
  border-left: 4px solid #22c55e;
}

.explanation-card.result-incorrect {
  border-left: 4px solid #ef4444;
}

.result-label {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.result-label.correct {
  color: #16a34a;
}

.result-label.incorrect {
  color: #dc2626;
}

.explanation-summary {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #475569;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.explanation-detail {
  font-size: 0.85rem;
  line-height: 1.7;
  color: #64748b;
  margin-bottom: 8px;
}

.explanation-detail strong {
  color: #1e293b;
}

.explanation-detail.is-correct strong {
  color: #16a34a;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.keyword-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 4px;
}

.btn-next {
  margin-top: 16px;
}

/* ===== Results Screen ===== */
.score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 6px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

.score-circle.score-a { border-color: #22c55e; }
.score-circle.score-b { border-color: #3b82f6; }
.score-circle.score-c { border-color: #f59e0b; }
.score-circle.score-d { border-color: #ef4444; }

.score-number {
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
}

.score-total {
  font-size: 0.85rem;
  color: #94a3b8;
}

.score-percentage {
  text-align: center;
  font-size: 1.2rem;
  color: #334155;
  margin-bottom: 8px;
}

.score-grade {
  text-align: center;
  font-size: 0.95rem;
  margin-bottom: 24px;
  padding: 10px 16px;
  border-radius: 8px;
}

.score-grade.score-a { background: #dcfce7; color: #15803d; }
.score-grade.score-b { background: #dbeafe; color: #1d4ed8; }
.score-grade.score-c { background: #fef3c7; color: #b45309; }
.score-grade.score-d { background: #fee2e2; color: #dc2626; }

.stats-section {
  margin: 20px 0;
}

.stats-section h3 {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 10px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 0.85rem;
}

.stat-label {
  flex: 1;
  color: #334155;
}

.stat-value {
  color: #64748b;
  min-width: 60px;
  text-align: right;
}

.stat-bar-bg {
  width: 80px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

/* ===== App Info Section ===== */
.app-info h2 {
  font-size: 1.1rem;
  color: #1e293b;
  margin-bottom: 16px;
}

.info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 0.85rem;
}

.info-list dt {
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
}

.info-list dd {
  color: #334155;
}

.info-details {
  margin-top: 16px;
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
}

.info-details summary {
  font-size: 0.85rem;
  color: #2563eb;
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
}

.info-details summary:hover {
  color: #1d4ed8;
}

.info-details-content {
  margin-top: 12px;
  font-size: 0.8rem;
  line-height: 1.8;
  color: #64748b;
}

.info-details-content h3 {
  font-size: 0.85rem;
  color: #334155;
  margin: 12px 0 6px;
}

.info-details-content h3:first-child {
  margin-top: 0;
}

.info-details-content ul {
  list-style: none;
  padding: 0;
}

.info-details-content li {
  padding-left: 16px;
  position: relative;
  margin-bottom: 6px;
}

.info-details-content li::before {
  content: '・';
  position: absolute;
  left: 0;
}

/* ===== Purchase Banner ===== */
.purchase-card {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #2563eb;
  text-align: center;
}

.purchase-info {
  margin-bottom: 16px;
}

.purchase-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.purchase-desc {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.6;
}

.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-accent:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ===== License Key Restore ===== */
.restore-card {
  text-align: center;
}

.restore-title {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 4px;
}

.restore-note {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 12px;
}

.restore-input {
  width: 100%;
  padding: 14px 16px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  color: #1e293b;
  font-family: "Consolas", "Monaco", monospace;
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.restore-input:focus {
  border-color: #2563eb;
}

.restore-input::placeholder {
  color: #94a3b8;
  letter-spacing: 2px;
}

.restore-error {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 24px 16px;
  color: #94a3b8;
  font-size: 0.8rem;
  border-top: 1px solid #e2e8f0;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  #app {
    padding: 12px;
  }

  .app-header h1 {
    font-size: 1.3rem;
  }

  .card {
    padding: 16px;
  }

  .question-card {
    padding: 16px;
  }

  .choice-btn {
    padding: 14px 16px;
    font-size: 0.9rem;
  }

  .score-circle {
    width: 130px;
    height: 130px;
  }

  .score-number {
    font-size: 1.6rem;
  }
}

/* ===== Phase 1.4.5: Authority, Conversion & Legal Styles ===== */

/* RISS監修バッジ */
.riss-badge {
  display: inline-block;
  background: #dbeafe;
  border: 1px solid rgba(37, 99, 235, 0.3);
  color: #1d4ed8;
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 8px;
}

/* 開発の物語テキスト */
.app-story {
  font-size: 0.875rem;
  color: #64748b;
  margin: 8px auto 0;
  max-width: 540px;
  line-height: 1.6;
  text-align: center;
}

/* クーポンバッジ */
.coupon-badge {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.875rem;
  color: #b45309;
  text-align: center;
  margin: 12px 0 8px;
}

/* クーポンヒントテキスト */
.coupon-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 6px;
}

/* フッターナビ（クロスリンク） */
.footer-nav {
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.footer-nav a {
  color: #64748b;
  text-decoration: none;
}

.footer-nav a:hover {
  color: #2563eb;
}

.footer-nav span {
  margin: 0 8px;
  color: #cbd5e1;
}

/* フッターリンク */
.footer-links {
  margin-top: 6px;
  font-size: 0.8rem;
}

.footer-links a {
  color: #94a3b8;
  text-decoration: none;
}

.footer-links a:hover {
  color: #2563eb;
}

.footer-links span {
  margin: 0 8px;
  color: #cbd5e1;
}

/* 作成者情報リンク */
.info-link {
  color: #2563eb;
  text-decoration: none;
}

.info-link:hover {
  text-decoration: underline;
}

/* ===== 法的ページ（legal.html / privacy.html）用スタイル ===== */

.legal-card {
  max-width: 800px;
  margin: 0 auto 32px;
}

.back-link {
  display: inline-block;
  margin-top: 8px;
  color: #2563eb;
  text-decoration: none;
  font-size: 0.875rem;
}

.back-link:hover {
  text-decoration: underline;
}

/* 特定商取引法テーブル */
.legal-table {
  width: 100%;
  border-collapse: collapse;
}

.legal-table th {
  width: 180px;
  padding: 12px 16px;
  text-align: left;
  color: #64748b;
  font-weight: 500;
  vertical-align: top;
  border-bottom: 1px solid #e2e8f0;
}

.legal-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .legal-table th {
    width: 120px;
    font-size: 0.85rem;
  }
  .legal-table td {
    font-size: 0.875rem;
  }
}

/* プライバシーポリシー本文 */
.legal-intro {
  color: #64748b;
  margin-bottom: 24px;
  line-height: 1.7;
}

.legal-section {
  margin-bottom: 28px;
}

.legal-h2 {
  font-size: 1.1rem;
  color: #1e293b;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.legal-h3 {
  font-size: 0.95rem;
  color: #334155;
  margin: 16px 0 6px;
}

.legal-section p {
  color: #64748b;
  line-height: 1.7;
  font-size: 0.9rem;
}

.legal-date {
  color: #94a3b8;
  font-size: 0.8rem;
  margin-top: 24px;
  text-align: right;
}
