/* ===== 全体 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  /* logo.svg の配色に合わせたパレット */
  --blue: #4768a8;        /* ロゴ濃青 */
  --blue-light: #6790c1;  /* ロゴ淡青 */
  --blue-dark: #344f83;
  --ink: #14181f;         /* ロゴの黒に近い墨色 */
  --bg: #f2f5fa;
  --card-bg: #fdfeff;
  --border: #c7d3e6;
  --muted: #68758a;
}

body {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "BIZ UDMincho", serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(103, 144, 193, 0.10) 0 120px, transparent 140px),
    radial-gradient(circle at 85% 80%, rgba(71, 104, 168, 0.08) 0 150px, transparent 170px);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== ヘッダー ===== */
.header {
  padding: 1rem 1rem 0.7rem;
  border-bottom: 3px double var(--blue);
  background: linear-gradient(180deg, rgba(71, 104, 168, 0.08), transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
}

.header-logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 3px rgba(52, 79, 131, 0.25));
}

.header-titles {
  text-align: center;
}

.header h1 {
  font-size: 1.7rem;
  letter-spacing: 0.25em;
  color: var(--blue-dark);
}

.subtitle {
  font-size: 0.85rem;
  letter-spacing: 0.5em;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ===== メイン ===== */
.main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===== 進行状況 ===== */
.progress-area {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

#progress-text {
  white-space: nowrap;
  font-feature-settings: "tnum";
}

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

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--blue-light));
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ===== 読み札 ===== */
.card-area {
  display: flex;
  justify-content: center;
  margin-bottom: 1.2rem;
}

.card {
  position: relative;
  width: 100%;
  max-width: 420px;
  min-height: 340px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow:
    0 4px 14px rgba(20, 24, 31, 0.14),
    inset 0 0 0 6px var(--card-bg),
    inset 0 0 0 8px var(--blue-light);
  padding: 1.6rem 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.card-watermark {
  position: absolute;
  right: -8%;
  bottom: -10%;
  width: 60%;
  max-width: 260px;
  opacity: 0.06;
  pointer-events: none;
  user-select: none;
}

.card--empty {
  justify-content: center;
  align-items: center;
}

.card-placeholder {
  text-align: center;
  color: var(--muted);
  line-height: 2;
  font-size: 0.95rem;
}

.card-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: cardIn 0.45s ease;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 2rem;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(52, 79, 131, 0.4);
}

.card-type {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--blue-dark);
  border: 1px solid var(--blue);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  background: rgba(71, 104, 168, 0.06);
}

.card-text {
  font-size: 1.45rem;
  line-height: 1.9;
  font-weight: bold;
  text-align: center;
  letter-spacing: 0.08em;
}

.card-meta {
  border-top: 1px dashed var(--border);
  padding-top: 0.8rem;
  font-size: 0.9rem;
  line-height: 1.8;
  color: #43506a;
  text-align: center;
}

.card-place {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--ink);
}

.card-place::before {
  content: "📍 ";
}

.card-detail {
  font-size: 0.85rem;
}

/* ===== ボタン ===== */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  letter-spacing: 0.05em;
}

.btn:hover:not(:disabled) {
  box-shadow: 0 2px 8px rgba(20, 24, 31, 0.15);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-primary {
  grid-column: 1 / -1;
  background: var(--blue);
  border-color: var(--blue-dark);
  color: #fff;
  font-size: 1.15rem;
  padding: 0.9rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.btn-danger {
  color: var(--blue-dark);
}

.btn-small {
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  display: inline-block;
}

.file-label {
  text-align: center;
}

/* ===== 設定 ===== */
.settings {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
}

.settings summary {
  padding: 0.7rem 1rem;
  cursor: pointer;
  letter-spacing: 0.1em;
  user-select: none;
}

.settings-body {
  padding: 0.4rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.setting-row input[type="range"] {
  flex: 1;
  min-width: 120px;
  accent-color: var(--blue);
}

.setting-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

/* ===== 既読札一覧 ===== */
.history h2 {
  font-size: 1rem;
  letter-spacing: 0.2em;
  border-left: 4px solid var(--blue);
  padding-left: 0.6rem;
  margin-bottom: 0.7rem;
  color: var(--blue-dark);
}

#history-count {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: normal;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 0.5rem;
}

.history-chip {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--blue-dark);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.history-chip:hover {
  transform: scale(1.08);
  border-color: var(--blue);
}

.history-chip--current {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue-dark);
}

/* ===== フッター ===== */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  .main {
    padding: 0.8rem;
  }
  .card {
    min-height: 300px;
    padding: 1.2rem 1rem;
  }
  .card-text {
    font-size: 1.25rem;
  }
  .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  }
}

@media (max-width: 480px) {
  .header {
    padding: 0.8rem 0.8rem 0.6rem;
  }
  .header-logo {
    width: 40px;
    height: 40px;
  }
  .header h1 {
    font-size: 1.3rem;
    letter-spacing: 0.15em;
  }
  .subtitle {
    font-size: 0.75rem;
    letter-spacing: 0.35em;
  }
  .card {
    min-height: 270px;
  }
  .card-initial {
    width: 54px;
    height: 54px;
    font-size: 1.7rem;
  }
  .card-text {
    font-size: 1.15rem;
  }
  .btn {
    font-size: 0.92rem;
    padding: 0.7rem 0.4rem;
  }
  .btn-primary {
    font-size: 1.05rem;
    padding: 0.85rem;
  }
}

@media (max-width: 340px) {
  .controls {
    grid-template-columns: 1fr;
  }
}

/* 横向きスマホなど高さが低い画面 */
@media (max-height: 520px) and (orientation: landscape) {
  .header {
    padding: 0.5rem 1rem 0.4rem;
  }
  .header-inner {
    gap: 0.6rem;
  }
  .header-logo {
    width: 34px;
    height: 34px;
  }
  .header h1 {
    font-size: 1.15rem;
  }
  .subtitle {
    display: none;
  }
  .card {
    min-height: 230px;
  }
}
