/* «Продолжи ряд» — онлайн-игра. Палитра a4umka, шрифт Georgia, без внешних зависимостей. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --green: #4a6b2a;
  --green-dark: #3a5520;
  --green-bright: #5a8835;
  --cream: #fffdf5;
  --cream-2: #f3f0e4;
  --border: #b8862c;
  --border-soft: #b8a86c;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background:
    radial-gradient(circle at 8% 92%, rgba(180, 220, 140, 0.30) 0%, transparent 26%),
    radial-gradient(circle at 92% 8%, rgba(255, 230, 180, 0.35) 0%, transparent 28%),
    linear-gradient(180deg, #f3f0e4 0%, #e7e0c8 100%);
  font-family: Georgia, 'Times New Roman', serif;
  color: #3a3320;
}

.game {
  position: relative;
  width: 100%;
  max-width: 720px;
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 18px 22px 26px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

/* ---- верхняя панель ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
}
.scores { display: flex; gap: 8px; }
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(232, 220, 180, 0.55);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 18px;
  color: var(--green-dark);
  min-width: 64px;
  justify-content: center;
}
.score-pill .ico { font-size: 17px; }
.score-pill.streak { border-color: #d98a2b; color: #b45a12; }
.score-pill.bump { animation: pop 0.4s ease; }

/* ---- выбор уровня ---- */
.level-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.level-btn {
  flex: 1 1 0;
  min-width: 92px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 9px 8px;
  border: 1.5px solid var(--border-soft);
  border-radius: 10px;
  background: #fff;
  color: var(--green);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.level-btn:hover { border-color: var(--green-bright); }
.level-btn:active { transform: scale(0.97); }
.level-btn.is-active {
  background: #c8d8a4;
  border-color: var(--green-bright);
  color: var(--green-dark);
}

/* ---- сцена ---- */
.stage { text-align: center; }
.prompt {
  margin: 0 0 16px;
  font-size: 19px;
  color: var(--green);
  font-weight: 700;
}

/* ряд с ячейками */
.row-wrap {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: clamp(4px, 1.4vw, 10px);
  margin-bottom: 10px;
  min-height: 84px;
  align-items: center;
}
.cell {
  flex: 0 0 auto;
  width: clamp(40px, 9.5vw, 72px);
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1.5px solid #e8dfc6;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
.cell svg { width: 100%; height: 100%; display: block; }
.cell.gap {
  border: 2px dashed var(--border);
  background: rgba(232, 220, 180, 0.30);
}
.cell.gap.filled {
  border-style: solid;
  border-color: var(--green-bright);
  background: #eef4dd;
  animation: pop 0.45s ease;
}

/* ---- зона обратной связи ---- */
.feedback {
  min-height: 30px;
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--green-bright);
  opacity: 0;
  transition: opacity 0.2s;
}
.feedback.show { opacity: 1; }
.feedback.bad { color: #c0552f; }

/* ---- варианты ответа ---- */
.choices {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(10px, 2.5vw, 18px);
  margin-bottom: 12px;
}
.choice {
  width: clamp(60px, 17vw, 90px);
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 2px solid var(--border-soft);
  background: #fffef9;
  padding: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}
.choice svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.choice:hover { border-color: var(--green-bright); box-shadow: 0 4px 14px rgba(90,136,53,0.20); }
.choice:active { transform: scale(0.93); }
.choice.correct {
  border-color: var(--green-bright);
  background: #dcebbf;
  background: #d8e9b6;
  animation: pop 0.45s ease;
}
.choice.wrong { animation: shake 0.4s ease; border-color: #c0552f; }
.choice.locked { pointer-events: none; }
.choice.dim { opacity: 0.35; pointer-events: none; }

/* ---- кнопка Дальше ---- */
.next-btn {
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  padding: 12px 34px;
  border: 1.5px solid var(--green-bright);
  border-radius: 12px;
  background: #c8d8a4;
  color: var(--green-dark);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  animation: rise 0.3s ease;
}
.next-btn:hover { background: #d6e4b6; }
.next-btn:active { transform: scale(0.96); }

/* ---- летящие звёзды при успехе ---- */
.burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.spark {
  position: absolute;
  font-size: 26px;
  will-change: transform, opacity;
  animation: fly 0.9s ease-out forwards;
}

/* ---- анимации ---- */
@keyframes pop {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fly {
  0% { opacity: 1; transform: translate(0, 0) scale(0.6) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.3) rotate(var(--rot)); }
}

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

/* фокус для доступности (клавиатура) */
.choice:focus-visible,
.level-btn:focus-visible,
.next-btn:focus-visible {
  outline: 3px solid var(--green-bright);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .game { padding: 14px 12px 20px; }
  .brand { font-size: 18px; }
  .prompt { font-size: 16px; }
}
