:root {
  --paper: #f3eadc;
  --paper-2: #e9dfcd;
  --ink: #241e18;
  --ink-soft: #6d6358;
  --ink-faint: #9a9084;
  --cinnabar: #9c3d32;
  --cinnabar-deep: #7a2e26;
  --line: rgba(36, 30, 24, 0.12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { background: #1c1814; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: #1c1814;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.app {
  min-height: 100%;
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(243, 234, 220, 0.52) 0%, rgba(243, 234, 220, 0.76) 48%, rgba(243, 234, 220, 0.9) 100%),
    url("assets/bg-east.jpg") center 18% / cover no-repeat;
  position: relative;
  overflow: hidden;
}

.app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.14  0 0 0 0 0.12  0 0 0 0 0.09  0 0 0 0.18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
  z-index: 0;
}

.screen {
  position: relative;
  z-index: 1;
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  padding: 28px 24px calc(28px + var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.is-on { display: flex; }

/* Home */
.brand {
  text-align: center;
  margin-top: 18px;
}
.brand-en {
  font-size: 11px;
  letter-spacing: 0.42em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.brand h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 34px;
  letter-spacing: 0.28em;
  margin: 10px 0 0 12px;
}
.brand p {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: 0.06em;
  line-height: 1.7;
  max-width: 18em;
  margin-left: auto;
  margin-right: auto;
}
.home-date {
  margin-top: 8px !important;
  font-size: 12px !important;
  color: var(--ink-faint) !important;
  letter-spacing: 0.12em !important;
}

.lot-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  perspective: 520px;
}

.lot {
  width: 124px;
  height: 236px;
  position: relative;
  transform-origin: 50% 86%;
  transform-style: preserve-3d;
  animation: lot-idle 1.1s ease-in-out infinite;
}
.lot.is-shake {
  animation: rattle 0.55s ease-in-out;
}
@keyframes lot-idle {
  0%, 100% { transform: rotate(-3.5deg); }
  50% { transform: rotate(3.5deg); }
}
@keyframes rattle {
  0%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(-10deg); }
  22% { transform: rotate(9deg); }
  34% { transform: rotate(-8deg); }
  46% { transform: rotate(7deg); }
  58% { transform: rotate(-5deg); }
  72% { transform: rotate(3deg); }
  86% { transform: rotate(-2deg); }
}

.lot-rim {
  position: absolute;
  left: 50%;
  top: 40px;
  width: 96px;
  height: 22px;
  margin-left: -48px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255, 236, 200, 0.55), transparent 55%),
    linear-gradient(180deg, #e8c992 0%, #a67c4a 55%, #7a5530 100%);
  box-shadow:
    0 2px 0 rgba(255, 230, 180, 0.35),
    inset 0 3px 6px rgba(255, 240, 210, 0.35),
    inset 0 -4px 8px rgba(60, 35, 10, 0.35);
  z-index: 3;
}

.lot-body {
  position: absolute;
  inset: 48px 10px 8px;
  background:
    linear-gradient(90deg, rgba(60, 35, 12, 0.22) 0%, transparent 14%, transparent 86%, rgba(60, 35, 12, 0.22) 100%),
    linear-gradient(180deg, #c9a06a 0%, #b08958 18%, #d7b17c 42%, #c49a64 68%, #9a7048 100%);
  border-radius: 12px 12px 22px 22px;
  box-shadow:
    inset 0 0 0 1px rgba(80, 50, 20, 0.28),
    inset 8px 0 16px rgba(255, 230, 180, 0.18),
    inset -10px 0 18px rgba(40, 22, 8, 0.22),
    0 22px 36px rgba(40, 24, 10, 0.28),
    0 4px 0 rgba(90, 55, 25, 0.35);
  overflow: hidden;
  z-index: 2;
}
.lot-body::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      95deg,
      transparent 0 7px,
      rgba(90, 55, 25, 0.05) 7px 8px
    );
  opacity: 0.7;
  pointer-events: none;
}
.lot-body::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 16px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid rgba(90, 50, 20, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 236, 200, 0.25);
}
.lot-label {
  position: absolute;
  left: 50%;
  top: 38px;
  transform: translateX(-50%);
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: rgba(90, 45, 28, 0.55);
  letter-spacing: 0.12em;
  z-index: 1;
}

.lot-shadow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 88px;
  height: 18px;
  margin-left: -44px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(40, 24, 10, 0.28), transparent 70%);
  z-index: 0;
}

.sticks {
  position: absolute;
  left: 50%;
  top: 2px;
  width: 72px;
  height: 168px;
  transform: translateX(-50%);
  z-index: 1;
}
.sticks i {
  position: absolute;
  bottom: 0;
  width: 8px;
  height: 152px;
  background:
    linear-gradient(90deg, rgba(120, 80, 30, 0.25) 0%, transparent 35%, transparent 65%, rgba(120, 80, 30, 0.18) 100%),
    linear-gradient(180deg, #fff4dc 0%, #f0d5a0 40%, #dcb56e 100%);
  border-radius: 5px 5px 2px 2px;
  box-shadow:
    inset -1px 0 0 rgba(120, 80, 30, 0.28),
    inset 1px 0 0 rgba(255, 250, 230, 0.5),
    1px 2px 3px rgba(60, 35, 12, 0.18);
}
.sticks i:nth-child(1) { left: 4px; height: 140px; transform: rotate(-9deg); }
.sticks i:nth-child(2) { left: 16px; height: 154px; transform: rotate(-4deg); }
.sticks i:nth-child(3) { left: 28px; height: 148px; transform: rotate(-1deg); }
.sticks i:nth-child(4) {
  left: 40px;
  height: 160px;
  transform: rotate(2deg);
  background:
    linear-gradient(90deg, rgba(120, 80, 30, 0.2) 0%, transparent 40%, transparent 60%, rgba(120, 80, 30, 0.15) 100%),
    linear-gradient(180deg, #fffaf0 0%, #f6e2b4 45%, #e8c98a 100%);
}
.sticks i:nth-child(5) { left: 52px; height: 146px; transform: rotate(5deg); }
.sticks i:nth-child(6) { left: 64px; height: 138px; transform: rotate(9deg); }

.lot.is-draw .sticks i:nth-child(4) {
  animation: rise 0.65s ease forwards;
}
@keyframes rise {
  to { height: 196px; transform: rotate(0deg) translateY(-20px); }
}

.home-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 0.22em;
  padding: 14px 28px;
  min-width: 220px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  letter-spacing: 0.14em;
  font-size: 13px;
  min-width: 0;
  padding: 8px 12px;
}
.hint {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}
#lot {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Result */
.result-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.result-top .mark {
  font-family: var(--serif);
  letter-spacing: 0.24em;
  font-size: 13px;
}
.result-top .date {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
}

.cover {
  width: 100%;
  aspect-ratio: 3 / 3.6;
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper-2);
  position: relative;
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: fadeup 0.8s ease;
}
@keyframes fadeup {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: none; }
}

.sign-title {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
  margin: 22px 0 12px;
}
.sign-text {
  text-align: center;
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink);
  max-width: 28em;
  margin: 0 auto;
}

.result-actions {
  margin-top: auto;
  padding-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.footnote {
  text-align: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
}

.lead {
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
  text-align: center;
}
.lead-copy {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  line-height: 1.6;
}
.lead-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.lead-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(243, 234, 220, 0.7);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 999px;
  outline: none;
}
.lead-row input::placeholder {
  color: var(--ink-faint);
}
.lead-row input:focus {
  border-color: rgba(156, 61, 50, 0.45);
}
.lead-note-wrap {
  display: block;
  margin-top: 10px;
  text-align: left;
}
.lead-note-wrap span {
  display: block;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.lead-note-wrap textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(243, 234, 220, 0.7);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 14px;
  outline: none;
  resize: none;
}
.lead-note-wrap textarea::placeholder {
  color: var(--ink-faint);
}
.lead-note-wrap textarea:focus {
  border-color: rgba(156, 61, 50, 0.45);
}
.btn-lead {
  min-width: 0;
  width: auto;
  padding: 12px 16px;
  letter-spacing: 0.12em;
  font-size: 13px;
  background: var(--cinnabar);
}
.lead-ok {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(28, 24, 20, 0.72);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.overlay.is-on { display: flex; }
.sheet {
  width: 100%;
  max-width: 430px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  padding: 18px 20px calc(22px + var(--safe-b));
  animation: up 0.28s ease;
}
@keyframes up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.sheet h2 {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.12em;
  text-align: center;
  margin-bottom: 6px;
}
.sheet .sub {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 14px;
}
.sheet-card {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #ddd;
}
.sheet-card img {
  width: 100%;
  display: block;
  max-height: 52dvh;
  object-fit: contain;
  background: var(--paper-2);
}
.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.sheet-actions .btn { min-width: 0; letter-spacing: 0.12em; font-size: 14px; padding: 12px 10px; }
.sheet-actions .btn-ghost {
  border: 1px solid var(--line);
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: 0.25s ease;
}
.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.stats {
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
  font-family: ui-monospace, monospace;
}

@media (max-height: 740px) {
  .cover { aspect-ratio: 3 / 2.7; }
  .brand h1 { font-size: 30px; }
  .sign-title { font-size: 28px; margin: 16px 0 10px; }
  .result-actions { padding-top: 16px; }
  .lead { margin-top: 4px; }
}

@media (min-width: 520px) {
  .app {
    min-height: 844px;
    margin: 32px auto;
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    overflow: hidden;
  }
  .screen { min-height: 844px; }
}
