:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --ink: #050912;
  --ink-2: #08111f;
  --slate: #6f7f90;
  --slate-soft: #9cacbd;
  --lilac: #d7caed;
  --cream: #f2ddb6;
  --dim: rgba(141, 159, 178, .30);
  --paper: rgba(111, 127, 144, .18);
  --paper-active: rgba(131, 148, 168, .25);
  --line: rgba(215, 202, 237, .24);
  --shadow: rgba(0, 0, 0, .55);
  --font-hand: "Segoe Print", "Bradley Hand", "Comic Sans MS", "Kaiti SC", "STKaiti", cursive;
  --font-ui: "Iowan Old Style", "Songti SC", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--ink); color: #eef1f8; }

body {
  font-family: var(--font-ui);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100svh;
  position: relative;
  overflow: hidden;
  padding: var(--eazo-safe-area-top) 18px var(--eazo-safe-area-bottom);
  display: flex;
  flex-direction: column;
  isolation: isolate;
  background:
    radial-gradient(circle at 48% 26%, rgba(67, 82, 108, .30), transparent 34%),
    radial-gradient(circle at 18% 88%, rgba(38, 31, 58, .40), transparent 38%),
    linear-gradient(180deg, #03060d 0%, #07101e 54%, #050813 100%);
}

.app::before,
.app::after {
  content: "";
  position: absolute;
  inset: -8%;
  pointer-events: none;
  z-index: -2;
}

.app::before {
  opacity: .30;
  background-image:
    repeating-linear-gradient(93deg, rgba(233, 227, 217, .025) 0 1px, transparent 1px 13px),
    repeating-linear-gradient(0deg, rgba(215, 202, 237, .018) 0 1px, transparent 1px 18px);
  transform: rotate(-2deg) scale(1.06);
}

.app::after {
  background:
    radial-gradient(circle at 50% -10%, transparent 0 34%, rgba(0,0,0,.28) 68%, rgba(0,0,0,.62) 100%);
  z-index: -1;
}

.hud {
  min-height: 44px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  flex: 0 0 auto;
}

.counter {
  justify-self: start;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  color: var(--lilac);
  font-family: var(--font-ui);
  font-size: clamp(28px, 8vw, 42px);
  line-height: 1;
  letter-spacing: .02em;
  text-shadow: 0 0 18px rgba(215, 202, 237, .22);
  position: relative;
}

.counter::before,
.counter::after {
  content: "";
  position: absolute;
  width: 21px;
  height: 6px;
  top: 4px;
  border-top: 1px solid rgba(215, 202, 237, .34);
  opacity: .8;
}

.counter::before { left: 2px; transform: rotate(-8deg); }
.counter::after { right: 2px; transform: rotate(8deg); }

.title-mark {
  justify-self: center;
  width: 86px;
  height: 38px;
  margin-top: 2px;
  opacity: .42;
  background:
    linear-gradient(90deg, transparent 0 10%, rgba(215,202,237,.45) 10% 12%, transparent 12% 18%, rgba(215,202,237,.38) 18% 20%, transparent 20% 100%),
    radial-gradient(ellipse at center, rgba(215,202,237,.16), transparent 68%);
  clip-path: polygon(0 50%, 10% 28%, 28% 28%, 32% 8%, 49% 42%, 68% 8%, 72% 28%, 90% 28%, 100% 50%, 90% 72%, 72% 72%, 68% 92%, 49% 58%, 32% 92%, 28% 72%, 10% 72%);
}

/* Language toggle: a single visible EN / 中文 button. */
.lang-toggle {
  justify-self: end;
  min-height: 44px;
  min-width: 92px;
  padding: 0 12px;
  border-radius: 999px;
  color: rgba(239, 234, 251, .78);
  border: 1px solid rgba(215, 202, 237, .22);
  background: rgba(7, 12, 22, .42);
  box-shadow: inset 0 0 22px rgba(215,202,237,.05);
  white-space: nowrap;
  font-size: 14px;
  letter-spacing: .03em;
}

.lang-toggle .seg { opacity: .42; transition: opacity 200ms ease; }
.lang-toggle .seg.on { opacity: 1; color: var(--cream); }
.lang-toggle .sep { opacity: .3; margin: 0 4px; }

/* Required Eazo locale select kept for the runtime, visually hidden but focusable. */
.visually-hidden-select {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding-top: 8px;
}

.scrap-field {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 26px;
  mask-image: linear-gradient(to bottom, transparent 0%, black 16%, black 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 16%, black 88%, transparent 100%);
}

.grid-thread {
  position: absolute;
  left: 50%;
  top: 4%;
  bottom: 8%;
  width: min(78vw, 360px);
  transform: translateX(-50%);
  pointer-events: none;
  opacity: .26;
  background:
    linear-gradient(90deg, transparent 0 6%, rgba(215,202,237,.11) 6% 6.5%, transparent 6.5% 50%, rgba(215,202,237,.08) 50% 50.4%, transparent 50.4% 93%, rgba(215,202,237,.08) 93% 93.5%, transparent 93.5%),
    repeating-linear-gradient(180deg, transparent 0 58px, rgba(215,202,237,.08) 58px 59px, transparent 59px 116px);
}

.stack {
  position: absolute;
  inset: 0;
  transition: transform 900ms cubic-bezier(.2, .65, .15, 1);
}

.scrap {
  --y: 0px;
  --x: 0px;
  --rot: 0deg;
  --scale: 1;
  --opacity: 1;
  --blur: 0px;
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(82vw, 342px);
  min-height: 72px;
  transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--rot)) scale(var(--scale));
  opacity: var(--opacity);
  filter: blur(var(--blur));
  padding: 14px 17px 12px;
  border-radius: 24px 20px 26px 18px;
  color: rgba(238, 241, 248, .88);
  text-align: left;
  overflow: visible;
  transition: transform 460ms cubic-bezier(.16,.8,.18,1), opacity 620ms ease, filter 620ms ease, background 300ms ease;
  white-space: normal;
  min-width: 44px;
}

.scrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 16% 28%, rgba(255,255,255,.08), transparent 12%),
    radial-gradient(circle at 82% 66%, rgba(215,202,237,.08), transparent 14%),
    linear-gradient(135deg, rgba(118, 137, 157, .30), rgba(58, 74, 94, .18));
  border: 1px solid rgba(215, 202, 237, .18);
  box-shadow: 0 18px 40px rgba(0,0,0,.30), inset 0 1px rgba(255,255,255,.08);
  clip-path: polygon(1% 13%, 8% 5%, 16% 7%, 28% 2%, 36% 8%, 48% 4%, 62% 7%, 74% 3%, 88% 8%, 98% 5%, 96% 28%, 100% 43%, 97% 59%, 99% 76%, 92% 95%, 78% 91%, 67% 98%, 56% 93%, 43% 98%, 32% 92%, 18% 97%, 6% 91%, 3% 73%, 0 60%, 3% 42%, 0 26%);
  z-index: -1;
}

.scrap::after {
  content: "";
  position: absolute;
  inset: 8px 12px;
  border-top: 1px solid rgba(215, 202, 237, .12);
  border-bottom: 1px solid rgba(215, 202, 237, .08);
  transform: rotate(-.6deg);
  pointer-events: none;
}

.scrap.good::before {
  background:
    radial-gradient(circle at 30% 34%, rgba(255,250,226,.18), transparent 18%),
    linear-gradient(135deg, rgba(242, 221, 182, .36), rgba(90, 82, 74, .16));
  border-color: rgba(242, 221, 182, .34);
  box-shadow: 0 0 38px rgba(242, 221, 182, .10), 0 18px 40px rgba(0,0,0,.30), inset 0 1px rgba(255,255,255,.10);
}

.scrap.done { pointer-events: none; }
.scrap.unrevealed { pointer-events: none; }

.scrap.active {
  z-index: 50 !important;
  --opacity: 1 !important;
  --blur: 0px !important;
  transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y) - 12px)) rotate(var(--rot)) scale(1.045);
}

.scrap.left { opacity: .22 !important; filter: blur(.4px) grayscale(.25); }
.scrap.gone { opacity: 0 !important; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y) - 26px)) rotate(var(--rot)) scale(.92); pointer-events: none; }

.stamp {
  display: block;
  margin-bottom: 4px;
  color: rgba(215, 202, 237, .62);
  font-family: var(--font-hand);
  font-size: 12px;
  line-height: 1.18;
  letter-spacing: .02em;
}

.line {
  display: block;
  font-family: var(--font-hand);
  font-size: clamp(17px, 4.8vw, 22px);
  line-height: 1.24;
  color: rgba(241, 244, 252, .86);
  text-shadow: 0 0 1px rgba(215,202,237,.20), .4px .3px rgba(0,0,0,.32);
  overflow-wrap: anywhere;
}

html[lang="zh-CN"] .line,
html[lang="zh-CN"] .stamp { letter-spacing: 0; line-height: 1.34; }

.good .line { color: rgba(242, 221, 182, .95); }
.good .stamp { color: rgba(242, 221, 182, .74); }

.actions {
  display: none;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

.scrap.active .actions { display: flex; }

.choice {
  min-height: 44px;
  min-width: 76px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(215, 202, 237, .24);
  color: rgba(239, 234, 251, .88);
  background: rgba(8, 13, 24, .58);
  box-shadow: inset 0 0 18px rgba(215,202,237,.05);
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: 14px;
}

.choice.unsend { color: var(--cream); border-color: rgba(242,221,182,.34); }

.hint {
  width: 100%;
  max-width: 460px;
  margin: 10px auto 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: rgba(215, 202, 237, .70);
  font-size: clamp(13px, 3.35vw, 15px);
  line-height: 1.32;
  padding: 0 8px;
}

.specks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}

.speck {
  position: absolute;
  width: var(--s);
  height: var(--s);
  left: var(--left);
  top: var(--top);
  border-radius: 999px;
  background: var(--c);
  opacity: 0;
  animation: drift 1450ms ease-out forwards;
}

@keyframes drift {
  0% { opacity: .86; transform: translate(0, 0) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.38); filter: blur(1.5px); }
}

.result-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.result-wrap.show { display: flex; }
.stage.hide { display: none; }

.result-card {
  width: 100%;
  max-height: 100%;
  overflow: auto;
  border-radius: 30px 24px 34px 22px;
  padding: 22px 18px 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(215,202,237,.12), transparent 38%),
    rgba(21, 30, 45, .58);
  border: 1px solid rgba(215, 202, 237, .20);
  box-shadow: 0 28px 70px rgba(0,0,0,.46), inset 0 1px rgba(255,255,255,.08);
  clip-path: polygon(1% 4%, 9% 1%, 23% 3%, 37% 0, 51% 3%, 67% 1%, 84% 3%, 99% 1%, 97% 18%, 100% 34%, 97% 52%, 99% 70%, 96% 96%, 78% 98%, 65% 95%, 51% 99%, 37% 96%, 21% 99%, 4% 95%, 2% 77%, 0 61%, 3% 43%, 0 24%);
}

.result-kicker {
  color: rgba(215, 202, 237, .64);
  font-size: 13px;
  margin-bottom: 10px;
}

.result-title {
  margin: 0 0 12px;
  font-family: var(--font-hand);
  font-size: clamp(28px, 8vw, 42px);
  line-height: 1.06;
  color: var(--cream);
  font-weight: 400;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.summary-cell {
  min-width: 0;
  padding: 12px;
  border-radius: 18px;
  background: rgba(4, 8, 16, .34);
  border: 1px solid rgba(215, 202, 237, .12);
}

.summary-cell b {
  display: block;
  font-size: 26px;
  line-height: 1;
  color: rgba(239, 234, 251, .95);
  font-weight: 500;
}

.summary-cell span {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: rgba(215, 202, 237, .62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.earliest, .closing {
  margin: 12px 0 0;
  color: rgba(239, 234, 251, .80);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.earliest em {
  font-family: var(--font-hand);
  font-style: normal;
  color: var(--cream);
  font-size: 1.15em;
}

.result-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin: 18px 0 8px;
}

.result-actions button {
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(215, 202, 237, .22);
  background: rgba(7, 12, 22, .52);
  color: rgba(239, 234, 251, .90);
  white-space: nowrap;
  font-size: 15px;
}

.result-actions .replay {
  color: var(--cream);
  border-color: rgba(242,221,182,.34);
  background: rgba(242, 221, 182, .08);
}

.share-note {
  grid-column: 1 / -1;
  margin: 0;
  color: rgba(215, 202, 237, .52);
  font-size: 12px;
  text-align: center;
}

.details-toggle {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  color: rgba(215, 202, 237, .78);
  border-top: 1px solid rgba(215, 202, 237, .12);
  white-space: nowrap;
}

.log {
  display: none;
  margin-top: 8px;
  padding: 0;
  list-style: none;
  max-height: 230px;
  overflow: auto;
}

.log.open { display: block; }

.log li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid rgba(215, 202, 237, .09);
  color: rgba(239, 234, 251, .78);
  font-size: 13px;
}

.log .msg {
  font-family: var(--font-hand);
  overflow-wrap: anywhere;
}

.log .act { color: rgba(215, 202, 237, .58); white-space: nowrap; }

@media (min-width: 720px) {
  .app { padding-left: 32px; padding-right: 32px; }
  .stage, .hud, .result-wrap { max-width: 620px; }
  .scrap { width: 430px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
