* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --text: #111;
  --muted: #888;
  --soft: rgba(0, 0, 0, 0.14);
  --soft2: rgba(0, 0, 0, 0.2);
  --mid: rgba(0, 0, 0, 0.34);
  --near: rgba(0, 0, 0, 0.56);
}

body {
  min-height: 100vh;
  background: #fff;
  font-family: Georgia, serif;
  overflow-x: hidden;
}

.center {
  width: min(1120px, calc(100vw - 32px));
  text-align: center;
  padding: 20px;
  position: fixed;
  left: 50%;
  top: 12vh;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  view-transition-name: phrase-stage;
}

/* clean reading area */
.center::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(78vw, 980px);
  height: clamp(180px, 30vh, 320px);
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 999px;
  z-index: -1;
}

.pt {
  font-size: clamp(1.27rem, 2.83vw, 2.5rem);
  line-height: 1.12;
  color: var(--text);
  margin-bottom: 16px;
  max-width: 980px;
  min-height: 2.24em; /* reserve space for 2 lines */
}

.en {
  font-size: clamp(0.75rem, 1.24vw, 1.09rem);
  line-height: 1.35;
  color: var(--muted);
  max-width: 760px;
  min-height: 2.7em; /* reserve space for 2 lines */
}

/* auth */
.auth {
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 3;
}

.user {
  display: none;
  align-items: center;
  gap: 10px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 9px;
  color: #444;
}

.user img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.user button {
  border: 1px solid #ddd;
  background: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

/* stacked previous phrases */
.cloud {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  height: 168px;
  min-height: 168px;
  overflow: hidden;
  margin-bottom: 56px;
  pointer-events: auto;
}

.cloud.on {
  display: flex;
}

.ghost {
  position: relative;
  display: block;
  max-width: min(92vw, 980px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  cursor: pointer;
  transition: color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.ghost:hover {
  color: rgba(0, 0, 0, 0.74);
}

.ghost.level-4 {
  font-size: clamp(0.46rem, 0.74vw, 0.64rem);
  line-height: 1.12;
  color: var(--soft);
  transform: scale(0.8);
  margin-bottom: 4px;
}

.ghost.level-3 {
  font-size: clamp(0.62rem, 1.01vw, 0.88rem);
  line-height: 1.14;
  color: var(--soft2);
  transform: scale(0.84);
  margin-bottom: 6px;
}

.ghost.level-2 {
  font-size: clamp(0.75rem, 1.3vw, 1.17rem);
  line-height: 1.14;
  color: var(--mid);
  transform: scale(0.9);
  margin-bottom: 6px;
}

.ghost.level-1 {
  font-size: clamp(0.94rem, 1.89vw, 1.66rem);
  line-height: 1.12;
  color: var(--near);
  transform: scale(0.96);
  margin-bottom: 10px;
}

/* smooth stage transition */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(phrase-stage),
::view-transition-new(phrase-stage) {
  mix-blend-mode: normal;
  animation-duration: 420ms;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  animation-fill-mode: both;
}

::view-transition-old(phrase-stage) {
  animation-name: phraseStageOld;
}

::view-transition-new(phrase-stage) {
  animation-name: phraseStageNew;
}

@keyframes phraseStageOld {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(22px) scale(0.985);
  }
}

@keyframes phraseStageNew {
  from {
    opacity: 0;
    transform: translateY(-22px) scale(0.972);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 768px) {
  .center {
    width: calc(100vw - 24px);
    top: 10vh;
    padding: 16px;
  }

  .center::before {
    width: 96vw;
    height: clamp(170px, 34vh, 250px);
    top: 60%;
  }

  .cloud {
    height: 118px;
    min-height: 118px;
    margin-bottom: 40px;
  }

  .pt {
    font-size: clamp(1.07rem, 4.42vw, 1.66rem);
    margin-bottom: 12px;
    min-height: 2.24em;
  }

  .en {
    font-size: 0.71rem;
    min-height: 2.7em;
  }

  .ghost.level-4 {
    font-size: 0.38rem;
    margin-bottom: 3px;
  }

  .ghost.level-3 {
    font-size: 0.52rem;
    margin-bottom: 4px;
  }

  .ghost.level-2 {
    font-size: 0.65rem;
    margin-bottom: 4px;
  }

  .ghost.level-1 {
    font-size: 0.83rem;
    margin-bottom: 7px;
  }
}