:root {
  --deep: #04141f;
  --mid: #0a2c40;
  --cyan: #63d3ea;
  --cyan-soft: #a7e8f5;
  --ink: #eaf7fb;
  --ink-dim: #8fb6c7;
  --glass: rgba(10, 40, 58, 0.55);
  --line: rgba(120, 200, 225, 0.22);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 8%, #0d3448 0%, #061c2a 45%, #030d15 100%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- 顶部 ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 0;
  z-index: 10; pointer-events: none;
}
#hud .back {
  pointer-events: auto;
  color: var(--ink-dim); text-decoration: none;
  font-size: 13px; letter-spacing: .04em;
  padding: 7px 14px; border-radius: 999px;
  background: rgba(6, 26, 38, .45);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  transition: .25s;
}
#hud .back:hover { color: var(--ink); border-color: rgba(120,200,225,.5); }

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink-dim);
  padding: 7px 14px 7px 12px; border-radius: 999px;
  background: rgba(6, 26, 38, .45);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4fd1a5; box-shadow: 0 0 10px #4fd1a5;
  animation: pulse 2.4s ease-in-out infinite;
}
.badge.listening .dot { background: #ffcf5c; box-shadow: 0 0 10px #ffcf5c; animation-duration: .9s; }
.badge.thinking .dot { background: #9d8cff; box-shadow: 0 0 10px #9d8cff; animation-duration: .55s; }
.badge.speaking .dot { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); animation-duration: .7s; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.45;transform:scale(.82)} }

/* ---------- 摄像头小窗 ---------- */
#camBox {
  position: fixed; top: calc(62px + env(safe-area-inset-top)); right: 20px;
  width: 148px; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line);
  background: #04121b;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  z-index: 10;
}
#camBox video { width: 100%; display: block; transform: scaleX(-1); opacity: .82; }
#camBox .camTag {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 10.5px; text-align: center; padding: 4px 0 5px;
  color: var(--ink-dim); letter-spacing: .08em;
  background: linear-gradient(transparent, rgba(4,18,27,.9));
}

/* ---------- 名字牌 ---------- */
#plate {
  position: fixed; left: 26px; bottom: 104px; z-index: 9;
  pointer-events: none;
  opacity: 0; transform: translateY(8px);
  transition: opacity .8s ease .3s, transform .8s ease .3s;
}
#plate.on { opacity: 1; transform: none; }
#plate h1 {
  font-size: 30px; font-weight: 700; letter-spacing: .06em;
  color: #eaf7fb;
  text-shadow: 0 2px 24px rgba(0,0,0,.6), 0 0 40px rgba(99,211,234,.25);
}
#plate p {
  margin-top: 6px; font-size: 12.5px; color: var(--ink-dim);
  letter-spacing: .05em;
}

/* ---------- 字幕 ---------- */
#caption {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(6px);
  bottom: 118px; z-index: 9;
  max-width: min(760px, 84vw);
  text-align: center;
  font-size: 19px; line-height: 1.65; letter-spacing: .02em;
  color: #f2fbfe;
  text-shadow: 0 2px 18px rgba(0,0,0,.85), 0 0 30px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
  padding: 0 10px;
}
#caption.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 底部输入 ---------- */
#dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: min(580px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 10px;
  border-radius: 999px;
  background: rgba(7, 30, 44, .62);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0,0,0,.42);
  z-index: 12;
}
#dock input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  color: var(--ink); font-size: 14.5px;
  padding: 9px 4px;
  font-family: inherit;
}
#dock input::placeholder { color: rgba(143,182,199,.65); }

#mic {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(99,211,234,.14);
  border: 1px solid rgba(99,211,234,.35);
  color: var(--cyan-soft);
  cursor: pointer; transition: .2s;
}
#mic:hover { background: rgba(99,211,234,.24); }
#mic.recording {
  background: #e2564f; border-color: #ff8b84; color: #fff;
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse { 0%,100%{box-shadow:0 0 0 0 rgba(226,86,79,.55)} 50%{box-shadow:0 0 0 12px rgba(226,86,79,0)} }

#send {
  flex: 0 0 auto;
  padding: 10px 18px; border-radius: 999px;
  background: linear-gradient(135deg, #4fc4de, #2f9fc0);
  color: #03151f; font-weight: 700; font-size: 13.5px;
  border: 0; cursor: pointer; transition: .2s;
  font-family: inherit;
}
#send:hover { filter: brightness(1.08); }
#send:disabled { opacity: .45; cursor: default; }

/* 开场时先藏起底部输入条 */
body.gated #dock { opacity: 0; visibility: hidden; }
#dock { transition: opacity .4s ease, visibility .4s; }

/* ---------- 开场卡 ---------- */
#gate {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: radial-gradient(70% 60% at 50% 42%, rgba(6,30,44,.22), rgba(3,13,21,.78));
  backdrop-filter: blur(1.5px);
  transition: opacity .6s ease, visibility .6s;
  padding: 20px;
}
#gate.off { opacity: 0; visibility: hidden; }

.card {
  width: min(430px, 100%);
  padding: 34px 30px 26px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(14,52,74,.66), rgba(7,28,41,.8));
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid rgba(120,200,225,.26);
  box-shadow: 0 26px 70px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06);
  text-align: center;
}
.card .fishIcon {
  font-size: 34px; margin-bottom: 10px;
  filter: drop-shadow(0 4px 18px rgba(99,211,234,.45));
}
.card h2 { font-size: 20px; font-weight: 700; letter-spacing: .03em; margin-bottom: 14px; }
.card p { font-size: 13.5px; line-height: 1.85; color: #b6d2de; }
.card p b { color: #d8f1f8; font-weight: 600; }
.card .tiny { margin-top: 14px; font-size: 11.5px; color: rgba(143,182,199,.7); }

.card button {
  width: 100%; padding: 14px; margin-top: 18px;
  border-radius: 13px; border: 0; cursor: pointer;
  font-size: 15px; font-weight: 700; font-family: inherit;
  background: linear-gradient(135deg, #59cde8, #2f9fc0);
  color: #03151f;
  transition: .2s;
}
.card button:hover { filter: brightness(1.07); }
.card button.ghost {
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--line); font-weight: 500; font-size: 13.5px;
  padding: 11px; margin-top: 8px;
}
.card button.ghost:hover { color: var(--ink); border-color: rgba(120,200,225,.45); }

/* ---------- 手机 ---------- */
@media (max-width: 640px) {
  #hud { padding: calc(10px + env(safe-area-inset-top)) 12px 0; }
  #hud .back { font-size: 12px; padding: 6px 11px; }
  .badge { font-size: 11.5px; padding: 6px 11px 6px 9px; }
  #camBox { width: 96px; top: calc(52px + env(safe-area-inset-top)); right: 12px; border-radius: 12px; }
  #camBox .camTag { font-size: 9px; }
  #plate { left: 18px; bottom: 88px; }
  #plate h1 { font-size: 19px; }
  #plate p { display: none; }
  #caption { font-size: 15px; bottom: 126px; max-width: 88vw; line-height: 1.6; }
  #dock { width: calc(100vw - 20px); padding: 6px 6px 6px 8px; }
  #mic { width: 38px; height: 38px; }
  #send { padding: 9px 14px; font-size: 12.5px; }
  .card { padding: 28px 22px 22px; }
  .card h2 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}
