/* Count With Me — same low-sensory design language as Speak With Me */

:root {
  --bg:       #f6f1e7;
  --panel:    #fffdf8;
  --ink:      #3c3a42;
  --muted:    #8a8676;
  --line:     #e7ddca;
  --sage:     #7fa98f;
  --sage-dim: #689079;
  --sky:      #8aa9c9;
  --coral:    #e07a70;
  --shadow:   0 6px 18px rgba(60, 58, 66, 0.08);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "Segoe UI Rounded", "Hiragino Maru Gothic ProN",
               "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  justify-content: center;
}

.app {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---- Screen switching -------------------------------------------------- */
.screen { display: none; flex: 1; flex-direction: column; padding: 20px; }
.screen.is-active { display: flex; }
[hidden] { display: none !important; }

/* ========================================================= HOME ========= */
.home { align-items: center; }

.home-head { text-align: center; margin: 28px 0 32px; }
.home-head h1 { font-size: clamp(28px, 8vw, 40px); font-weight: 800; }
.tagline { color: var(--muted); margin-top: 6px; font-size: clamp(15px, 4vw, 18px); }

.level-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 420px;
}

.level-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.08s ease;
  text-align: left;
  width: 100%;
}
.level-btn:hover  { border-color: var(--sage); }
.level-btn:active { transform: scale(0.97); }

.level-num {
  font-size: clamp(38px, 11vw, 52px);
  font-weight: 900;
  color: var(--sage);
  min-width: 52px;
  text-align: center;
  line-height: 1;
}

.level-info { display: flex; flex-direction: column; gap: 4px; }
.level-name { font-size: clamp(17px, 5vw, 21px); font-weight: 800; }
.level-desc { font-size: clamp(13px, 3.5vw, 15px); color: var(--muted); }

.text-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  display: inline-block;
}
.text-btn:hover { color: var(--sage-dim); }
.home-link { margin-top: 22px; }

/* ========================================================= PLAY ========= */
.play { gap: 10px; }

.play-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--sage); }

.level-label {
  font-size: 16px;
  font-weight: 800;
  color: var(--sage-dim);
  flex: 1;
  text-align: center;
}

.round-label {
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Item grid */
.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}

.item-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 16px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  width: 100%;
}

.item-grid.pop { animation: pop 0.28s ease-out; }

.item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  line-height: 1;
}

/* Prompt */
.prompt-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}

.prompt-text {
  font-size: clamp(17px, 5vw, 21px);
  font-weight: 800;
  text-align: center;
}

.replay-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  font-size: 17px;
  padding: 6px 10px;
  cursor: pointer;
  min-height: 40px;
  min-width: 44px;
  flex-shrink: 0;
}
.replay-btn:hover { border-color: var(--sky); }

/* Choices */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  flex-shrink: 0;
}

.choice-btn {
  font-family: inherit;
  font-size: clamp(26px, 8vw, 36px);
  font-weight: 900;
  min-width: 80px;
  min-height: 76px;
  flex: 1 1 80px;
  max-width: 140px;
  border-radius: 20px;
  border: 3px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
}
.choice-btn:hover:not(:disabled)  { border-color: var(--sky); transform: scale(1.04); }
.choice-btn:active:not(:disabled) { transform: scale(0.96); }

.choice-btn.correct {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
  transform: scale(1.06);
}
.choice-btn.wrong {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
  animation: shake 0.38s ease;
}
.choice-btn:disabled { cursor: default; }
.choice-btn.correct:disabled { opacity: 1; }

/* Feedback line */
.feedback {
  font-size: clamp(16px, 4.5vw, 19px);
  font-weight: 700;
  min-height: 26px;
  text-align: center;
  color: var(--sage-dim);
  padding: 0 8px;
  flex-shrink: 0;
}
.feedback.wrong-msg { color: var(--coral); }

/* ========================================================= DONE ========= */
.done-screen {
  align-items: center;
  justify-content: center;
}

.done-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 28px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: pop 0.35s ease-out;
}

.done-star  { font-size: 68px; line-height: 1; }
.done-title { font-size: clamp(22px, 6vw, 28px); font-weight: 800; }
.done-sub   { font-size: clamp(15px, 4vw, 17px); color: var(--muted); max-width: 26ch; line-height: 1.5; }

.done-btns {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

/* Shared round buttons */
.round-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(15px, 4.4vw, 18px);
  border-radius: 18px;
  padding: 14px 24px;
  min-height: 54px;
  cursor: pointer;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, background 0.12s ease;
}
.round-btn:active { transform: scale(0.97); }
.round-btn.go   { background: var(--sage); color: #fff; }
.round-btn.go:hover { background: var(--sage-dim); }
.round-btn.soft { background: var(--panel); border-color: var(--line); color: var(--ink); }
.round-btn.soft:hover { border-color: var(--sky); }

/* ========================================================= FOOTER ====== */
.foot {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  padding: 8px;
  flex-shrink: 0;
}

/* ========================================================= ANIMATIONS == */
@keyframes pop {
  0%   { transform: scale(0.86); opacity: 0; }
  65%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-7px); }
  40%       { transform: translateX(7px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* ========================================================= FULLSCREEN == */
.app:fullscreen,
.app:-webkit-full-screen {
  max-width: 100vw;
  width: 100vw;
  height: 100vh;
}

/* ========================================================= MOTION ====== */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
