/* ============================================================
   静音舱 · 雨夜末班车
   深蓝夜色 + 钠灯暖橙。纯 CSS，无位图，无字体文件。
   ============================================================ */

:root {
  --night: #060b16;
  --deep: #0a1220;
  --mid: #10203a;
  --frame: #1b2434;
  --steel: #8ea0b8;
  --ink: #c7d4e6;
  --muted: #5b6b82;
  --sodium: #ff9a3d;
  --sodium-soft: rgba(255, 170, 90, 0.55);
  --fog: rgb(174, 186, 204);
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Noto Sans SC", "Microsoft YaHei", sans-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% 90% at 50% 0%, var(--mid) 0%, var(--deep) 46%, var(--night) 100%);
  transition: filter 1.2s ease;
}
#stage.leaned { filter: brightness(0.9); }

/* 暗角 */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(90% 78% at 50% 46%, transparent 58%, rgba(2, 5, 10, 0.55) 100%);
  z-index: 40;
}

#cabin {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}
#cabin.seated { transform: translateY(22px); }

/* ---------- 车顶 ---------- */
#ceiling {
  position: relative;
  height: 92px;
  flex: none;
  background: linear-gradient(#182238 0%, #0c1526 62%, #0a1220 100%);
}
#ceiling::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 26px; bottom: 0;
  background: radial-gradient(60% 130% at 50% 0%, rgba(255, 160, 70, 0.14), transparent 62%);
  pointer-events: none;
}
#lightBar {
  position: absolute;
  top: 18px;
  left: 12%;
  width: 76%;
  height: 9px;
  border-radius: 5px;
  background: linear-gradient(90deg, #ffd9a0, #ffb26b 30%, #ff9a3d 55%, #ffb26b 80%, #ffd9a0);
  box-shadow: 0 0 18px rgba(255, 160, 70, 0.45), 0 0 46px rgba(255, 150, 60, 0.22);
  opacity: 0.92;
}
#rail {
  position: absolute;
  left: 0; right: 0; bottom: 8px;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(#a9bad2, #556478 70%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#railReflection {
  position: absolute;
  left: 0; right: 0; bottom: 1px;
  height: 5px;
  background: linear-gradient(rgba(174, 186, 204, 0.22), transparent);
  filter: blur(1px);
}

/* ---------- 吊环 ---------- */
#strap, .strapDecor {
  position: absolute;
  top: 84px;
  width: 44px;
  height: 118px;
  z-index: 30;
  transform-origin: top center;
  pointer-events: none;
}
#strap { left: 28%; animation: swayIdle 7s ease-in-out infinite; }
.strapDecor { left: 63%; transform: rotate(4deg); opacity: 0.8; animation: swayIdle 9s ease-in-out infinite reverse; }

#strap i, .strapDecor i { display: block; margin: 0 auto; }
#strap .hook, .strapDecor .hook {
  width: 12px; height: 10px;
  border: 3px solid #9fb0c8;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
#strap .rope, .strapDecor .rope {
  width: 3px; height: 42px;
  background: linear-gradient(90deg, #6c7d96, #aebfd8, #6c7d96);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}
#strap .loop, .strapDecor .loop {
  position: relative;
  width: 26px; height: 44px;
  border: 7px solid #93a5c0;
  border-top-color: #b7c6dd;
  border-radius: 14px / 22px;
  box-shadow: inset 0 2px 4px rgba(20, 30, 50, 0.55), 0 2px 6px rgba(0, 0, 0, 0.5);
}

@keyframes swayIdle {
  0%   { transform: rotate(-2deg); }
  50%  { transform: rotate(2deg); }
  100% { transform: rotate(-2deg); }
}

#strap.swing { animation: strapSwing 1.6s cubic-bezier(0.3, 0.7, 0.4, 1); }
@keyframes strapSwing {
  0%   { transform: rotate(0deg); }
  12%  { transform: rotate(15deg); }
  32%  { transform: rotate(-11deg); }
  52%  { transform: rotate(7deg); }
  72%  { transform: rotate(-4deg); }
  88%  { transform: rotate(2deg); }
  100% { transform: rotate(0deg); }
}

/* ---------- 车窗 ---------- */
#windowWrap {
  flex: 1;
  min-height: 0;
  padding: 6px 16px 10px;
}

#window {
  position: relative;
  height: 100%;
  max-width: 460px;
  margin: 0 auto;
  border: 9px solid var(--frame);
  border-radius: 16px;
  overflow: hidden;
  background: var(--night);
  box-shadow:
    inset 0 0 0 1px rgba(160, 185, 220, 0.12),
    inset 0 2px 10px rgba(0, 0, 0, 0.55),
    0 6px 24px rgba(0, 0, 0, 0.6);
}

#outside {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(#122142 0%, #0c1a30 42%, #081124 78%, #060d18 100%);
}

/* 城市剪影（两份拼接，平移 -50% 无缝循环） */
.city {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 200%;
  display: flex;
  animation: drive linear infinite;
}
.city svg { width: 50%; height: 100%; display: block; }
.city.far  { height: 34%; opacity: 0.9; animation-duration: 52s; }
.city.near { height: 24%; animation-duration: 30s; }

/* 钠灯 */
.lamps {
  position: absolute;
  left: 0;
  bottom: 12%;
  width: 200%;
  height: 26%;
  background-image: radial-gradient(circle at 50% 58%,
    rgba(255, 190, 120, 0.95) 0 2.5px,
    rgba(255, 160, 70, 0.5) 7px,
    rgba(255, 150, 60, 0.16) 15px,
    rgba(255, 140, 50, 0.05) 24px,
    transparent 30px);
  background-size: 300px 100%;
  background-repeat: repeat-x;
  animation: drive 14s linear infinite;
  opacity: 0.85;
}
.lampGlow {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 42%;
  background: linear-gradient(to top, rgba(255, 150, 60, 0.15), rgba(255, 150, 60, 0.04) 60%, transparent);
  pointer-events: none;
}

@keyframes drive {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* 画布层 */
#rainCanvas, #fogCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#rainCanvas { z-index: 2; }
#fogCanvas  { z-index: 5; cursor: pointer; }

/* 上次的留言（藏在雾后面） */
#noteLayer {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  pointer-events: none;
}
#noteText {
  display: none;
  max-width: 100%;
  color: rgba(255, 233, 190, 0.62);
  font-size: 16px;
  line-height: 1.9;
  letter-spacing: 3px;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 180, 100, 0.3);
}
#noteText.has { display: inline-block; }

/* 玻璃反光 */
#glassSheen {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(112deg,
      rgba(190, 215, 255, 0.10) 0%,
      rgba(190, 215, 255, 0.02) 22%,
      transparent 42%,
      transparent 64%,
      rgba(190, 215, 255, 0.05) 82%,
      rgba(190, 215, 255, 0.01) 100%);
}

/* 呼吸提示 */
#hint {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  text-align: center;
  font-size: 17px;
  letter-spacing: 8px;
  text-indent: 8px;
  color: #e3ecf8;
  text-shadow: 0 0 14px rgba(160, 190, 230, 0.55), 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  animation: breathe 3.6s ease-in-out infinite;
  transition: opacity 0.9s ease;
}
#hint.gone { opacity: 0 !important; animation: none; }
@keyframes breathe {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 0.95; }
}

/* ---------- 座椅与地板 ---------- */
#floor {
  position: relative;
  flex: none;
  height: 86px;
  background: linear-gradient(#0d1526 0%, #070d18 80%, #05090f 100%);
}
#seatRow {
  position: absolute;
  top: 0;
  left: 4%;
  right: 4%;
  height: 30px;
  border-radius: 0 0 10px 10px;
  background: repeating-linear-gradient(90deg,
    #131e33 0 54px,
    #0a1120 54px 62px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
}
#floorLight {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 8px;
  height: 34px;
  background: radial-gradient(50% 100% at 50% 100%, rgba(255, 160, 70, 0.12), transparent 75%);
}

/* ---------- 动作按钮 ---------- */
#actions {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 6px 14px 8px;
  position: relative;
  z-index: 50;
}
#actions button {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border: 1px solid rgba(120, 150, 190, 0.22);
  border-radius: 12px;
  background: linear-gradient(#16233c, #101a2e);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.3s ease, border-color 0.3s ease;
}
#actions button:active {
  transform: scale(0.96);
  background: linear-gradient(#1d2d4c, #16233c);
  border-color: rgba(160, 190, 230, 0.4);
}
#actions button.on {
  border-color: rgba(255, 170, 90, 0.45);
  color: #ffd9ae;
}

/* ---------- 一句话（车窗正下方，淡黄暖光） ---------- */
#quote {
  flex: none;
  min-height: 30px;
  padding: 8px 22px 2px;
  text-align: center;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 2px;
  color: rgba(255, 238, 186, 0.95);
  text-shadow:
    0 0 8px rgba(255, 200, 110, 0.4),
    0 0 24px rgba(255, 170, 60, 0.22);
  opacity: 0;
  transition: opacity 1.4s ease;
  position: relative;
  z-index: 50;
}
#quote.show { opacity: 1; }

/* ---------- 留言入口（最右按钮正下方） ---------- */
#dock {
  flex: none;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 2px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  position: relative;
  z-index: 60;
}
#noteBtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(120, 150, 190, 0.25);
  background: rgba(14, 22, 38, 0.82);
  color: rgba(160, 178, 205, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease, transform 0.12s ease;
}
#noteBtn:active { transform: scale(0.92); color: #ffd9ae; border-color: rgba(255, 170, 90, 0.5); }

/* ---------- 留言面板 ---------- */
#notePanel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 8, 16, 0.74);
  touch-action: auto;
}
#notePanel[hidden] { display: none; }

#noteSheet {
  width: min(88vw, 360px);
  padding: 26px 22px 18px;
  border-radius: 16px;
  background: linear-gradient(#14213a, #0d1526);
  border: 1px solid rgba(120, 150, 190, 0.2);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6);
}
#noteSheet h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #dde7f5;
}
#noteSheet .sub {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}
#noteInput {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(120, 150, 190, 0.28);
  background: #0a1120;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  font-family: inherit;
  resize: none;
  outline: none;
}
#noteInput:focus { border-color: rgba(255, 170, 90, 0.55); }
#noteInput::placeholder { color: #43536b; }
#noteCount {
  margin-top: 6px;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}
#noteSheet .row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
#noteSheet .row button {
  flex: 1;
  min-height: 46px;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  letter-spacing: 2px;
  cursor: pointer;
}
#noteSave {
  border: 1px solid rgba(255, 170, 90, 0.5);
  background: linear-gradient(#8a5a2c, #6e4620);
  color: #ffe6c8;
}
#noteClose {
  border: 1px solid rgba(120, 150, 190, 0.25);
  background: transparent;
  color: var(--muted);
}

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

body.paused .city,
body.paused .lamps,
body.paused #hint,
body.paused #strap,
body.paused .strapDecor { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .city, .lamps, #strap, .strapDecor { animation: none; }
}
