/* V27: one coherent phone grid for navigation, questions and answer actions. */
:root {
  --v27-ink: #173228;
  --v27-forest: #285746;
  --v27-mist: #e6eee9;
  --v27-paper: #f8faf7;
  --v27-line: rgba(23, 50, 40, 0.14);
}

.track-switch {
  gap: 3px;
  padding: 4px;
  border: 0;
  background: var(--v27-mist);
  box-shadow: none;
}

.track-button,
.track-button.is-active {
  min-width: 0;
  border: 0;
  box-shadow: none;
}

.track-button {
  color: var(--v27-ink);
  background: transparent;
}

.track-button > span,
.track-button.is-active > span {
  background: transparent;
  color: inherit;
}

.track-button.is-active {
  color: #fff;
  background: var(--v27-forest);
}

.hungry-notes-link {
  color: var(--v27-ink);
  background: #dbe7df;
}

.hungry-notes-mark .notes-cover {
  fill: #285746;
  stroke: #173228;
}

.hungry-notes-mark .notes-page {
  fill: #f8faf7;
  stroke: #173228;
}

.hungry-notes-mark .notes-line {
  fill: none;
  stroke: #74977d;
}

.hungry-notes-mark .notes-leaf {
  fill: #a9c49c;
  stroke: #173228;
}

.wallet {
  min-width: 0;
  width: auto;
  justify-content: flex-start;
}

.treehouse-card {
  cursor: pointer;
  touch-action: manipulation;
}

.treehouse-card:focus-visible {
  outline: 3px solid rgba(40, 87, 70, 0.24);
  outline-offset: 2px;
}

.treehouse-upgrade {
  cursor: pointer;
}

.treehouse-upgrade[aria-disabled="true"] {
  opacity: 0.62;
}

.challenge-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto 58px;
  align-items: center;
}

.challenge-meta .round-timer {
  grid-column: -1;
}

.question-heading-row {
  display: block;
  min-width: 0;
}

.question-heading-row h1 {
  min-height: 50px;
  margin: 0;
  overflow-wrap: normal;
  word-break: normal;
}

.choice-wrap:has(.choice-speaker) .choice,
.choice.is-correct,
.choice.is-wrong {
  padding-right: 52px;
  padding-left: 52px;
}

.choice-word,
.choice-pinyin {
  justify-self: center;
  text-align: center;
}

.choice-speaker {
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  background: rgba(40, 87, 70, 0.08);
}

.choice.is-correct,
.choice.is-wrong {
  transform: none;
}

@keyframes answerChoiceCorrect {
  0% { opacity: 0.72; transform: translateY(2px); }
  100% { opacity: 1; transform: none; }
}

.explanation-lock {
  z-index: 20;
  pointer-events: auto;
}

.explanation-lock button {
  position: relative;
  z-index: 21;
  pointer-events: auto;
  touch-action: manipulation;
}

@media (max-width: 720px) {
  body:not(.needs-entry) .topbar {
    grid-template-columns: 34px auto minmax(0, 1fr);
    margin: 0;
  }

  body:not(.needs-entry) .track-switch {
    min-width: 86px;
  }

  body:not(.needs-entry) .track-button {
    width: 39px;
    min-width: 39px;
    height: 34px;
    padding: 4px;
    justify-content: center;
  }

  body:not(.needs-entry) .track-button > span,
  body:not(.needs-entry) .track-button[data-track="en"] > span {
    width: auto;
    height: auto;
    font-size: .68rem;
  }

  body:not(.needs-entry) .track-button small {
    display: none;
  }

  body:not(.needs-entry) .topbar-tools {
    justify-content: flex-end;
  }

  body:not(.needs-entry) .hungry-notes-link {
    min-width: 56px;
    padding: 4px 6px;
    gap: 4px;
  }

  body:not(.needs-entry) .hungry-notes-link svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
  }

  body:not(.needs-entry) .hungry-notes-link span {
    max-width: none;
    overflow: visible;
    font-size: .55rem;
    text-overflow: clip;
  }

  body:not(.needs-entry) .wallet {
    min-width: 74px;
    max-width: 96px;
    padding: 4px 5px;
    gap: 4px;
    justify-content: center;
  }

  body:not(.needs-entry) .wallet .leaf-icon {
    width: 14px;
    height: 14px;
  }

  body:not(.needs-entry) #leafCount {
    min-width: 20px;
    font-size: .78rem;
    text-align: center;
  }

  body:not(.needs-entry) .wallet-redeem {
    min-height: 25px;
    padding: 3px 5px;
  }

  body:not(.needs-entry) .stage {
    grid-template-rows: auto 98px minmax(0, 1fr);
  }

  body:not(.needs-entry) .mascot-scene,
  body:not(.needs-entry) .mascot-card,
  body:not(.needs-entry) .mascot-bubble {
    min-height: 98px;
    height: 98px;
  }

  body:not(.needs-entry) .mascot-bubble {
    padding: 8px 63px 7px 9px;
  }

  body:not(.needs-entry) .mascot-bubble strong {
    display: block;
    overflow: hidden;
    font-size: .69rem;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:not(.needs-entry) .mascot-bubble > span:last-child {
    display: block;
    overflow: hidden;
    font-size: .57rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:not(.needs-entry) .treehouse-card {
    top: 6px;
    right: 6px;
    bottom: auto;
    z-index: 45;
    grid-template-columns: 40px;
    width: 54px;
    min-width: 54px;
    min-height: 66px;
    padding: 5px;
    gap: 2px;
    overflow: visible;
    border: 0;
    background: rgba(248, 250, 247, .96);
    box-shadow: 0 8px 18px rgba(23, 50, 40, .14);
    transition: width 180ms ease, grid-template-columns 180ms ease, box-shadow 180ms ease;
  }

  body:not(.needs-entry) .treehouse-card.is-open {
    grid-template-columns: 42px minmax(88px, 1fr);
    width: 178px;
    padding: 7px;
    box-shadow: 0 14px 30px rgba(23, 50, 40, .22);
  }

  body:not(.needs-entry) .treehouse-art {
    width: 38px;
    height: 31px;
  }

  body:not(.needs-entry) .treehouse-copy {
    min-width: 0;
  }

  body:not(.needs-entry) .treehouse-copy > span,
  body:not(.needs-entry) .treehouse-upgrade,
  body:not(.needs-entry) .treehouse-tip {
    display: none;
  }

  body:not(.needs-entry) .treehouse-copy small {
    display: block;
    font-size: .52rem;
    text-align: center;
  }

  body:not(.needs-entry) .treehouse-card.is-open .treehouse-copy > span {
    display: flex;
  }

  body:not(.needs-entry) .treehouse-card.is-open .treehouse-copy small {
    text-align: left;
  }

  body:not(.needs-entry) .treehouse-card.is-open .treehouse-upgrade:not([hidden]) {
    display: flex;
    grid-column: 1 / -1;
    min-height: 30px;
  }

  body:not(.needs-entry) .treehouse-card.is-open .treehouse-tip {
    right: 0;
    bottom: auto;
    top: calc(100% + 6px);
  }

  body:not(.needs-entry) .challenge {
    padding: 8px 10px 10px;
    gap: 7px;
    overflow-y: auto;
  }

  body:not(.needs-entry) .challenge-meta {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 54px;
    gap: 7px;
    min-height: 38px;
  }

  body:not(.needs-entry) .challenge-meta #trackLabel,
  body:not(.needs-entry) .challenge-meta #costLabel {
    display: none;
  }

  body:not(.needs-entry) .previous-button,
  body:not(.needs-entry) .pass-button {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    margin: 0;
    padding: 6px 9px;
    border: 0;
    font-size: .7rem;
  }

  body:not(.needs-entry) .challenge-meta > button[hidden] {
    display: none !important;
  }

  body:not(.needs-entry) .previous-button { grid-column: 1; }
  body:not(.needs-entry) .pass-button { grid-column: 2; }
  body:not(.needs-entry) .challenge-meta:has(.pass-button[hidden]) .previous-button:not([hidden]) {
    grid-column: 1 / 3;
  }
  body:not(.needs-entry) .challenge-meta .round-timer {
    grid-column: 3;
    width: 54px;
    min-width: 54px;
    height: 38px;
    min-height: 38px;
    aspect-ratio: auto;
  }

  body:not(.needs-entry) .question-heading-row {
    display: block;
    min-height: 42px;
  }

  body:not(.needs-entry) .question-heading-row h1 {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 2px;
    font-size: .91rem;
    line-height: 1.25;
    white-space: nowrap;
  }

  body:not(.needs-entry) .question-heading-row h1.is-long {
    font-size: .8rem;
    white-space: normal;
  }

  body:not(.needs-entry) .question-heading-row h1.is-very-long {
    font-size: .74rem;
  }

  body:not(.needs-entry) .choice-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
    gap: 8px;
  }

  body:not(.needs-entry) .choice-wrap,
  body:not(.needs-entry) .choice-wrap .choice {
    min-height: 62px;
  }

  body:not(.needs-entry) .choice-wrap .choice,
  body:not(.needs-entry) .choice-wrap:has(.choice-speaker) .choice,
  body:not(.needs-entry) .choice.is-correct,
  body:not(.needs-entry) .choice.is-wrong {
    display: grid;
    place-content: center;
    width: 100%;
    height: 100%;
    padding: 10px 48px;
    border: 0;
    transform: none;
  }

  body:not(.needs-entry) .choice-word {
    font-size: 1rem;
    line-height: 1.15;
  }

  body:not(.needs-entry) .choice-speaker {
    top: 50%;
    right: 12px;
    width: 32px;
    height: 32px;
    transform: translateY(-50%);
  }

  body:not(.needs-entry) .choice-grid.has-examples .choice-wrap,
  body:not(.needs-entry) .choice-grid.has-examples .choice {
    min-height: 86px;
  }

  body:not(.needs-entry) .choice-grid.has-examples .choice-speaker {
    top: 17px;
    transform: none;
  }

  body:not(.needs-entry) .feedback:empty {
    min-height: 0;
    padding: 0;
  }

  body:not(.needs-entry) .result-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    min-height: 42px;
    margin: 0;
  }

  body:not(.needs-entry) .result-actions[hidden] {
    display: none;
  }

  body:not(.needs-entry) .result-actions > button {
    min-height: 42px;
    border: 0;
  }

  body:not(.needs-entry) .result-actions > button:disabled {
    opacity: .48;
    cursor: default;
  }

  body:not(.needs-entry) .explanation-panel {
    position: relative;
    z-index: 10;
    margin: 0;
  }

  body:not(.needs-entry) .explanation-lock {
    z-index: 30;
    inset: 2px 0 0;
    pointer-events: auto;
  }

  body:not(.needs-entry) .explanation-lock button {
    z-index: 31;
    width: min(260px, 100%);
    min-height: 42px;
  }
}

@media (max-width: 390px) {
  body:not(.needs-entry) .topbar {
    padding-right: 5px;
    padding-left: 5px;
  }

  body:not(.needs-entry) .support-link {
    display: none;
  }

  body:not(.needs-entry) .wallet {
    max-width: 92px;
  }

  body:not(.needs-entry) .question-heading-row h1 {
    font-size: .86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .treehouse-card {
    transition: none;
  }
}
