/* ==========================================================================
   《天台倒計時 v2.0》DEBT & DEGEN — Director's Cut Visual Polish
   Retro Bloomberg Financial Terminal × Neon Cyberpunk Rooftop Underground OS
   ========================================================================== */

:root {
  --bg-void: #06070c;
  --bg-panel: rgba(13, 17, 28, 0.92);
  --bg-panel-2: rgba(20, 26, 42, 0.92);
  --bg-inset: rgba(7, 10, 17, 0.94);
  --border-dim: #242f4b;
  --border-glow: #3e5280;
  --text-main: #ecf2ff;
  --text-dim: #8b9bc0;
  --neon-green: #00ff88;
  --neon-red: #ff2a6d;
  --neon-gold: #ffb800;
  --neon-cyan: #05d9e8;
  --neon-purple: #c05cff;
  --ambient-glow: rgba(5, 217, 232, 0.14);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}

/* Dynamic Time-of-Day Ambient Lighting */
body.period-0 { --ambient-glow: rgba(5, 217, 232, 0.16); }   /* 早盤: Cold Cyber Cyan */
body.period-1 { --ambient-glow: rgba(255, 184, 0, 0.15); }   /* 午盤: Overheating Amber */
body.period-2 { --ambient-glow: rgba(192, 92, 255, 0.18); }  /* 深夜: Underground Neon Violet */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-void);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  user-select: none;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ==========================================================================
   CYBERPUNK ROOFTOP SKYLINE WALLPAPER & ANIMATED RAIN
   ========================================================================== */
.rooftop-wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle at 72% 15%, var(--ambient-glow) 0%, #06070c 68%);
  transition: background 0.8s ease;
}

.skyline-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 46vh;
  opacity: 0.72;
}

.rain-layer {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    102deg,
    transparent 0px,
    transparent 38px,
    rgba(5, 217, 232, 0.045) 39px,
    transparent 40px
  );
  animation: rainDrift 4s linear infinite;
}

@keyframes rainDrift {
  from { background-position: 0 0; }
  to   { background-position: -60px 260px; }
}

.fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 9400;
  pointer-events: none;
}

/* ==========================================================================
   CRT SCANLINES & TILT / RED-HOT OVERLAYS
   ========================================================================== */
.crt-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0px,
    rgba(255, 255, 255, 0) 2px,
    rgba(0, 0, 0, 0.14) 3px,
    rgba(0, 0, 0, 0.14) 4px
  );
  opacity: 0.52;
  transition: opacity 0.25s;
}
body:not(.crt-enabled) .crt-overlay { opacity: 0; }

.tilt-vignette {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 8900;
  box-shadow: inset 0 0 110px rgba(255, 20, 60, 0);
  transition: box-shadow 0.35s ease;
}

body.tilt-active .tilt-vignette {
  box-shadow: inset 0 0 140px rgba(255, 20, 60, 0.68);
  animation: tiltPulse 0.7s infinite alternate;
}

body.tilt-active .os-desktop { animation: tiltShake 0.28s infinite; }

@keyframes tiltPulse {
  from { box-shadow: inset 0 0 90px rgba(255, 20, 60, 0.45); }
  to   { box-shadow: inset 0 0 175px rgba(255, 20, 60, 0.88); }
}

@keyframes tiltShake {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-1.5px, 1px); }
  50%  { transform: translate(1.5px, -1px); }
  75%  { transform: translate(-1px, -1px); }
  100% { transform: translate(1px, 1px); }
}

body.screen-grayscale { filter: grayscale(100%) contrast(1.25); }

.floating-fx-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9500;
  overflow: hidden;
}

.float-pop {
  position: fixed;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 24px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95);
  pointer-events: none;
  animation: floatUpFade 1.15s ease-out forwards;
}

@keyframes floatUpFade {
  0%   { transform: translate(-50%, 0) scale(0.75); opacity: 1; }
  30%  { transform: translate(-50%, -24px) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -82px) scale(0.95); opacity: 0; }
}

/* ==========================================================================
   START / BOOT SCREEN
   ========================================================================== */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, rgba(28, 32, 62, 0.82) 0%, rgba(6, 7, 12, 0.94) 72%);
  padding: 24px;
}

.start-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(5, 217, 232, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(5, 217, 232, 0.07) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 90%);
}

.start-card {
  position: relative;
  width: 100%;
  max-width: 800px;
  background: rgba(13, 17, 28, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  padding: 36px 38px;
  box-shadow: 0 0 70px rgba(255, 42, 109, 0.2), 0 0 30px rgba(5, 217, 232, 0.12), 0 28px 70px rgba(0, 0, 0, 0.85);
}

.start-badge-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

.badge-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}
.badge-danger { background: rgba(255, 42, 109, 0.18); color: var(--neon-red); border: 1px solid rgba(255, 42, 109, 0.5); }
.badge-gold   { background: rgba(255, 184, 0, 0.15); color: var(--neon-gold); border: 1px solid rgba(255, 184, 0, 0.45); }
.badge-cyan   { background: rgba(5, 217, 232, 0.14); color: var(--neon-cyan); border: 1px solid rgba(5, 217, 232, 0.45); }

.start-title { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.glitch-text {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 3px 0 var(--neon-red), -3px 0 var(--neon-cyan), 0 0 26px rgba(5, 217, 232, 0.35);
}
.start-subtitle { font-family: var(--font-mono); font-size: 15px; color: var(--neon-gold); letter-spacing: 1px; }
.start-pitch { color: #c7d4f0; font-size: 14.5px; line-height: 1.75; margin-bottom: 26px; }
.start-pitch strong { color: #fff; }

.start-mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }

.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 18px;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}
.mode-card:hover { transform: translateY(-2px); }
.mode-free:hover  { border-color: var(--neon-green); box-shadow: 0 0 26px rgba(0, 255, 136, 0.22); }
.mode-daily:hover { border-color: var(--neon-gold);  box-shadow: 0 0 26px rgba(255, 184, 0, 0.26); }

.mode-icon  { font-size: 34px; }
.mode-info  { flex: 1; }
.mode-title { font-size: 16px; font-weight: 800; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.mode-desc  { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.mode-arrow { font-weight: 900; color: var(--neon-cyan); font-size: 14px; white-space: nowrap; }

.tag-hot { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--neon-red); color: #fff; font-family: var(--font-mono); }
.tag-cyan { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: rgba(5, 217, 232, 0.15); color: var(--neon-cyan); border: 1px solid rgba(5, 217, 232, 0.35); }

.start-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border-dim); }
.start-tips { font-size: 12px; color: var(--text-dim); }

/* ==========================================================================
   MAIN OS DESKTOP LAYOUT
   ========================================================================== */
.os-desktop {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(9, 12, 20, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-glow);
  flex-shrink: 0;
}

.top-brand { display: flex; align-items: center; gap: 8px; }
.os-logo { font-weight: 900; font-size: 15px; color: var(--neon-cyan); letter-spacing: 1px; text-shadow: 0 0 10px rgba(5,217,232,0.5); }
.mode-tag { font-size: 11px; padding: 2px 7px; border-radius: 4px; background: rgba(192, 92, 255, 0.18); color: #e2b3ff; border: 1px solid rgba(192, 92, 255, 0.45); font-family: var(--font-mono); }
.day-badge { font-size: 12.5px; font-weight: 800; padding: 3px 10px; border-radius: 5px; background: rgba(255, 184, 0, 0.15); color: var(--neon-gold); border: 1px solid rgba(255, 184, 0, 0.4); }

.top-metrics { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: center; }

.metric-box {
  display: flex;
  flex-direction: column;
  padding: 4px 11px;
  background: var(--bg-inset);
  border: 1px solid var(--border-dim);
  border-radius: 7px;
  min-width: 115px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.metric-box .m-label { font-size: 10px; color: var(--text-dim); letter-spacing: 0.4px; }
.metric-box .m-val   { font-size: 14.5px; font-weight: 900; }
.metric-countdown .m-val { color: var(--neon-gold); font-size: 13px; }
.metric-cash .m-val      { color: var(--neon-green); text-shadow: 0 0 10px rgba(0, 255, 136, 0.35); }
.metric-debt .m-val      { color: var(--neon-red); }

.metric-bpm { flex-direction: row; align-items: center; gap: 8px; min-width: 165px; }
.metric-bpm.danger-bpm { border-color: var(--neon-red); background: rgba(255, 42, 109, 0.15); box-shadow: 0 0 14px rgba(255, 42, 109, 0.3); }
.metric-bpm .m-val { color: var(--neon-red); }

.top-actions { display: flex; align-items: center; gap: 6px; }
.btn-next-period {
  background: linear-gradient(135deg, #ff8800, #ff2a6d);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(255, 42, 109, 0.4);
  transition: transform 0.12s, filter 0.15s;
}
.btn-next-period:hover { transform: translateY(-1px); filter: brightness(1.12); }

.btn-icon {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;
}
.btn-icon:hover { border-color: var(--neon-cyan); }

/* SURVIVAL STRIP */
.survival-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 14px;
  background: rgba(12, 16, 27, 0.88);
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
  overflow-x: auto;
}
.stat-pill { display: flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.stat-name { color: var(--text-dim); font-weight: 700; }
.stat-bar-track { width: 74px; height: 8px; background: #192136; border-radius: 99px; overflow: hidden; border: 1px solid #2d3b5e; }
.stat-bar-fill { height: 100%; transition: width 0.35s ease; }
.fill-sanity  { background: linear-gradient(90deg, #ff2a6d, #05d9e8); }
.fill-partner { background: linear-gradient(90deg, #ff2a6d, #ff77aa); }
.fill-health  { background: linear-gradient(90deg, #ff2a6d, #00ff88); }
.stat-num { font-weight: 800; font-size: 12px; min-width: 24px; }
.kidney-val { color: var(--neon-gold); }

.relic-quick-bar { display: flex; align-items: center; gap: 8px; margin-left: auto; overflow-x: auto; }
.relic-label { font-size: 11.5px; color: var(--neon-purple); font-weight: 800; white-space: nowrap; }
.relic-chips { display: flex; gap: 6px; align-items: center; }
.relic-empty { font-size: 11.5px; color: var(--text-dim); }
.relic-chip {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(192, 92, 255, 0.16);
  border: 1px solid rgba(192, 92, 255, 0.5);
  color: #f0d6ff;
  white-space: nowrap;
  cursor: help;
}
.synergy-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(255, 184, 0, 0.18);
  border: 1px solid var(--neon-gold);
  color: #ffe388;
  font-weight: 800;
  white-space: nowrap;
}

/* WORKSPACE SPLIT */
.workspace-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 336px 1fr;
  gap: 10px;
  padding: 10px;
  min-height: 0;
}

.window-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glow);
  border-radius: 11px;
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.window-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: linear-gradient(180deg, #171e32, #111626);
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}
.win-dots { display: flex; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }
.win-title { font-size: 12.5px; font-weight: 800; color: #d1dcf7; }

/* ==========================================================================
   LEFT PANEL: WECHAT (微訊) WITH CUSTOM SVG PORTRAITS
   ========================================================================== */
.wechat-body { flex: 1; display: grid; grid-template-columns: 94px 1fr; min-height: 0; }
.wechat-contacts { background: rgba(9, 12, 20, 0.95); border-right: 1px solid var(--border-dim); overflow-y: auto; display: flex; flex-direction: column; }

.contact-item {
  position: relative;
  padding: 9px 6px;
  border-bottom: 1px solid #161d30;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  transition: background 0.15s;
}
.contact-item:hover { background: #141c30; }
.contact-item.active { background: #1c2640; border-left: 3px solid var(--neon-green); }
.contact-avatar { width: 38px; height: 38px; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.contact-name { font-size: 11px; font-weight: 700; color: #d9e4ff; line-height: 1.2; }
.contact-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--neon-red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(255, 42, 109, 0.7);
}

.wechat-chat-pane { display: flex; flex-direction: column; min-height: 0; background: rgba(11, 15, 25, 0.92); }
.wechat-chat-header { padding: 8px 10px; font-size: 12.5px; font-weight: 800; border-bottom: 1px solid #1d263d; color: var(--neon-cyan); background: #101626; }
.wechat-messages { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 9px; }

.chat-msg { max-width: 92%; padding: 8px 10px; border-radius: 9px; font-size: 12.5px; line-height: 1.5; word-break: break-word; }
.chat-msg.incoming { align-self: flex-start; background: #192136; border: 1px solid #2b3859; color: #e8f0ff; }
.chat-msg.outgoing { align-self: flex-end; background: #0e4f3c; border: 1px solid #1d9470; color: #ecfff8; }

.voice-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 42, 109, 0.16);
  border: 1px solid rgba(255, 42, 109, 0.45);
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 5px;
  font-size: 11px;
  color: #ffa3be;
  cursor: pointer;
}
.chat-meta { font-size: 10px; color: var(--text-dim); margin-top: 3px; }
.wechat-reply-box { padding: 8px; border-top: 1px solid #1d263d; background: #0a0d16; display: flex; flex-direction: column; gap: 6px; }
.reply-btn { background: #17213a; border: 1px solid #30426e; color: #e2ecff; border-radius: 6px; padding: 6px 8px; font-size: 12px; text-align: left; cursor: pointer; transition: all 0.15s; }
.reply-btn:hover { border-color: var(--neon-green); background: #1e2d4d; }

/* ==========================================================================
   RIGHT PANEL: APP TABS & VIEWPORT
   ========================================================================== */
.main-app-titlebar { padding: 6px 10px; justify-content: flex-start; }
.app-tabs { display: flex; gap: 5px; flex-wrap: wrap; }
.app-tab {
  background: #0d1220;
  border: 1px solid var(--border-dim);
  color: var(--text-dim);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.app-tab:hover { color: #fff; border-color: var(--border-glow); }
.app-tab.active {
  background: linear-gradient(180deg, #1f2b4a, #141c33);
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 14px rgba(5, 217, 232, 0.28);
}

.app-viewport { flex: 1; overflow-y: auto; padding: 12px 14px; position: relative; }
.app-view { display: none; height: 100%; }
.app-view.active { display: flex; flex-direction: column; gap: 9px; }

/* ==========================================================================
   APP 1: 極速交易所 (Bloomberg Terminal Upgrade)
   ========================================================================== */
.exchange-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 7px 12px;
  flex-wrap: wrap;
}
.stock-selector-wrap { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.terminal-select, .terminal-input { background: #131b2e; color: #fff; border: 1px solid var(--border-glow); border-radius: 6px; padding: 5px 9px; font-size: 12.5px; font-weight: 700; outline: none; }
.stock-tag { font-size: 11px; padding: 2px 7px; border-radius: 4px; background: rgba(255, 42, 109, 0.16); color: var(--neon-red); border: 1px solid rgba(255, 42, 109, 0.45); }
.mood-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: rgba(0, 255, 136, 0.12); color: var(--neon-green); border: 1px solid rgba(0, 255, 136, 0.4); font-weight: 800; }
.stock-lore-bar { font-size: 11.5px; color: var(--text-dim); padding: 0 4px; }

.price-display { display: flex; align-items: baseline; gap: 8px; }
.price-val { font-size: 24px; font-weight: 900; }
.price-chg { font-size: 13px; font-weight: 800; padding: 2px 6px; border-radius: 4px; }
.price-up   { color: var(--neon-green); }
.price-down { color: var(--neon-red); }

.session-timer-box { display: flex; align-items: center; gap: 8px; }
.timer-bar-wrap { width: 105px; height: 10px; background: #182036; border-radius: 99px; overflow: hidden; border: 1px solid #2e3b60; }
.timer-bar-fill { height: 100%; background: linear-gradient(90deg, var(--neon-red), var(--neon-gold), var(--neon-green)); transition: width 0.08s linear; }
.timer-num { font-size: 14px; font-weight: 900; color: var(--neon-gold); min-width: 42px; }

.insider-banner { padding: 7px 12px; border-radius: 6px; background: rgba(192, 92, 255, 0.18); border: 1px solid var(--neon-purple); color: #f2d9ff; font-size: 12.5px; font-weight: 700; }

.kline-terminal-grid {
  display: grid;
  grid-template-columns: 1fr 170px;
  gap: 8px;
  flex: 1;
  min-height: 225px;
}

.kline-stage {
  position: relative;
  background: #05070d;
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#kline-canvas { width: 100%; height: 100%; display: block; }

.orderbook-pane {
  background: #070a12;
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}
.ob-title { font-size: 11.5px; font-weight: 800; color: var(--neon-cyan); border-bottom: 1px solid #1b243c; padding-bottom: 4px; }
.ob-list  { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 11px; overflow: hidden; }
.ob-row   { display: flex; justify-content: space-between; }
.ob-buy   { color: var(--neon-green); }
.ob-sell  { color: var(--neon-red); }
.ob-empty { color: var(--text-dim); text-align: center; margin-top: 30px; font-family: var(--font-sans); }

.network-lag-overlay { position: absolute; inset: 0; background: rgba(7, 8, 13, 0.84); display: flex; align-items: center; justify-content: center; z-index: 20; }
.lag-box { text-align: center; padding: 18px 26px; background: #1a1019; border: 2px solid var(--neon-red); border-radius: 10px; box-shadow: 0 0 32px rgba(255, 42, 109, 0.45); }
.lag-spinner { font-size: 32px; animation: spin 1s linear infinite; }
.lag-title { font-size: 17px; font-weight: 900; color: var(--neon-red); margin-top: 6px; }
.lag-sub   { font-size: 13px; color: #ffbfd0; margin-top: 4px; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.btn-rewind {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 25;
  background: linear-gradient(135deg, #05d9e8, #7b2cbf);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 900;
  font-size: 12.5px;
  cursor: pointer;
  animation: pulseBtn 0.8s infinite alternate;
}

.position-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  background: rgba(10, 14, 24, 0.92);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  font-size: 12px;
}
.pos-badge { padding: 2px 6px; border-radius: 4px; font-weight: 800; font-size: 11px; }
.pos-long  { background: rgba(0, 255, 136, 0.2); color: var(--neon-green); }
.pos-short { background: rgba(255, 42, 109, 0.2); color: var(--neon-red); }

.exchange-controls { display: flex; flex-direction: column; gap: 9px; background: var(--bg-panel-2); border: 1px solid var(--border-dim); border-radius: 8px; padding: 10px 12px; }
.control-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
.leverage-box, .margin-box { background: var(--bg-inset); border: 1px solid var(--border-dim); border-radius: 7px; padding: 8px 10px; transition: all 0.2s; }
.leverage-box.lev-hot { border-color: #ff6b00; box-shadow: 0 0 18px rgba(255, 107, 0, 0.35); }
.leverage-box.lev-inferno { border-color: var(--neon-red); box-shadow: 0 0 28px rgba(255, 42, 109, 0.6); animation: infernoPulse 0.45s infinite alternate; }
@keyframes infernoPulse { from { box-shadow: 0 0 14px rgba(255, 42, 109, 0.4); } to { box-shadow: 0 0 30px rgba(255, 42, 109, 0.88); } }

.lev-header { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.lev-val { font-size: 15px; color: var(--neon-gold); }
#lev-slider { width: 100%; accent-color: var(--neon-red); cursor: pointer; }
.lev-ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }
.tick-100 { color: var(--neon-red); font-weight: 800; }
.lev-smoke { margin-top: 5px; font-size: 11px; color: #ff8e53; font-weight: 700; }

.margin-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.btn-chip { background: #17213b; border: 1px solid #2e3d66; color: #dce7ff; border-radius: 5px; padding: 6px 8px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.14s; }
.btn-chip:hover, .btn-chip.active { border-color: var(--neon-cyan); background: #213259; color: #fff; }
.btn-chip-allin { border-color: rgba(255, 42, 109, 0.65); color: #ff80a6; }

.trade-action-row { display: flex; gap: 7px; flex-wrap: wrap; position: relative; }

.btn-trade {
  border: none;
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  transition: transform 0.12s, filter 0.15s, box-shadow 0.2s;
  flex: 1;
  min-width: 102px;
}
.btn-trade:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; }
.btn-trade:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.1); }

.btn-open-market { background: linear-gradient(135deg, #05d9e8, #0077ff); color: #04101f; }
.btn-long        { background: linear-gradient(135deg, #00c96c, #008f4c); }
.btn-short       { background: linear-gradient(135deg, #ff2a6d, #b80f44); }
.btn-reverse     { background: linear-gradient(135deg, #9d4edd, #5a189a); }
.btn-close-pos   { background: linear-gradient(135deg, #4b5c82, #2e3a57); }
.btn-allin-degen { background: linear-gradient(135deg, #ffb800, #ff2a6d); box-shadow: 0 0 18px rgba(255, 184, 0, 0.35); }

body.tilt-active .btn-allin-degen {
  transform: scale(1.12);
  box-shadow: 0 0 36px #ffb800, 0 0 70px rgba(255, 184, 0, 0.8) !important;
  animation: holyGlow 0.55s infinite alternate;
  z-index: 30;
}
@keyframes holyGlow {
  from { box-shadow: 0 0 22px #ffb800, 0 0 40px #ff2a6d; filter: brightness(1.05); }
  to   { box-shadow: 0 0 42px #fff3a1, 0 0 85px #ffb800; filter: brightness(1.3); }
}

.evading-active { position: relative; transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1) !important; z-index: 40; }

.btn-ghost { background: transparent; border: 1px solid var(--border-glow); color: var(--text-main); border-radius: 6px; padding: 7px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.btn-ghost:hover { border-color: var(--neon-cyan); color: var(--neon-cyan); }

/* ==========================================================================
   APP 2: 賽博賽馬場
   ========================================================================== */
.app-header-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.app-header-bar h2 { font-size: 17px; }
.sub-hint { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.race-status-pill { padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 800; background: rgba(0, 255, 136, 0.14); color: var(--neon-green); border: 1px solid rgba(0, 255, 136, 0.45); }

.race-track-wrap { position: relative; background: #070a12; border: 1px solid var(--border-glow); border-radius: 8px; overflow: hidden; }
#race-canvas { width: 100%; height: 220px; display: block; }

.race-qte-overlay { position: absolute; inset: 0; background: rgba(7, 10, 18, 0.86); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; z-index: 20; }
.qte-title { font-size: 16px; font-weight: 900; color: var(--neon-gold); }
.qte-bar { position: relative; width: 90%; max-width: 560px; height: 34px; display: flex; border-radius: 8px; overflow: hidden; border: 2px solid #fff; font-size: 11px; font-weight: 800; }
.qte-zone-black  { flex: 1.2; background: #18181f; color: #ff5d8f; display: flex; align-items: center; justify-content: center; }
.qte-zone-normal { flex: 1.5; background: #263554; color: #b7c8eb; display: flex; align-items: center; justify-content: center; }
.qte-zone-gold   { flex: 0.9; background: linear-gradient(90deg, #ff9900, #ffe600, #ff9900); color: #111; display: flex; align-items: center; justify-content: center; }
.qte-cursor { position: absolute; top: -2px; bottom: -2px; width: 6px; background: #fff; box-shadow: 0 0 12px #fff, 0 0 20px var(--neon-cyan); left: 50%; }

.race-commentary { padding: 7px 10px; background: #121829; border-left: 3px solid var(--neon-gold); border-radius: 5px; font-size: 12.5px; color: #ffe399; }
.horse-roster { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.horse-card { background: var(--bg-panel-2); border: 1px solid var(--border-dim); border-radius: 8px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: all 0.14s; }
.horse-card:hover { border-color: var(--neon-cyan); transform: translateY(-2px); }
.horse-card.selected { border-color: var(--neon-gold); background: rgba(255, 184, 0, 0.13); box-shadow: 0 0 18px rgba(255, 184, 0, 0.25); }
.horse-top { display: flex; justify-content: space-between; align-items: center; }
.horse-odds { font-family: var(--font-mono); font-weight: 900; color: var(--neon-gold); font-size: 13px; }
.horse-name { font-size: 12.5px; font-weight: 800; }
.horse-trait { font-size: 11px; color: var(--text-dim); line-height: 1.3; }

.race-bet-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: var(--bg-inset); border: 1px solid var(--border-dim); border-radius: 8px; padding: 10px; }
.bet-input-group, .sabotage-group { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.btn-sabotage { background: #24132b; border: 1px solid #8a35b8; color: #e9baff; border-radius: 6px; padding: 7px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.btn-sabotage:hover { background: #341a40; border-color: var(--neon-purple); }
.btn-sabotage.used  { opacity: 0.5; border-color: var(--neon-green); color: var(--neon-green); }

/* ==========================================================================
   APP 3 & 4: 盲盒刮刮樂 + 地下賭場 (Slot Machine & Russian Roulette)
   ========================================================================== */
.gacha-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; height: 100%; }
.gacha-card-panel { background: var(--bg-panel-2); border: 1px solid var(--border-dim); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.casino-neon-panel   { border-color: rgba(255, 184, 0, 0.45); box-shadow: inset 0 0 28px rgba(255, 184, 0, 0.06); }
.casino-danger-panel { border-color: rgba(255, 42, 109, 0.45); box-shadow: inset 0 0 28px rgba(255, 42, 109, 0.07); }

.panel-head { display: flex; justify-content: space-between; align-items: center; }
.scratch-tier-row, .scratch-actions, .bb-action-row, .slot-bet-row, .bullet-select-row { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }

.slot-cabinet {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: linear-gradient(180deg, #0b0e18, #191124);
  border: 2px solid var(--neon-gold);
  border-radius: 12px;
  padding: 18px 14px;
  box-shadow: 0 0 24px rgba(255, 184, 0, 0.2), inset 0 0 16px rgba(0, 0, 0, 0.85);
}
.slot-reel {
  height: 96px;
  background: linear-gradient(180deg, #090c14 0%, #1c243b 50%, #090c14 100%);
  border: 1px solid #3c4f7a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  box-shadow: inset 0 6px 12px rgba(0, 0, 0, 0.7), inset 0 -6px 12px rgba(0, 0, 0, 0.7);
}

.revolver-stage {
  background: var(--bg-inset);
  border: 1px solid rgba(255, 42, 109, 0.35);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.revolver-cylinder {
  font-size: 56px;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 16px rgba(255, 42, 109, 0.45));
}
.roulette-odds-hint { font-size: 13px; color: #dbe6ff; }

.scratch-stage { position: relative; width: 100%; max-width: 340px; height: 200px; margin: 0 auto; border-radius: 10px; overflow: hidden; border: 2px solid var(--neon-gold); background: linear-gradient(135deg, #2b1800, #140b00); }
.scratch-underlay { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); gap: 6px; padding: 10px; }
.scratch-cell { background: rgba(255, 215, 0, 0.08); border: 1px dashed rgba(255, 184, 0, 0.35); border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; }
.scratch-cell .sc-ico { font-size: 26px; }
.scratch-cell .sc-amt { font-size: 11px; color: var(--neon-gold); font-family: var(--font-mono); }
#scratch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

.mini-status { font-size: 12.5px; padding: 7px 10px; border-radius: 6px; background: var(--bg-inset); color: var(--neon-gold); text-align: center; }
.blindbox-stage { background: var(--bg-inset); border: 1px solid var(--border-dim); border-radius: 8px; padding: 14px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bb-box-visual { font-size: 46px; }
.bb-info { font-size: 12.5px; color: #dbe6ff; }
.bb-inventory-header { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 700; }
.bb-inventory-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; max-height: 210px; }
.bb-item-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; background: var(--bg-inset); border: 1px solid var(--border-dim); border-radius: 6px; font-size: 12px; }
.bb-item-row.rarity-SSR { border-color: var(--neon-gold); background: rgba(255, 184, 0, 0.1); }
.bb-item-row.rarity-SR  { border-color: var(--neon-purple); }
.empty-hint { color: var(--text-dim); font-size: 12px; text-align: center; padding: 14px; }

/* ==========================================================================
   APP 5 & 6: 地下錢莊 & 深夜會所 + 流派羈絆
   ========================================================================== */
.survival-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.surv-panel { background: var(--bg-panel-2); border: 1px solid var(--border-dim); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.judgment-box { background: rgba(255, 42, 109, 0.1); border: 1px solid rgba(255, 42, 109, 0.45); border-radius: 8px; padding: 10px; font-size: 12.5px; line-height: 1.65; }
.repay-row { display: flex; gap: 8px; }
.section-sub { font-size: 13.5px; color: var(--neon-cyan); margin-top: 4px; }
.loan-cards, .hustle-list { display: flex; flex-direction: column; gap: 8px; }
.action-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-inset); border: 1px solid var(--border-dim); border-radius: 8px; padding: 9px 11px; }
.action-card.danger-card { border-color: rgba(255, 42, 109, 0.55); }
.ac-title { font-size: 13px; font-weight: 800; }
.ac-desc  { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }

.club-insider-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.insider-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-panel-2); border: 1px solid var(--border-glow); border-radius: 8px; padding: 10px 12px; }

.synergy-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.synergy-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 8px;
  font-size: 11.5px;
  opacity: 0.65;
}
.synergy-box.active {
  opacity: 1;
  border-color: var(--neon-gold);
  background: rgba(255, 184, 0, 0.12);
  box-shadow: 0 0 14px rgba(255, 184, 0, 0.22);
}
.synergy-title { font-weight: 800; color: #fff; margin-bottom: 3px; }

.relic-shop-grid, .relic-owned-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.relic-card { background: var(--bg-panel-2); border: 1px solid var(--border-dim); border-radius: 9px; padding: 11px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.relic-card.owned { border-color: var(--neon-purple); background: rgba(192, 92, 255, 0.09); }
.rc-head { display: flex; justify-content: space-between; align-items: center; }
.rc-ico  { font-size: 24px; }
.rc-price { font-family: var(--font-mono); font-weight: 800; color: var(--neon-gold); font-size: 13px; }
.rc-name { font-size: 13.5px; font-weight: 800; color: #fff; }
.rc-desc { font-size: 11.5px; color: var(--text-dim); line-height: 1.45; }

/* ==========================================================================
   BOTTOM NEWS TICKER & OVERLAYS
   ========================================================================== */
.news-ticker-bar { display: flex; align-items: center; background: #090c16; border-top: 1px solid var(--border-dim); height: 30px; flex-shrink: 0; overflow: hidden; }
.ticker-badge { background: var(--neon-red); color: #fff; font-size: 11px; font-weight: 900; padding: 0 10px; height: 100%; display: flex; align-items: center; white-space: nowrap; z-index: 2; }
.ticker-track { flex: 1; overflow: hidden; white-space: nowrap; }
.ticker-content { display: inline-block; padding-left: 100%; font-size: 12px; color: #ffd666; animation: tickerScroll 26s linear infinite; }
@keyframes tickerScroll { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

.liquidation-overlay { position: fixed; inset: 0; z-index: 9800; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; }
.shatter-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.liq-banner { position: relative; z-index: 2; text-align: center; background: rgba(8, 8, 10, 0.92); border-top: 3px solid #fff; border-bottom: 3px solid #fff; width: 100%; padding: 32px 20px; animation: liqSlam 0.25s ease-out; }
.liq-code     { font-family: var(--font-mono); font-size: 14px; letter-spacing: 5px; color: #bbb; }
.liq-headline { font-size: 38px; font-weight: 900; color: #fff; margin: 10px 0; letter-spacing: 2px; }
.liq-loss     { font-size: 28px; font-weight: 900; color: #ff4466; }
@keyframes liqSlam { 0% { transform: scale(1.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 9600; background: rgba(5, 7, 12, 0.85); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-card { background: var(--bg-panel); border: 1px solid var(--border-glow); border-radius: 14px; padding: 22px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85); }
.modal-badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 4px; background: rgba(255, 42, 109, 0.18); color: var(--neon-red); margin-bottom: 8px; }
.jm-desc { font-size: 13.5px; color: #cfd9f2; line-height: 1.65; margin: 10px 0 14px; }
.jm-stats { background: var(--bg-inset); border: 1px solid var(--border-dim); border-radius: 8px; padding: 12px; margin-bottom: 16px; font-size: 13px; line-height: 1.7; }
.jm-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.ending-card { max-width: 840px; }
.ending-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.ending-top-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.diagnosis-preview-wrap { background: #06080e; border: 1px solid var(--border-dim); border-radius: 8px; padding: 12px; display: flex; justify-content: center; overflow: auto; max-height: 70vh; }
#diagnosis-canvas { max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6); }

.toast-container { position: fixed; top: 56px; right: 16px; z-index: 9700; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast-item { background: rgba(16, 22, 36, 0.96); border-left: 4px solid var(--neon-cyan); border-top: 1px solid var(--border-glow); border-right: 1px solid var(--border-glow); border-bottom: 1px solid var(--border-glow); color: #fff; padding: 10px 14px; border-radius: 7px; font-size: 12.5px; max-width: 340px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55); animation: toastIn 0.2s ease-out; }
.toast-item.toast-danger { border-left-color: var(--neon-red); }
.toast-item.toast-gold   { border-left-color: var(--neon-gold); }
.toast-item.toast-green  { border-left-color: var(--neon-green); }

@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulseBtn { from { transform: scale(1); } to { transform: scale(1.06); } }

@media (max-width: 1060px) {
  .workspace-grid { grid-template-columns: 1fr; overflow-y: auto; }
  .wechat-window  { max-height: 250px; }
  .kline-terminal-grid { grid-template-columns: 1fr; }
  .orderbook-pane { display: none; }
  .horse-roster   { grid-template-columns: repeat(2, 1fr); }
  .synergy-panel  { grid-template-columns: repeat(2, 1fr); }
  .gacha-split, .survival-grid, .club-insider-strip, .relic-shop-grid { grid-template-columns: 1fr; }
}
