/* ============================================================
   云自习山 · 一间可以久坐的书院
   墨色 / 宣纸米白 / 一点烛光暖黄。纯 CSS，无位图，无字体文件。
   沿用静音舱的「首次点击解锁音频 + 后台暂停」逻辑。
   ============================================================ */

:root {
  --paper:       #ece1c8;
  --paper-deep:  #d9c8a6;
  --paper-light: #f6efdc;
  --ink:         #2f2c24;
  --ink-soft:    #5c5545;
  --ink-faint:   #8a8069;
  --wood:        #5a4028;
  --wood-dark:   #3b2a1b;
  --wood-light:  #7a5a38;
  --candle:      #e8a33d;
  --candle-soft: rgba(232, 163, 61, 0.35);
  --line:        rgba(74, 58, 38, 0.28);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper-deep);
}

body {
  font-family: "Songti SC", "SimSun", "Noto Serif SC", "STSong", Georgia, serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- 舞台：宣纸底 ---------- */
#stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  touch-action: none;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 250, 232, 0.85), transparent 62%),
    repeating-linear-gradient(92deg, rgba(120, 100, 70, 0.022) 0 1px, transparent 1px 5px),
    linear-gradient(160deg, var(--paper-light) 0%, var(--paper) 48%, var(--paper-deep) 100%);
  transition: filter 1.2s ease;
}
/* 点灯后整间屋亮一档 */
#stage.lit { filter: brightness(1.06); }

/* 四周暗角（纸的边） */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(96% 82% at 50% 46%, transparent 56%, rgba(74, 58, 38, 0.18) 100%);
  z-index: 40;
}

/* ---------- 匾额 / 身份 ---------- */
#plaque {
  position: relative;
  z-index: 50;
  flex: none;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 8px;
  text-align: center;
}
.plaque-title {
  font-size: 21px;
  letter-spacing: 9px;
  text-indent: 9px;
  color: var(--ink);
  font-weight: 700;
}
.plaque-sub {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 4px;
  text-indent: 4px;
  color: var(--ink-faint);
}
.identity {
  margin-top: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
#myName {
  font-size: 13px;
  letter-spacing: 1.5px;
  color: var(--ink-soft);
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 250, 234, 0.55);
}
#btnChangeName {
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
}
#btnChangeName:disabled { opacity: 0.4; cursor: default; }
#btnSound {
  position: absolute;
  right: 12px;
  top: calc(12px + env(safe-area-inset-top, 0px));
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 250, 234, 0.6);
  color: var(--ink-faint);
  cursor: pointer;
}

/* ---------- 窗外 · 江南烟雨（远山两笔、徽派屋舍一处，余皆雨雾留白） ---------- */
#windowWrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 2px 16px 6px;
  display: flex;
}
#window {
  position: relative;
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  /* 窗框：比桌面木色略浅一档 */
  border: 8px solid #6e5236;
  border-radius: 3px;
  overflow: hidden;
  background: #8b9384;
  box-shadow:
    inset 0 0 0 1px rgba(255, 240, 205, 0.18),
    inset 0 2px 12px rgba(40, 30, 18, 0.45),
    0 5px 16px rgba(60, 44, 26, 0.22);
}
/* 自成一个堆叠层：内部景物的 z-index 不会盖到窗外的雨丝 / 窗棂 */
#outside { position: absolute; inset: 0; overflow: hidden; isolation: isolate; }

/* 天空 + 远处青山：只两笔轮廓，一浓一淡，中间大片留白 */
.sky {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 40% 26% at 17% 71%, rgba(54, 83, 79, 0.46) 0%, rgba(54, 83, 79, 0.21) 56%, transparent 75%),
    radial-gradient(ellipse 28% 18% at 42% 73%, rgba(46, 72, 74, 0.32) 0%, rgba(46, 72, 74, 0.13) 58%, transparent 77%),
    linear-gradient(#c6cec9 0%, #b9c4bf 34%, #aab8b5 66%, #99a8a6 100%);
}

/* 旧庭院的三丛竹影、石头、密排竖线全部退场 —— 要零星，不要密密麻麻 */
.bamboo, .stone, .courtyard::after { display: none; }

/* 近处水面 / 地平线：只留一条淡淡的分界 */
.courtyard {
  position: absolute; left: 0; right: 0; bottom: 0; height: 22%; z-index: 1;
  background: linear-gradient(to bottom, rgba(148, 163, 161, 0.16), rgba(116, 132, 131, 0.40));
  border-top: 1px solid rgba(88, 106, 105, 0.18);
}

/* 雨雾：把山和屋舍都往雾里再推一层，轮廓才「模糊」 */
.mist {
  position: absolute; left: 0; right: 0; bottom: 10%; height: 52%; z-index: 2;
  background: linear-gradient(to top, rgba(238, 240, 232, 0.44), rgba(238, 240, 232, 0.12) 55%, transparent 85%);
  pointer-events: none;
}

/* 近处徽派屋舍：全窗只此一处，靠右偏下，白墙黛瓦 + 两端马头墙 */
#outside::before {
  content: "";
  position: absolute; right: 5%; bottom: 12%;
  width: 42%; height: 34%; z-index: 3;
  background:
    /* 墙面上零星两扇小窗，才认得出是屋舍 */
    linear-gradient(rgba(56, 70, 72, 0.58), rgba(56, 70, 72, 0.58)) 30% 46% / 7% 12% no-repeat,
    linear-gradient(rgba(56, 70, 72, 0.58), rgba(56, 70, 72, 0.58)) 58% 50% / 6% 11% no-repeat,
    /* 黛瓦与马头墙顶：贴着剪影上缘的一条深色，随阶梯一起起伏 */
    linear-gradient(rgba(46, 60, 62, 0.94), rgba(46, 60, 62, 0.90)) 0 0 / 100% 25% no-repeat,
    /* 粉墙：上略亮，下被雨气浸暗 */
    linear-gradient(rgba(241, 243, 236, 0.84), rgba(228, 232, 224, 0.46)) 0 0 / 100% 100% no-repeat;
  /* 两端马头墙逐级跌落、中间屋面略低，只此一处屋群 */
  clip-path: polygon(
    0% 7%, 7% 7%, 7% 15%, 15% 15%, 15% 23%, 24% 23%,
    50% 19%, 76% 23%, 85% 23%, 85% 15%, 93% 15%, 93% 7%, 100% 7%,
    100% 100%, 0% 100%
  );
  /* 底部没入雨雾，不留生硬的切线 */
  -webkit-mask-image: linear-gradient(to top, transparent 0%, #000 16%);
  mask-image: linear-gradient(to top, transparent 0%, #000 16%);
  filter: blur(1.3px);
  opacity: 0.72;
  pointer-events: none;
}
#rainCanvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
/* 木格窗棂：中式四扇、两两对开——25%/75% 为合缝、50% 为分界立柱；
   通体素玻璃，只留竖向框梃，中间和上下都不再做内格 */
#lattice {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    /* 两处合缝各一对小铜件，点出「两两对开」 */
    radial-gradient(circle at calc(25% - 4px) 50%, rgba(188, 148, 80, 0.95) 0 3px, transparent 3.6px),
    radial-gradient(circle at calc(25% + 4px) 50%, rgba(188, 148, 80, 0.95) 0 3px, transparent 3.6px),
    radial-gradient(circle at calc(75% - 4px) 50%, rgba(188, 148, 80, 0.95) 0 3px, transparent 3.6px),
    radial-gradient(circle at calc(75% + 4px) 50%, rgba(188, 148, 80, 0.95) 0 3px, transparent 3.6px),
    /* 三道竖框：25%/75% 是对开合缝（双梃＋暗缝），50% 是分界立柱，竖向贯通 */
    linear-gradient(90deg,
      transparent 0 calc(25% - 10px),
      rgba(98, 72, 47, 0.94) calc(25% - 10px) calc(25% - 2px),
      rgba(44, 31, 18, 0.94) calc(25% - 2px) calc(25% + 2px),
      rgba(98, 72, 47, 0.94) calc(25% + 2px) calc(25% + 10px),
      transparent calc(25% + 10px) calc(50% - 7px),
      rgba(92, 68, 44, 0.92) calc(50% - 7px) calc(50% + 7px),
      transparent calc(50% + 7px) calc(75% - 10px),
      rgba(98, 72, 47, 0.94) calc(75% - 10px) calc(75% - 2px),
      rgba(44, 31, 18, 0.94) calc(75% - 2px) calc(75% + 2px),
      rgba(98, 72, 47, 0.94) calc(75% + 2px) calc(75% + 10px),
      transparent calc(75% + 10px) 100%);
  box-shadow: inset 0 0 0 6px rgba(82, 60, 39, 0.56);
}
#glassSheen {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: linear-gradient(112deg, rgba(255, 252, 235, 0.16) 0%, transparent 34%, transparent 70%, rgba(255, 250, 226, 0.08) 100%);
}

/* ---------- 案上一句话 ---------- */
#quote {
  flex: none;
  min-height: 28px;
  padding: 4px 22px 2px;
  text-align: center;
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: 3px;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 1.4s ease;
  position: relative;
  z-index: 50;
}
#quote.show { opacity: 1; }

/* ---------- 木质长桌（俯视） ---------- */
#tableWrap {
  flex: none;
  padding: 2px 14px 0;
  position: relative;
  z-index: 20;
}
#longTable {
  max-width: 520px;
  margin: 0 auto;
  border-radius: 8px;
  padding: 7px 8px 8px;
  background:
    repeating-linear-gradient(88deg, rgba(28, 18, 10, 0.10) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, var(--wood-light) 0%, var(--wood) 22%, #4a3421 70%, var(--wood-dark) 100%);
  border: 1px solid rgba(30, 20, 12, 0.5);
  box-shadow: 0 6px 18px rgba(58, 42, 26, 0.3), inset 0 1px 0 rgba(255, 226, 175, 0.18);
}
.seat-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
/* 下排一行五座自动铺满 1–5 列，「我」由 renderSeats() 插在第 3 位，正对铺纸 */
#tableSurface {
  position: relative;
  margin: 6px 0;
  min-height: 74px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(238, 224, 190, 0.10), rgba(20, 12, 6, 0.14));
  border: 1px dashed rgba(238, 220, 180, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 8px 20px;
}

/* 座位牌 */
.seat {
  min-width: 0;
  padding: 5px 2px 4px;
  border-radius: 2px;
  background: linear-gradient(#f3e9cf, #e2d2b0);
  border: 1px solid rgba(90, 64, 40, 0.45);
  text-align: center;
  box-shadow: 0 2px 3px rgba(24, 16, 8, 0.22);
  transition: opacity 0.6s ease, filter 0.6s ease;
  overflow: hidden;
}
.seat .seat-name {
  display: block;
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat .seat-state {
  display: block;
  margin-top: 2px;
  font-size: 8px;
  letter-spacing: 0.3px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat.mine {
  background: linear-gradient(#fff3d6, #f0dcae);
  border-color: var(--candle);
  box-shadow: 0 0 0 1px rgba(232, 163, 61, 0.5), 0 0 12px rgba(232, 163, 61, 0.35);
}
.seat.mine .seat-name { color: #7a4a12; font-weight: 700; }
.seat.away { opacity: 0.42; filter: grayscale(0.6); }
/* 离席归来：座位由暗渐亮（不重建 DOM，动画不会被整排刷新打断） */
.seat.returning {
  animation: seatReturn 1.4s ease both;
  transition: none;
}
@keyframes seatReturn {
  from { opacity: 0.42; filter: grayscale(0.6); }
  to   { opacity: 1;    filter: none; }
}

/* ---------- 三仪式物件 ---------- */
.ritual-obj {
  position: relative;
  width: 62px; height: 58px;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0;
}
.ritual-obj:disabled { cursor: default; opacity: 0.55; }
.obj-label {
  margin-top: 3px;
  font-size: 9px;
  letter-spacing: 2px;
  color: rgba(255, 240, 208, 0.8);
}

/* 砚台 */
.obj-ink {
  width: 40px; height: 22px;
  border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 40% 35%, #4a4740, #23211d 70%);
  border: 2px solid #1b1a17;
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;               /* 墨晕只在砚池内扩散，不溢到桌面 */
}
.obj-ink::after {
  content: "";
  position: absolute; left: 8px; top: 5px; right: 8px; bottom: 5px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 45% 40%, rgba(120, 130, 126, 0.55), rgba(10, 10, 9, 0.9));
}
#inkstone.grinding .obj-ink::after { animation: inkSwirl 1.1s ease-in-out infinite; }
@keyframes inkSwirl {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50%      { transform: rotate(8deg) scale(1.06); }
}

/* 墨汁扩散：一滴墨落入砚池，由中心层层晕开、外缘略浓，循环如涟漪 */
.ink-diffuse {
  position: absolute; left: 50%; top: 50%;
  width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border-radius: 50%;
  z-index: 2;                     /* 盖在墨池之上 */
  pointer-events: none;
  opacity: 0;
  transform: scale(0.12);
  background: radial-gradient(circle,
    rgba(8, 12, 10, 0.98) 0%,
    rgba(14, 20, 17, 0.78) 26%,
    rgba(20, 28, 24, 0.50) 48%,
    rgba(26, 35, 30, 0.60) 66%,    /* 外缘墨环：扩散边略浓，像墨汁推进的锋面 */
    rgba(30, 38, 33, 0.16) 84%,
    rgba(30, 38, 33, 0) 100%);
}
#inkstone.grinding .ink-diffuse { animation: inkDiffuse 2.2s ease-out infinite; }
#inkstone.grinding .ink-diffuse.d2 { animation-delay: 1.1s; }
@keyframes inkDiffuse {
  0%   { opacity: 0;    transform: scale(0.12); }
  16%  { opacity: 0.92; }
  100% { opacity: 0;    transform: scale(1.5); }
}
.obj-progress {
  position: absolute;
  left: 4px; right: 4px; bottom: 15px;
  height: 3px;
  border-radius: 2px;
  background: rgba(20, 14, 8, 0.55);
  overflow: hidden;
  display: none;
}
.obj-progress i {
  display: block; height: 100%; width: 0%;
  background: var(--candle);
}
#inkstone.grinding .obj-progress { display: block; }

/* 宣纸：从右向左展开 */
#paperObj { opacity: 0.55; }
#paperSheet {
  display: block;
  width: 44px; height: 30px;
  background: linear-gradient(100deg, #fbf5e4, #efe4c8);
  border: 1px solid rgba(120, 96, 60, 0.5);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transform: scaleX(0.06);
  transform-origin: left center;
}
#paperObj.spreading #paperSheet { animation: paperUnfold 1.5s cubic-bezier(0.25, 0.7, 0.3, 1) forwards; }
@keyframes paperUnfold {
  from { transform: scaleX(0.06); }
  to   { transform: scaleX(1); }
}
#paperObj.done #paperSheet { transform: scaleX(1); }
#paperObj.done { opacity: 1; }

/* 油灯 */
.lamp-bowl {
  width: 30px; height: 13px;
  border-radius: 4px 4px 14px 14px;
  background: linear-gradient(#8a6a3c, #5b4224);
  border: 1px solid #3a2a16;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}
.lamp-flame {
  position: absolute;
  top: 6px;
  width: 11px; height: 17px;
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  background: radial-gradient(ellipse at 50% 70%, #fff3c4, var(--candle) 55%, rgba(232, 130, 30, 0));
  opacity: 0;
  transform: scale(0.4);
  filter: blur(0.4px);
}
#lampObj.lit .lamp-flame {
  animation: lampFlicker 2.4s ease-in-out infinite;
  opacity: 1;
}
@keyframes lampFlicker {
  0%, 100% { transform: scale(1) translateY(0); opacity: 0.95; }
  35%      { transform: scale(1.1) translateY(-1px); opacity: 1; }
  70%      { transform: scale(0.94) translateY(1px); opacity: 0.85; }
}
#lampObj.lit::before {
  content: "";
  position: absolute;
  top: -18px; left: -30px;
  width: 122px; height: 90px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 196, 90, 0.28), transparent 68%);
  pointer-events: none;
}

#deskNote {
  position: absolute;
  left: 6px; right: 6px; bottom: 4px;
  text-align: center;
  font-size: 9px;
  letter-spacing: 1px;
  color: rgba(255, 238, 205, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 三仪式按钮 ---------- */
#actions {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 8px 14px 4px;
  position: relative;
  z-index: 50;
}
#actions button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 1px solid rgba(90, 64, 40, 0.4);
  border-radius: 4px;
  background: linear-gradient(#f6ecd4, #e6d5b3);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  letter-spacing: 3px;
  text-indent: 3px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.3s ease, opacity 0.3s ease;
}
#actions button:active:not(:disabled) { transform: scale(0.96); }
#actions button:disabled { opacity: 0.4; cursor: default; }
#actions button.on {
  border-color: var(--candle);
  background: linear-gradient(#fff0cc, #f2dda8);
  color: #7a4a12;
}
#btnCancel {
  flex: 0 0 88px !important;
  font-size: 11px !important;
  letter-spacing: 1px !important;
  text-indent: 0 !important;
  background: transparent !important;
  color: var(--ink-faint) !important;
}
#btnCancel[hidden] { display: none; }

/* ---------- 计时 / 藏书阁 ---------- */
/* 「习志」已并入上方按钮行，这里只留计时文字与格子，通栏排布 */
#dock {
  flex: none;
  position: relative;
  z-index: 50;
  padding: 2px 16px calc(8px + env(safe-area-inset-bottom, 0px));
}
.dock-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--ink-soft);
}
#libraryGrid {
  margin-top: 5px;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}
.lib-cell {
  height: 7px;
  border-radius: 1px;
  background: rgba(90, 70, 44, 0.14);
  border: 1px solid rgba(90, 70, 44, 0.16);
  transition: background 0.6s ease, box-shadow 0.6s ease;
}
.lib-cell.filled {
  background: linear-gradient(#8a6a3c, #5a4028);
  border-color: #4a341e;
  box-shadow: 0 0 5px rgba(232, 163, 61, 0.35);
}
/* 「习志」按钮位于 #actions 行内，尺寸由 #actions button 统一给出，与研墨/铺纸/点灯一致 */

/* ---------- 入院门（音频解锁） ---------- */
#gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(70% 60% at 50% 42%, rgba(255, 240, 200, 0.35), transparent 70%),
    linear-gradient(160deg, #f3ead2, #d9c8a6);
  cursor: pointer;
  transition: opacity 0.9s ease;
}
#gate.gone { opacity: 0; pointer-events: none; }
.gate-inner { text-align: center; }
.gate-title {
  font-size: 34px;
  letter-spacing: 14px;
  text-indent: 14px;
  color: #3b3324;
  font-weight: 700;
}
.gate-sub {
  margin-top: 12px;
  font-size: 14px;
  letter-spacing: 6px;
  text-indent: 6px;
  color: var(--ink-faint);
}
.gate-btn {
  margin-top: 46px;
  display: inline-block;
  padding: 12px 30px;
  border: 1px solid rgba(90, 64, 40, 0.45);
  border-radius: 3px;
  font-size: 14px;
  letter-spacing: 5px;
  text-indent: 5px;
  color: var(--ink);
  background: rgba(255, 250, 234, 0.5);
  animation: breathe 3.4s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ---------- 面板通用 ---------- */
#namePanel, #notePanel, #leavePanel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(46, 36, 24, 0.62);
  touch-action: auto;
}
#namePanel[hidden], #notePanel[hidden], #leavePanel[hidden] { display: none; }
#nameSheet, #noteSheet, #leaveSheet {
  width: min(88vw, 360px);
  padding: 24px 20px 18px;
  border-radius: 5px;
  background: linear-gradient(#f8f0db, #e9dcc0);
  border: 1px solid rgba(90, 64, 40, 0.5);
  box-shadow: 0 14px 44px rgba(30, 20, 10, 0.45);
}
#nameSheet h2, #noteSheet h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--ink);
}
#nameSheet .sub, #noteSheet .sub {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-faint);
}
#nameChoices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 18px;
}
#nameChoices button {
  height: 46px;
  font-family: inherit;
  font-size: 20px;
  border: 1px solid rgba(90, 64, 40, 0.4);
  border-radius: 3px;
  background: rgba(255, 252, 240, 0.7);
  color: var(--ink);
  cursor: pointer;
}
#nameChoices button:active { background: #fff0cc; }
#noteInput {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border-radius: 3px;
  border: 1px solid rgba(90, 64, 40, 0.4);
  background: rgba(255, 252, 240, 0.8);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  font-family: inherit;
  white-space: pre-wrap;      /* 保留输入的换行，按行显示 */
  overflow-wrap: break-word;
  resize: none;
  outline: none;
}
#noteInput:focus { border-color: var(--candle); }
#noteCount { margin-top: 6px; text-align: right; font-size: 11px; color: var(--ink-faint); }
#nameSheet .row, #noteSheet .row, #leaveSheet .row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
#nameSheet .row button, #noteSheet .row button, #leaveSheet .row button {
  flex: 1;
  min-height: 44px;
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  letter-spacing: 2px;
  cursor: pointer;
}
#noteSave, #leaveRelight {
  border: 1px solid #8a6a3c;
  background: linear-gradient(#8a6a3c, #5a4028);
  color: #fff3d6;
}
#nameClose, #noteClose, #leaveClose {
  border: 1px solid rgba(90, 64, 40, 0.35);
  background: transparent;
  color: var(--ink-faint);
}
/* 离席提示：两行文言，居中舒展 */
#leaveSheet .leave-line {
  margin: 0;
  text-align: center;
  font-size: 16px;
  line-height: 2.1;
  letter-spacing: 3px;
  text-indent: 3px;
  color: var(--ink);
}
#leaveSheet .leave-line + .leave-line { color: var(--ink-soft); }
#leaveSheet .row { margin-top: 20px; }

.noscript {
  position: absolute; left: 0; right: 0; top: 46%;
  text-align: center; color: var(--ink-faint); font-size: 14px; z-index: 300;
}

body.paused .bamboo-a, body.paused .lamp-flame { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .gate-btn, #inkstone.grinding .obj-ink::after, #inkstone.grinding .ink-diffuse, #lampObj.lit .lamp-flame, .seat.returning { animation: none; }
  .seat { transition: none; }
}

/* 矮屏（横屏 / 小手机）压缩桌面与窗 */
@media (max-height: 620px) {
  #windowWrap { padding-bottom: 2px; }
  #longTable { padding: 4px 6px 5px; }
  #tableSurface { min-height: 58px; margin: 4px 0; padding-bottom: 16px; }
  .ritual-obj { height: 46px; }
  #actions button { min-height: 38px; }
  #plaque { padding-top: 6px; }
}
