:root {
  --brand: #1b6dc1;
  --brand-2: #2ea7e0;
  --sky: #9ed4f5;
  --ink: #123457;
  --ink-soft: #3a5b7d;
  --card: rgba(255, 255, 255, 0.82);
  --card-strong: rgba(255, 255, 255, 0.92);
  --line: rgba(27, 109, 193, 0.14);
  --shadow: 0 10px 30px rgba(18, 52, 87, 0.18);
  --shadow-sm: 0 4px 16px rgba(18, 52, 87, 0.16);
  --radius: 20px;
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #eaf6ff 0%, #cfe9fb 40%, #9ed2f2 78%, #7fc0ec 100%);
  overflow: hidden;
}
body { position: fixed; inset: 0; touch-action: none; user-select: none; }

#app { position: absolute; inset: 0; }
#app canvas { display: block; width: 100%; height: 100%; }

/* ---------- UI 覆盖层 ---------- */
#ui {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}

/* ---------- 顶部 ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; margin-top: 4px;
}
.brand { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.brand-name { font-weight: 900; font-size: 21px; color: var(--brand); text-shadow: 0 1px 0 #fff; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: var(--ink-soft); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.chip {
  pointer-events: none; font-size: 12px; padding: 7px 13px; border-radius: 20px;
  background: var(--card); color: var(--brand); box-shadow: var(--shadow-sm);
  font-weight: 700; white-space: nowrap; backdrop-filter: blur(8px);
}
.chip-btn { pointer-events: auto; cursor: pointer; border: none; transition: transform .12s, background .2s; }
.chip-btn:active { transform: scale(.94); }

/* ---------- 状态卡 ---------- */
.status-card {
  align-self: center; text-align: center; max-width: 88%; min-width: min(88%, 380px);
  background: var(--card-strong); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow); backdrop-filter: blur(10px); border: 1px solid var(--line);
  transition: opacity .3s;
}
.status-emoji { font-size: 40px; line-height: 1; animation: floaty 2.4s ease-in-out infinite; }
.status-card h1 { margin: 8px 0 4px; font-size: 22px; color: var(--brand); font-weight: 900; }
.status-card p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink-soft); }
#status.off { opacity: 0; pointer-events: none; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- 字幕气泡 ---------- */
.bubble {
  position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%);
  width: min(88%, 560px); background: var(--card-strong); border-radius: 18px;
  box-shadow: var(--shadow); padding: 13px 40px 13px 14px; display: flex; align-items: center; gap: 10px;
  transition: opacity .25s, transform .25s; pointer-events: auto; border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.bubble.hidden { opacity: 0; transform: translateX(-50%) translateY(12px); pointer-events: none; }
.bubble-avatar { font-size: 32px; line-height: 1; }
.bubble-text { font-size: 16px; line-height: 1.55; color: var(--ink); }
.bubble-close { position: absolute; right: 10px; top: 8px; border: none; background: transparent; font-size: 22px; color: var(--ink); cursor: pointer; opacity: .55; pointer-events: auto; }
.bubble-close:active { opacity: 1; }

/* ---------- 底部控制 ---------- */
#controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; pointer-events: auto; }
.btn {
  pointer-events: auto; border: none; cursor: pointer; padding: 12px 17px; border-radius: 26px;
  font-size: 15px; font-weight: 800; color: #fff; background: var(--brand);
  box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .2s;
}
.btn:active { transform: scale(.93); box-shadow: 0 2px 8px rgba(18,52,87,.2); }
.btn-primary { background: linear-gradient(135deg, var(--brand-2), var(--brand)); font-size: 16px; }
.btn-wave { background: linear-gradient(135deg, #34b6ee, #1b6dc1); }
.btn-pink { background: linear-gradient(135deg, #ff9ab0, #f76a8c); }
.btn-ghost { background: rgba(255,255,255,.92); color: var(--brand); }

.hint { text-align: center; font-size: 13px; line-height: 1.7; margin: 10px auto 0; color: var(--ink-soft); opacity: .8; max-width: 640px; pointer-events: none; }

/* ---------- 关于面板（底部抽屉） ---------- */
.sheet {
  position: absolute; inset: 0; pointer-events: auto; z-index: 30;
  display: flex; align-items: flex-end; background: rgba(18,52,87,.28);
  transition: opacity .28s;
}
.sheet.hidden { opacity: 0; pointer-events: none; }
.sheet-card {
  width: 100%; max-height: 86vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card-strong); border-radius: 24px 24px 0 0; padding: 20px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(18,52,87,.28); backdrop-filter: blur(14px);
  transform: translateY(0); transition: transform .28s;
}
.sheet.hidden .sheet-card { transform: translateY(30px); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-title { font-size: 21px; font-weight: 900; color: var(--brand); }
.sheet-sub { font-size: 13px; color: var(--ink-soft); margin-top: 4px; letter-spacing: 1px; }
.sheet-close { border: none; background: var(--card); color: var(--ink); font-size: 22px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; box-shadow: var(--shadow-sm); flex: 0 0 auto; }
.sheet-para { font-size: 14.5px; line-height: 1.75; color: var(--ink-soft); margin: 0 0 16px; }
.dept { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.dept-ico { font-size: 26px; line-height: 1.2; }
.dept-name { font-weight: 800; color: var(--brand); font-size: 16px; margin-bottom: 3px; }
.dept-desc { font-size: 13.5px; line-height: 1.6; color: var(--ink-soft); }
.train { background: linear-gradient(135deg, rgba(46,167,224,.12), rgba(27,109,193,.08)); border: 1px solid rgba(46,167,224,.3); border-radius: 14px; padding: 12px 14px; margin: 14px 0; }
.train-title { font-weight: 800; color: var(--brand); font-size: 16px; margin-bottom: 4px; }
.train-desc { font-size: 13.5px; line-height: 1.6; color: var(--ink-soft); }
.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; }

/* ---------- 启动动画 ---------- */
.boot {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; background: radial-gradient(circle at 50% 30%, #eaf6ff, #a9d8f1);
  transition: opacity .6s; z-index: 20;
}
.boot.fade { opacity: 0; pointer-events: none; }
.boot-wave { font-size: 68px; animation: bob 1.4s ease-in-out infinite; }
.boot-title { font-size: 25px; font-weight: 900; color: var(--brand); }
.boot-note { font-size: 15px; color: var(--ink-soft); opacity: .85; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }

@media (max-width: 640px) {
  .brand-sub { display: none; }
  .hint { font-size: 12px; }
  .status-card h1 { font-size: 19px; }
}
