:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #657186;
  --panel: #ffffff;
  --line: #d8dee9;
  --field: #f4f7fb;
  --blue: #2b6cb0;
  --teal: #0f766e;
  --coral: #c2410c;
  --plum: #7c3aed;
  --gold: #b7791f;
  --green: #2f855a;
  --shadow: 0 16px 42px rgba(24, 38, 64, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(124, 58, 237, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(15, 118, 110, 0.12), transparent 38%),
    #eef3f8;
  color: var(--ink);
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.top-band {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 18px;
}

.eyebrow,
.round-theme {
  margin: 0 0 5px;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.stats {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 6px 18px rgba(24, 38, 64, 0.08);
  font-weight: 800;
}

.status-badge.correct {
  border-color: #9ae6b4;
  background: #ecfdf5;
  color: #166534;
}

.status-badge.try-again {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.controls label,
.answer-form label,
.custom-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 104px;
  padding: 12px;
  line-height: 1.45;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.16);
}

.controls button,
.answer-form button,
.custom-panel button,
.history-panel button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

#showAnswerBtn {
  background: var(--teal);
}

#acceptAlternateBtn {
  background: var(--plum);
}

#clearHistoryBtn {
  min-height: 34px;
  background: var(--coral);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 360px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.play-panel,
.skill-panel,
.custom-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.play-panel {
  padding: clamp(14px, 2vw, 20px);
}

.prompt-row,
.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.item-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 148px;
  padding: 16px 12px;
  border: 2px solid #c8d1de;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-weight: 900;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.item-card:hover,
.item-card:focus-visible {
  border-color: var(--blue);
  outline: none;
  transform: translateY(-2px);
}

.item-card.selected {
  border-color: var(--gold);
  background: #fff8e6;
}

.item-card.correct {
  border-color: var(--green);
  background: #ecfdf5;
  color: #166534;
}

.item-card.incorrect {
  border-color: var(--coral);
  background: #fff7ed;
  color: #9a3412;
}

.visual {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: var(--tile-color, #dbeafe);
  color: #111827;
  font-size: 1.4rem;
  font-weight: 950;
  box-shadow: inset 0 -8px 0 rgba(17, 24, 39, 0.08);
}

.item-name {
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.2;
}

.answer-form {
  display: grid;
  gap: 10px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feedback {
  min-height: 58px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.feedback.success {
  border-color: #9ae6b4;
  background: #ecfdf5;
  color: #166534;
}

.feedback.notice {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.skill-panel,
.custom-panel,
.history-panel {
  padding: 16px;
}

.sentence-frame {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

#selectedWord {
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 950;
}

#customForm {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.history-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
}

.history-list li {
  padding: 10px;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  background: #fff8e6;
  color: #4a3520;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 10px;
  }

  .top-band,
  .prompt-row {
    align-items: start;
    flex-direction: column;
  }

  .stats {
    justify-content: start;
  }

  .controls {
    align-items: stretch;
  }

  .controls label,
  .controls button,
  .answer-form button {
    flex: 1 1 135px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
