@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --bg: #1a1410;
  --bg2: #241c16;
  --bg3: #2f231a;
  --card: #352820;
  --border: #5a3e2b;
  --gold: #c9993e;
  --gold-light: #e0b55a;
  --red: #b83232;
  --red-light: #e05050;
  --green: #3a7a4a;
  --green-light: #5ab86a;
  --text: #e8dcc8;
  --text-dim: #a08060;
  --text-muted: #6a5040;
  --white: #f5ede0;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== HEADER ===== */
header {
  background: linear-gradient(180deg, #0e0b08 0%, var(--bg2) 100%);
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.header-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.15rem;
  color: var(--gold);
  letter-spacing: 0.05em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-flag {
  width: 28px;
  height: 19px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.15);
  object-fit: cover;
  flex-shrink: 0;
}
.header-nav { display: flex; gap: 8px; }
.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.2s;
  font-family: 'Noto Sans JP', sans-serif;
}
.nav-btn:hover, .nav-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201,153,62,0.1);
}

/* ===== MAIN CONTAINER ===== */
.container { max-width: 800px; margin: 0 auto; padding: 32px 20px; }

/* ===== HOME ===== */
.hero {
  text-align: center;
  padding: 40px 0 32px;
}
.hero-ornament {
  color: var(--gold);
  font-size: 2rem;
  margin-bottom: 8px;
  letter-spacing: 0.3em;
}
.hero h1 {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.8rem;
  color: var(--white);
  margin-bottom: 8px;
}
.hero p { color: var(--text-dim); font-size: 0.9rem; }

.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 32px;
}
.work-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.work-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  opacity: 0;
  transition: opacity 0.2s;
}
.work-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.work-card:hover::before { opacity: 1; }
.work-card-year { color: var(--text-muted); font-size: 0.75rem; margin-bottom: 4px; }
.work-card-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.1rem;
  color: var(--white);
  margin-bottom: 4px;
}
.work-card-author { color: var(--text-dim); font-size: 0.82rem; margin-bottom: 12px; }
.work-card-count {
  background: rgba(201,153,62,0.15);
  border: 1px solid rgba(201,153,62,0.3);
  color: var(--gold);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}
.work-card-best {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}
.work-card-best span {
  color: var(--gold);
  font-weight: 700;
}
.work-card-buttons {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.btn-list, .btn-quiz {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: 'Noto Sans JP', sans-serif;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-weight: 500;
}
.btn-list {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-list:hover { border-color: var(--gold); color: var(--gold); }
.btn-quiz {
  background: linear-gradient(135deg, var(--gold), #a07828);
  color: #1a1000;
}
.btn-quiz:hover { background: linear-gradient(135deg, var(--gold-light), var(--gold)); }

/* ===== CHARACTER LIST ===== */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.back-btn:hover { border-color: var(--gold); color: var(--gold); }
.screen-header-info h2 {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.3rem;
  color: var(--white);
}
.screen-header-info p { color: var(--text-dim); font-size: 0.82rem; }
.btn-quiz-sm {
  padding: 8px 20px;
  border-radius: 8px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, var(--gold), #a07828);
  color: #1a1000;
  transition: all 0.2s;
}
.btn-quiz-sm:hover { background: linear-gradient(135deg, var(--gold-light), var(--gold)); }

.character-grid { display: grid; gap: 14px; }
.char-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  transition: border-color 0.2s;
}
.char-card:hover { border-color: rgba(201,153,62,0.4); }
.char-card-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.char-main-name {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.1rem;
  color: var(--white);
}
.char-role {
  background: rgba(90,62,43,0.6);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
}
.char-stat-badge {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.char-stat-badge span { color: var(--gold); font-weight: 700; }
.char-full-name {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 12px;
  font-style: italic;
}
.names-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 7px;
}
.names-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.name-tag {
  background: rgba(201,153,62,0.1);
  border: 1px solid rgba(201,153,62,0.25);
  color: var(--gold-light);
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: 14px;
}
.name-tag.primary {
  background: rgba(201,153,62,0.2);
  border-color: rgba(201,153,62,0.5);
  color: var(--gold);
  font-weight: 500;
}
.char-desc {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-top: 10px;
  line-height: 1.6;
  border-top: 1px solid rgba(90,62,43,0.4);
  padding-top: 10px;
}

/* ===== QUIZ ===== */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.quiz-progress-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  min-width: 100px;
}
.quiz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 3px;
  transition: width 0.4s ease;
}
.quiz-counter { color: var(--text-dim); font-size: 0.85rem; white-space: nowrap; }
.quiz-score-badge {
  background: rgba(201,153,62,0.15);
  border: 1px solid rgba(201,153,62,0.3);
  color: var(--gold);
  font-size: 0.82rem;
  padding: 3px 12px;
  border-radius: 12px;
}
.quiz-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  margin-bottom: 20px;
}
.quiz-type-badge {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.quiz-question {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.15rem;
  color: var(--white);
  line-height: 1.7;
}
.quiz-question em {
  color: var(--gold);
  font-style: normal;
  font-weight: 700;
}
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 500px) {
  .choices-grid { grid-template-columns: 1fr; }
}
.choice-btn {
  background: var(--bg3);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  text-align: left;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(201,153,62,0.08);
}
.choice-label {
  background: rgba(90,62,43,0.6);
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.choice-btn.correct {
  border-color: var(--green-light);
  background: rgba(58,122,74,0.15);
  color: var(--white);
}
.choice-btn.correct .choice-label { background: var(--green); color: white; }
.choice-btn.wrong {
  border-color: var(--red-light);
  background: rgba(184,50,50,0.12);
  color: var(--text-dim);
}
.choice-btn.wrong .choice-label { background: var(--red); color: white; }
.choice-btn:disabled { cursor: default; }

.quiz-feedback {
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
}
.quiz-feedback.correct-fb {
  background: rgba(58,122,74,0.2);
  border: 1px solid rgba(90,184,106,0.4);
  color: #8ad49a;
}
.quiz-feedback.wrong-fb {
  background: rgba(184,50,50,0.15);
  border: 1px solid rgba(224,80,80,0.3);
  color: #e09090;
}
.feedback-icon { font-size: 1.1rem; margin-right: 6px; }

.next-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--gold), #a07828);
  border: none;
  color: #1a1000;
  padding: 13px;
  border-radius: 10px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.next-btn:hover { background: linear-gradient(135deg, var(--gold-light), var(--gold)); }

/* ===== STATS SCREEN ===== */
.stats-section { margin-bottom: 32px; }
.stats-section-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.1rem;
  color: var(--white);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.stats-work-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 14px;
}
.stats-work-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.stats-work-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1rem;
  color: var(--white);
}
.stats-meta { color: var(--text-muted); font-size: 0.78rem; }
.stats-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stats-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  text-align: center;
  flex: 1;
  min-width: 80px;
}
.stats-box-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  font-family: 'Noto Serif JP', serif;
}
.stats-box-label { font-size: 0.72rem; color: var(--text-muted); }

.history-list { }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(90,62,43,0.3);
  font-size: 0.83rem;
}
.history-item:last-child { border-bottom: none; }
.history-date { color: var(--text-muted); }
.history-score { color: var(--text); }
.history-score strong { color: var(--gold); }

.char-stats-grid { display: grid; gap: 8px; margin-top: 12px; }
.char-stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}
.char-stat-name { color: var(--text-dim); min-width: 100px; }
.char-stat-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.char-stat-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.char-stat-bar.good { background: var(--green-light); }
.char-stat-bar.mid { background: var(--gold); }
.char-stat-bar.bad { background: var(--red-light); }
.char-stat-pct { color: var(--text-muted); font-size: 0.75rem; min-width: 36px; text-align: right; }

.empty-stats {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.empty-stats .icon { font-size: 2.5rem; margin-bottom: 10px; }

.clear-btn {
  background: transparent;
  border: 1px solid rgba(184,50,50,0.4);
  color: rgba(224,80,80,0.7);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Noto Sans JP', sans-serif;
}
.clear-btn:hover { border-color: var(--red-light); color: var(--red-light); }

/* ===== RESULT ===== */
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 28px;
  text-align: center;
}
.result-ornament { font-size: 3rem; margin-bottom: 12px; }
.result-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.5rem;
  color: var(--white);
  margin-bottom: 8px;
}
.result-score {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--gold);
  margin: 16px 0 4px;
  font-family: 'Noto Serif JP', serif;
}
.result-total { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 20px; }
.result-rank {
  background: rgba(201,153,62,0.15);
  border: 1px solid rgba(201,153,62,0.3);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 24px;
}
.result-rank-title { color: var(--gold); font-size: 1.1rem; font-weight: 700; }
.result-rank-desc { color: var(--text-dim); font-size: 0.85rem; margin-top: 4px; }
.result-new-best {
  background: rgba(58,122,74,0.2);
  border: 1px solid rgba(90,184,106,0.4);
  color: #8ad49a;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  margin-bottom: 20px;
}
.result-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.result-btn {
  padding: 11px 24px;
  border-radius: 10px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.result-btn.primary {
  background: linear-gradient(135deg, var(--gold), #a07828);
  color: #1a1000;
}
.result-btn.primary:hover { background: linear-gradient(135deg, var(--gold-light), var(--gold)); }
.result-btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.result-btn.secondary:hover { border-color: var(--gold); color: var(--gold); }

/* ===== STORAGE NOTICE ===== */
.storage-notice {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 28px;
}
.storage-notice-title {
  font-weight: 700;
  color: var(--white);
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.storage-notice-body p {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 12px;
  line-height: 1.7;
}
.storage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 12px;
}
.storage-table th {
  background: rgba(90,62,43,0.4);
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 6px 10px;
  font-weight: 500;
}
.storage-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(90,62,43,0.25);
  color: var(--text-dim);
}
.storage-table tr:last-child td { border-bottom: none; }
.storage-table tr.safe td:first-child { color: var(--green-light); }
.storage-table tr.danger td:first-child { color: #e0a060; }
.storage-table tr.danger td:last-child { color: var(--red-light); font-weight: 500; }
.storage-table tr.safe td:last-child { color: var(--green-light); font-weight: 500; }
.storage-tip {
  color: var(--text-muted) !important;
  font-size: 0.78rem !important;
  line-height: 1.6 !important;
  border-top: 1px solid rgba(90,62,43,0.3);
  padding-top: 10px;
  margin-top: 4px;
  margin-bottom: 0 !important;
}

/* ===== TERMS ===== */
.terms-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.terms-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(90,62,43,0.35);
}
.terms-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.terms-section h3 {
  font-family: 'Noto Serif JP', serif;
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 10px;
}
.terms-section p {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.8;
}
.terms-section ul {
  margin-top: 8px;
  padding-left: 20px;
}
.terms-section ul li {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.8;
}

/* ===== RESULT CREATOR ===== */
.result-creator {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(90,62,43,0.35);
  text-align: center;
}
.result-creator-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 8px;
}
.result-creator-sns {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.result-creator-sns a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all 0.2s;
}
.result-creator-sns a:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ===== TERMS SNS ===== */
.terms-sns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.terms-sns a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all 0.2s;
}
.terms-sns a:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ===== FOOTER ===== */
.app-footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 1px solid rgba(90,62,43,0.25);
  margin-top: 40px;
}
.footer-main { margin-bottom: 8px; }
.app-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  transition: color 0.2s;
}
.app-footer a:hover { color: var(--gold); }
.footer-sep { margin: 0 8px; }
.footer-author {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-sns {
  display: flex;
  gap: 8px;
}
.footer-sns a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  padding: 2px 8px;
  border: 1px solid rgba(90,62,43,0.4);
  border-radius: 10px;
  transition: all 0.2s;
}
.footer-sns a:hover { border-color: var(--gold); color: var(--gold); }

/* ===== HIDDEN ===== */
.screen { display: none; }
.screen.active { display: block; }
