:root {
  --ink: #102a43;
  --ink-deep: #071d31;
  --ink-soft: #294b68;
  --paper: #f4f0e7;
  --paper-bright: #fffdf8;
  --line: #d6d0c3;
  --muted: #6f7d84;
  --mint: #a7ebcf;
  --mint-deep: #287e69;
  --coral: #ff806d;
  --coral-deep: #b74b43;
  --gold: #f4bd62;
  --sky: #9cc8e8;
  --shadow: 0 18px 55px rgba(7, 29, 49, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--ink-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--ink-deep);
  background-size: 28px 28px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 64px) 22px;
}

.topbar,
.app-footer {
  color: var(--paper);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: clamp(24px, 4vw, 58px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  color: var(--ink);
  background: var(--mint);
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.06em;
  transform: rotate(-7deg);
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  color: var(--paper-bright);
  font-size: 12px;
  letter-spacing: 0.16em;
}

.brand-copy small,
.bank-count,
.app-footer,
.signal-label,
.eyebrow,
.results-kicker,
.quiz-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-copy small {
  color: #92a6b3;
  letter-spacing: 0.1em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.mode-switch {
  display: flex;
  gap: 2px;
  border: 1px solid #44637a;
  padding: 2px;
}

.mode-button {
  min-height: 30px;
  border: 0;
  padding: 7px 10px;
  color: #92a6b3;
  background: transparent;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.09em;
  line-height: 1;
  transition: background 150ms ease, color 150ms ease;
}

.mode-button:hover,
.mode-button.is-active {
  color: var(--ink);
  background: var(--mint);
}

.bank-count {
  color: #92a6b3;
  letter-spacing: 0.09em;
  white-space: nowrap;
}

.bank-count span {
  color: var(--mint);
  font-weight: 800;
}

.icon-button {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 1px solid #44637a;
  color: var(--paper-bright);
  background: transparent;
  font-size: 22px;
  line-height: 1;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  border-color: var(--mint);
  color: var(--mint);
  transform: rotate(-18deg);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(275px, 0.72fr) minmax(0, 1.5fr);
  gap: clamp(18px, 3vw, 44px);
  align-items: stretch;
}

.intro-panel {
  position: relative;
  display: flex;
  min-height: 670px;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(28px, 4vw, 54px) clamp(24px, 4vw, 50px) 36px;
  color: var(--paper);
  background:
    linear-gradient(145deg, rgba(38, 85, 110, 0.42), transparent 48%),
    var(--ink);
  box-shadow: var(--shadow);
}

.intro-panel::before {
  position: absolute;
  right: -28px;
  bottom: 76px;
  color: rgba(167, 235, 207, 0.06);
  content: "50";
  font-family: Georgia, serif;
  font-size: 220px;
  font-weight: 700;
  line-height: 0.7;
  pointer-events: none;
  transform: rotate(-13deg);
}

.intro-panel::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 34%;
  height: 9px;
  background: var(--coral);
  content: "";
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--mint);
  font-weight: 800;
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  background: var(--coral);
}

.intro-panel h1 {
  position: relative;
  z-index: 1;
  max-width: 500px;
  margin: 28px 0 22px;
  color: var(--paper-bright);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 5.2vw, 74px);
  font-weight: 400;
  letter-spacing: -0.06em;
  line-height: 0.94;
}

.intro-panel h1 em {
  color: var(--mint);
  font-style: italic;
}

.intro-copy {
  position: relative;
  z-index: 1;
  max-width: 410px;
  margin: 0;
  color: #aec0c8;
  font-size: 15px;
  line-height: 1.65;
}

.signal-strip {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: auto;
  padding-top: 42px;
}

.signal-item {
  display: grid;
  gap: 7px;
  border-top: 1px solid #48657a;
  padding-top: 11px;
}

.signal-label {
  color: #91a8b7;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.signal-item strong {
  color: var(--paper-bright);
  font-family: Georgia, serif;
  font-size: 27px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.legend-block {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 9px;
  margin-top: 32px;
}

.legend-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #91a8b7;
  font-size: 11px;
}

.legend-key {
  width: 8px;
  height: 8px;
}

.legend-key.mint {
  background: var(--mint);
}

.legend-key.coral {
  background: var(--coral);
}

.quiz-panel {
  position: relative;
  display: flex;
  min-height: 670px;
  flex-direction: column;
  padding: clamp(23px, 3vw, 43px) clamp(20px, 4vw, 55px) 27px;
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: panel-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.quiz-panel::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 115px;
  height: 9px;
  background: var(--mint);
  content: "";
}

.quiz-mode-view {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.quiz-topline,
.quiz-footer,
.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quiz-topline {
  color: var(--muted);
  justify-content: flex-end;
}

.progress-meta {
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 22px;
}

.progress-slash {
  padding: 0 5px;
  color: #a8ada8;
  font-family: "Avenir Next", sans-serif;
  font-size: 12px;
}

.progress-track {
  height: 5px;
  margin-top: 15px;
  overflow: hidden;
  background: #ddd8cd;
}

.progress-track span {
  display: block;
  width: 10%;
  height: 100%;
  background: var(--coral);
  transition: width 360ms ease;
}

.question-copy {
  margin: 25px 0 25px;
}

.question-copy h2 {
  max-width: 860px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 2.5vw, 36px);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

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

.choice-button {
  display: grid;
  min-height: 68px;
  grid-template-columns: 31px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid #c7c2b7;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.72);
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.choice-button:hover:not(:disabled) {
  border-color: var(--ink-soft);
  background: var(--paper-bright);
  transform: translateY(-2px);
}

.choice-button:disabled {
  cursor: default;
}

.choice-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--muted);
  border: 1px solid #d7d1c5;
  font-size: 12px;
  font-weight: 700;
}

.choice-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.choice-button.selected-correct,
.choice-button.correct-reveal {
  border-color: var(--mint-deep);
  background: var(--mint);
}

.choice-button.selected-correct .choice-number,
.choice-button.correct-reveal .choice-number {
  color: var(--ink);
  border-color: var(--mint-deep);
}

.choice-button.selected-wrong {
  border-color: var(--coral-deep);
  background: #ffd1c7;
}

.choice-button.selected-wrong .choice-number {
  color: var(--coral-deep);
  border-color: var(--coral-deep);
}

.matching-heading {
  margin: 25px 0 18px;
}

.matching-kicker {
  color: var(--mint-deep);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.matching-heading h2 {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 2.5vw, 35px);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.18;
}

.matching-list {
  display: grid;
  gap: 9px;
}

.matching-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) minmax(175px, 225px);
  align-items: center;
  gap: 13px;
  border: 1px solid #c7c2b7;
  padding: 10px 12px;
  background: rgba(255, 253, 248, 0.72);
  transition: border-color 150ms ease, background 150ms ease;
}

.matching-letter {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid #d7d1c5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.matching-text {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}

.matching-control {
  display: grid;
  gap: 5px;
}

.matching-select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #b9b2a5;
  border-radius: 0;
  padding: 8px 9px;
  color: var(--ink);
  background: var(--paper-bright);
  font-size: 12px;
  font-weight: 700;
}

.matching-answer {
  color: var(--mint-deep);
  font-size: 10px;
  line-height: 1.25;
}

.matching-row.is-correct {
  border-color: var(--mint-deep);
  background: #e2f4e9;
}

.matching-row.is-wrong {
  border-color: var(--coral-deep);
  background: #f9e5dd;
}

.matching-row.is-wrong .matching-answer {
  color: var(--coral-deep);
}

.matching-feedback {
  margin-top: 17px;
  border-left: 5px solid var(--mint-deep);
  padding: 14px 18px;
  background: #e8eee7;
}

.matching-feedback.is-wrong {
  border-left-color: var(--coral-deep);
  background: #f9e5dd;
}

.matching-feedback strong {
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 400;
}

.matching-feedback p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

.matching-submit:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.matching-footer {
  gap: 10px;
}

.feedback {
  margin-top: 20px;
  border-left: 5px solid var(--mint-deep);
  padding: 18px 22px;
  background: #e8eee7;
}

.feedback.is-wrong {
  border-left-color: var(--coral-deep);
  background: #f9e5dd;
}

.explanation-box {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.explanation-label {
  padding-top: 3px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.35;
}

.explanation-box p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.5;
}

.quiz-footer {
  margin-top: auto;
  justify-content: flex-end;
  padding-top: 28px;
}

.next-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 43px;
  border: 0;
  padding: 10px 17px;
  color: var(--paper-bright);
  background: var(--ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 150ms ease, transform 150ms ease;
}

.next-button:hover,
.primary-button:hover {
  background: var(--coral-deep);
  transform: translateY(-2px);
}

.next-button span:last-child,
.primary-button span:last-child {
  color: var(--mint);
  font-size: 19px;
  line-height: 0.7;
}

.results-panel {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 40px;
  color: var(--paper);
  background: var(--ink);
  text-align: center;
  animation: panel-in 360ms ease both;
}

.results-kicker {
  color: var(--mint);
  font-weight: 800;
}

.results-panel h2 {
  margin: 16px 0 8px;
  color: var(--paper-bright);
  font-family: Georgia, serif;
  font-size: clamp(38px, 5vw, 64px);
  font-weight: 400;
  letter-spacing: -0.05em;
}

.results-panel p {
  max-width: 330px;
  margin: 0;
  color: #adc0c8;
  line-height: 1.6;
}

.results-language-count {
  display: grid;
  gap: 2px;
  margin: 28px 0;
}

.results-language-count span {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 52px;
  line-height: 0.9;
}

.results-language-count small {
  color: #adc0c8;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.primary-button {
  color: var(--ink);
  background: var(--mint);
}

.primary-button:hover {
  color: var(--paper-bright);
  background: var(--coral-deep);
}

.app-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  color: #718896;
  font-size: 9px;
  letter-spacing: 0.14em;
}

.footer-rule {
  width: 45px;
  height: 1px;
  background: #45677e;
}

[hidden] {
  display: none !important;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .intro-panel {
    min-height: auto;
    padding-bottom: 29px;
  }

  .intro-panel h1 {
    margin-top: 22px;
    font-size: clamp(45px, 10vw, 72px);
  }

  .intro-copy {
    max-width: 550px;
  }

  .signal-strip {
    max-width: 560px;
    margin-top: 32px;
    padding-top: 0;
  }

  .legend-block {
    display: flex;
    gap: 20px;
    margin-top: 23px;
  }

  .quiz-panel {
    min-height: 650px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 18px 12px 15px;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 23px;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    justify-items: end;
  }

  .mode-switch {
    grid-column: 1 / -1;
    width: 100%;
  }

  .mode-button {
    flex: 1;
  }

  .brand-copy strong {
    font-size: 10px;
    letter-spacing: 0.11em;
  }

  .brand-copy small,
  .bank-count {
    font-size: 8px;
  }

  .icon-button {
    width: 35px;
    height: 35px;
  }

  .intro-panel,
  .quiz-panel {
    padding-right: 18px;
    padding-left: 18px;
  }

  .intro-panel h1 {
    margin-top: 20px;
    font-size: clamp(43px, 15vw, 65px);
  }

  .intro-copy {
    font-size: 14px;
  }

  .signal-strip {
    gap: 8px;
  }

  .signal-item strong {
    font-size: 23px;
  }

  .legend-block {
    display: grid;
    gap: 8px;
  }

  .quiz-panel {
    min-height: 650px;
  }

  .question-copy {
    margin-top: 20px;
  }

  .question-copy h2 {
    font-size: clamp(24px, 6.5vw, 32px);
    line-height: 1.22;
  }

  .matching-heading {
    margin-top: 20px;
  }

  .matching-heading h2 {
    font-size: clamp(24px, 6.5vw, 32px);
  }

  .matching-row {
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 10px;
  }

  .matching-control {
    grid-column: 2;
  }

  .matching-text {
    font-size: 13px;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

  .choice-button {
    min-height: 59px;
  }

  .explanation-box {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .explanation-box p {
    font-size: 15px;
  }

  .quiz-footer {
    padding-top: 22px;
  }

  .next-button {
    padding-right: 13px;
    padding-left: 13px;
    font-size: 10px;
  }

  .app-footer {
    flex-wrap: wrap;
    line-height: 1.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
