:root {
  --paper: #e9e3d7;
  --paper-deep: #ddd5c6;
  --ink: #3a2d27;
  --ink-soft: #6f6057;
  --ink-faint: rgba(58, 45, 39, 0.45);
  --card: #f4efe6;
  --accent: #b8543f;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Lora', Georgia, 'Songti SC', 'Noto Serif SC', serif;
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%233a2d27' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M12 3v6M12 15v6M3 12h6M15 12h6'/%3E%3Ccircle cx='12' cy='12' r='2' fill='%233a2d27' stroke='none'/%3E%3C/g%3E%3C/svg%3E") 12 12, crosshair;
  user-select: none;
  -webkit-user-select: none;
}

/* 纸张：暗角 + 亚麻噪点 */
.paper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255, 252, 245, 0.55), rgba(255, 255, 255, 0) 62%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 52%, rgba(90, 66, 45, 0.22) 100%);
}
.paper::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.55;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.86 0 0 0 0 0.82 0 0 0 0 0.76 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
}

/* 顶栏 */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 26px 40px 6px;
  pointer-events: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.paw {
  width: 40px;
  height: 40px;
  color: var(--ink);
  transform: rotate(-12deg);
  flex: none;
}
.brand h1 {
  font-family: 'Playfair Display', 'Songti SC', 'Noto Serif SC', Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1.15;
}
.tagline {
  margin: 4px 0 0;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-soft);
}
.meta {
  text-align: right;
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  padding-top: 4px;
}
.meta-line + .meta-line { margin-top: 6px; }
.meta-line.strong {
  color: var(--ink);
  font-weight: 500;
}

/* 舞台 */
.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
}
canvas#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 底栏 */
.bottombar {
  position: relative;
  z-index: 2;
  padding: 4px 24px 18px;
  text-align: center;
}
.caption {
  margin: 0 0 12px;
  min-height: 1.5em;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
  transition: opacity 0.25s ease;
}
.caption.flash { animation: captionIn 0.45s ease; }
@keyframes captionIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.toolbar {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid rgba(58, 45, 39, 0.42);
  border-radius: 999px;
  padding: 11px 22px 11px 18px;
  box-shadow:
    0 1px 0 rgba(58, 45, 39, 0.35),
    0 8px 18px -8px rgba(58, 45, 39, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn svg {
  width: 17px;
  height: 17px;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1.2);
}
.btn:hover {
  background: #fbf7ef;
  transform: translateY(-1px);
  box-shadow:
    0 2px 0 rgba(58, 45, 39, 0.35),
    0 12px 22px -8px rgba(58, 45, 39, 0.4);
}
.btn:hover svg { transform: rotate(-70deg); }
.btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(58, 45, 39, 0.35);
}
.btn.spin svg { transform: rotate(-360deg); }
.btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.hint {
  font-size: 12.5px;
  font-style: italic;
  color: var(--ink-faint);
}
kbd {
  font-family: 'IBM Plex Mono', Menlo, monospace;
  font-style: normal;
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid rgba(58, 45, 39, 0.35);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.35);
}

.colophon {
  margin: 16px 0 0;
  font-family: 'IBM Plex Mono', Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
}

@media (max-width: 720px) {
  .topbar { padding: 18px 20px 2px; }
  .brand h1 { font-size: 20px; }
  .tagline { font-size: 12px; }
  .meta { display: none; }
  .caption { font-size: 13.5px; margin-bottom: 8px; }
  .hint { display: none; }
  .colophon { display: none; }
  .bottombar { padding-bottom: 14px; }
}
