* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --cyan: #00e5ff; --purple: #a855f7; --bg: #02040a; --card: #0a0f1c; --text: #e0f0ff; --muted: #8b9bb4;
  --mono: 'Consolas', 'Courier New', monospace;
}
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

/* 屏幕切换 */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; opacity: 0; transition: opacity 0.5s; }
.screen.active { display: flex; opacity: 1; z-index: 10; }
.screen.hidden { display: none; opacity: 0; z-index: 0; }

/* ================= 第一幕：高能方舟反应炉 ================= */
#boot-screen { align-items: center; justify-content: center; background: radial-gradient(circle at 50% 50%, rgba(0,229,255,0.08) 0%, var(--bg) 70%); cursor: pointer; }

/* 动态星尘背景 */
.hud-particles { position: absolute; inset: 0; background-image: radial-gradient(var(--cyan) 1px, transparent 1px), radial-gradient(var(--purple) 1px, transparent 1px); background-size: 50px 50px, 70px 70px; background-position: 0 0, 25px 25px; opacity: 0.15; animation: drift 10s linear infinite; }
@keyframes drift { to { background-position: 50px 50px, -25px 45px; } }

.reactor-wrap { position: relative; width: 220px; height: 220px; display: flex; align-items: center; justify-content: center; transition: 0.3s; }
.reactor-wrap:active { transform: scale(0.92); }

.ring { position: absolute; border-radius: 50%; border: 2px solid transparent; }
.ticks { width: 110%; height: 110%; border: 2px dashed rgba(0, 229, 255, 0.4); animation: spin 15s linear infinite; }
.outer-cyan { width: 100%; height: 100%; border-top: 3px solid var(--cyan); border-bottom: 3px solid var(--cyan); animation: spin 3s cubic-bezier(0.4, 0, 0.2, 1) infinite; box-shadow: 0 0 20px rgba(0,229,255,0.2); }
.outer-purple { width: 85%; height: 85%; border-left: 3px solid var(--purple); border-right: 3px solid var(--purple); animation: spin-reverse 2s linear infinite; box-shadow: 0 0 30px rgba(168,85,247,0.2); }
.inner-dashed { width: 65%; height: 65%; border: 2px dashed rgba(255, 255, 255, 0.5); animation: spin 8s linear infinite; }
.inner-solid { width: 50%; height: 50%; border-top: 1px solid #fff; border-bottom: 1px solid #fff; animation: spin-reverse 1.5s ease-in-out infinite; }

.core-glow { position: absolute; width: 45%; height: 45%; border-radius: 50%; background: radial-gradient(circle, #fff 0%, var(--cyan) 40%, transparent 80%); box-shadow: 0 0 60px var(--cyan), 0 0 100px var(--purple); animation: heartbeat 1.5s ease-in-out infinite alternate; }
.core-center { position: absolute; width: 15%; height: 15%; background: #fff; border-radius: 50%; box-shadow: 0 0 20px #fff; }

.hud-text { position: absolute; font-family: var(--mono); color: var(--cyan); font-size: 11px; letter-spacing: 2px; }
.hud-text.top { top: -40px; animation: blink 2s infinite; }
.hud-text.bottom { bottom: -50px; font-size: 13px; text-shadow: 0 0 10px var(--cyan); animation: pulse 1s infinite alternate; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-reverse { to { transform: rotate(-360deg); } }
@keyframes heartbeat { from { transform: scale(0.9); opacity: 0.7; } to { transform: scale(1.15); opacity: 1; } }
@keyframes blink { 50% { opacity: 0.2; } }
@keyframes pulse { from { opacity: 0.5; } to { opacity: 1; } }

/* 爆闪特效 */
#flash-screen { position: fixed; inset: 0; background: #fff; z-index: 9999; opacity: 0; pointer-events: none; }
#flash-screen.active { animation: bigFlash 0.6s ease-out forwards; }
@keyframes bigFlash { 0% { opacity: 0; } 10% { opacity: 1; } 100% { opacity: 0; } }

/* 屏幕震动 */
.shake { animation: screenShake 0.4s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes screenShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* ================= 第二幕：门厅 ================= */
#lobby-screen { justify-content: center; padding: 20px; background: radial-gradient(circle at 50% 0%, rgba(0,229,255,0.05) 0%, transparent 60%); overflow-y: auto; }
.lobby-header { text-align: center; margin-bottom: 30px; margin-top: 20px; }
.glitch-text { font-family: var(--mono); color: var(--cyan); font-size: 26px; letter-spacing: 4px; position: relative; }
.glitch-text::before, .glitch-text::after { content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg); }
.glitch-text::before { left: 2px; text-shadow: -2px 0 red; animation: glitch 3s infinite; }
.glitch-text::after { left: -2px; text-shadow: 2px 0 blue; animation: glitch 2s infinite reverse; }
@keyframes glitch { 0%, 90% { clip-path: inset(0 0 0 0); } 92% { clip-path: inset(20% 0 40% 0); } 94% { clip-path: inset(60% 0 10% 0); } }

.lobby-cards { display: flex; flex-direction: column; gap: 16px; max-width: 420px; margin: 0 auto; width: 100%; }
.lobby-card { background: rgba(10, 15, 28, 0.85); border: 1px solid rgba(0, 229, 255, 0.2); border-radius: 16px; padding: 24px; text-align: left; cursor: pointer; transition: 0.3s; backdrop-filter: blur(10px); position: relative; overflow: hidden; }
.lobby-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cyan); opacity: 0.5; transition: 0.3s; }
.lobby-card:hover { border-color: var(--cyan); transform: translateX(5px); box-shadow: 0 10px 30px rgba(0, 229, 255, 0.15); }
.lobby-card:hover::before { opacity: 1; box-shadow: 0 0 15px var(--cyan); }
.lobby-card .icon { font-size: 30px; margin-bottom: 12px; }
.lobby-card h2 { color: #fff; font-size: 19px; margin-bottom: 6px; }
.lobby-card p { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* ================= 第三幕：聊天界面 ================= */
#chat-screen { height: 100%; display: flex; flex-direction: column; }
header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: rgba(2, 4, 10, 0.9); border-bottom: 1px solid rgba(0, 229, 255, 0.2); backdrop-filter: blur(10px); z-index: 10; }
.btn-back, .btn-clear { background: transparent; border: none; color: var(--muted); font-family: var(--mono); font-size: 14px; cursor: pointer; }
.btn-back:hover { color: var(--cyan); }
.title { font-family: var(--mono); color: var(--cyan); font-weight: bold; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; box-shadow: 0 0 10px #22c55e; }

main#chat-box { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 12px; font-size: 15px; line-height: 1.6; word-break: break-word; }
.msg.bot { align-self: flex-start; background: rgba(0, 229, 255, 0.08); border: 1px solid rgba(0, 229, 255, 0.3); color: #b6f6ff; border-radius: 0 12px 12px 12px; }
.msg.user { align-self: flex-end; background: rgba(168, 85, 247, 0.15); border: 1px solid rgba(168, 85, 247, 0.4); color: #fff; border-radius: 12px 0 12px 12px; }
.msg code { background: #000; padding: 2px 6px; border-radius: 4px; font-family: var(--mono); color: var(--cyan); }
.msg pre { background: #000; padding: 12px; border-radius: 8px; overflow-x: auto; margin-top: 8px; border: 1px solid rgba(0, 229, 255, 0.2); }

footer { padding: 12px 16px; background: rgba(2, 4, 10, 0.95); border-top: 1px solid rgba(0, 229, 255, 0.2); display: flex; gap: 10px; align-items: flex-end; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
textarea { flex: 1; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(0, 229, 255, 0.3); border-radius: 8px; color: #fff; padding: 12px; font-family: var(--mono); font-size: 15px; resize: none; outline: none; max-height: 120px; }
textarea:focus { border-color: var(--cyan); }
#send-btn { background: var(--cyan); color: #000; border: none; padding: 0 16px; height: 44px; border-radius: 8px; font-weight: bold; font-family: var(--mono); cursor: pointer; transition: 0.2s; }
#send-btn:disabled { background: #333; color: #888; }