:root {
  color-scheme: light;
  --ink: #17141d;
  --muted: #675e62;
  --paper: #fff8ec;
  --paper-strong: #fffdf7;
  --line: rgba(23, 20, 29, 0.13);
  --gold: #d7ad51;
  --teal: #1f4e5f;
  --teal-soft: #dbece9;
  --red: #a53b43;
  --green: #2f7656;
  --shadow: 0 18px 42px rgba(31, 78, 95, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 0 0, rgba(215, 173, 81, 0.16), transparent 32rem),
    linear-gradient(180deg, #fffaf1 0%, #f8efe0 100%);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.7;
  min-height: 100vh;
}

button,
a {
  font: inherit;
}

a {
  color: var(--teal);
  font-weight: 800;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

button {
  border: 0;
  cursor: pointer;
}

body.has-kids-popup {
  overflow: hidden;
}

.app-header {
  align-items: center;
  background: rgba(255, 248, 236, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(18px, 5vw, 56px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.brand img {
  border-radius: 12px;
  height: 42px;
  width: 42px;
}

.brand span {
  font-size: 18px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-end;
}

main {
  margin: 0 auto;
  max-width: 1120px;
  padding: 28px clamp(16px, 4vw, 34px) 54px;
}

.hero {
  align-items: end;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 260px;
  padding: clamp(28px, 7vw, 60px) 0;
}

.eyebrow,
.section-label {
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 8px;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(36px, 8vw, 72px);
  line-height: 1.05;
  margin: 0 0 18px;
}

.headline-break {
  display: inline;
}

.hero p:not(.eyebrow) {
  color: var(--muted);
  font-size: clamp(17px, 2.4vw, 22px);
  margin: 0;
  max-width: 720px;
}

.hero-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-selector {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: -10px 0 24px;
}

.mode-card {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 96px;
  padding: 18px;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.mode-card:hover,
.mode-card:focus-visible {
  box-shadow: 0 22px 48px rgba(31, 78, 95, 0.18);
  transform: translateY(-2px);
}

.mode-card span {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 900;
  line-height: 1.18;
}

.mode-card strong {
  border-radius: 999px;
  font-size: 15px;
  font-weight: 900;
  grid-row: span 2;
  padding: 6px 12px;
  white-space: nowrap;
}

.mode-card small {
  color: inherit;
  font-size: 13px;
  font-weight: 900;
  opacity: 0.78;
}

.mode-card.is-general {
  background: var(--teal);
  color: #fffdf7;
}

.mode-card.is-general strong {
  background: rgba(255, 253, 247, 0.18);
}

.mode-card.is-kids {
  background: linear-gradient(135deg, #ffe4a3, #dbece9);
  color: var(--ink);
}

.mode-card.is-kids strong {
  background: rgba(31, 78, 95, 0.12);
  color: var(--teal);
}

.primary-action,
.secondary-action,
.inline-actions button,
.ghost-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
}

.primary-action,
.inline-actions button {
  background: var(--teal);
  color: #fffdf7;
}

.secondary-action {
  background: var(--gold);
  color: var(--ink);
}

.ghost-button {
  background: var(--teal-soft);
  color: var(--teal);
}

.daily-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
}

.panel {
  background: rgba(255, 253, 247, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  padding: clamp(18px, 3.2vw, 28px);
}

.panel-head,
.section-title,
.quiz-top {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.certainty,
#today-theme,
.saved-state,
#quiz-progress,
#kids-quiz-progress {
  background: var(--teal-soft);
  border-radius: 999px;
  color: var(--teal);
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 10px;
  white-space: nowrap;
}

blockquote {
  border-left: 5px solid var(--gold);
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 900;
  line-height: 1.45;
  margin: 16px 0;
  padding-left: 16px;
}

.quote-meta,
.quote-note,
.prompt {
  color: var(--muted);
  margin: 0 0 16px;
}

.prompt {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

ruby {
  ruby-position: over;
}

rt {
  color: var(--muted);
  font-size: 0.54em;
  font-weight: 800;
  line-height: 1;
}

.character-stage {
  align-items: center;
  background: linear-gradient(135deg, rgba(219, 236, 233, 0.88), rgba(255, 248, 236, 0.92));
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 112px minmax(0, 1fr);
  margin: 16px 0;
  min-height: 128px;
  overflow: hidden;
  padding: 12px;
}

.character-avatar {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  width: 112px;
}

.character-avatar svg {
  display: block;
  height: 100%;
  width: 100%;
}

.portrait-avatar {
  display: block;
  height: 100%;
  margin: 0;
  width: 100%;
}

.portrait-frame {
  background: #fffdf7;
  border: 4px solid var(--portrait-accent, var(--gold));
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(23, 20, 29, 0.18);
  display: block;
  height: 100%;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.portrait-frame img {
  display: block;
  filter: saturate(0.96) contrast(1.04);
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
  width: 100%;
}

.portrait-badge {
  background: var(--teal);
  border: 2px solid #fffdf7;
  border-radius: 999px;
  bottom: 2px;
  color: #fffdf7;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  max-width: 76px;
  overflow: hidden;
  padding: 6px 7px;
  position: absolute;
  right: 2px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portrait-fallback {
  align-items: center;
  background: var(--teal);
  border: 4px solid var(--gold);
  border-radius: 50%;
  color: #fffdf7;
  display: inline-flex;
  font-size: 42px;
  font-weight: 900;
  height: 100%;
  justify-content: center;
  width: 100%;
}

.character-caption {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.character-caption strong {
  font-size: 18px;
  line-height: 1.3;
}

.character-caption span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.character-stage[data-mood="speaking"] .character-avatar {
  animation: avatar-talk 0.44s ease-in-out infinite;
}

.character-stage[data-mood="correct"] .character-avatar {
  animation: avatar-correct 0.72s ease-out 1;
}

.character-stage[data-mood="correct"] .portrait-frame {
  border-color: var(--green);
  box-shadow: 0 0 0 6px rgba(47, 118, 86, 0.14), 0 14px 28px rgba(47, 118, 86, 0.2);
}

.character-stage[data-mood="correct"] .portrait-badge {
  background: var(--green);
}

.character-stage[data-mood="wrong"] .character-avatar {
  animation: avatar-wrong 0.48s ease-in-out 1;
}

.character-stage[data-mood="wrong"] .portrait-frame {
  border-color: var(--red);
  box-shadow: 0 0 0 6px rgba(165, 59, 67, 0.13), 0 14px 28px rgba(165, 59, 67, 0.17);
}

.character-stage[data-mood="wrong"] .portrait-frame img {
  filter: grayscale(0.42) saturate(0.84) contrast(0.96);
}

.character-stage[data-mood="wrong"] .portrait-badge {
  background: var(--red);
}

.character-stage[data-mood="thinking"] .character-avatar {
  animation: avatar-think 1.8s ease-in-out infinite;
}

@keyframes avatar-talk {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-5px) rotate(-2deg);
  }
}

@keyframes avatar-correct {
  0% {
    transform: scale(0.94);
  }
  45% {
    transform: scale(1.1) rotate(-3deg);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes avatar-wrong {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

@keyframes avatar-think {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.section {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 30px;
}

.section-title {
  margin-bottom: 18px;
}

.section-title h2 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.15;
  margin: 0;
}

.theme-list {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.theme-card {
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  min-height: 230px;
  padding: 18px;
}

.theme-card h3 {
  font-size: 21px;
  line-height: 1.35;
  margin: 0;
}

.theme-card p {
  color: var(--muted);
  margin: 0;
}

.theme-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.theme-meta span {
  background: #f0e7d8;
  border-radius: 999px;
  color: #5a4b34;
  font-size: 12px;
  font-weight: 900;
  padding: 3px 9px;
}

.theme-card button {
  background: var(--gold);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 900;
  min-height: 44px;
  padding: 10px 14px;
}

#themes {
  scroll-margin-top: 88px;
}

.kids-section {
  scroll-margin-top: 88px;
}

.kids-layout,
.kids-play-grid {
  display: grid;
  gap: 18px;
}

.kids-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  margin-bottom: 18px;
}

.kids-play-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kids-timeline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: thin;
}

.kids-era {
  background: #f2e6d2;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #6a5637;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 900;
  min-width: 72px;
  padding: 7px 10px;
  text-align: center;
}

.kids-era.is-passed {
  background: #e3f0e4;
  color: var(--green);
}

.kids-era.is-current {
  background: var(--teal);
  color: #fffdf7;
}

.kids-stage-list,
.kids-order-list {
  display: grid;
  gap: 12px;
}

.kids-stage-card,
.kids-order-card,
.kids-order-active {
  background: #fffaf1;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.kids-stage-card {
  grid-template-columns: minmax(0, 1fr) auto;
}

.kids-stage-card h3,
.kids-order-card h3,
.kids-order-active h3 {
  font-size: 18px;
  line-height: 1.35;
  margin: 0;
}

.kids-stage-card p,
.kids-order-card p {
  color: var(--muted);
  margin: 6px 0 0;
}

.kids-stage-card button,
.kids-order-card button,
.kids-order-options button,
.kids-order-reset,
.kids-order-close {
  background: var(--teal);
  border-radius: 8px;
  color: #fffdf7;
  font-weight: 900;
  min-height: 40px;
  padding: 8px 12px;
}

.kids-stage-card.is-locked {
  background: #f5efe6;
  opacity: 0.72;
}

.kids-stage-card.is-locked button {
  background: #b5aa9b;
  color: #fffdf7;
  cursor: default;
}

.kids-card-album {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kids-card {
  align-content: start;
  background: linear-gradient(180deg, #fff9ed, #f0e2c7);
  border: 1px solid rgba(215, 173, 81, 0.52);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  min-height: 148px;
  padding: 10px;
  text-align: center;
}

.kids-card img,
.kids-card span {
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  width: 100%;
}

.kids-card img {
  object-fit: cover;
}

.kids-card span {
  align-items: center;
  background: #efe5d5;
  color: #7a6b57;
  font-size: 34px;
  font-weight: 900;
  justify-content: center;
}

.kids-card-art {
  align-content: center;
  aspect-ratio: 1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 42%),
    linear-gradient(180deg, #f5e1b7, #d9b467);
  border-radius: 8px;
  color: #2c2630;
  display: grid;
  gap: 6px;
  justify-items: center;
  overflow: hidden;
  padding: 12px 8px;
  position: relative;
  width: 100%;
}

.kids-card-art::before {
  border: 2px solid rgba(255, 253, 247, 0.46);
  border-radius: 999px;
  content: "";
  height: 74%;
  position: absolute;
  width: 74%;
}

.kids-card-art.is-green {
  background: linear-gradient(180deg, #dff0d4, #8bb879);
}

.kids-card-art.is-blue {
  background: linear-gradient(180deg, #dcecf5, #76a6c2);
}

.kids-card-art.is-steel {
  background: linear-gradient(180deg, #e7e7df, #8f9998);
}

.kids-card-art.is-red {
  background: linear-gradient(180deg, #f2d7ca, #c66f63);
}

.kids-card-art.is-purple {
  background: linear-gradient(180deg, #eadcf1, #a886bd);
}

.kids-card-art.is-earth {
  background: linear-gradient(180deg, #eadbc8, #b28d67);
}

.kids-card-art.is-locked-art {
  background: #efe5d5;
  color: #7a6b57;
}

.kids-card .kids-card-art .kids-card-symbol,
.kids-popup-visual .kids-card-art .kids-card-symbol {
  align-items: center;
  aspect-ratio: auto;
  background: transparent;
  border-radius: 0;
  color: currentColor;
  display: inline-flex;
  font-size: clamp(24px, 6vw, 36px);
  font-weight: 900;
  height: auto;
  justify-content: center;
  line-height: 1.05;
  position: relative;
  text-align: center;
  width: auto;
  z-index: 1;
}

.kids-card-art small {
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  position: relative;
  z-index: 1;
}

.kids-card strong {
  font-size: 13px;
  line-height: 1.35;
}

.kids-card.is-locked {
  filter: grayscale(0.6);
  opacity: 0.75;
}

.kids-order-card.is-complete {
  border-color: rgba(47, 118, 86, 0.45);
}

.kids-order-selected {
  background: #f7efe3;
  border-radius: 8px;
  color: var(--teal);
  font-weight: 900;
  min-height: 44px;
  padding: 10px 12px;
}

.kids-order-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kids-hint,
.kids-card-reward {
  background: #f7efe3;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.kids-card-reward {
  color: var(--teal);
}

.kids-quiz-shell {
  margin-top: 28px;
}

.compact-source-list {
  gap: 6px;
  margin: 12px 0;
}

.compact-source-list .source-item {
  font-size: 13px;
  padding: 10px;
}

.kids-popup {
  align-items: center;
  background: rgba(23, 20, 29, 0.42);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 18px;
  position: fixed;
  z-index: 80;
}

.kids-popup[hidden] {
  display: none;
}

.kids-popup-card {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 26px 72px rgba(23, 20, 29, 0.28);
  display: grid;
  gap: 12px;
  max-width: 420px;
  padding: 22px;
  position: relative;
  text-align: center;
  width: min(100%, 420px);
}

.kids-popup-close {
  align-items: center;
  background: #f0e7d8;
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 22px;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  position: absolute;
  right: 12px;
  top: 12px;
  width: 38px;
}

.kids-popup-visual {
  aspect-ratio: 1;
  background: linear-gradient(180deg, #fff6e7, #ead7b5);
  border: 4px solid var(--gold);
  border-radius: 50%;
  display: grid;
  margin: 0 auto;
  overflow: hidden;
  place-items: center;
  width: 148px;
}

.kids-popup-visual img {
  display: block;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
  width: 100%;
}

.kids-popup-visual span {
  color: #735f3d;
  font-size: 54px;
  font-weight: 900;
}

.kids-popup-avatar {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  width: 100%;
}

.kids-popup-card h2 {
  font-size: clamp(24px, 6vw, 34px);
  line-height: 1.3;
  margin: 0;
}

.kids-popup-card p {
  margin: 0;
}

.kids-popup-card > button:last-child {
  background: var(--teal);
  border-radius: 8px;
  color: #fffdf7;
  font-weight: 900;
  min-height: 46px;
  padding: 10px 16px;
}

.kids-popup.is-correct .kids-popup-visual,
.kids-popup.is-unlock .kids-popup-visual {
  border-color: var(--green);
  box-shadow: 0 0 0 8px rgba(47, 118, 86, 0.14);
}

.kids-popup.is-wrong .kids-popup-visual {
  border-color: var(--red);
  box-shadow: 0 0 0 8px rgba(165, 59, 67, 0.13);
}

.kids-popup.is-unlock .kids-popup-card {
  background: linear-gradient(180deg, #fffdf7 0%, #fff2cf 100%);
}

.quiz-shell {
  margin-top: 28px;
}

.quiz-top {
  margin-bottom: 12px;
}

.quiz-card h2 {
  font-size: clamp(23px, 4vw, 36px);
  line-height: 1.35;
  margin: 12px 0 18px;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice {
  background: #fffaf1;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  font-weight: 800;
  gap: 8px;
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: 58px;
  padding: 12px;
  text-align: left;
}

.choice:disabled {
  cursor: default;
  opacity: 0.9;
}

.choice.correct {
  background: #e5f2e9;
  border-color: rgba(47, 118, 86, 0.55);
}

.choice.wrong {
  background: #f8e5e4;
  border-color: rgba(165, 59, 67, 0.5);
}

.choice-id {
  align-items: center;
  background: var(--teal);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.result {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.result-title {
  font-size: 20px;
  font-weight: 900;
  margin: 0 0 8px;
}

.contested-note {
  color: var(--red);
  font-weight: 800;
}

.source-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 18px;
}

.source-item {
  background: #f7efe3;
  border-radius: 8px;
  padding: 12px;
}

.source-item p {
  color: var(--muted);
  margin: 5px 0 0;
}

.app-footer {
  background: var(--ink);
  color: var(--paper);
  padding: 24px clamp(16px, 4vw, 34px);
}

.app-footer p {
  margin: 4px auto;
  max-width: 1120px;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .app-header,
  .hero,
  .daily-grid,
  .section-title,
  .quiz-top {
    align-items: stretch;
    display: flex;
    flex-direction: column;
  }

  .nav {
    font-size: 14px;
    gap: 9px;
    justify-content: flex-start;
  }

  .headline-break {
    display: block;
  }

  .theme-list {
    grid-template-columns: 1fr;
  }

  .mode-selector {
    grid-template-columns: 1fr;
    margin-top: -4px;
  }

  .mode-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .mode-card strong {
    grid-row: auto;
    justify-self: start;
  }

  .kids-layout,
  .kids-play-grid {
    grid-template-columns: 1fr;
  }

  .kids-stage-card {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .character-stage {
    grid-template-columns: 92px minmax(0, 1fr);
    min-height: 108px;
  }

  .character-avatar {
    width: 92px;
  }
}
