:root {
  --bg-1: #f9fbff;
  --bg-2: #e9f3ff;
  --card: #ffffffcc;
  --ink: #243447;
  --accent: #1565c0;
  --accent-soft: #e3f2fd;
  --good: #2e7d32;
  --bad: #c62828;
  --muted: #5b6775;
  --shadow: 0 18px 40px rgba(24, 48, 84, 0.12);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background: linear-gradient(130deg, var(--bg-1), var(--bg-2));
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(2px);
}

.bg-shape-a {
  width: 380px;
  height: 380px;
  right: -120px;
  top: -100px;
  background: radial-gradient(circle, #bbdefb 0%, rgba(187, 222, 251, 0.08) 68%);
}

.bg-shape-b {
  width: 420px;
  height: 420px;
  left: -160px;
  bottom: -170px;
  background: radial-gradient(circle, #ffe0b2 0%, rgba(255, 224, 178, 0.08) 68%);
}

.app-header {
  padding: 20px 20px 8px;
  text-align: center;
}

h1,
h2,
h3 {
  font-family: "Baloo 2", sans-serif;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}

.app-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px 28px;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.card {
  background: var(--card);
  backdrop-filter: blur(5px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed #c8d7ea;
}

.inline-form {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

input,
textarea,
select,
button {
  border-radius: 12px;
  border: 1px solid #b7cadf;
  font-size: 1rem;
  font-family: inherit;
  padding: 10px 12px;
}

textarea {
  width: 100%;
  resize: vertical;
  margin: 8px 0;
}

button {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #607d8b;
}

button.reset-btn {
  background: #ef6c00;
  font-size: 0.9rem;
  padding: 7px 10px;
}

button:hover {
  filter: brightness(1.05);
}

label {
  display: block;
  margin-top: 10px;
  font-weight: 700;
}

.hint {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.lessons-overview {
  display: grid;
  gap: 10px;
}

.lesson-item {
  border: 1px solid #cfdeee;
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.lesson-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.lesson-meta {
  margin-top: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

.practice-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.stat-box {
  background: #f2f7fd;
  border-radius: 12px;
  padding: 10px;
}

.stat-box .label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-box .value {
  display: block;
  margin-top: 4px;
  font-size: 1.3rem;
  font-weight: 800;
}

.question-card {
  position: relative;
  min-height: 310px;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 14px;
  padding: 18px;
  border: 2px solid #c6dcf5;
  border-radius: 14px;
  background: #fff;
}

.question-card.question-enter {
  animation: questionFadeIn 260ms ease-out;
}

.direction {
  margin: 0;
  color: var(--muted);
}

.question-word {
  font-family: "Baloo 2", sans-serif;
  font-size: clamp(2.5rem, 7vw, 5rem);
  line-height: 1;
}

.answer-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.answer-form input {
  min-width: 260px;
}

.practice-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.history-panel {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  border: 1px solid #cfdeee;
}

.history-panel-top {
  margin: 0;
}

#answer-history {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 170px;
  overflow-y: auto;
}

#answer-history li {
  padding: 9px;
  border-bottom: 1px dashed #d6e2f1;
  font-size: 1.02rem;
  transition: opacity 0.18s ease;
}

#answer-history li:first-child {
  font-size: 1.18rem;
  font-weight: 700;
}

#answer-history li.good {
  color: var(--good);
}

#answer-history li.bad {
  color: var(--bad);
}

#answer-history .bad-given {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

#answer-history .bad-expected {
  color: var(--good);
  font-weight: 700;
}

.hidden {
  display: none;
}

.empty-note {
  color: var(--muted);
  font-style: italic;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(19, 37, 64, 0.62);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(1180px, 98vw);
  height: min(880px, 95vh);
  background: #eef5ff;
  border: 2px solid #c7dcf4;
  border-radius: 20px;
  box-shadow: 0 28px 60px rgba(7, 22, 47, 0.36);
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.modal-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 0;
}

.modal-close {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #e36b6b;
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.modal-close:hover {
  filter: brightness(1.08);
}

#practice-view {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  min-height: 0;
}

.wrong-feedback {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #ffffffee;
  border-radius: 12px;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  animation: wrongFeedbackIn 180ms ease-out;
}

.wrong-feedback.hidden {
  display: none;
}

.wrong-icon {
  color: var(--bad);
  font-size: clamp(3rem, 7vw, 4.6rem);
  font-weight: 800;
  line-height: 1;
}

.wrong-line {
  color: var(--bad);
  font-family: "Baloo 2", sans-serif;
  font-size: clamp(1.8rem, 4.4vw, 3rem);
}

.wrong-line span {
  text-decoration: line-through;
  text-decoration-thickness: 3px;
}

.wrong-correct {
  color: var(--good);
  font-family: "Baloo 2", sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
}

.wrong-continue {
  color: var(--muted);
  font-size: 1rem;
}

@media (min-width: 920px) {
  .layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .inline-form {
    grid-template-columns: 1fr auto;
  }

  #wordlist-form .inline-form {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .practice-stats {
    grid-template-columns: 1fr;
  }

  .answer-form input {
    min-width: 100%;
  }

  .modal {
    padding: 6px;
  }

  .modal-content {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 10px;
  }

  #answer-history li:first-child {
    font-size: 1.06rem;
  }
}

@keyframes questionFadeIn {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes wrongFeedbackIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
