:root {
  --bg: #f4f6fb;
  --blue: #3058ff;
  --dark-blue: #1b2c4d;
  --light-blue: #dfe8ff;
  --green: #3fa66c;
  --red: #e25a5a;
  --text: #102040;
  --muted: #6b7a99;
  --border: #e0e6f3;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

html {
  font-size: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

main {
  min-height: 100vh;
}

.screen {
  display: none;
  min-height: 100vh;
}

.screen.is-active {
  display: flex;
}


.primary-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 2.5rem;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(33, 99, 255, 0.25);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-btn:disabled {
  background: var(--border);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}

.primary-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(33, 99, 255, 0.35);
}


/* Start screen */
.screen--start {
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1.5rem, 5vw, 3rem);
  background: url("images/bg.png") center/cover no-repeat;
  position: relative;
}

.start-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.25rem, 3vw, 2.5rem);
  width: min(780px, 95vw);
  margin-top: clamp(2rem, 16vh, 6rem);
}

.start-logo {
  position: absolute;
  top: clamp(1rem, 3vw, 2.5rem);
  right: clamp(1rem, 3vw, 2.5rem);
  width: clamp(100px, 16vw, 160px);
  height: auto;
  z-index: 2;
}

.start-hero__banner {
  width: 100%;
  display: block;
}

.start-hero__banner img {
  width: 100%;
  height: auto;
  display: block;
}

.start-btn {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
}

.start-btn img {
  display: block;
  width: min(340px, 70vw);
  height: auto;
}

.chat-btn {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
}

.chat-btn img {
  display: block;
  width: min(260px, 60vw);
  height: auto;
}

.chat-btn:not(:disabled):hover {
  box-shadow: none;
  transform: translateY(-3px);
}

.start-btn:not(:disabled):hover {
  box-shadow: none;
  transform: translateY(-4px);
}


/* Rail */
.rail {
  width: 90px;
  background: var(--dark-blue);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0;
  gap: 2rem;
}

.rail--decorative {
  background: #6f4a2a;
  background: linear-gradient(180deg, #6f4a2a 0%, #a56c3f 100%);
  align-items: center;
  justify-content: flex-start;
  padding-top: 3rem;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.42), 0 6px 14px rgba(0, 0, 0, 0.32);
  position: relative;
  z-index: 3;
}

.rail__icons {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  width: 100%;
  margin-top: 3.5rem;
}

.rail-icon {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #fff;
  display: grid;
  place-items: center;
  color: #fff;
  position: relative;
}

.rail-icon--character.is-active {
  background: #d2a16f;
}

.rail-icon--character:hover {
  cursor: pointer;
}

.rail-icon--message.is-active {
  background: #d2a16f;
}

.rail-icon:first-child {
  border-top: 1px solid #fff;
}

.rail-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-icon img {
  width: 85%;
  height: 85%;
  object-fit: contain;
  display: block;
}

.rail-icon__badge {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e53935;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}

.rail-icon__badge.is-shaking {
  animation: rail-badge-bounce 1.1s ease-in-out infinite;
  transform-origin: center;
}

@keyframes rail-badge-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Selection screen */
.screen--selection {
  flex: 1;
  background: var(--bg);
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
}

.screen--selection.is-active {
  display: grid;
  grid-template-rows: auto 1fr;
  background: url("images/bg_selection.png") center/cover no-repeat;
}

.selection-hero {
  width: 100%;
  background: #a38261;
  color: #fff;
  height: 90px;
  padding: 0 clamp(1.5rem, 4vw, 3rem);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.selection-hero__banner {
  width: 100%;
  max-width: min(880px, 94vw);
  display: block;
  height: 100%;
  max-height: 80px;
  object-fit: contain;
}

.selection-hero__npc {
  position: absolute;
  left: 62px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  font-weight: 700;
  z-index: 3;
}

.selection-hero__npc.is-visible {
  display: inline-flex;
}

.selection-hero__npc.is-hidden {
  display: none;
}

.selection-hero__npc-avatar {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  color: #254368;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.16);
}

.selection-hero__npc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.selection-hero__npc-name {
  font-size: 1.6rem;
  color: #f7d5ad;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.selection-hero h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
}


.selection-layout {
  flex: 1;
  display: flex;
  width: 100%;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.selection {
  --selection-left-width: 420px;
  --selection-toggle-width: 20px;
  flex: 1;
  position: relative;
  display: flex;
  align-items: stretch;
  height: 100%;
  min-height: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0 24px 24px 0;
  overflow: hidden;
}

.selection.has-preview {
  border: none;
}

.selection.is-mobile-list {
  border-top: none;
}

.selection__left {
  flex: 0 0 var(--selection-left-width);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 10px 10px 0;
  border-right: 1px solid var(--border);
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  background: url("images/bg_selection_left.png") center/cover no-repeat;
  transition: width 200ms ease, opacity 200ms ease;
}

.selection__body {
  flex: 1;
  display: none;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0;
  height: 100%;
  min-height: 0;
  background: transparent;
  position: relative;
}

.selection.show-notice .selection__body {
  display: flex;
}

.selection-notice {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.selection-notice img {
  max-width: 80%;
  width: 80%;
  height: auto;
  display: block;
}

.selection.show-notice .lesson-preview {
  display: none;
}

.mobile-back-btn {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: none;
  z-index: 4;
}

.mobile-back-btn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mobile-back-btn.is-hidden {
  display: none !important;
}

.selection.has-preview .selection__body,
.selection.is-chat-mode .selection__body {
  display: flex;
}

.selection__top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 0 0;
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  min-width: 0;
}

.select-wrap {
  background: transparent;
  border-radius: 6px;
  padding: 0;
  border: none;
  width: 100%;
  box-shadow: none;
}

.custom-select {
  position: relative;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.custom-select__toggle {
  width: 100%;
  background: #704216;
  color: #fff;
  border: none;
  border-radius: 6px;
  height: 50px;
  padding: 0 2.5rem 0 1.1rem;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: left;
  cursor: pointer;
  position: relative;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.custom-select__label {
  font-size: 1.4rem;
}

.custom-select__chevron {
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
}

.custom-select__chevron::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  border-right: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(45deg);
  margin: auto;
}

.custom-select.is-open .custom-select__chevron::before {
  transform: rotate(-135deg) translateY(-4px);
}

.custom-select__list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #d6d6d6;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.18);
  border-top: 1px solid #fff;
  overflow: hidden;
  display: none;
}

.custom-select.is-open .custom-select__list {
  display: block;
}

.custom-select__option {
  width: 100%;
  border: none;
  background: #d6d6d6;
  color: #704216;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
  padding: 0.3rem 1.1rem;
  text-align: left;
  cursor: pointer;
  border-bottom: 3px solid #fff;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.9);
}

.custom-select__list li {
  margin: 0;
  padding: 0;
}

.custom-select__option:last-child {
  border-bottom: none;
}

.custom-select__option.is-selected {
  background: #835f3b;
  color: #fff;
}

.custom-select__option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.selection-toggle {
  position: absolute;
  top: 50%;
  left: calc(var(--selection-left-width) + (var(--selection-toggle-width) / 2));
  transform: translate(-50%, -50%);
  width: var(--selection-toggle-width);
  height: 60px;
  border-radius: 0 12px 12px 0;
  border: 2px solid #fff;
  border-left: none;
  background: #c1c1c1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  color: #fff;
  cursor: pointer;
  transition: left 200ms ease, transform 200ms ease;
  z-index: 2;
}

.selection-toggle span {
  display: inline-block;
  transform: translateX(-3px);
}

.selection.is-collapsed {
  --selection-left-width: calc(var(--selection-toggle-width) + 2px);
}

.selection.is-collapsed .selection__left {
  flex-basis: 0;
  width: 0;
  opacity: 0;
  pointer-events: none;
  border-right: none;
  padding: 0;
}

.selection.is-collapsed .selection__top,
.selection.is-collapsed .lesson-list {
  display: none;
}

.selection.is-collapsed .selection-toggle {
  left: calc(var(--selection-toggle-width) / 2);
  transform: translate(-50%, -50%);
}

.placeholder-card {
  background: #fff;
  border-radius: 18px;
  padding: 1.5rem;
  border: 1px dashed var(--border);
  color: var(--muted);
}

.lesson-card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.2rem;
  border: 2px solid #fff;
  appearance: none;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  min-height: 72px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
  position: relative;
}

.lesson-card[data-ready="true"] {
  --ready-left-width: calc(72px * 72 / 150);
  --ready-right-width: calc(72px * 75 / 150);
  color: #fff;
  box-shadow: none;
  outline: none;
  border-style: solid;
  border-width: 0 var(--ready-right-width) 0 var(--ready-left-width);
  border-image-source: url("images/lesson_border_ready.png");
  border-image-slice: 0 75 0 72 fill;
  border-image-repeat: stretch;
  border-image-width: 0 var(--ready-right-width) 0 var(--ready-left-width);
  background: none;
}

.lesson-card[data-ready="false"] {
  background: #b0b0b0;
  color: #fff;
  border-color: #fff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.14);
  opacity: 1;
  cursor: not-allowed;
}

.lesson-card[data-ready="false"]:disabled {
  --not-ready-left-width: calc(72px * 72 / 150);
  --not-ready-right-width: calc(72px * 75 / 150);
  min-height: 72px;
  border-style: solid;
  border-width: 0 var(--not-ready-right-width) 0 var(--not-ready-left-width);
  border-image-source: url("images/lesson_border_not_ready.png");
  border-image-slice: 0 75 0 72 fill;
  border-image-repeat: stretch;
  border-image-width: 0 var(--not-ready-right-width) 0 var(--not-ready-left-width);
  background: none;
  box-shadow: none;
  outline: none;
  transform: none;
  transition: none;
}

.lesson-card[data-ready="false"]:disabled .lesson-card__title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-card[data-ready="false"]:disabled:hover,
.lesson-card[data-ready="false"]:disabled.is-selected {
  box-shadow: none;
  outline: none;
  transform: none;
}

.lesson-card[data-ready="false"]::before {
  content: "敬請期待";
  position: absolute;
  top: -14px;
  left: 10px;
  background: #7a7a7a;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 6px;
  padding: 4px 12px 3px;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.18);
  letter-spacing: 0.05em;
}

.lesson-card:hover {
  transform: translateX(4px);
}

.lesson-card.is-selected {
  color: #fff;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
  outline: 2px solid #fff;
  outline-offset: 0;
}

.lesson-card[data-ready="true"].is-selected {
  border-image-source: url("images/lesson_border_selected.png");
  background: none;
  box-shadow: none;
  outline: none;
}

.lesson-card__title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.3;
  display: flex;
  align-items: center;
}

.lesson-preview {
  background: transparent;
  border-radius: 24px;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2vh, 1.75rem);
  text-align: center;
  height: 100%;
  min-height: 100%;
}

.preview-avatar {
  width: clamp(180px, 35vh, 330px);
  height: clamp(180px, 35vh, 330px);
  border-radius: 50%;
  background: transparent;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 4rem;
  margin: clamp(12px, 6vh, 60px) auto 0;
  overflow: hidden;
}

.preview-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: clamp(-30px, -6vh, -40px);
}

.preview-title {
  margin: 0.5rem 0 0.2rem;
  font-size: clamp(1.4rem, 3vw, 2.5rem);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-family: "Chiron GoRound TC", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
    sans-serif;
  color: #fff;
  padding: 0.3rem 0.8rem;
  letter-spacing: 0.08em;
  z-index: 1;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0.09em 0 #783f04, -0.09em 0 #783f04, 0 0.09em #783f04,
    0 -0.09em #783f04, 0.065em 0.065em #783f04, -0.065em 0.065em #783f04,
    0.065em -0.065em #783f04, -0.065em -0.065em #783f04;
}

.preview-desc {
  color: #783f04;
  margin-bottom: 1.5rem;
  font-size: clamp(1rem, 2.4vw, 1.8rem);
  font-weight: 700;
  max-width: 38ch;
  white-space: pre-wrap;
  margin-top: 0.25rem;
}

@media (max-width: 960px) {
  .selection {
    border-radius: 0;
  }

  .selection__left,
  .selection__body {
    flex: 1 1 auto;
    width: 100%;
  }

  .selection__body {
    display: none;
  }

  .selection.has-preview .selection__left {
    display: none;
  }

  .selection.has-preview .selection__body {
    display: flex;
  }

  .selection.show-notice .selection__body {
    display: flex;
  }

  .selection.is-mobile-list .selection__left {
    display: flex;
  }

  .selection.is-mobile-list .selection__body {
    display: none;
  }

  .selection.has-preview.is-mobile-list .selection__left {
    display: flex;
  }

  .selection.has-preview.is-mobile-list .selection__body {
    display: none;
  }

  .selection .selection-toggle {
    display: none;
  }

  .mobile-back-btn {
    display: flex;
  }

}

/* Chat panel */
.chat-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 0;
  gap: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: transparent;
  border-radius: 24px;
}

.selection.is-chat-mode .lesson-preview {
  display: none;
}

.selection.is-chat-mode .chat-panel {
  display: flex;
}

.chat-log {
  background: transparent;
  border-radius: 24px;
  flex: 1;
  padding: 1rem 1.5rem;
  overflow-y: auto;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  padding-bottom: 3.5rem;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 2.25rem;
  align-items: flex-start;
  width: 100%;
}

.message.message--npc {
  align-items: center;
}

.message--player {
  justify-content: flex-end;
}

.message__bubble {
  background: #fff;
  padding: 1.1rem 2rem;
  border-radius: 18px;
  max-width: min(480px, 90%);
  box-shadow: 0 6px 18px rgba(25, 64, 120, 0.1);
  white-space: pre-wrap;
  font-size: 1.12rem;
  font-weight: 700;
}

.message__bubble--image {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.message__image {
  display: block;
  max-width: min(420px, 85vw);
  width: 100%;
  height: auto;
  border-radius: 14px;
  object-fit: contain;
}

.message--player .message__bubble {
  background: #a7e3b3;
  color: #000;
  margin-left: auto;
}

.message--player .message__bubble.is-wrong {
  background: #ffc6da;
  color: #000;
}

.message.message--npc .message__bubble {
  margin-right: 90px;
}

.message__avatar {
  width: 120px;
  height: 120px;
  flex: 0 0 120px;
  border-radius: 50%;
  background: transparent;
  border: none;
  box-shadow: none;
  outline: none;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-weight: 600;
  overflow: hidden;
  cursor: pointer;
}

.message__avatar--spacer {
  visibility: hidden;
  flex: 0 0 120px;
  width: 120px;
  height: 120px;
  cursor: default;
}

.message--player .message__avatar {
  display: none;
}

.preview-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.message__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.option-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #e2ecf6;
  padding: 0.3rem 1.5rem;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
  width: 300px;
  margin: 0 auto;
}

.option-btn:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.option-btn.is-correct {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.option-btn.is-wrong {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.9;
}

.chat-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  background: transparent;
  padding: 1rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  width: 100%;
  border-top: 1px solid var(--border);
  border-radius: 0 0 24px 24px;
  background: url("images/bg_answers.png") center/cover no-repeat;
}

.author-dialog {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.author-dialog.is-open {
  display: flex;
}

.author-dialog__mask {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
}

.author-dialog__panel {
  position: relative;
  width: 60vw;
  max-width: 960px;
  min-width: 320px;
  aspect-ratio: 16 / 9;
  background: url("images/dialog_wide.png") center/contain no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  overflow: hidden;
}

.author-dialog__close {
  position: absolute;
  top: 0;
  right: 0;
  transform: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #a38261;
  color: #fff;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

.lesson-preview--dialog {
  width: min(82%, 620px);
  height: min(84%, 560px);
  min-height: 0;
  padding: clamp(0.6rem, 1.8vw, 1.4rem) clamp(0.9rem, 2.6vw, 1.8rem);
  gap: clamp(0.25rem, 1vw, 0.7rem);
  justify-content: space-between;
  max-width: calc(100% - clamp(1rem, 4vw, 2.6rem));
  max-height: calc(100% - clamp(1rem, 4vw, 2.6rem));
  overflow: hidden;
}

.lesson-preview--dialog .preview-avatar {
  width: clamp(72px, 14vw, 170px);
  height: clamp(72px, 14vw, 170px);
  margin-top: clamp(0.05rem, 0.4vw, 0.3rem);
  flex-shrink: 1;
}

.lesson-preview--dialog .preview-info {
  margin-top: 0;
  width: 100%;
  height: 50%;
  min-height: 50%;
  padding: 0 clamp(0.4rem, 1.6vw, 1rem);
  justify-content: center;
  gap: clamp(0.08rem, 0.45vw, 0.3rem);
}

.lesson-preview--dialog .preview-title {
  font-size: clamp(1.05rem, 2.5vw, 2rem);
  white-space: normal;
  line-height: 1.1;
}

.lesson-preview--dialog .preview-desc {
  font-size: clamp(0.8rem, 1.45vw, 1.2rem);
  max-width: min(34ch, 100%);
  margin-top: 0;
  line-height: 1.3;
}

.lesson-preview--dialog .preview-desc {
  margin-bottom: 0;
}

body.is-author-dialog-open {
  overflow: hidden;
}

@supports (height: 100dvh) {
  main {
    min-height: 100dvh;
  }

  .screen {
    min-height: 100dvh;
  }

  .screen--selection {
    min-height: 100dvh;
    height: 100dvh;
  }
}

.chat-controls__options {
  width: 100%;
}

.helper-text {
  margin: 1.2rem 0 0;
  font-size: 1rem;
  color: #fff;
  background: #404040;
  padding: 0.5rem 1.4rem;
  border-radius: 999px;
  display: inline-block;
  white-space: pre-line;
  text-align: center;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 960px) {
  .rail {
    display: none;
  }
  .screen--selection.is-active {
    flex-direction: column;
  }
  .selection {
    flex-direction: column;
    border-radius: 0 0 24px 24px;
  }
  .selection__left {
    flex: 1;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 10px 0;
    opacity: 1 !important;
    pointer-events: auto;
  }
  .selection.is-collapsed .selection__left {
    opacity: 1;
    pointer-events: auto;
    padding: 0;
  }
  .selection-toggle {
    display: none;
  }
}

@media (max-width: 600px) {
  .screen--start {
    background-image: url("images/bg_mobile.png");
  }
  .screen--selection.is-active {
    background-image: url("images/bg_selection_mobile.png");
  }
  .selection-hero__banner {
    object-position: right center;
  }
  .selection-hero.is-npc-hidden .selection-hero__banner {
    object-position: center;
  }
  .preview-avatar {
    margin-top: clamp(6px, 3vh, 30px);
  }
  .chat-log {
    padding-left: 0;
    padding-right: 10px;
  }
  .lesson-preview {
    padding: 1.2rem;
  }
  .message__bubble {
    max-width: 100%;
    padding: 1.1rem;
  }

  .selection-hero__npc {
    left: 54px;
    gap: 0.4rem;
  }

  .selection-hero__npc-avatar {
    width: 44px;
    height: 44px;
    font-size: 0.95rem;
  }

  .selection-hero__npc-name {
    font-size: 1.2rem;
  }

  .message {
    gap: 0.5rem;
  }

  .message.message--npc .message__bubble {
    margin-right: 50px;
  }

  .message__avatar {
    width: 90px;
    height: 90px;
    flex: 0 0 90px;
  }

  .message__avatar img {
    width: 80%;
    height: 80%;
  }
}

@media (orientation: portrait) {
  .author-dialog__panel {
    width: min(92vw, 600px);
    aspect-ratio: 720 / 684;
    background-image: url("images/dialog_mobile.png");
    background-size: 100% 100%;
  }

  .author-dialog__close {
    top: 7%;
    right: 8%;
    transform: translate(50%, -50%);
    width: 40px;
    height: 40px;
  }

  .lesson-preview--dialog {
    width: min(80%, 480px);
    height: min(84%, 540px);
    padding: clamp(0.55rem, 2.2vw, 1.2rem) clamp(0.75rem, 2.5vw, 1.3rem);
    max-width: calc(100% - clamp(1rem, 4.5vw, 2.1rem));
    max-height: calc(100% - clamp(1rem, 4.5vw, 2.1rem));
  }

  .lesson-preview--dialog .preview-avatar {
    width: clamp(128px, 36vw, 264px);
    height: clamp(128px, 36vw, 264px);
    margin-top: 0;
  }

  .lesson-preview--dialog .preview-title {
    font-size: clamp(0.95rem, 4.4vw, 1.5rem);
  }

  .lesson-preview--dialog .preview-desc {
    font-size: clamp(0.74rem, 2.9vw, 0.98rem);
  }
}
