:root {
  --bg: #f8f4ec;
  --paper: #fffdf7;
  --paper-deep: #f1eadf;
  --ink: #34312d;
  --muted: #746f67;
  --line: #ded4c6;
  --sage: #7f9a7a;
  --sage-dark: #49664e;
  --wood: #c9ad86;
  --soft-green: #e7efe4;
  --shadow: 0 18px 45px rgba(70, 58, 42, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(127, 154, 122, 0.18);
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffefa;
  color: var(--ink);
  padding: 14px 15px;
  line-height: 1.6;
}

textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(127, 154, 122, 0.35);
  outline-offset: 3px;
}

.app-shell {
  width: min(980px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.25rem, 4vw, 1.7rem);
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.75rem, 7vw, 4rem);
  line-height: 1.08;
  letter-spacing: 0;
  word-break: keep-all;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--sage-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quiet-text {
  color: var(--muted);
  line-height: 1.7;
}

.storage-note {
  margin-top: 14px;
  border-left: 4px solid rgba(127, 154, 122, 0.45);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  padding-left: 12px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 24px;
  align-items: stretch;
  min-height: 420px;
}

.hero-copy,
.timer-panel,
.page-card,
.support-layout,
.wrap-form {
  min-width: 0;
  border: 1px solid rgba(222, 212, 198, 0.9);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 6vw, 58px);
}

.hero-copy .quiet-text {
  margin-top: 20px;
  font-size: 1.05rem;
}

.mascot-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: center;
  min-width: 0;
  border-radius: 18px;
  background:
    linear-gradient(0deg, rgba(255, 253, 247, 0.85), rgba(255, 253, 247, 0.85)),
    repeating-linear-gradient(90deg, rgba(201, 173, 134, 0.16), rgba(201, 173, 134, 0.16) 1px, transparent 1px, transparent 18px);
  padding: 22px;
}

.mascot,
.mini-mascot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(73, 102, 78, 0.16);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 12px 25px rgba(70, 58, 42, 0.11);
}

.mascot {
  min-height: 145px;
  border-radius: 34px 34px 26px 26px;
  flex-direction: column;
  gap: 12px;
}

.mascot::before,
.mascot::after {
  content: "";
  position: absolute;
  top: 42px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(52, 49, 45, 0.32);
}

.mascot::before {
  left: 32%;
}

.mascot::after {
  right: 32%;
}

.mascot-bubu {
  background: linear-gradient(145deg, #f1eadf, #ded9c8);
}

.mascot-xiang {
  background: linear-gradient(145deg, #eef3df, #dce8d6);
  border-radius: 36px 36px 16px 36px;
}

.mascot-dong {
  grid-column: span 2;
  min-height: 118px;
  background: linear-gradient(145deg, #f9eee1, #e9d7bf);
  border-radius: 40px;
}

.mascot-face {
  margin-top: 28px;
  font-weight: 800;
}

.mascot-label {
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.8);
  padding: 5px 12px;
  font-size: 0.86rem;
  font-weight: 700;
}

.home-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.primary-tile,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.choice {
  border: 0;
  border-radius: 14px;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-tile {
  display: flex;
  min-width: 0;
  min-height: 116px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: left;
}

.primary-tile span {
  font-size: 1.1rem;
  font-weight: 800;
}

.primary-tile small {
  color: var(--muted);
}

.screen-heading {
  margin: 14px 0 18px;
}

.screen-heading h2,
.support-layout h2 {
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1.14;
}

.pager {
  min-height: 250px;
}

.page-card {
  display: none;
  min-height: 250px;
  padding: clamp(22px, 5vw, 42px);
}

.page-card.is-active {
  display: block;
}

.page-card label,
.field-label,
.wrap-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.topic-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.topic-chip {
  min-width: 0;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffefa;
  color: var(--ink);
  padding: 10px 14px;
  font-weight: 800;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.topic-chip.is-selected {
  border-color: rgba(73, 102, 78, 0.45);
  background: var(--soft-green);
  color: var(--sage-dark);
  box-shadow: inset 0 0 0 1px rgba(73, 102, 78, 0.18);
}

.choice {
  min-width: 0;
  min-height: 58px;
  border: 1px solid var(--line);
  background: #fffefa;
  color: var(--ink);
  padding: 12px;
  font-weight: 700;
}

.choice.is-selected {
  border-color: rgba(73, 102, 78, 0.45);
  background: var(--soft-green);
  box-shadow: inset 0 0 0 1px rgba(73, 102, 78, 0.18);
}

.pager-controls,
.action-row,
.timer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-button {
  background: var(--sage-dark);
  color: #fffdf7;
  padding: 12px 18px;
  font-weight: 800;
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.78);
  color: var(--ink);
  padding: 12px 18px;
  font-weight: 800;
}

.danger-button {
  border: 1px solid rgba(122, 69, 56, 0.35);
  background: #f5e8e3;
  color: #7a4538;
  padding: 12px 18px;
  font-weight: 800;
}

.is-hidden {
  display: none !important;
}

.timer-panel {
  display: grid;
  justify-items: center;
  padding: clamp(26px, 6vw, 56px);
  text-align: center;
}

.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: clamp(4rem, 20vw, 9.5rem);
  line-height: 0.95;
}

.task-line {
  max-width: 620px;
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.flip-card {
  width: min(520px, 100%);
  min-height: 210px;
  margin-top: 24px;
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: transparent;
  padding: 0;
  transform-style: preserve-3d;
  transition: transform 420ms ease;
}

.flip-card.is-flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  border-radius: 18px;
  backface-visibility: hidden;
  padding: 26px;
}

.card-front {
  background: linear-gradient(145deg, #fffefa, #f3ebdf);
}

.card-back {
  background: linear-gradient(145deg, #eef3df, #fffefa);
  transform: rotateY(180deg);
}

.card-kicker,
.card-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.card-face strong {
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.35;
}

.support-layout {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: clamp(22px, 5vw, 42px);
}

.mini-mascot {
  width: 100px;
  height: 100px;
  border-radius: 28px;
  font-weight: 900;
}

.soft-list {
  margin: 18px 0 0;
  padding-left: 1.35rem;
  color: var(--muted);
  line-height: 1.9;
}

.rescue-time {
  display: inline-flex;
  margin-top: 14px;
  border-radius: 999px;
  background: var(--soft-green);
  color: var(--sage-dark);
  padding: 8px 13px;
  font-weight: 900;
}

.wrap-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
  padding: clamp(18px, 4vw, 30px);
}

.wrap-form label:nth-child(4),
.wrap-form label:nth-child(5) {
  grid-column: span 2;
}

.import-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, 0.78);
  padding: 18px;
}

.import-panel summary {
  cursor: pointer;
  font-weight: 900;
}

.import-panel .quiet-text {
  margin: 10px 0 14px;
}

.import-panel .secondary-button {
  margin-top: 12px;
}

.site-disclaimer {
  margin: 22px auto 0;
  max-width: 860px;
  border-top: 1px solid rgba(222, 212, 198, 0.85);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
  padding: 16px 4px 6px;
  text-align: center;
}

@media (max-width: 740px) {
  .app-shell {
    padding: 14px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 14px;
  }

  .topbar .ghost-button {
    min-width: 74px;
    padding-inline: 14px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: auto;
  }

  .hero-copy {
    min-height: 280px;
    padding: 28px 18px;
  }

  h2,
  .quiet-text,
  .storage-note,
  .task-line,
  .card-face strong {
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  .hero-copy h2 {
    font-size: clamp(2.1rem, 8.8vw, 2.65rem);
  }

  .hero-copy .quiet-text {
    margin-top: 16px;
  }

  .mascot-stage {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
  }

  .mascot {
    grid-column: auto;
    min-height: 112px;
    border-radius: 28px;
  }

  .mascot-dong {
    grid-column: auto;
    min-height: 96px;
    border-radius: 28px;
  }

  .mascot-face {
    margin-top: 20px;
    font-size: 0.8rem;
  }

  .home-actions {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .primary-tile {
    min-height: 86px;
    padding: 16px;
  }

  .primary-tile span {
    font-size: 1.05rem;
  }

  .primary-tile small {
    line-height: 1.45;
  }

  .screen-heading {
    margin: 8px 0 14px;
  }

  .pager {
    min-height: 0;
  }

  .page-card {
    min-height: 0;
    padding: 24px 18px;
  }

  .topic-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .topic-chip {
    min-height: 56px;
    border-radius: 16px;
    padding: 10px 12px;
  }

  .choice-grid,
  .wrap-form {
    grid-template-columns: 1fr;
  }

  .choice {
    min-height: 56px;
    padding: 13px 14px;
  }

  .pager-controls,
  .action-row {
    gap: 10px;
  }

  .pager-controls button,
  .action-row button {
    min-height: 54px;
  }

  .timer-panel {
    min-height: calc(100vh - 132px);
    padding: 26px 18px max(112px, calc(92px + env(safe-area-inset-bottom)));
  }

  .timer-display {
    font-size: clamp(5.2rem, 24vw, 7rem);
  }

  .task-line {
    margin-top: 14px;
    font-size: 1rem;
  }

  .flip-card {
    min-height: 190px;
    margin-top: 20px;
  }

  .flip-card-inner {
    min-height: 190px;
  }

  .card-face {
    padding: 22px 18px;
  }

  .card-face strong {
    font-size: clamp(1.25rem, 6vw, 1.65rem);
  }

  .timer-actions {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    border: 1px solid rgba(222, 212, 198, 0.9);
    border-radius: 18px;
    background: rgba(255, 253, 247, 0.94);
    box-shadow: 0 12px 32px rgba(70, 58, 42, 0.18);
    padding: 8px;
    backdrop-filter: blur(12px);
  }

  .timer-actions button {
    min-height: 54px;
    padding: 10px 8px;
    border-radius: 13px;
    white-space: nowrap;
  }

  .support-layout {
    grid-template-columns: 1fr;
  }

  .support-layout h2,
  .screen-heading h2 {
    font-size: clamp(2.1rem, 12vw, 3.1rem);
  }

  .wrap-form label:nth-child(4),
  .wrap-form label:nth-child(5) {
    grid-column: auto;
  }

  .pager-controls button,
  .action-row button {
    flex: 1 1 135px;
  }

  .site-disclaimer {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

@media (hover: hover) and (pointer: fine) {
  .primary-tile:hover,
  .primary-button:hover,
  .secondary-button:hover,
  .ghost-button:hover,
  .choice:hover,
  .danger-button:hover,
  .topic-chip:hover {
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
