/* ===== 昭和児童絵本・世界名作劇場風 CSS ===== */
:root {
  --primary-color: #aa382c;
  --primary-hover: #c94a3d;
  --bg-gradient: linear-gradient(135deg, #e6ded3 0%, #d8cdbf 50%, #cbbfae 100%);
  --book-bg: #f9f6f0;
  --text-color: #2b2625;
  --text-muted: #6b6360;
  --accent-gold: #c69c58;
  --card-shadow: 0 16px 36px rgba(43, 38, 37, 0.2), 0 4px 12px rgba(0, 0, 0, 0.1);
  --border-radius: 12px;
  --font-family: 'Zen Maru Gothic', 'Sawarabi Mincho', serif;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-color);
  padding: 16px;
  overflow-x: hidden;
}

/* ざらっとした紙質感風背景 */
.bg-pattern {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.2) 0%, transparent 80%);
  pointer-events: none;
  z-index: 0;
}

/* 絵本コンテナ（昭和児童書装丁風） */
.book-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 880px;
  background: var(--book-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  border: 8px solid #8c2b20;
  outline: 2px solid #c69c58;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ヘッダー */
.book-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background-color: #8c2b20;
  color: #fff;
  border-bottom: 3px double #c69c58;
}

.book-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #fceade;
  letter-spacing: 0.08em;
}

.controls-top {
  display: flex;
  gap: 12px;
}

button {
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  border-radius: 6px;
  transition: all 0.2s ease-in-out;
}

.btn-icon {
  background: #fdfaf6;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c69c58;
}

.btn-icon:hover {
  background: #fff;
}

.btn-secondary {
  background: #fdfaf6;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #8c2b20;
  border: 1px solid #c69c58;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover, .btn-secondary.active {
  background: #c69c58;
  color: #fff;
}

/* ステージ */
.book-stage {
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 480px;
}

/* ページカード */
.page-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: #fffefb;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 3px double #d1c5b4;
  overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.page-card.flip-out {
  opacity: 0;
  transform: scale(0.98) translateX(-15px);
}

.page-card.flip-in {
  opacity: 0;
  transform: scale(0.98) translateX(15px);
}

/* 挿絵領域 */
.illustration-wrapper {
  position: relative;
  width: 100%;
  height: 380px;
  background-color: #eae5dc;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 2px solid #ded6c8;
}

.illustration-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #f7f2e9;
  filter: sepia(0.04) contrast(1.02);
}

/* 衝撃演出 */
.effect-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.effect-overlay.impact {
  animation: flashRed 0.4s ease;
}

@keyframes flashRed {
  0% { opacity: 0.7; background-color: rgba(170, 56, 44, 0.3); }
  50% { opacity: 0.3; background-color: rgba(255, 255, 255, 0.5); }
  100% { opacity: 0; }
}

/* テキストエリア */
.text-wrapper {
  padding: 22px 28px;
  position: relative;
  background: #fffdf9;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.page-badge {
  position: absolute;
  top: -14px;
  left: 28px;
  background: #8c2b20;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 4px;
  border: 1px solid #c69c58;
}

.picture-book-text {
  font-size: 1.45rem;
  line-height: 1.85;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #2b2625;
  transition: opacity 0.15s ease-in-out;
}

.text-wrapper {
  transition: opacity 0.15s ease-in-out;
}

/* 表紙のタイトル表示 */
.cover-title-display {
  text-align: center;
  padding: 6px 0;
}

.cover-title-display h2 {
  font-size: 1.8rem;
  color: #8c2b20;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.cover-title-display .author-text {
  font-size: 1.05rem;
  color: #554a47;
  font-weight: 700;
  line-height: 1.4;
}

.picture-book-text strong {
  font-size: 1.75rem;
  color: #8c2b20;
  font-weight: 900;
}

/* フッター */
.book-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background-color: #eedec8;
  border-top: 2px solid #c69c58;
}

.btn-nav {
  background: #8c2b20;
  color: #fff;
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid #671d15;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-nav:hover:not(:disabled) {
  background: #aa382c;
}

.btn-nav:disabled {
  background: #bfaea5;
  border-color: #aaa;
  cursor: not-allowed;
}

.page-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.page-num-display {
  font-size: 1.05rem;
  font-weight: 900;
  color: #3d3331;
}

.progress-bar {
  width: 140px;
  height: 6px;
  background: #d8cdbf;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #8c2b20;
  transition: width 0.3s ease;
}

@media (max-width: 640px) {
  .illustration-wrapper {
    height: 250px;
  }
  .picture-book-text {
    font-size: 1.2rem;
  }
  .picture-book-text strong {
    font-size: 1.4rem;
  }
}

/* 「おわり」ページ表示 */
.owari-display {
  text-align: center;
  padding: 20px 0;
}

.owari-display h2 {
  font-size: 2.5rem;
  color: #8c2b20;
  font-weight: 900;
  letter-spacing: 0.15em;
  margin-bottom: 16px;
}

.owari-display .owari-subtitle {
  font-size: 1.15rem;
  color: #554a47;
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 20px;
}

.btn-restart {
  font-family: var(--font-family);
  background: #8c2b20;
  color: #fff;
  padding: 14px 32px;
  font-size: 1.15rem;
  font-weight: 700;
  border: 2px solid #671d15;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transition: all 0.2s ease;
}

.btn-restart:hover {
  background: #aa382c;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(140, 43, 32, 0.4);
}

/* キー・パッドで操作している時の選択枠(2026-10-24) */
button:focus-visible, .btn-nav:focus {
  outline: 3px solid #ffb703;
  outline-offset: 3px;
}

/* スマホで 1 画面に収める(2026-10-24 直し係) */
.btn-nav, .btn-secondary { white-space: nowrap; }
@media (max-width: 640px) {
  body { padding: 6px; }
  .book-header { padding: 8px 12px; gap: 8px; }
  .book-title { font-size: 1.05rem; letter-spacing: 0.02em; }
  .book-author { font-size: 0.75rem; }
  .controls-top { gap: 6px; }
  .btn-secondary { padding: 6px 10px; font-size: 0.85rem; }
  .book-stage { padding: 10px; min-height: 0; }
  .illustration-wrapper { height: 34dvh; }
  .text-wrapper { padding: 18px 16px 14px; min-height: 0; }
  .book-footer { padding: 8px 10px; gap: 8px; }
  .btn-nav { padding: 10px 14px; }
  .page-indicator { flex: 1; min-width: 0; }
}
/* 横持ちのスマホ: 絵と文を左右に並べる */
@media (orientation: landscape) and (max-height: 560px) {
  body { padding: 4px; align-items: flex-start; }
  .book-container { max-width: none; height: calc(100dvh - 8px); }
  .book-header { padding: 4px 16px; }
  .book-stage { padding: 6px 10px; min-height: 0; flex: 1; overflow: hidden; }
  .page-card { flex-direction: row; height: 100%; }
  .illustration-wrapper { width: 55%; height: 100%; border-bottom: none; border-right: 2px solid #ded6c8; }
  .text-wrapper { flex: 1; overflow-y: auto; padding: 36px 18px 10px; min-height: 0; }
  .page-badge { top: 8px; left: 18px; }
  .picture-book-text { font-size: 1.1rem; }
  .book-footer { padding: 4px 16px; }
  .btn-nav { padding: 6px 16px; }
}
