/* English phrase lessons — same palette as «Скажи по-английски» and «Собери слово» */

:root {
  --ink: #3d2b2f;
  --muted: #8b7576;
  --sky: #d7f0ff;
  --cream: #fff8ec;
  --pig: #ff7096;          /* main colour — the listen button */
  --pig-dark: #e04f78;
  --pig-soft: #ffe1ea;
  --ok: #22a35a;
  --ok-bg: #dcf8e7;
  --bad: #e5484d;
  --mic: #3fb36b;          /* the speak button */
  --mic-dark: #2a8f52;
  --accent: #f2b31c;
  --accent-soft: #fff1c9;
  --line: #eadfcd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--sky) 0%, var(--cream) 55%) fixed;
  color: var(--ink);
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button:disabled { cursor: default; }
[hidden] { display: none !important; }
/* Elements of one code file only (body data-code, set by the build) */
body:not([data-mic]) .only-mic,
body:not([data-code="assemble"]) .only-assemble,
body:not([data-code="tenses"]) .only-tenses,
body:not([data-mode="tenses-listen"]) .only-tenses-listen,
body:not([data-mode="tenses-say"]) .only-tenses-say { display: none !important; }

/* ---------- Topics and score ---------- */

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 0;
}

.score {
  font-size: 26px;
  font-weight: 900;
  padding: 4px 18px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--accent-soft);
}
.score.bump { animation: pop 0.45s ease-out; }

.topics {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1100px;
}

.topic {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  background: rgba(255, 255, 255, 0.7);
  border: 3px solid transparent;
  border-radius: 16px;
  transition: transform 0.15s, background 0.15s;
}
.topic:hover { transform: translateY(-2px); }
.topic.current { background: #fff; border-color: var(--accent); box-shadow: 0 4px 0 var(--accent-soft); }
.topic.done { border-color: var(--ok); }
.topic-icon { font-size: 24px; line-height: 1; }
.topic-name { font-weight: 800; font-size: 15px; }
.topic-count { font-size: 13px; color: var(--muted); }
.topic.done .topic-count { color: var(--ok); }

/* ---------- Word card ---------- */

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.board {
  width: min(100%, 720px);
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 26px;
  background: #fff;
  border-radius: 32px;
  box-shadow: 0 6px 0 var(--accent-soft), 0 10px 24px rgba(61, 43, 47, 0.08);
  text-align: center;
}

.task { font-size: 18px; color: var(--muted); font-weight: 800; }
.question { font-size: 46px; font-weight: 900; line-height: 1.15; overflow-wrap: anywhere; animation: pop 0.35s ease-out; }
.answer {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.2;
  padding: 6px 18px;
  color: var(--ink);
  background: var(--accent-soft);
  border-radius: 18px;
  animation: pop 0.35s ease-out;
}
.answer.ok { color: var(--ok); background: var(--ok-bg); }
.heard { min-height: 1.3em; font-size: 18px; color: var(--muted); overflow-wrap: anywhere; }

.question.muted { color: var(--line); letter-spacing: 0.2em; }

/* ---------- Tenses: the time buttons, the target time, the clue ---------- */

.times { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.time {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 128px;
  padding: 14px 18px 12px;
  font-size: 40px;
  line-height: 1;
  background: #fff;
  border: 4px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 5px 0 var(--line);
  transition: transform 0.1s;
}
.time span { font-size: 22px; font-weight: 900; }
.time:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.time-past { border-color: #b9a7f0; }
.time-now { border-color: #8fd6a9; }
.time-future { border-color: #8cc8f2; }
.time.wrong { opacity: 0.35; animation: shake 0.4s ease-in-out; }
.time.right { background: var(--ok-bg); border-color: var(--ok); animation: pop 0.35s ease-out; }
.time:disabled { cursor: default; }

.target { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.time-badge { padding: 6px 16px; font-size: 26px; font-weight: 900; border-radius: 999px; }
.time-badge.time-past { background: #ece6ff; }
.time-badge.time-now { background: #ddf6e6; }
.time-badge.time-future { background: #dff0fd; }
.target-ru { font-size: 22px; color: var(--muted); }
.target-label { font-size: 18px; font-weight: 800; color: var(--muted); }
.clue { min-height: 1.3em; font-size: 18px; color: var(--ok); font-weight: 800; }

/* ---------- Assemble: the answer line and the word bank ---------- */

[data-code="assemble"] .question { font-size: 28px; color: var(--muted); }
.line {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  padding: 8px;
  border-radius: 20px;
}
.line.ok { background: var(--ok-bg); }
.line.ok .card-word { border-color: var(--ok); color: var(--ok); }
.slot {
  width: 84px;
  height: 56px;
  border: 3px dashed var(--line);
  border-radius: 16px;
}
.bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 760px;
}
.card-word {
  min-width: 64px;
  min-height: 56px;
  padding: 8px 18px;
  font-size: 26px;
  font-weight: 800;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--line);
  transition: transform 0.1s, opacity 0.15s;
}
.card-word:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.card-word.used { opacity: 0.25; box-shadow: none; }
.card-word.wrong { border-color: var(--bad); color: var(--bad); animation: shake 0.4s ease-in-out; }
.line .card-word { animation: pop 0.25s ease-out; }
.line .card-word.wrong { animation: shake 0.4s ease-in-out; }

/* ---------- Listen / speak ---------- */

.actions { display: flex; gap: 30px; justify-content: center; flex-wrap: wrap; }

.round {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  padding: 0;
  font-size: 20px;
  font-weight: 800;
}
.round-icon {
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 48px;
  transition: transform 0.1s;
}
.listen .round-icon { background: var(--pig); box-shadow: 0 6px 0 var(--pig-dark); }
.speak .round-icon { background: var(--mic); box-shadow: 0 6px 0 var(--mic-dark); }
.hint-btn .round-icon { background: var(--accent); box-shadow: 0 6px 0 #c98f0a; }
.round:active:not(:disabled) .round-icon { transform: translateY(4px); box-shadow: none; }
.round:disabled { opacity: 0.45; }

/* A gentle nudge towards the next button to press */
.round.hint .round-icon { animation: nudge 1.6s ease-in-out infinite; }
/* Playing / listening right now */
.listen.active .round-icon, .hint-btn.active .round-icon { animation: beat 0.6s ease-in-out infinite; }
.speak.active .round-icon { background: var(--bad); box-shadow: 0 6px 0 #b8363a; animation: ring 1.2s ease-out infinite; }

/* ---------- Message and buttons ---------- */

#message { margin: 0; max-width: 100%; overflow-wrap: anywhere; min-height: 1.4em; font-size: 28px; font-weight: 900; text-align: center; }
#message.ok { color: var(--ok); animation: pop 0.3s ease-out; }
#message.miss { color: var(--pig-dark); }

.controls { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.btn {
  font-size: 21px;
  font-weight: 800;
  padding: 12px 26px;
  border-radius: 999px;
  border: 3px solid var(--line);
  background: #fff;
  box-shadow: 0 4px 0 var(--line);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--pig); border-color: var(--pig); color: #fff; box-shadow: 0 4px 0 var(--pig-dark); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--pig-dark); }
#manual-ok { border-color: var(--mic); color: var(--mic-dark); box-shadow: 0 4px 0 var(--ok-bg); }

.note { max-width: 520px; margin: 0; font-size: 15px; color: var(--muted); text-align: center; }

/* ---------- "Topic done" dialog ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(61, 43, 47, 0.35);
}
.card {
  max-width: 440px;
  width: 100%;
  padding: 28px 24px;
  background: #fff;
  border-radius: 28px;
  text-align: center;
  box-shadow: 0 10px 0 var(--accent-soft), 0 20px 50px rgba(0, 0, 0, 0.2);
  animation: pop 0.35s ease-out;
}
.card-icon { font-size: 84px; line-height: 1.1; }
.card h2 { margin: 10px 0 6px; font-size: 30px; font-weight: 900; }
.card p { margin: 0 0 22px; color: var(--muted); font-size: 18px; }

/* ---------- Confetti ---------- */

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti span { position: absolute; top: -50px; animation: fall 1.8s ease-in forwards; }

/* ---------- Animations ---------- */

@keyframes pop { 0% { transform: scale(0.85); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14%); } }
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.55); }
  100% { box-shadow: 0 0 0 26px rgba(229, 72, 77, 0); }
}
@keyframes fall {
  to { transform: translate(var(--drift, 0), 110vh) rotate(540deg); opacity: 0.9; }
}

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

/* ---------- Phone ---------- */

@media (max-width: 700px) {
  header { padding: 10px 8px 0; gap: 8px; }
  .score { font-size: 22px; }
  .topics { gap: 5px; }
  .topic { flex-direction: column; gap: 0; padding: 4px 7px; border-radius: 12px; }
  .topic-name { display: none; }
  .topic-icon { font-size: 22px; }
  .topic-count { font-size: 11px; }
  main { gap: 14px; padding-top: 12px; padding-bottom: 80px; }
  .board { min-height: 150px; padding: 16px 14px; border-radius: 26px; }
  .task { font-size: 15px; }
  .question { font-size: 30px; }
  .answer { font-size: 22px; padding: 4px 12px; }
  .heard { font-size: 15px; }
  [data-code="assemble"] .question { font-size: 20px; }
  .times { gap: 8px; }
  .time { min-width: 96px; padding: 10px 10px 8px; font-size: 32px; }
  .time span { font-size: 18px; }
  .time-badge { font-size: 20px; }
  .target-ru { font-size: 17px; }
  .clue { font-size: 15px; }
  .line { gap: 6px; min-height: 52px; padding: 4px; }
  .slot { width: 60px; height: 46px; }
  .bank { gap: 8px; }
  .card-word { min-width: 48px; min-height: 46px; padding: 6px 12px; font-size: 20px; }
  .actions { gap: 18px; }
  .round { font-size: 17px; }
  .round-icon { width: 78px; height: 78px; font-size: 36px; }
  .btn { font-size: 17px; padding: 10px 18px; }
  #message { font-size: 22px; }
}
