#app,
html,
body {
  height: 100%;
  margin: 0;

  scrollbar-width: none;
}

body {
  opacity: 0.87;
  cursor: default;

  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

.pinyin,
.zhuyin,
.char,
.english,
.output,
#wordsSeen,
#wordsSeenNumber {
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
}

p {

}

#app {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  align-content: center;
}

#welcome {
  animation: fadeInPanda .2s;
}

.fadeIn {
	opacity: 1;
	animation-name: fadeInOpacity;
	animation-iteration-count: 1;
	animation-timing-function: ease-out;
	animation-duration: .1s;
}

@keyframes fadeInOpacity {
	0% {
		opacity: 0;
	}
	100% {
		opacity: 1;
	}
}

#pandaPoof {

  position: absolute;
  bottom: -12px;

  z-index: 1;

}

#panda {
  filter: grayscale(0.5);

  position: absolute;
  bottom: -120px;
  cursor: pointer;

  z-index: 1;
  transition-property: bottom;
  transition-duration: .1s;
  transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#panda.animate-in {
  animation: floatIn .2s ease-out forwards;
}

#panda:hover {
  filter: none;
  opacity: 1;
  bottom: -12px;
}

@keyframes floatIn {
  from { transform: translateY(40px); }
  to { transform: translateY(0); }
}

#panda.fade {
  opacity: 0;
  cursor: default !important;
}

#wordsSeen,
#welcome {
  font-family: "Noto Sans", Fallback, sans-serif;
  font-size: 2em;
  position: absolute;

  top: 0px;

  opacity: 1;

  padding-top: 1em;
  transition: opacity .2s ease-in-out;
  transition-delay: 0.6s;
}

#wordsSeenNumber,
#welcome {
  vertical-align: middle;
  font-size: 4em !important;
}

#easter {
  position: absolute;
  z-index: 100;
}

#wordsSeen.invisible {
  opacity: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 0.87;
  }
}

.char {
  margin: 0 0.1em;

  font-size: clamp(3rem, 23vw, 20rem);

}

@media screen and (max-width: 768px) {
  .char {

    font-size: clamp(2rem, 20vw, 11rem);
  }

  .pinyin {
    font-size: 1.5rem !important;
  }

  .english {
    font-size: 1rem;
  }

  .zhuyin {
    font-size: 2rem !important;
  }

  #wordsSeen {
    font-size: 1rem !important;
  }

  #wordsSeenNumber {
    font-size: 2rem !important;
  }

  #panda {
    width: 160px;
    bottom: -80px;
  }

  #ai {
    margin-bottom: 3rem !important;
    min-height: 4rem !important;

    left:0;
    right:0;
  }

  #ai pre:first-of-type {
    font-size: 2rem !important;
  }

  .output {
    font-size: 1rem !important;
  }

}

@media screen and (max-width: 480px) {
  .char {

    font-size: clamp(2rem, 20vw, 6rem);
  }

  .pinyin {
    font-size: 1.2rem !important;
  }

  .english {
    font-size: 1.5rem !important;
  }

  .zhuyin {
    font-size: 1.6rem !important;
  }

  #wordsSeen {
    font-size: 0.9rem !important;
  }

  #wordsSeenNumber {
    font-size: 1.8rem !important;
  }

  #panda {
    width: 120px;
    bottom: -60px;
  }

  #ai {
    margin-bottom: 3rem !important;
    min-height: 2rem !important;

    left:0;
    right:0;
  }

  #ai pre:first-of-type {
    font-size: 1.5rem !important;
  }

  .output {
    font-size: 1rem !important;
  }

}

:root {
  --font-PingFang: "PingFang SC", "PingFang", "-apple-system", sans-serif;
  --font-Wawati: "Wawati SC", "Wawati", sans-serif;
  --font-Xingkai: "Xingkai SC", "Xingkai", serif;
  --font-HanziPen: "HanziPen SC", "HanziPen", sans-serif;
  --font-Hannotate: "Hannotate SC", "Hannotate", sans-serif;
  --font-Baoli: "Baoli SC", "Baoli", sans-serif;
  --font-LingWai: "LingWai SC", "LingWai", sans-serif;
  --font-Yuanti: "Yuanti SC", "Yuanti", sans-serif;
  --font-Libian: "Libian SC", "Libian", serif;
  --font-Songti: "Songti SC", "Songti", serif;
  --font-Yuppy: "Yuppy SC", "Yuppy", sans-serif;
  --font-BiauKaiTC: "BiauKaiTC", "BiauKai", serif;
  --font-Lantinghei: "Lantinghei SC", "Lantinghei", sans-serif;
  --font-Weibei: "Weibei SC", "Weibei", serif;
  --font-Times: "Times New Roman", "Times", serif;
  --font-Kaiti: "STKaiti", "Kaiti", "KaiTi", serif;
  --font-Heiti: "Heiti SC", "Heiti", sans-serif;
}

body[data-char="traditional"] {
  --font-PingFang: "PingFang TC", "PingFang SC", "PingFang", "-apple-system", sans-serif;
  --font-Wawati: "Wawati TC", "Wawati SC", "Wawati", sans-serif;
  --font-Xingkai: "Xingkai TC", "Xingkai SC", "Xingkai", serif;
  --font-HanziPen: "HanziPen TC", "HanziPen SC", "HanziPen", sans-serif;
  --font-Hannotate: "Hannotate TC", "Hannotate SC", "Hannotate", sans-serif;
  --font-Baoli: "Baoli TC", "Baoli SC", "Baoli", sans-serif;
  --font-LingWai: "LingWai TC", "LingWai SC", "LingWai", sans-serif;
  --font-Yuanti: "Yuanti TC", "Yuanti SC", "Yuanti", sans-serif;
  --font-Libian: "Libian TC", "Libian SC", "Libian", serif;
  --font-Songti: "Songti TC", "Songti SC", "Songti", serif;
  --font-Yuppy: "Yuppy TC", "Yuppy SC", "Yuppy", sans-serif;
  --font-BiauKaiTC: "BiauKaiTC", "BiauKai", serif;
  --font-Lantinghei: "Lantinghei TC", "Lantinghei SC", "Lantinghei", sans-serif;
  --font-Weibei: "Weibei TC", "Weibei SC", "Weibei", serif;
  --font-Times: "Times New Roman", "Times", serif;
  --font-Kaiti: "Kaiti TC", "STKaiti", "Kaiti", "KaiTi", serif;
  --font-Heiti: "Heiti TC", "Heiti SC", "Heiti", sans-serif;
}

.PingFang-font {
  font-family: var(--font-PingFang) !important;
}

.Wawati-font {
  font-family: var(--font-Wawati) !important;
}

.Xingkai-font {
  font-family: var(--font-Xingkai) !important;
}

.HanziPen-font {
  font-family: var(--font-HanziPen) !important;
}

.Hannotate-font {
  font-family: var(--font-Hannotate) !important;
}

.Baoli-font {
  font-family: var(--font-Baoli) !important;
}

.LingWai-font {
  font-family: var(--font-LingWai) !important;
}

.Yuanti-font {
  font-family: var(--font-Yuanti) !important;
}

.Libian-font {
  font-family: var(--font-Libian) !important;
}

.Songti-font {
  font-family: var(--font-Songti) !important;
}

.Yuppy-font {
  font-family: var(--font-Yuppy) !important;
}

.BiauKaiTC-font {
  font-family: var(--font-BiauKaiTC) !important;
}

.Lantinghei-font {
  font-family: var(--font-Lantinghei) !important;
}

.Weibei-font {
  font-family: var(--font-Weibei) !important;
}

.Times-font {
  font-family: var(--font-Times) !important;
}

.Kaiti-font {
  font-family: var(--font-Kaiti) !important;

  margin-bottom: 0.1em;
}

.Heiti-font {
  font-family: var(--font-Heiti) !important;

  margin-bottom: 0.1em;
}

a {
  color: inherit;
  text-decoration: inherit;
}

.charClickable {
  cursor: pointer;
  transition: transform .6s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.charClickable:hover {

  transform: scale(1.01);
  transition-duration: .3s;

}

.pinyin {

  font-family: "Noto Sans", Fallback, sans-serif !important;
  font-size: 2.5rem;
  margin: 0.1em;
  font-weight: bold;

}

.english {
  font-family: "Noto Sans", Fallback, sans-serif;
  font-size: 1.5rem;

  margin: 0.1em !important;
}

 .pos {
    opacity: .5;
  }

.zhuyin {

  font-size: 3rem;
  font-weight: bold;

  margin: 0.1em !important;

}

.hide {
  display: none;
}

.tone1 { background-image: linear-gradient(rgba(227, 0, 0, 0.67), rgba(227, 0, 0, 1));}
.tone2 { background-image: linear-gradient(rgba(2, 179, 28, 0.67), rgba(2, 179, 28, 1));}
.tone3 { background-image: linear-gradient(rgba(36, 32, 255, 0.67), rgba(36, 32, 255, 1));}
.tone4 { background-image: linear-gradient(rgba(160, 16, 218, 0.67), rgba(160, 16, 218, 1));}
.tone5 { background-image: linear-gradient(rgba(0, 0, 0, 0.67), rgba(0, 0, 0, 1));}

.tone1,
.tone2,
.tone3,
.tone4,
.tone5 {

  color: transparent;
  background-clip: text;
}

.tone1::selection {
color: rgba(227, 0, 0, 0.67);
}
.tone2::selection {
color: rgba(2, 179, 28, 0.67);
}
.tone3::selection {
color: rgba(36, 32, 255, 0.67);
}
.tone4::selection {
color: rgba(160, 16, 218, 0.67);
}
.tone5::selection {
color: rgba(0, 0, 0, 0.67);
}
.tone1::selection,
.tone2::selection,
.tone3::selection,
.tone4::selection,
.tone5::selection {
background-color: #c4dbfc;
}

@media (prefers-color-scheme: dark) {

.tone5 { background-image: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 1)); }

.tone1::selection {
color: rgba(227, 0, 0, 1);
}
.tone2::selection {
color: rgba(2, 179, 28, 1);
}
.tone3::selection {
color: rgba(36, 32, 255, 1);
}
.tone4::selection {
color: rgba(160, 16, 218, 1);
}
.tone5::selection {
color: rgba(255, 255, 255, 0.67);
}
.tone1::selection,
.tone2::selection,
.tone3::selection,
.tone4::selection,
.tone5::selection {
background-color: #374964;
}
}

  #ai {

    position: absolute;
    left:0;
    right:0;

    bottom: 0px;

    margin-top: 1em;
    margin-bottom: 4em;

    user-select: text;

  }

  .output {
    font-family: "Noto Sans", Fallback, sans-serif;
    font-size: 2rem;

    opacity: 1;

    text-wrap: balance;

    user-select: text;

    transition: opacity .1s ease-in-out;
    text-align: center;

    margin-top: 0;
    margin-bottom: 0.1em;

}

#ai pre:first-of-type {

  font-size: 3rem;
  margin-bottom: 0.1em;
}

#ai {
  contain: layout paint;
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;

  pointer-events: none;

  z-index: 2;
}

.fsrs-slot {
  font-size: 18px;
  min-height: calc(1.2em + .84em + 2px);
  display: flex;
  align-items: center;
  justify-content: center;

  margin-top: 1.6rem;
  margin-bottom: 1.5rem;
}

.fsrs-rate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  font-size: 18px;

  animation: fsrsRateIn .35s ease-out both;
  animation-delay: .1s;
}

.fsrs-rate-btn {
  font: inherit;
  color: inherit;
  cursor: pointer;

  padding: .42em 1.25em;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;

  opacity: .38;
  transition: opacity .18s ease, border-color .18s ease;
}

.fsrs-rate-btn:hover,
.fsrs-rate-btn:focus-visible {
  opacity: .85;
}

.fsrs-rate-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.fsrs-rate.is-rated .fsrs-rate-btn {
  cursor: default;
  pointer-events: none;
  opacity: .18;
}

.fsrs-rate.is-rated .fsrs-rate-btn.is-picked {
  opacity: .8;
}

@keyframes fsrsRateIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fsrs-rate {
    animation: none;
  }
}

@media (pointer: coarse) and (max-width: 900px) {
  .fsrs-slot {
    position: fixed;
    left: 0;
    right: 0;

    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    margin: 0;
    min-height: 0;
    z-index: 5;
    pointer-events: none;
  }

  .fsrs-slot.fsrs-slot--top {
    bottom: auto;
    top: calc(1rem + env(safe-area-inset-top, 0px));
  }

  .fsrs-rate {
    pointer-events: auto;
    gap: 1rem;
  }

  .fsrs-rate-btn {
    font-size: 20px;
    padding: .6em 1.7em;

    opacity: .5;
  }
}

.char--second {
  font-size: 3rem;
  margin-top: -2rem;
  opacity: .72;
}

@media screen and (max-width: 768px) {
  .char--second { font-size: clamp(1rem, 10vw, 5.5rem); margin-top: -0.18em; }
}

@media screen and (max-width: 480px) {
  .char--second { font-size: clamp(1rem, 10vw, 3rem); margin-top: -0.18em; }
}

.char--second.char--equal {
  font-size: clamp(3rem, 23vw, 20rem);

  margin-top: -0.08em;

  opacity: .88;
}

@media screen and (max-width: 768px) {
  .char--second.char--equal { font-size: clamp(2rem, 20vw, 11rem); }
}

@media screen and (max-width: 480px) {
  .char--second.char--equal { font-size: clamp(2rem, 20vw, 6rem); }
}

body.upside-down {
  transform: rotate(180deg);
}

@media (pointer: coarse) and (orientation: landscape) {
  #app:has(#ai) {
    padding-right: 50%;
  }

  #app:has(#ai) #ai {
    left: 50%;
    right: 0;
    top: 0;
    bottom: 0;
    margin: 0;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  #app:has(#ai) .char {
    font-size: min(11vw, 24vh);
  }
}

@media (pointer: coarse) and (orientation: landscape) {

  #app:has(#ai) {

    padding-left: env(safe-area-inset-left, 0px);
    padding-right: 50%;

    --poster-h: 94vh;

    --extra-zhuyin: 0px;
    --extra-pinyin: 0px;
    --extra-english: 0px;
    --poster-extra: calc(
      var(--extra-zhuyin) + var(--extra-pinyin) + var(--extra-english)
    );

    --poster-rows: 1.1;
  }

  #app:has(#ai):has(.zhuyin)  { --extra-zhuyin: 44px; }
  #app:has(#ai):has(.pinyin)  { --extra-pinyin: 38px; }
  #app:has(#ai):has(.english) { --extra-english: 34px; }

  #app:has(#ai):has(#charSecond) { --poster-rows: 1.65; }
  #app:has(#ai):has(#charSecond.char--equal) { --poster-rows: 2.2; }

  #app:has(#ai) .char {
    line-height: 1.06;

    margin: 0;
  }

  #app:has(#ai) .char:not(.char--second) {
    font-size: min(
      calc((50vw - env(safe-area-inset-left, 0px) - 0.5rem) / max(var(--len, 2), 1)),
      calc((var(--poster-h) - var(--poster-extra)) / var(--poster-rows))
    );
  }

  #app:has(#ai) .char--second {
    font-size: min(
      calc((50vw - env(safe-area-inset-left, 0px) - 0.5rem) / max(var(--len, 2), 1) / 2),
      calc((var(--poster-h) - var(--poster-extra)) / var(--poster-rows) / 2)
    );
    margin-top: -0.04em;
  }

  #app:has(#ai) .char--second.char--equal {
    font-size: min(
      calc((50vw - env(safe-area-inset-left, 0px) - 0.5rem) / max(var(--len, 2), 1)),
      calc((var(--poster-h) - var(--poster-extra)) / var(--poster-rows))
    );
    margin-top: -0.04em;
  }

  #app:has(#ai) .zhuyin {
    font-size: clamp(1.1rem, 6.5vh, 1.75rem) !important;
    margin: 0 !important;
  }
  #app:has(#ai) .pinyin {
    font-size: clamp(1rem, 5.5vh, 1.5rem) !important;
    margin: 0 !important;
  }

  #app:has(#ai) #ai {
    left: 50%;
    right: env(safe-area-inset-right, 0px);
    top: 0;
    bottom: 0;
    margin: 0;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    font-size: clamp(1.1rem, 5.2vh, 1.9rem);
  }

  #app:has(#ai) #ai pre {
    white-space: pre-wrap;
    max-width: 96%;
    margin-left: auto;
    margin-right: auto;
    font-size: 1em !important;
    line-height: 1.25;
  }

  #app:has(#ai) #ai pre:first-of-type {
    font-size: 1.7em !important;
  }
}

@supports (height: 1svh) {
  @media (pointer: coarse) and (orientation: landscape) {
    #app:has(#ai) { --poster-h: 94svh; }
  }
}

.settings-gear {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 10;
  font-size: 20px;
  line-height: 1;
  padding: 8px;
  text-decoration: none;
  color: inherit;
  opacity: .25;
  transition: opacity .18s ease;
}

.settings-gear:hover,
.settings-gear:focus-visible {
  opacity: .8;
}

@media (pointer: coarse) and (orientation: landscape) {
  .settings-gear {
    display: none;
  }
}

.install-hint {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  background: rgba(127, 127, 127, .16);
  backdrop-filter: blur(8px);
}

.install-hint button {
  flex: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  opacity: .6;
  padding: 4px 8px;
}

.back-link {
  display: inline-block;
  margin-bottom: 1em;
  color: inherit;
  opacity: .6;
  font-size: 14px;
}
