﻿* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: #f4f6fa;
  color: #222;
  line-height: 1.7;
}

header {
  background: #2f4b8a;
  color: #fff;
  text-align: center;
  padding: 28px 16px;
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
}

header p {
  margin: 4px 0 0;
  opacity: 0.85;
}

main {
  max-width: 680px;
  margin: 24px auto;
  padding: 0 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card h2 {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

button {
  font: inherit;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid #ccd3e0;
  background: #fff;
  cursor: pointer;
}

button.primary {
  background: #2f4b8a;
  border-color: #2f4b8a;
  color: #fff;
}

button.primary:hover {
  background: #243b6e;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field select {
  display: block;
  margin-top: 4px;
  padding: 8px;
  font: inherit;
  min-width: 220px;
}

/* 問題画面 */
.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #666;
}

.tag {
  background: #e7ecf7;
  color: #2f4b8a;
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 0.85rem;
}

/* ---- 注意書き・バックアップ・報告 ---- */
.notice-bar {
  background: #fff4d6;
  color: #6b4e00;
  font-size: 0.85rem;
  text-align: center;
  padding: 8px 16px;
  border-bottom: 1px solid #f0dca0;
}

.backup {
  margin-top: 20px;
  border-top: 1px solid #eee;
  padding-top: 12px;
}

.backup summary {
  cursor: pointer;
  color: #2f4b8a;
  font-size: 0.9rem;
}

.feedback-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.version {
  font-size: 0.75rem;
  color: #aaa;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  background: #222c40;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 200;
}

/* ---- 模擬試験 ---- */
button.exam-open {
  border-color: #2f4b8a;
  color: #2f4b8a;
  font-weight: bold;
}

.timer {
  font-weight: bold;
  color: #2f4b8a;
  font-variant-numeric: tabular-nums;
}

.timer.urgent {
  color: #d04545;
}

.exam-verdict {
  font-size: 1.4rem;
  font-weight: bold;
  margin: 4px 0;
}

.exam-verdict.pass {
  color: #3a9d5d;
}

.exam-verdict.fail {
  color: #d04545;
}

.exam-topics {
  margin: 12px 0;
  font-size: 0.9rem;
}

.exam-row {
  display: grid;
  grid-template-columns: 6.5em 1fr 4em 6em;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  margin: 4px 0;
  font-size: 0.9rem;
  background: #f4f6fa;
}

.exam-row.pass .exam-row-mark {
  color: #3a9d5d;
  font-weight: bold;
}

.exam-row.fail .exam-row-mark {
  color: #d04545;
}

.exam-row-date,
.exam-row-mode {
  color: #666;
}

/* ---- 苦手分析 ---- */
.ana-item {
  border: 1px solid #e3e7ef;
  border-left: 5px solid #ccc;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
}

.ana-item.low {
  border-left-color: #d04545;
}

.ana-item.mid {
  border-left-color: #e0a100;
}

.ana-item.high {
  border-left-color: #3a9d5d;
}

.ana-item.low .stat-bar-fill {
  background: #d04545;
}

.ana-item.mid .stat-bar-fill {
  background: #e0a100;
}

.ana-head {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  margin-bottom: 4px;
}

.ana-item.low .ana-rate {
  color: #d04545;
}

.ana-item.none .ana-rate {
  color: #999;
  font-weight: normal;
}

.ana-item .stat {
  margin: 6px 0;
}

/* ---- 高難易度モード ---- */
.hard-field {
  font-weight: bold;
  color: #b8401f;
}

.stat-title {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 6px;
}

.stats.hard .stat-tile {
  background: #fdeee6;
}

.stats.hard .stat-num {
  color: #b8401f;
}

.stats.hard .stat-bar-fill {
  background: linear-gradient(90deg, #e0672f, #f39a5b);
}

.hard-step {
  margin-bottom: 16px;
}

.hard-step-title {
  font-weight: bold;
  color: #b8401f;
  margin: 0 0 8px;
}

.pen-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 520px) {
  .pen-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.pen-choice {
  text-align: center;
  padding: 10px 6px;
}

.rep-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice.picked {
  background: #fff3d6;
  border-color: #e0a100;
  box-shadow: inset 0 0 0 1px #e0a100;
}

/* ---- 補助輪モード ---- */
.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  cursor: pointer;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.hint-legend {
  display: flex;
  gap: 14px;
  margin-top: 0;
}

.hl-key {
  background: linear-gradient(transparent 58%, #ffe066 58%);
}

.hl-num {
  color: #c0392b;
}

.hl-ask {
  text-decoration: underline wavy #2f8ad8;
  text-underline-offset: 4px;
}

/* ---- カードの拡大表示 ---- */
body.no-scroll {
  overflow: hidden;
}

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 30, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 12px;
}

.viewer-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 100%;
}

.viewer-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

#viewer-img {
  display: block;
  max-width: min(480px, calc(100vw - 110px));
  max-height: calc(100vh - 110px);
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  background: #fff;
}

.viewer-nav {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.6rem;
  line-height: 1;
}

.viewer-close {
  position: absolute;
  top: -6px;
  right: 40px;
  z-index: 1;
  background: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.viewer-caption {
  color: #fff;
  margin: 8px 0 2px;
  text-align: center;
}

#viewer-count {
  margin-left: 8px;
  opacity: 0.8;
  font-size: 0.9rem;
}

.viewer-link {
  color: #b9c8ee;
  font-size: 0.8rem;
}

.card-images a {
  cursor: zoom-in;
}

/* ---- 解いた数の表示 ---- */
.stats {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 520px) {
  .stat-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-tile {
  background: #eef2fa;
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}

.stat-num {
  font-size: 1.6rem;
  font-weight: bold;
  color: #2f4b8a;
  line-height: 1.2;
}

.stat-unit {
  font-size: 0.85rem;
  margin-left: 2px;
}

.stat-label {
  font-size: 0.78rem;
  color: #666;
}

.stat-bar-wrap {
  margin-top: 14px;
}

.stat-bar-label {
  font-size: 0.9rem;
  color: #444;
  margin-bottom: 4px;
}

.stat-bar {
  height: 12px;
  background: #e3e7ef;
  border-radius: 999px;
  overflow: hidden;
}

.stat-bar.small {
  height: 8px;
  flex: 1;
}

.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3a9d5d, #5cc47f);
  border-radius: 999px;
  transition: width 0.4s;
}

.stat-details {
  margin-top: 10px;
  font-size: 0.88rem;
}

.stat-details summary {
  cursor: pointer;
  color: #2f4b8a;
}

.stat-topic {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.stat-topic-name {
  width: 11em;
  flex-shrink: 0;
}

.stat-topic-num {
  width: 4.5em;
  text-align: right;
  color: #666;
}

/* ---- 記録・見返す機能 ---- */
.hint {
  color: #666;
  font-size: 0.9rem;
  margin: 8px 0;
}

.head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flag-btn {
  padding: 4px 10px;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid #e0b100;
  background: #fff;
  color: #8a6d00;
  white-space: nowrap;
}

.flag-btn.on {
  background: #ffd84d;
  border-color: #e0b100;
  color: #4a3a00;
}

.quiz-foot {
  margin-top: 16px;
  text-align: right;
}

.link-btn {
  border: none;
  background: none;
  color: #666;
  text-decoration: underline;
  padding: 4px;
  font-size: 0.85rem;
}

button.danger {
  border-color: #d04545;
  color: #d04545;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.reset-area {
  margin-top: 32px;
  justify-content: flex-end;
}

.review-item {
  border: 1px solid #e3e7ef;
  border-left: 4px solid #2f4b8a;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 12px 0;
  background: #fafbfd;
}

.review-item summary {
  cursor: pointer;
  list-style: none;
}

.review-item summary::-webkit-details-marker {
  display: none;
}

.review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.review-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag.ng-tag {
  background: #fbe5e5;
  color: #d04545;
}

.review-item .wrong-q {
  margin: 8px 0 4px;
}

.stat {
  color: #888;
  font-size: 0.8rem;
  margin: 0;
}

.review-body {
  border-top: 1px dashed #d5dbe6;
  margin-top: 10px;
  padding-top: 10px;
}

.review-answer {
  font-weight: bold;
  color: #3a9d5d;
}

.retry-one {
  font-size: 0.85rem;
  padding: 6px 14px;
}

.card-images.small img {
  width: 100px;
}

/* タイプのマーク（{炎} などで表示） */
.type-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  margin: 0 0.1em;
  border-radius: 50%;
  font-size: 0.85em;
  font-weight: bold;
  line-height: 1;
  color: #fff;
  vertical-align: 0.05em;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.type-grass { background: #3e9b47; }
.type-fire { background: #e0472f; }
.type-water { background: #2f8ad8; }
.type-lightning { background: #f3c51b; color: #3b3200; }
.type-psychic { background: #9b4fb6; }
.type-fighting { background: #b8602a; }
.type-darkness { background: #2e3842; }
.type-metal { background: #8796a2; }
.type-dragon { background: #b39528; }
.type-colorless { background: #eeeeee; color: #333; }

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tag.topic {
  background: #2f4b8a;
  color: #fff;
}

.card-images {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-images:empty {
  display: none;
}

.card-images figure {
  margin: 0;
}

.card-images a {
  display: block;
  color: #2f4b8a;
  text-decoration: none;
  text-align: center;
}

.card-images img {
  display: block;
  width: 150px;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.card-images img:hover {
  transform: scale(1.03);
}

.card-images figcaption {
  font-size: 0.8rem;
  margin-top: 4px;
}

.question {
  font-size: 1.15rem;
  font-weight: bold;
  margin: 16px 0;
}

#choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice {
  text-align: left;
}

.choice:hover:not(:disabled) {
  background: #f0f3fa;
}

.choice:disabled {
  cursor: default;
  color: #222;
  opacity: 1;
}

.choice:disabled:not(.correct):not(.wrong) {
  color: #888;
}

/* ---- スマホ向け ---- */
@media (max-width: 520px) {
  header {
    padding: 16px 12px;
  }

  header h1 {
    font-size: 1.4rem;
  }

  header p {
    font-size: 0.85rem;
  }

  .notice-bar {
    font-size: 0.78rem;
    padding: 6px 12px;
  }

  main {
    margin: 12px auto;
    padding: 0 8px;
  }

  .card {
    padding: 16px;
  }

  .card-images img {
    width: 120px;
  }

  .card-images.small img {
    width: 90px;
  }

  .question {
    font-size: 1.05rem;
  }

  .field select {
    width: 100%;
  }

  .quiz-head {
    flex-wrap: wrap;
    gap: 6px;
  }

  .exam-row {
    grid-template-columns: 5.5em 1fr 3.5em;
  }

  .exam-row-mode {
    grid-column: 1 / -1;
  }

  .exam-row-mode:empty {
    display: none;
  }

  .stat-topic-name {
    width: 8.5em;
    font-size: 0.8rem;
  }
}

.choice.correct {
  background: #e3f5e8;
  border-color: #3a9d5d;
}

.choice.wrong {
  background: #fbe5e5;
  border-color: #d04545;
}

#feedback {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

#feedback-result {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
}

.source {
  color: #888;
  font-size: 0.85rem;
}

.ok {
  color: #3a9d5d;
}

.ng {
  color: #d04545;
}

/* 結果画面 */
.score {
  font-size: 1.5rem;
  font-weight: bold;
}

.wrong-item {
  border-left: 4px solid #d04545;
  padding: 4px 12px;
  margin-bottom: 16px;
}

.wrong-item p {
  margin: 4px 0;
}

.wrong-q {
  font-weight: bold;
}

.wrong-exp {
  color: #555;
  font-size: 0.95rem;
}

.buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

footer {
  text-align: center;
  color: #888;
  font-size: 0.85rem;
  padding: 16px;
}
