:root {
  --bg-top: #edf4ee;
  --bg-mid: #f7f1e7;
  --bg-bottom: #fcfaf4;
  --card: #fffdf8;
  --ink: #26323b;
  --brand: #cb8450;
  --brand-strong: #b66f3f;
  --soft-blue: #dbe7df;
  --yellow: #efe3bc;
  --good: #4f7755;
  --warn: #7f6742;
  --danger-soft: #f4e6dc;
  --radius: 20px;
  --shadow: 0 10px 28px rgba(38, 50, 59, 0.11);
  --focus: 0 0 0 4px rgba(102, 135, 119, 0.24);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Nunito", "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  color: var(--ink);
}

body {
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 58%, var(--bg-bottom) 100%);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; }
[hidden] { display: none !important; }

.bg-scene .deco {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  animation: floaty 16s ease-in-out infinite;
}

.sun { top: 10px; right: 14px; font-size: 2.7rem; }
.cloud.c1 { top: 28px; left: 6%; font-size: 2rem; }
.cloud.c2 { top: 70px; right: 8%; font-size: 2rem; }
.grass { bottom: 12px; right: 12px; font-size: 2rem; }

.app {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 12px;
}

.screen { display: none; }
.screen.is-active { display: block; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 3px solid #fff;
  padding: clamp(14px, 2.8vw, 24px);
}

.start-card,
.end-card {
  min-height: 85svh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.start-card {
  max-width: 760px;
  margin: 0 auto;
}

.title,
.title-end {
  margin: 0;
  font-size: clamp(2rem, 6.2vw, 3.3rem);
  line-height: 1.1;
}

.subtitle,
.subtitle-end {
  margin: 0;
  font-size: clamp(1.1rem, 3.8vw, 1.4rem);
  font-weight: 700;
}

.mascot { font-size: clamp(2rem, 8vw, 3.2rem); }

.main-helper,
.mode-helper {
  margin: 0;
  max-width: 34rem;
  font-size: 0.98rem;
  font-weight: 700;
  color: #51626b;
}

.default-mode-text {
  margin: -2px 0 0;
  padding: 10px 14px;
  font-size: 0.96rem;
  font-weight: 800;
  color: #4f5d49;
  background: #f5efde;
  border: 2px solid #e7d9ae;
  border-radius: 999px;
}

.start-guide {
  width: min(100%, 640px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.guide-item {
  min-height: 110px;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 12px;
  background: linear-gradient(180deg, #f8faf4 0%, #fffaf0 100%);
  border: 2px solid #e9dcc0;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(38, 50, 59, 0.06);
}

.guide-item p {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.35;
  color: #51626b;
}

.guide-step {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fcf7eb;
  color: #8b6b40;
  font-weight: 900;
  box-shadow: 0 6px 14px rgba(139, 107, 64, 0.12);
}

.mode-grid {
  width: min(100%, 520px);
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 16px;
  padding: 13px 16px;
  min-height: 52px;
  font-size: clamp(1.04rem, 3.8vw, 1.2rem);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.16s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-main {
  background: var(--brand);
  color: #fff;
  min-width: 180px;
}

.btn-main:hover { background: var(--brand-strong); }

.btn-mode { background: var(--yellow); color: #4b3911; }
.btn-ghost { background: var(--soft-blue); color: #2f4a3d; }
.btn-parent { margin-top: 4px; }

.game-card {
  min-height: 85svh;
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr auto auto auto;
  gap: 12px;
}

.game-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.btn-icon {
  background: var(--soft-blue);
  color: #2f4a3d;
  min-height: 44px;
  font-size: 0.95rem;
  padding-inline: 10px;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  min-height: 24px;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ebe7de;
  border: 2px solid #d7d0c0;
}

.dot.done { background: #ceddcf; border-color: #93af96; }
.dot.now { transform: scale(1.12); border-color: #a98560; }

.round-status {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill {
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid #d9e1d8;
  background: #f2f6f0;
  color: #42544a;
  font-size: 0.97rem;
  font-weight: 800;
}

.status-pill-focus {
  border-color: #e7d8b1;
  background: #f8f1df;
  color: #6a593e;
}

.mode-label {
  margin: 0;
  text-align: center;
  font-size: clamp(1.4rem, 4.8vw, 2rem);
}

.instruction-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.instruction {
  margin: 0;
  font-size: clamp(1.2rem, 4.8vw, 1.8rem);
  font-weight: 800;
  text-align: center;
}

.btn.small {
  min-height: 42px;
  padding: 8px 12px;
  font-size: 1rem;
}

.prompt-visual {
  min-height: 98px;
  display: grid;
  place-items: center;
  padding: 10px;
  overflow: hidden;
  font-size: clamp(3.2rem, 13vw, 5rem);
  font-weight: 900;
  background: linear-gradient(180deg, #f7f1df 0%, #fffdf7 100%);
  border: 3px solid #e6d8b2;
  border-radius: 18px;
}

.prompt-visual.is-image {
  min-height: 240px;
  padding: 18px;
  background: linear-gradient(180deg, #f7f0dd 0%, #fffdf6 100%);
  border-color: #e6d8b2;
}

.prompt-image {
  display: block;
  width: min(100%, 320px);
  max-height: 220px;
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(34, 51, 71, 0.14));
}

.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-self: start;
}

.choice {
  min-height: 108px;
  background: #fbf5e8;
  border: 3px solid #dcc9a3;
  border-radius: 18px;
  color: #3a3121;
  font-size: clamp(2.4rem, 10vw, 4rem);
  font-weight: 900;
}

.choice.is-wrong {
  background: var(--danger-soft);
  border-color: #d8b199;
  animation: softShake 0.25s ease;
}

.choice.hint {
  box-shadow: 0 0 0 4px rgba(186, 160, 112, 0.24);
  animation: hintPulse 1s ease-in-out infinite;
}

.choice.is-disabled {
  opacity: 0.45;
  filter: saturate(0.6);
}

.choice.is-correct {
  background: #edf4ec;
  border-color: #a6bca6;
  color: #34503b;
}

.assist-text {
  min-height: 44px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: #50616b;
  border-radius: 18px;
  padding-inline: 14px;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.assist-text.is-active {
  padding-block: 10px;
  background: #f3f5ee;
  border: 2px solid #d7ddd0;
}

.assist-highlight {
  box-shadow: 0 0 0 4px rgba(177, 198, 186, 0.35);
  animation: hintPulse 1s ease-in-out infinite;
}

.feedback {
  min-height: 32px;
  text-align: center;
  font-size: clamp(1rem, 3.8vw, 1.2rem);
  font-weight: 700;
}

.feedback.affirm { color: var(--good); }
.feedback.note { color: var(--warn); }

.btn-next {
  justify-self: center;
  width: min(100%, 360px);
  animation: fadeIn 0.25s ease;
}

.end-mode-text {
  margin: -4px 0 0;
  font-size: 1rem;
  font-weight: 800;
  color: #5a6a61;
}

.letter-review {
  width: min(100%, 560px);
  min-height: 42px;
  padding: 14px 16px;
  font-size: clamp(1.45rem, 6vw, 2rem);
  letter-spacing: 3px;
  line-height: 1.5;
  word-break: break-word;
  color: #36443d;
  background: #f6f1e5;
  border: 2px solid #e5d7b6;
  border-radius: 18px;
}

.end-summary-text {
  margin: -2px 0 6px;
  font-size: 1rem;
  font-weight: 700;
  color: #556158;
}

.end-actions {
  width: min(100%, 420px);
  display: grid;
  gap: 10px;
}

.parent-panel {
  position: fixed;
  inset: 0;
  background: rgba(20, 31, 45, 0.42);
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 12px;
}

.panel-card {
  width: min(100%, 560px);
  max-height: 92svh;
  overflow: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 3px solid #fff;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.panel-card h2 {
  margin: 0;
  text-align: center;
  font-size: clamp(1.3rem, 4.2vw, 1.8rem);
}

.setting-group { display: grid; gap: 8px; }
.setting-label { font-size: 1rem; font-weight: 800; }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 2px solid #c7d3c8;
  background: #eef3ee;
  color: #2f4a3d;
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 42px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.chip.wide { width: 120px; }
.chip.active { border-color: #90ac98; background: #dde8df; }

@media (max-width: 740px) {
  .game-top {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "home mute"
      "progress progress";
  }

  #btnHome { grid-area: home; }
  #btnMute { grid-area: mute; justify-self: end; }
  #progressDots { grid-area: progress; }

  .start-guide { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .app { padding: 8px; }
  .card { padding: 12px; }
  .mode-grid { grid-template-columns: 1fr; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .choice.full-row { grid-column: 1 / -1; }
  .round-status { display: grid; width: 100%; }
  .status-pill { width: 100%; text-align: center; }
  .default-mode-text { border-radius: 18px; }
  .letter-review { letter-spacing: 2px; }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes softShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(186, 160, 112, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(186, 160, 112, 0.38); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
