/* === Базовые стили и клетчатый фон === */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --paper: #f5f0e6;
  --paper-dark: #e8e2d5;
  --ink: #2c2416;
  --ink-light: #5a4d3a;
  --accent: #e07a5f;
  --accent-bright: #f4a261;
  --success: #81b29a;
  --shadow: rgba(44, 36, 22, 0.12);
  --shadow-strong: rgba(44, 36, 22, 0.2);
}

html, body {
  height: 100%;
  font-family: 'Caveat', cursive, sans-serif;
  font-size: 20px;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

.lang-switcher {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.25rem;
  z-index: 100;
}

.lang-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.35rem 0.6rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.lang-btn:hover {
  background: var(--paper-dark);
}

.lang-btn.active {
  background: var(--accent-bright);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
}

.screens-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* === Экраны === */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Стартовый экран === */
.quiz-title {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-align: center;
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--shadow);
}

.cat-container {
  margin-bottom: 1.5rem;
}

.cat-start, .cat-start svg {
  width: 140px;
  height: auto;
  display: block;
}

.cat-start {
  animation: catIdle 2s ease-in-out infinite;
}

@keyframes catIdle {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

.start-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
}

.start-form label {
  font-size: 1.5rem;
  font-weight: 500;
}

.start-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1.4rem;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  outline: none;
  transition: box-shadow 0.2s, transform 0.2s;
}

.start-form input:focus {
  box-shadow: 4px 4px 0 var(--shadow);
  transform: translate(-1px, -1px);
}

.start-form input::placeholder {
  color: var(--ink-light);
  opacity: 0.6;
}

/* === Кнопки === */
.btn {
  font-family: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  padding: 0.8rem 2rem;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--accent-bright);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--shadow);
}

.btn:active {
  transform: translate(0, 0);
  box-shadow: 2px 2px 0 var(--shadow);
}

.btn-start {
  background: var(--success);
}

/* === Экран вопроса === */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 1rem;
  gap: 1rem;
}

.cat-quiz-container {
  flex-shrink: 0;
}

.cat-quiz, .cat-quiz svg {
  width: 80px;
  height: auto;
  display: block;
}

.cat-quiz {
  transition: transform 0.3s ease;
}

.cat-quiz.cat-happy {
  animation: catJump 0.6s ease;
}

.cat-quiz.cat-sad {
  animation: catShake 0.5s ease;
}

@keyframes catJump {
  0% { transform: scale(1) translateY(0); }
  30% { transform: scale(1.1) translateY(-15px); }
  60% { transform: scale(1.05) translateY(-5px); }
  100% { transform: scale(1) translateY(0); }
}

@keyframes catShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.question-counter {
  font-size: 1.2rem;
  color: var(--ink-light);
}

.question-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.question-image-wrap {
  background: white;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 4px 4px 0 var(--shadow);
  border: 2px solid var(--ink);
}

.question-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain;
}

.question-placeholder {
  font-size: 1.5rem;
  padding: 1rem;
  text-align: center;
  color: var(--ink-light);
}

.answers-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.answer-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.answer-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--shadow);
}

.answer-btn:active {
  transform: translate(0, 0);
}

.answer-btn img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 100px;
  object-fit: contain;
}

.answer-btn.correct {
  border-color: var(--success);
  box-shadow: 0 0 0 3px var(--success);
}

.answer-btn.wrong {
  border-color: var(--accent);
  animation: wrongShake 0.4s ease;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* === Финальный экран === */
.final-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

.cat-final, .cat-final svg {
  width: 160px;
  height: auto;
  display: block;
}

.cat-final {
  animation: catIdle 2s ease-in-out infinite;
}

.final-title {
  font-size: 2.5rem;
  font-weight: 700;
}

.final-message {
  font-size: 1.4rem;
  color: var(--ink-light);
}

.btn-restart {
  margin-top: 0.5rem;
}

/* === Подпись проекта === */
.project-credit {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 1rem;
  color: var(--ink-light);
  text-align: center;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* === Адаптивность === */
@media (max-width: 480px) {
  .quiz-title {
    font-size: 2.2rem;
  }

  .answers-container {
    grid-template-columns: 1fr 1fr;
  }
}
