:root {
  --color-pitch: #3a8d4d;
  --color-pitch-light: #5cba6f;
  --color-sky: #87ceeb;
  --color-sun: #ffc857;
  --color-bg: #fdfaf3;
  --color-text: #2a2a2a;
  --color-correct: #4caf50;
  --color-soft: #ffd5cb;
  --color-paper: #fffaf0;
  --color-stroke: #2a2a2a;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --tap: 60px;
  --font: 'M PLUS Rounded 1c', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.screen { display: block; }
.screen[hidden] { display: none; }

button {
  font-family: inherit;
  font-weight: 700;
  border: 3px solid var(--color-stroke);
  border-radius: var(--radius-md);
  background: var(--color-sun);
  padding: 14px 24px;
  min-height: var(--tap);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--color-stroke);
  transition: transform 0.05s, box-shadow 0.05s;
}
button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--color-stroke);
}

ruby rt { font-size: 0.5em; }

/* ===== Phase 4: Screen styles ===== */

h1.title { font-size: 1.8rem; text-align: center; margin: 16px 0; color: var(--color-pitch); }
.next-info { text-align: center; margin: 12px 0; font-size: 1.1rem; }
.home-buttons { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }
button.primary { background: var(--color-pitch); color: white; }
button.danger { background: #ff7b7b; }

.ep-header { margin-bottom: 16px; }
.ep-header h2 { font-size: 1.4rem; margin: 8px 0; }
.subtitle { color: #666; margin-bottom: 12px; font-size: 0.95rem; }
.progress-mini { font-size: 0.9rem; color: #777; font-weight: 500; }

.story-body {
  background: var(--color-paper);
  border: 3px solid var(--color-stroke);
  border-radius: var(--radius-lg);
  padding: 20px;
  font-size: 1.3rem;
  line-height: 2.2;
  margin: 16px 0;
}
.story-body p { margin-bottom: 1em; }
.story-body p:last-child { margin-bottom: 0; }
.furigana-needed ruby rt { visibility: hidden; }

.question { font-size: 1.3rem; margin: 16px 0; line-height: 1.6; }
.situation {
  background: var(--color-soft);
  border-radius: var(--radius-md);
  padding: 14px;
  margin: 12px 0;
  font-style: italic;
  line-height: 1.6;
}

.choices { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.choice {
  background: var(--color-paper);
  text-align: left;
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.5;
  padding: 14px 18px;
  white-space: normal;
  word-break: break-word;
}
.choice:disabled { opacity: 0.55; cursor: default; }

.feedback {
  min-height: 2.5em;
  margin: 16px 0;
  font-size: 1.15rem;
  text-align: center;
  line-height: 1.5;
}
.feedback .ok { color: var(--color-correct); font-weight: 900; }
.feedback .soft { color: #d57; font-weight: 700; }

.link-btn {
  background: transparent;
  border: none;
  box-shadow: none;
  color: #468;
  text-decoration: underline;
  padding: 6px 10px;
  font-size: 0.95rem;
  min-height: auto;
}
.link-btn:active { transform: none; box-shadow: none; }

/* ----- Map ----- */
.map { display: flex; flex-direction: column; gap: 18px; margin: 18px 0; }
.stage h3 { margin-bottom: 10px; font-size: 1.1rem; color: var(--color-pitch); }
.episodes { display: flex; flex-wrap: wrap; gap: 8px; }
.ep {
  background: #eee;
  min-height: 50px;
  padding: 10px 14px;
  font-size: 0.95rem;
  flex: 1 1 calc(50% - 8px);
  min-width: 0;
}
.ep.done { background: var(--color-pitch-light); color: white; }
.ep.gold { background: var(--color-sun); border-color: #d4a017; }
.ep.next { box-shadow: 0 4px 0 var(--color-pitch), 0 0 0 4px var(--color-sun); }
.ep.locked { background: #ddd; color: #999; opacity: 0.6; cursor: not-allowed; box-shadow: none; }

/* ----- Reward ----- */
.gold { color: #d4a017; font-weight: 900; font-size: 1.25rem; text-align: center; margin: 12px 0; }
.sticker-stage {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  margin: 24px 0;
  flex-wrap: wrap;
}
.sticker-stage svg { width: 120px; height: 120px; animation: pop 0.5s ease-out; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.reward-msg { text-align: center; margin: 16px 0; font-size: 1.1rem; }
.reward-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

/* ----- Sticker Book ----- */
.album {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.slot {
  aspect-ratio: 1;
  border: 2px dashed #bbb;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  padding: 4px;
}
.slot.filled { border-style: solid; border-color: var(--color-stroke); }
.slot.gold { background: #fff8e0; }
.slot.gold-empty { color: #d4a017; }
.slot.memorial {
  background: linear-gradient(135deg, #ffd1dc, #ffec8b, #c8e6c9);
  grid-column: span 2;
}
.slot.memorial-empty {
  grid-column: span 2;
  border-color: #d4a017;
}
.slot-sticker { width: 80%; height: 75%; display: flex; align-items: center; justify-content: center; }
.slot-sticker svg { width: 100%; height: 100%; }
.slot-label { font-size: 0.75rem; color: #555; margin-top: 2px; }
.slot.filled .slot-label { color: var(--color-stroke); font-weight: 700; }

/* ----- Settings ----- */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  font-size: 1.1rem;
  border-bottom: 1px solid #eee;
}
.setting-row select {
  padding: 8px 12px;
  font-size: 1rem;
  min-height: var(--tap);
  border: 2px solid var(--color-stroke);
  border-radius: var(--radius-sm);
  font-family: inherit;
}
.setting-row input[type="checkbox"] {
  width: 30px;
  height: 30px;
  cursor: pointer;
}
.hint-small { font-size: 0.9rem; color: #666; margin: 10px 0; }
hr { margin: 24px 0; border: none; border-top: 2px dashed #ccc; }
