body {
  min-height: 100vh;
  min-height: 100dvh;
}

.stage {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px 40px;
}

.top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.hello {
  margin: 0;
  font-size: 24px;
  line-height: 1.35;
}

.sub {
  margin: 6px 0 0;
  color: var(--muted);
}

.lamp {
  width: 72px;
  height: 84px;
  position: relative;
  flex: none;
}

.lamp-glow {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffd36a;
  border: 4px solid #2c2118;
}

.lamp-glow::before,
.lamp-glow::after {
  content: "";
  position: absolute;
  top: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2c2118;
}

.lamp-glow::before { left: 14px; }
.lamp-glow::after { right: 14px; }

.lamp-foot {
  position: absolute;
  left: 28px;
  bottom: 4px;
  width: 16px;
  height: 18px;
  border-radius: 0 0 8px 8px;
  background: #2c2118;
}

.poem-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.poem-tools input {
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  border: 3px solid #2c2118;
  padding: 0 12px;
  background: white;
}
.poem-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.poem-groups button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 3px solid #2c2118;
  background: white;
  font-size: 14px;
  font-weight: 700;
}
.poem-groups button.on { background: #ffd36a; }
.cards { display: grid; gap: 14px; }

.poem-card {
  display: block;
  text-decoration: none;
  background: var(--card);
  border: 3px solid #2c2118;
  border-radius: 22px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.poem-card h2 {
  margin: 0;
  font-size: 26px;
}

.poem-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stars { color: var(--star); letter-spacing: 2px; font-size: 18px; }

.verse-list { display: grid; gap: 10px; margin: 18px 0; }

.verse {
  margin: 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--card);
  border: 3px solid transparent;
  font-family: KaiTi, STKaiti, FangSong, serif;
  font-size: 28px;
  line-height: 1.4;
}

.verse.focus {
  border-color: var(--orange);
  background: #fff1e4;
}

.actions, .recite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  min-height: 56px;
  padding: 0 18px;
  border-radius: 999px;
  border: 3px solid #2c2118;
  background: white;
  font-size: 18px;
}

.btn.primary {
  background: var(--orange);
  color: white;
}

.btn.sky { background: var(--sky); }

.panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 22px;
  background: var(--card);
  border: 3px solid #2c2118;
}

.scene {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  min-height: 168px;
  margin-top: 8px;
  padding: 18px;
  background: var(--card);
  border: 3px solid #2c2118;
  border-radius: 22px;
}
.scene.adding {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
}
.pile { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 280px; }
.scene.adding .pile { width: 100%; }
.plus { font-size: 42px; font-weight: 800; line-height: 1; }

.toy { width: 76px; height: 76px; display: block; flex: none; }
.toy svg { width: 100%; height: 100%; display: block; }

.replay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}
.replay-btn {
  min-width: 88px;
  height: 56px;
  padding: 0 16px;
  border-radius: 999px;
  border: 3px solid #2c2118;
  background: #ffd36a;
  box-shadow: 0 5px 0 #f3d7b8;
  font-size: 18px;
  font-weight: 800;
}
.replay-count {
  min-width: 56px;
  height: 56px;
  padding: 0 8px;
  border-radius: 18px;
  border: 3px solid #2c2118;
  background: white;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
}
.gate { margin-top: 18px; text-align: center; }
.gate h2 { margin: 0; font-size: 32px; }
.gate p { margin: 8px 0 0; color: #7a6556; font-size: 18px; }
.gate-actions { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }
.replay-btn.leave { background: white; }
.picks { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }
.picks.lines {
  display: grid;
  grid-template-columns: 1fr;
}
.pick {
  width: 92px;
  height: 92px;
  border-radius: 24px;
  border: 3px solid #2c2118;
  background: white;
  font-size: 40px;
}
.pick.line {
  width: 100%;
  height: auto;
  min-height: 64px;
  padding: 14px 18px;
  font-family: KaiTi, STKaiti, FangSong, serif;
  font-size: 28px;
  line-height: 1.4;
  letter-spacing: 0.06em;
}
.pick.yes { background: #e5f6ec; }
#line-choices { display: grid; grid-template-columns: 1fr; }
#line-choices .btn {
  width: 100%;
  font-family: KaiTi, STKaiti, FangSong, serif;
  font-size: 26px;
}
.pick.picture {
  width: auto;
  height: auto;
  min-width: 108px;
  padding: 12px 10px 8px;
  display: grid;
  justify-items: center;
  gap: 8px;
  font-size: 16px;
}
.pick.no { background: #ffd0c2; }
  width: 100%;
  min-height: 64px;
  margin-bottom: 12px;
  border-radius: 16px;
  border: 3px solid var(--line);
  padding: 0 12px;
  font-size: 28px;
}

textarea {
  width: 100%;
  min-height: 96px;
  border-radius: 16px;
  border: 3px solid var(--line);
  padding: 12px;
  resize: vertical;
  background: white;
}

.result .back { margin-top: 12px; }
.result {
  margin-top: 16px;
  padding: 18px;
  border-radius: 22px;
  background: #e9f8ef;
  border: 3px solid #2c2118;
}

.result.miss { background: #fff4ea; }

.result h2 { margin: 0 0 8px; font-size: 26px; }

.mask {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  box-sizing: border-box;
  background: rgba(44, 33, 24, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding:
    max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
}

.mask::before,
.mask::after {
  content: "";
  flex: 1 0 0px;
  align-self: stretch;
}

.mask > .dialog {
  flex: 0 0 auto;
  max-width: 100%;
}

body:has(.mask:not([hidden])) {
  overflow: hidden;
}

.dialog {
  width: min(360px, 100%);
  background: var(--card);
  border: 3px solid #2c2118;
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.dialog h2 { margin: 0 0 8px; }

.dialog input {
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  border: 3px solid var(--line);
  padding: 0 12px;
  margin: 12px 0;
}

.foot {
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
}

.foot a { font-weight: 700; }

.error {
  padding: 12px 14px;
  border-radius: 14px;
  background: #ffe1d6;
}
