@font-face {
  font-family: 'LinKeeKai';
  src: url('assets/fonts/linkeekai.woff2?v=9edf6d6435') format('woff2');
  font-display: swap;
}

/* —— 颜色：白天 / 黄昏 / 夜晚，页面、加载层、按钮都读这一套 —— */
:root {
  --paper: #f6efe2;
  --paper-2: #efe3cc;
  --ink: #3a2a20;
  --ink-soft: #6b5446;
  --line: #5a3b28;
  --mint: #8fc2aa;
  --mint-deep: #4f8a72;
  --coral: #e2705d;
  --coral-deep: #c4533f;
  --mustard: #e8b24a;
  --card: rgba(255, 251, 242, 0.86);
  --card-line: rgba(90, 59, 40, 0.28);
  --btn: #fffaf0;
  --btn-ink: #3a2a20;
  --shadow: 0 2px 0 rgba(90, 59, 40, 0.18), 0 10px 24px -14px rgba(58, 42, 32, 0.45);
  --focus: #2f6f9a;
  --sky-top: #f8f1e3;
  --sky-bottom: #eadcc2;
  color-scheme: light;
}
:root.is-dusk {
  --paper: #f5e2cf;
  --paper-2: #ecc9ad;
  --sky-top: #f6dcc4;
  --sky-bottom: #dfae95;
  --card: rgba(255, 246, 234, 0.84);
}
:root.is-night {
  --paper: #232838;
  --paper-2: #1a1e2b;
  --ink: #f3e8d4;
  --ink-soft: #c9bba5;
  --line: #e9d8bb;
  --mint: #6f9f8e;
  --mint-deep: #9fd0bb;
  --card: rgba(36, 41, 58, 0.82);
  --card-line: rgba(243, 232, 212, 0.22);
  --btn: #2d3347;
  --btn-ink: #f3e8d4;
  --shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 12px 26px -14px rgba(0, 0, 0, 0.7);
  --focus: #f5c46b;
  --sky-top: #2a3048;
  --sky-bottom: #171b27;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { background: var(--paper); }
body {
  font-family: 'LinKeeKai', 'Songti SC', 'STKaiti', 'KaiTi', serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: color 0.8s ease;
}
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { position: fixed; inset: 0; }
#stage, #scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#scene { touch-action: none; outline: none; cursor: grab; }
#scene.dragging { cursor: grabbing; }
#scene.hovering { cursor: pointer; }
#scene:focus-visible { box-shadow: inset 0 0 0 3px var(--focus); }

/* —— 标题 —— */
#masthead {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  left: max(28px, env(safe-area-inset-left));
  max-width: min(420px, 46vw);
  pointer-events: none;
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.32em;
  color: var(--mint-deep);
}
#masthead h1 {
  margin: 0;
  font-size: 46px;
  line-height: 1.05;
  font-weight: 400;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.12em;
}
#masthead .sign {
  display: inline-block;
  padding: 0.06em 0.22em 0.1em;
  margin-right: 0.08em;
  color: #fff6e6;
  background: var(--coral);
  border: 2px solid var(--line);
  border-radius: 6px 6px 8px 8px;
  box-shadow: 0 3px 0 rgba(90, 59, 40, 0.25);
  transform: rotate(-2deg);
}
:root.is-night #masthead .sign { color: #2a2018; background: var(--mustard); border-color: #2a2018; }
.tagline {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* —— 日夜 —— */
#daylight {
  position: absolute;
  top: max(24px, env(safe-area-inset-top));
  right: max(26px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.seg {
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--card-line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.seg button {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 15px;
  color: var(--ink-soft);
  cursor: pointer;
  min-height: 34px;
  transition: background 0.25s ease, color 0.25s ease;
}
.seg button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#clock { margin: 0; font-size: 14px; color: var(--ink-soft); letter-spacing: 0.04em; }
#clock-time { font-variant-numeric: tabular-nums; color: var(--ink); }

/* —— 动作按钮 —— */
#dock {
  position: absolute;
  left: max(24px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
}
.act {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 9px 18px 9px 12px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--btn);
  color: var(--btn-ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, background 0.3s ease, opacity 0.3s ease;
}
.act:hover:not(:disabled) { transform: translateY(-2px); }
.act:active:not(:disabled) { transform: translateY(1px); }
.act:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.act:disabled { cursor: default; opacity: 0.55; }
.act[aria-busy="true"] { opacity: 0.75; }
.act-main { background: var(--coral); color: #fff8ee; border-color: var(--line); }
:root.is-night .act-main { background: var(--mustard); color: #2a2018; border-color: #2a2018; }
.act-ghost { background: var(--card); }
.act-icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; }
.act-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.act-text { display: flex; flex-direction: column; line-height: 1.2; }
.act-label { font-size: 19px; letter-spacing: 0.04em; }
.act-note { font-size: 13px; opacity: 0.78; margin-top: 2px; white-space: nowrap; }
#btn-focus .icon-out { display: none; }
#btn-focus[aria-pressed="true"] .icon-in { display: none; }
#btn-focus[aria-pressed="true"] .icon-out { display: block; }

/* —— 提示 —— */
#hint {
  position: absolute;
  right: max(26px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}
#hint p { margin: 0; }
.hint-narrow { display: none; }
.tiny {
  border: 1.5px solid var(--card-line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  min-height: 30px;
}
.tiny:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* —— 台词气泡 —— */
#bubble {
  position: absolute;
  left: 0; top: 0;
  max-width: 220px;
  padding: 9px 14px 10px;
  background: #fffaf1;
  color: #3a2a20;
  border: 2px solid #5a3b28;
  border-radius: 16px;
  font-size: 16px;
  line-height: 1.4;
  box-shadow: 0 3px 0 rgba(90, 59, 40, 0.18);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%) scale(0.92);
  transform-origin: 50% 100%;
  transition: opacity 0.22s ease, transform 0.22s ease;
  white-space: nowrap;
}
#bubble p { margin: 0; }
#bubble::after {
  content: '';
  position: absolute;
  left: var(--tail-x, 50%);
  bottom: -9px;
  width: 14px; height: 14px;
  background: #fffaf1;
  border-right: 2px solid #5a3b28;
  border-bottom: 2px solid #5a3b28;
  transform: translateX(-50%) rotate(45deg);
}
#bubble.show { opacity: 1; transform: translate(-50%, -100%) scale(1); }
:root.is-night #bubble, :root.is-night #bubble::after { background: #fff4df; }

/* —— 加载 —— */
#loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  z-index: 10;
  transition: opacity 0.7s ease, visibility 0.7s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-card { text-align: center; color: var(--ink); }
.loader-cup { width: 120px; height: 120px; overflow: visible; }
.loader-cup .cup, .loader-cup .saucer { fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.loader-cup .fill { fill: #7a4a2a; transition: y 0.4s ease; }
.loader-cup .steam path { fill: none; stroke: var(--ink-soft); stroke-width: 2.5; stroke-linecap: round; opacity: 0.6; animation: steam 2.4s ease-in-out infinite; }
.loader-cup .steam path:nth-child(2) { animation-delay: 0.6s; }
@keyframes steam { 0%, 100% { transform: translateY(2px); opacity: 0.15; } 50% { transform: translateY(-4px); opacity: 0.7; } }
.loader-title { margin: 8px 0 4px; font-size: 26px; letter-spacing: 0.12em; }
.loader-step { margin: 0; font-size: 15px; color: var(--ink-soft); min-height: 1.4em; }
.loader-count { margin: 4px 0 0; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; min-height: 1.2em; }
#loader-retry { margin-top: 12px; }

/* —— 窄屏（手机竖屏） —— */
@media (max-width: 640px) {
  #masthead { top: max(16px, env(safe-area-inset-top)); left: 18px; max-width: 62vw; }
  .eyebrow { font-size: 11px; letter-spacing: 0.24em; margin-bottom: 4px; }
  #masthead h1 { font-size: 32px; }
  .tagline { font-size: 13px; margin-top: 6px; line-height: 1.45; }
  #daylight { top: max(16px, env(safe-area-inset-top)); right: 14px; gap: 6px; }
  .seg button { padding: 6px 9px; font-size: 13px; min-height: 32px; }
  #clock { font-size: 12px; }
  #dock {
    left: 12px; right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    gap: 8px;
  }
  .act { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px; padding: 8px 4px 9px; min-height: 66px; border-radius: 14px; text-align: center; }
  .act-icon { width: 28px; height: 28px; }
  .act-icon svg { width: 26px; height: 26px; }
  .act-text { align-items: center; }
  .act-label { font-size: 16px; }
  .act-note { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  #hint { left: 0; right: 0; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 76px); justify-content: center; font-size: 12px; }
  .hint-wide { display: none; }
  .hint-narrow { display: inline; }
  #bubble { font-size: 14px; max-width: 180px; padding: 7px 11px 8px; }
}

/* 横着拿手机这类很矮的视口 */
@media (max-height: 520px) and (min-width: 641px) {
  #masthead h1 { font-size: 32px; }
  .tagline { display: none; }
  .act { min-height: 50px; padding: 6px 14px 6px 10px; }
  .act-note { display: none; }
  #hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
.nowrap { white-space: nowrap; }
