:root {
  --bg: #f4facf;
  --panel: #fffef5;
  --panel-soft: #f0f7d6;
  --line: #cbdf9d;
  --text: #304726;
  --muted: #607447;
  --accent: #357529;
  --accent-dark: #296020;
  --wrong: #bd3549;
  --btn: #be4e13;
  --btn-hover: #a6400e;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  min-height: 100%;
  height: auto;
  isolation: isolate;
}

.fruit-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  user-select: none;
}

.fruit-background span {
  position: absolute;
  font-size: clamp(38px, 7vw, 88px);
  line-height: 1;
  opacity: 0.65;
}

.fruit-background span:nth-child(1) { left: 5%; top: 5%; transform: rotate(-22deg); }
.fruit-background span:nth-child(2) { left: 38%; top: 3%; transform: rotate(15deg); }
.fruit-background span:nth-child(3) { right: 6%; top: 9%; transform: rotate(22deg); }
.fruit-background span:nth-child(4) { left: 17%; top: 30%; transform: rotate(-15deg); }
.fruit-background span:nth-child(5) { right: 18%; top: 34%; transform: rotate(18deg); }
.fruit-background span:nth-child(6) { left: 3%; top: 57%; transform: rotate(15deg); }
.fruit-background span:nth-child(7) { right: 3%; top: 62%; transform: rotate(-18deg); }
.fruit-background span:nth-child(8) { left: 24%; bottom: 6%; transform: rotate(-20deg); }
.fruit-background span:nth-child(9) { right: 30%; bottom: 4%; transform: rotate(12deg); }
.fruit-background span:nth-child(10) { right: 7%; bottom: 5%; transform: rotate(-15deg); }
.fruit-background span:nth-child(11) { left: 48%; top: 48%; transform: rotate(12deg); }
.fruit-background span:nth-child(12) { left: 4%; bottom: 4%; transform: rotate(25deg); }

.game {
  width: 100%;
  max-width: 520px;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 32px rgba(89, 117, 35, 0.14);
}

.hud {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.lives {
  color: var(--wrong);
  letter-spacing: 0.06em;
}

.play-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.question-label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.description {
  margin: 0;
  background: var(--question-bg, #fff2bd);
  border: 1px solid var(--question-border, #ebd887);
  color: var(--question-text, var(--text));
  border-radius: 16px;
  padding: 20px 16px;
  font-size: 1.15rem;
  line-height: 1.5;
  min-height: 84px;
  display: flex;
  align-items: center;
  word-break: keep-all;
}

#answerForm {
  display: flex;
  gap: 8px;
}

#answerInput {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

#answerInput:focus {
  outline: 2px solid var(--btn);
  outline-offset: 1px;
}

#answerInput::placeholder { color: #73815e; }

#answerInput:disabled {
  background: #f1f3e7;
  opacity: 0.75;
}

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--btn);
  color: #ffffff;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover:not(:disabled) { background: var(--btn-hover); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled {
  background: var(--panel-soft);
  color: var(--muted);
  cursor: not-allowed;
}

.feedback {
  margin: 0;
  min-height: 24px;
  font-size: 0.95rem;
  font-weight: 600;
}

.feedback.ok { color: var(--accent); }
.feedback.no { color: var(--wrong); }

.controls {
  display: flex;
  gap: 8px;
}

.controls button { flex: 1; }

.controls button {
  background: var(--accent);
  border-radius: 14px;
}
.controls button:hover:not(:disabled) { background: var(--accent-dark); }
button:focus-visible { outline: 3px solid var(--accent-dark); outline-offset: 3px; }

@media (max-width: 400px), (max-height: 500px) {
  body { padding: 10px; }
  .game { padding: 14px; gap: 10px; border-radius: 18px; }
  .play-area { gap: 9px; }
  .description { padding: 14px 12px; }
}

@media (max-height: 440px) {
  body { justify-content: flex-start; }
}
