@font-face {
  font-family: "Roboto";
  src: url("../assets/Roboto-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #1d2528;
  --muted: #617077;
  --paper: #fffaf1;
  --paper-strong: #ffffff;
  --line: rgba(29, 37, 40, 0.15);
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --wrong: #a33a2d;
  --shadow: 0 24px 70px rgba(17, 24, 28, 0.26);
}

* {
  box-sizing: border-box;
}

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

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

button:focus-visible,
.choice:focus-visible,
.blank-input:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.45);
  outline-offset: 3px;
}

.app {
  min-height: 100vh;
  padding: clamp(14px, 3vw, 36px);
  display: grid;
  place-items: center;
}

.stage {
  position: relative;
  width: min(1120px, 100%);
  min-height: min(760px, calc(100vh - 28px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #243339;
  box-shadow: var(--shadow);
}

.scene {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(180deg, rgba(11, 21, 23, 0.18), rgba(11, 21, 23, 0.56)),
    var(--story-background);
  background-position: center;
  background-size: cover;
}

.topbar,
.controls,
.dialogue-panel,
.quiz-panel,
.results-panel,
.start-panel {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(18px, 3vw, 34px);
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 5px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 650px;
  font-size: clamp(1.65rem, 4.5vw, 3.25rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.progress {
  width: min(230px, 34vw);
  min-width: 150px;
  padding-top: 8px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
}

.progress-track {
  height: 8px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #f3d27a;
  transition: width 180ms ease;
}

.dialogue-panel {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 18px;
  width: min(860px, calc(100% - 32px));
  margin: clamp(130px, 19vh, 210px) auto 0;
  align-items: end;
}

.dialogue-panel.reference {
  margin-top: clamp(38px, 6vh, 72px);
}

.dialogue-panel.right {
  grid-template-columns: minmax(0, 1fr) 132px;
}

.dialogue-panel.right .speaker-wrap {
  grid-column: 2;
}

.dialogue-panel.right .bubble {
  grid-column: 1;
  grid-row: 1;
}

.speaker-wrap {
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
}

.speaker-image {
  width: 128px;
  height: 128px;
  object-fit: contain;
  filter: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.3));
}

.bubble,
.quiz-panel {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.94);
  box-shadow: 0 18px 46px rgba(12, 20, 22, 0.24);
  backdrop-filter: blur(12px);
}

.bubble {
  min-height: 150px;
  padding: clamp(18px, 3vw, 28px);
}

.speaker-name,
.quiz-label {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.line-text {
  margin: 0;
  font-size: clamp(1.08rem, 2.25vw, 1.65rem);
  line-height: 1.28;
  font-weight: 650;
}

.cloze-line {
  line-height: 1.75;
}

.audio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.audio-row .speaker-name {
  margin: 0;
}

.audio-button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  background: #eef8f5;
  color: var(--accent-dark);
  font-size: 0.86rem;
  box-shadow: none;
}

.blank-input {
  display: inline-block;
  min-width: 9ch;
  max-width: min(100%, 28ch);
  margin: 0 4px;
  padding: 3px 7px 4px;
  border: 0;
  border-bottom: 3px solid rgba(15, 118, 110, 0.55);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: center;
}

.blank-input.is-correct {
  border-bottom-color: var(--accent);
  background: #e7f6ef;
}

.blank-input.is-wrong {
  border-bottom-color: var(--wrong);
  background: #fff0ec;
}

.filled-answer {
  display: inline;
  margin: 0 2px;
  color: var(--accent-dark);
  font-weight: 850;
}

.revealed-answer {
  display: inline;
  margin: 0 2px;
  color: #7f1d1d;
  font-weight: 850;
}

.quiz-panel,
.results-panel,
.start-panel {
  width: min(720px, calc(100% - 32px));
  margin: clamp(70px, 13vh, 150px) auto 0;
  padding: clamp(18px, 3vw, 30px);
}

.quiz-panel.with-reference {
  margin-top: 18px;
}

.quiz-panel h2,
.results-panel h2,
.start-panel h2 {
  margin: 0;
  font-size: clamp(1.12rem, 2.4vw, 1.55rem);
  line-height: 1.24;
  letter-spacing: 0;
}

.results-panel,
.start-panel {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.94);
  box-shadow: 0 18px 46px rgba(12, 20, 22, 0.24);
  backdrop-filter: blur(12px);
  text-align: center;
}

.panel-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 20px;
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
  text-decoration: none;
}

.panel-link-button:hover {
  background: var(--accent-dark);
}

.secondary-link {
  margin-left: 10px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  background: #eef8f5;
  color: var(--accent-dark);
}

.secondary-link:hover {
  background: #d9eee8;
}

.menu-panel {
  text-align: left;
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.menu-actions .panel-link-button {
  margin-top: 0;
}

.score-text {
  margin: 18px 0 0;
  color: var(--accent-dark);
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  font-weight: 850;
}

.results-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 650;
}

.choices {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.choice {
  width: 100%;
  min-height: 54px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  color: var(--ink);
  text-align: left;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.choice:hover:not(:disabled) {
  border-color: rgba(15, 118, 110, 0.5);
  transform: translateY(-1px);
}

.choice.is-correct {
  border-color: var(--accent);
  background: #e7f6ef;
}

.choice.is-wrong {
  border-color: var(--wrong);
  background: #fff0ec;
}

.feedback {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--muted);
  font-weight: 650;
}

.feedback.error {
  color: var(--wrong);
}

.controls {
  position: absolute;
  right: clamp(16px, 3vw, 34px);
  bottom: clamp(16px, 3vw, 34px);
  left: clamp(16px, 3vw, 34px);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.controls button {
  min-width: 132px;
  min-height: 48px;
  padding: 12px 18px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 76, 74, 0.24);
}

.controls button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.controls .secondary {
  border: 1px solid rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.controls .secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.26);
}

button:disabled {
  cursor: default;
  opacity: 0.48;
}

.is-hidden {
  display: none;
}

@media (max-width: 720px) {
  .stage {
    min-height: calc(100vh - 28px);
  }

  .topbar {
    display: grid;
  }

  .progress {
    width: 100%;
    text-align: left;
  }

  .dialogue-panel,
  .dialogue-panel.right {
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 12px;
    width: calc(100% - 24px);
    margin-top: 80px;
  }

  .dialogue-panel.right {
    grid-template-columns: minmax(0, 1fr) 78px;
  }

  .speaker-wrap {
    width: 78px;
    height: 78px;
  }

  .speaker-image {
    width: 76px;
    height: 76px;
  }

  .bubble {
    min-height: 132px;
  }

  .audio-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls button {
    min-width: 0;
    flex: 1;
  }
}
