* {
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --blue: #2586c7;
  --blue-dark: #1f6fa6;
  --blue-darker: #195b88;
  --blue-wrong: #527c99;
  --green: #52d71f;
  --white: #ffffff;
  --text: #1e1e1e;
  --correct: #eeeeee;
  --correct-border: transparent;
  --wrong-flash: #d96b6b;
  --wrong-bg: #f6d6d6;
  --wrong-border: #c74a4a;
  --shadow: rgba(0, 0, 0, 0.08);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", "Segoe UI", Arial, sans-serif;
}

.page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  text-align: center;
}

h1 {
  color: var(--blue);
  font-size: clamp(1.45rem, 2.5vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0 0 14px;
}

.page-subtitle {
  color: #4b5a66;
  font-size: 0.95rem;
  line-height: 1.45;
  margin: -4px auto 0;
  max-width: 680px;
}

.instructions {
  max-width: 660px;
  margin: 0 auto 20px;
  text-align: left;
  font-size: 0.92rem;
  line-height: 1.45;
}

.instructions ul {
  margin: 0;
}

.quiz-meta {
  color: #4b5a66;
  font-size: 0.9rem;
  font-weight: 700;
  margin: -4px 0 16px;
}

.selector-page {
  max-width: 1200px;
}

.quiz-selectors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 22px;
  align-items: start;
  margin-top: 22px;
}

.selector-panel {
  background: #f7f9fb;
  border: 1px solid #e0e8ef;
  border-radius: 12px;
  box-shadow: 0 8px 20px var(--shadow);
  padding: 22px;
  text-align: left;
}

.selector-panel:last-child {
  padding-bottom: 22px;
}

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

.selector-panel h2 {
  color: var(--blue);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.15;
  margin: 0;
}

.selected-count {
  color: #4b5a66;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 4px 0 0;
}

.letter-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.letter-option {
  background: var(--white);
  border: 2px solid var(--blue);
  border-radius: 8px;
  box-shadow: none;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  min-height: 48px;
  padding: 9px 12px;
  text-align: center;
}

.letter-option.wide {
  grid-column: 1 / -1;
}

.letter-option.selected {
  background: var(--blue);
  color: var(--white);
}

.letter-option:active {
  box-shadow: none;
}

.selector-actions {
  margin-top: 18px;
}

.toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

button,
.button-link {
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: var(--white);
  cursor: pointer;
  display: inline-block;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  font-family: inherit;
  line-height: normal;
  text-decoration: none;
  box-shadow: 0 4px 0 var(--blue-dark);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

button:hover,
.button-link:hover {
  filter: brightness(1.03);
}

button:focus-visible,
.button-link:focus-visible,
.answer-input:focus-visible {
  outline: 3px solid var(--blue-darker);
  outline-offset: 3px;
}

button:active,
.button-link:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--blue-dark);
}

.quiz-grid {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.card {
  background: var(--blue);
  border-radius: 14px;
  width: 100%;
  max-width: 158px;
  aspect-ratio: 213 / 304;
  padding: 36px 18px 28px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 18px var(--shadow);
  transition: background-color 0.25s ease, transform 0.15s ease;
}

.card.active {
  background: var(--blue-darker);
  transform: translateY(-2px);
}

.card.correct {
  background: var(--green);
}

.card.wrong {
  background: var(--blue-wrong);
}

.card.wrong-flash {
  background: var(--wrong-flash);
}

.card.shake {
  animation: shake 0.32s ease;
}

.letter {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.9rem;
  color: var(--white);
  line-height: 0.95;
  margin: 0;
}

.answer-shell {
  width: 100%;
  max-width: 112px;
  height: 62px;
  border-radius: 4px;
  background: var(--white);
  position: relative;
}

.ghost-answer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(30, 30, 30, 0.48);
  font-size: 1.25rem;
  pointer-events: none;
  z-index: 0;
}

.answer-input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 1.25rem;
  outline: none;
  padding: 8px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.answer-input.correct {
  background: var(--correct);
  color: rgba(30, 30, 30, 0.28);
}

.answer-shell:has(.answer-input.correct) {
  background: var(--correct);
  box-shadow: none;
}

.answer-input.incorrect {
  color: #6d4a4a;
}

.answer-shell:has(.answer-input.incorrect) {
  background: var(--wrong-bg);
  box-shadow: inset 0 0 0 3px var(--wrong-border);
}

.answer-input.wrong-flash {
  color: #6d4a4a;
}

.answer-shell:has(.answer-input.wrong-flash) {
  background: #f1b6b6;
  box-shadow: inset 0 0 0 3px #b93c3c;
}

.answer-shell.has-ghost {
  background: var(--white);
  box-shadow: none;
}

.finish-section {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.finish-btn {
  padding: 13px 20px;
  font-size: 0.95rem;
}

.secondary-link {
  background: var(--white);
  box-shadow: inset 0 0 0 2px var(--blue);
  color: var(--blue);
  min-width: 92px;
  text-align: center;
}

.results {
  max-width: 760px;
  margin: 40px auto 0;
  background: #f7f9fb;
  border: 1px solid #e4ebf2;
  border-radius: 12px;
  padding: 26px;
  text-align: left;
  box-shadow: 0 8px 20px var(--shadow);
}

.results h2 {
  color: var(--blue);
  font-size: 1.15rem;
  margin: 28px 0 14px;
}

.results h2:first-child {
  margin-top: 0;
}

.results-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--white);
  border: 1px solid #e0e8ef;
  border-radius: 10px;
  padding: 18px 20px;
}

.score-number {
  color: var(--blue);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
}

.score-label {
  color: #4b5a66;
  font-size: 1rem;
  font-weight: 700;
}

.results-message {
  background: #edf9e9;
  border: 1px solid #ccefc2;
  border-radius: 8px;
  color: #255b17;
  font-weight: 700;
  margin: 18px 0 0;
  padding: 14px 16px;
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-row {
  display: grid;
  grid-template-columns: 78px repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 14px;
  background: var(--white);
  border: 1px solid #e0e8ef;
  border-radius: 10px;
  padding: 12px 14px;
}

.review-letter {
  align-items: center;
  background: var(--blue);
  border-radius: 8px;
  color: var(--white);
  display: flex;
  font-size: 2.2rem;
  height: 58px;
  justify-content: center;
  line-height: 1;
}

.review-answer,
.review-typed,
.review-final {
  min-width: 0;
}

.review-label {
  color: #697782;
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.review-row strong {
  color: var(--text);
  display: block;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

@keyframes shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

@media (max-width: 700px) {
  .instructions {
    font-size: 0.86rem;
  }

  .letter-options {
    grid-template-columns: 1fr;
  }

  .letter-option {
    font-size: 0.9rem;
    min-height: 54px;
  }

  .card {
    max-width: 146px;
    padding: 32px 16px 26px;
  }

  .letter {
    min-height: 64px;
    font-size: 3.45rem;
  }

  .answer-shell {
    max-width: 104px;
    height: 58px;
  }

  .answer-input,
  .ghost-answer {
    font-size: 1.15rem;
  }

  .results {
    padding: 18px;
  }

  .review-row {
    grid-template-columns: 1fr;
  }

  .results-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .review-letter {
    width: 68px;
  }
}
