:root {
  --ink: #20242a;
  --muted: #667085;
  --line: #d7dde8;
  --panel: #ffffff;
  --page: #f4f7fb;
  --accent: #b71948;
  --accent-2: #0b7285;
  --good: #198754;
  --bad: #c92a2a;
  --focus: #ffd43b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 42px;
  padding: 0 14px;
}

button:hover {
  border-color: var(--accent-2);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.practice {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 48px;
  line-height: 1;
}

h2 {
  font-size: 20px;
}

.score {
  display: grid;
  gap: 4px;
  text-align: right;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.filters {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 700;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 36px;
  border-radius: 999px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(31, 41, 55, 0.08);
}

.quiz-card,
.start-card,
.end-card {
  padding: 22px;
}

.start-card h2,
.end-card h2 {
  margin-bottom: 14px;
}

.start-form {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.category {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.question-type {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 6px;
  border-radius: 8px;
  background: #eef7f8;
  color: var(--accent-2);
  font-size: 14px;
  font-weight: 700;
  padding: 0 10px;
}

.prompt {
  display: grid;
  place-items: center;
  min-height: 210px;
  margin: 14px 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcff;
  text-align: center;
}

.word-prompt {
  font-size: 76px;
  font-weight: 800;
  line-height: 1.05;
}

.picture-prompt {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.picture {
  position: relative;
  overflow: hidden;
  width: min(220px, 56vw);
  aspect-ratio: var(--crop-ratio, 1);
  border-radius: 8px;
  background: #f7f2ea;
  border: 1px solid var(--line);
}

.picture img {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  max-width: none;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.picture-direct {
  display: grid;
  place-items: center;
  background: #f8f7f2;
}

.picture-direct img {
  position: static;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.answer-label {
  color: var(--muted);
  font-weight: 700;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}

.primary {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
  font-weight: 700;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-button {
  display: grid;
  justify-items: center;
  gap: 6px;
  height: 148px;
  padding: 10px;
}

.choice-button:disabled,
.primary:disabled {
  cursor: default;
  opacity: 0.65;
}

.choice-button .picture {
  width: 82px;
}

.text-choice {
  align-content: center;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

.feedback {
  min-height: 32px;
  margin: 12px 0 4px;
  font-weight: 700;
}

.feedback.good {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.wrong-summary {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.wrong-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 10px 12px;
}

.wrong-item strong {
  display: block;
}

.wrong-item span,
.end-card p {
  color: var(--muted);
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(244, 247, 251, 0.82);
  backdrop-filter: blur(4px);
  padding: 20px;
}

.result-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(31, 41, 55, 0.22);
  padding: 28px;
  text-align: center;
}

.result-overlay.good .result-panel {
  border-color: rgba(25, 135, 84, 0.35);
}

.result-overlay.bad .result-panel {
  border-color: rgba(11, 114, 133, 0.28);
}

.result-icon {
  display: grid;
  place-items: center;
  width: 92px;
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: 48px;
}

.result-overlay.good .result-icon {
  background: #e8f7ef;
}

.result-overlay.bad .result-icon {
  background: #eef7f8;
}

.correct-answer {
  color: var(--accent-2);
  font-size: 26px;
  font-weight: 800;
}

.result-panel p {
  margin: 0;
  color: var(--muted);
}

.countdown {
  display: grid;
  place-items: center;
  width: 54px;
  aspect-ratio: 1;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

@media (max-width: 860px) {
  .choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 20px, 900px);
    padding: 14px 0;
  }

  .topbar,
  .answer-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .score {
    text-align: left;
  }

  h1 {
    font-size: 34px;
  }

  .word-prompt {
    font-size: 42px;
  }

  .choices,
  .filters {
    grid-template-columns: 1fr;
  }

  .choice-button {
    height: 122px;
  }
}

@media (max-width: 700px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app {
    width: 100%;
    height: 100dvh;
    padding: 8px;
  }

  .practice {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
  }

  .topbar {
    align-items: center;
    margin-bottom: 8px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 26px;
  }

  .score {
    gap: 1px;
    font-size: 12px;
    text-align: right;
  }

  .start-card,
  .end-card {
    max-height: calc(100dvh - 76px);
    overflow: auto;
    padding: 14px;
  }

  .quiz-card {
    display: grid;
    grid-template-rows: auto auto minmax(110px, 0.9fr) minmax(220px, 1.1fr) auto;
    min-height: 0;
    height: 100%;
    padding: 12px;
    overflow: hidden;
  }

  .category {
    min-height: 0;
    font-size: 13px;
  }

  .question-type {
    min-height: 24px;
    margin-top: 4px;
    font-size: 12px;
  }

  .prompt {
    min-height: 0;
    margin: 8px 0;
    padding: 8px;
  }

  .word-prompt {
    font-size: 40px;
  }

  .picture {
    width: min(170px, 48vw);
  }

  .choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    min-height: 0;
    gap: 8px;
  }

  .choice-button {
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 8px;
  }

  .choice-button .picture {
    width: min(118px, 32vw);
  }

  .text-choice {
    font-size: 20px;
  }

  .feedback {
    min-height: 20px;
    margin: 6px 0 0;
    font-size: 13px;
  }

  .actions {
    display: none;
  }

  .result-panel {
    padding: 22px;
  }
}
