/* Fantan Desktop — purple theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple: #7c5cfc;
  --purple-dark: #5b4fcf;
  --purple-light: #a855f7;
  --purple-bg: #f3f0ff;
  --purple-border: #d4c4ff;
  --sidebar-w: 220px;
  --header-h: 56px;
  --panel-w: 280px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f8;
  color: #333;
  overflow: hidden;
}

a { color: var(--purple); text-decoration: none; }
.hidden { display: none !important; }
body.modal-open { overflow: hidden; }

/* Login / Register */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.login-box h2 {
  text-align: center;
  margin-bottom: 24px;
  color: var(--purple-dark);
  font-size: 22px;
}
.login-box input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.login-box input:focus { border-color: var(--purple); }
.login-box button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
}
.login-box button:hover { opacity: 0.92; }
.login-box .link { text-align: center; margin-top: 12px; font-size: 13px; }
.login-err { color: #ef4444; text-align: center; margin-top: 8px; font-size: 13px; min-height: 18px; }

/* Header */
.header {
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 0 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--purple-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}
.marquee {
  flex: 1;
  margin: 0 24px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 13px;
  color: #666;
}
.marquee span { display: inline-block; animation: marquee-scroll 25s linear infinite; }
@keyframes marquee-scroll {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}
.header-actions { display: flex; gap: 16px; align-items: center; font-size: 13px; color: #666; }
.header-actions span { cursor: pointer; }
.header-actions span:hover { color: var(--purple); }

/* Main layout */
.main {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid #eee;
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}
.user-card {
  text-align: center;
  padding: 16px 0;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 12px;
}
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-light), var(--purple));
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  font-weight: 600;
}
.vip {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
}
.balance-box {
  background: var(--purple-bg);
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
  text-align: center;
}
.balance-box .label { font-size: 12px; color: #888; }
.balance-box .amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--purple-dark);
  margin: 4px 0;
}
.balance-btns { display: flex; gap: 8px; }
.balance-btns button {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.btn-up { background: linear-gradient(135deg, var(--purple), var(--purple-light)); color: #fff; }
.btn-down { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #555;
  margin-bottom: 4px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover, .nav-item.active {
  background: var(--purple-bg);
  color: var(--purple-dark);
  font-weight: 600;
}
.nav-item .icon { width: 20px; text-align: center; }

/* Center */
.center {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f5f5f7;
  min-width: 0;
  overflow: hidden;
}
.game-bar {
  background: #fff;
  padding: 12px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.issue { font-size: 14px; font-weight: 600; }
.status-tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-open { background: #e8f5e9; color: #2e7d32; }
.status-closed { background: #fce4ec; color: #c62828; }
.countdown { color: var(--purple); font-weight: 700; }
.balls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; perspective: 200px; }
.ball {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}
.ball.ball-blue {
  background: linear-gradient(135deg, #42a5f5, #1e88e5);
  box-shadow: 0 2px 6px rgba(30, 136, 229, 0.35);
}
.ball.spinning {
  animation: ballRoll 0.18s linear infinite;
  box-shadow: 0 0 10px rgba(255, 200, 80, 0.65);
}
@keyframes ballRoll {
  0% { transform: rotateX(0deg) scale(1.05); filter: brightness(1.1); }
  50% { transform: rotateX(180deg) scale(1.08); filter: brightness(1.4); }
  100% { transform: rotateX(360deg) scale(1.05); filter: brightness(1.1); }
}
.ball-eq { margin: 0 4px; color: #888; font-weight: 600; }
.fan-result { font-size: 16px; font-weight: 700; color: var(--purple-dark); }

/* Chat */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.chat-tabs {
  display: flex;
  gap: 0;
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 0 16px;
  flex-shrink: 0;
}
.chat-tab {
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  color: #888;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.chat-tab:hover { color: var(--purple); }
.chat-tab.active {
  color: var(--purple-dark);
  border-bottom-color: var(--purple);
  font-weight: 600;
}
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  overscroll-behavior: contain;
  min-height: 0;
  background: #f0f1f5;
}
.messages-loading {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: #aaa;
}

/* 图三风格：头像 + 名称 + 气泡 + 时间 */
.msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  align-items: flex-start;
}
.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #ddd;
}
.msg-avatar.text-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.msg-body { flex: 1; min-width: 0; max-width: calc(100% - 50px); }
.msg-name {
  font-size: 13px;
  color: #5a6a85;
  margin-bottom: 4px;
  font-weight: 600;
}
.msg-bubble {
  display: inline-block;
  background: #fff;
  color: #222;
  padding: 10px 14px;
  border-radius: 4px 12px 12px 12px;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  white-space: pre-wrap;
  position: relative;
}
.msg-bubble::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 10px;
  border: 6px solid transparent;
  border-right-color: #fff;
  border-left: 0;
}
.msg-time {
  font-size: 11px;
  color: #aaa;
  margin-top: 4px;
}
.msg.announcer .msg-name { color: #1e88e5; }
.msg.player .msg-name,
.msg.self .msg-name { color: #5a6a85; }
/* 图四：规则红色字体 */
.msg.announcer .msg-bubble.warn-text,
.msg.warn .msg-bubble {
  color: #e53935;
  font-weight: 600;
}
/* 图九：自己与活跃用户同一左侧布局（头像+名称+气泡+时间） */
.msg.self .msg-bubble {
  background: #fff;
  color: #222;
}
.msg.system { justify-content: center; }
.msg.system .system-body { max-width: 90%; text-align: center; }
.msg.system .msg-bubble.system {
  background: #f3f0ff;
  color: #7c5cfc;
  border: 1px solid #d4c4ff;
  box-shadow: none;
}
.msg.system .msg-bubble.system::before { display: none; }
.msg-bubble.draw-img {
  padding: 6px;
  background: #fff;
}
.msg-bubble.draw-img img {
  max-width: 320px;
  width: 100%;
  display: block;
  border-radius: 6px;
}

.chat-input {
  background: #fff;
  border-top: 1px solid #eee;
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.chat-input input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
}
.chat-input input:focus { border-color: var(--purple); }
.btn-send {
  padding: 10px 24px;
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  color: #fff;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.btn-quick {
  padding: 10px 16px;
  background: var(--purple-bg);
  color: var(--purple-dark);
  border: 1px solid var(--purple-border);
  border-radius: 24px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

/* Right panel */
.right-panel {
  width: var(--panel-w);
  background: #fff;
  border-left: 1px solid #eee;
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}
.panel-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#historyList {
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-bottom: 4px;
  padding-right: 4px;
  overscroll-behavior: contain;
}
#historyList::-webkit-scrollbar { width: 5px; }
#historyList::-webkit-scrollbar-thumb {
  background: #cfcfcf;
  border-radius: 4px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 12px;
}
.history-item .hi-balls { display: flex; gap: 3px; }
.history-item .hi-ball {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.history-item .hi-ball.blue { background: #1e88e5; }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.quick-btn {
  padding: 10px 0;
  text-align: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  color: #fff;
}
.q-fan { background: var(--purple); }
.q-jiao { background: #3b82f6; }
.q-pa { background: #06b6d4; }
.q-lian { background: #10b981; }
.q-nian { background: #f59e0b; }
.q-zheng { background: #ef4444; }
.q-dan { background: #8b5cf6; }
.q-shuang { background: #ec4899; }
.amount-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.amount-btn {
  padding: 8px;
  text-align: center;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  background: #fafafa;
  transition: all 0.15s;
}
.amount-btn.active { border-color: var(--purple); background: var(--purple-bg); color: var(--purple-dark); font-weight: 600; }
.btn-bet-now {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.ann-item { padding: 8px 0; border-bottom: 1px solid #f5f5f5; font-size: 12px; color: #666; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-box { background: var(--purple-bg); border-radius: 8px; padding: 10px; text-align: center; }
.stat-box .val { font-size: 16px; font-weight: 700; color: var(--purple-dark); }
.stat-box .lbl { font-size: 11px; color: #888; margin-top: 2px; }

/* Overlay base */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay-panel {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
}
.overlay-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.overlay-header h3 { font-size: 16px; color: var(--purple-dark); }
.overlay-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 4px 8px;
}
.overlay-close:hover { color: #333; }
.overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  min-height: 0;
}

/* Rules modal */
.rules-content {
  font-size: 14px;
  line-height: 1.8;
  color: #444;
  white-space: pre-wrap;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
}

/* Trend */
.trend-panel { max-width: 720px; }
.trend-body-scroll {
  max-height: min(80vh, 700px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.trend-table-wrap { overflow-x: auto; }
.trend-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.trend-table thead { position: sticky; top: 0; z-index: 2; }
.trend-table th {
  background: #42a5f5;
  color: #fff;
  padding: 10px 8px;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
}
.trend-table td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid #f0f0f0;
}
.trend-table tr:nth-child(even) td { background: #fafafa; }
.trend-table tr:hover td { background: #fff8e1; }
.trend-result { display: inline-flex; gap: 4px; align-items: center; justify-content: center; flex-wrap: wrap; }
.trend-result .eq { margin: 0 2px; color: #888; }
.trend-ball {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid #bbb;
  background: #fff;
  color: #333;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.trend-ball.blue { border-color: #1e88e5; color: #1565c0; }
.trend-ball.sum { background: #e53935; border-color: #e53935; color: #fff; }
.fan-box {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.fan-1 { background: #1e88e5; }
.fan-2 { background: #43a047; }
.fan-3 { background: #fbc02d; color: #333; }
.fan-4 { background: #e53935; }

.roadmap-title {
  text-align: center;
  background: #eceff1;
  padding: 10px;
  margin: 16px 0 10px;
  font-weight: 600;
  color: #455a64;
  border-radius: 6px;
}
.roadmap {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 0 16px;
  min-height: 140px;
}
.road-col { display: flex; flex-direction: column; gap: 4px; }
.road-cell {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.road-cell.empty { background: #f5f5f5; border: 1px dashed #ddd; }
.road-empty { color: #aaa; padding: 20px; text-align: center; width: 100%; }

/* Points form */
.points-form label { display: block; font-size: 13px; color: #666; margin-bottom: 8px; }
.points-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 12px;
}
.points-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.points-quick button {
  padding: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
}
.points-quick button:hover { border-color: var(--purple); color: var(--purple); }

/* Profile modal */
.profile-grid { display: grid; gap: 12px; }
.profile-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--purple-bg);
  border-radius: 10px;
  font-size: 14px;
}
.profile-row .label { color: #888; }
.profile-row .val { font-weight: 600; color: var(--purple-dark); }

/* CS Modal */
.cs-box {
  background: #f5f5f5;
  border-radius: 12px;
  width: 420px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.cs-header {
  background: #fff;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.cs-header .info { display: flex; align-items: center; gap: 12px; }
.cs-header .cs-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
}
.cs-header h4 { font-size: 15px; color: #333; }
.cs-header small { color: #888; font-size: 12px; }
.cs-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #999; }
.cs-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 280px;
  max-height: 50vh;
}
.cs-empty { text-align: center; color: #aaa; margin-top: 80px; font-size: 14px; }
.cs-msg { margin-bottom: 14px; font-size: 13px; }
.cs-msg .cs-time { font-size: 11px; color: #aaa; margin-bottom: 4px; }
.cs-msg.user { text-align: right; }
.cs-msg.user .bubble {
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  color: #fff;
  display: inline-block;
  padding: 8px 14px;
  border-radius: 16px 16px 4px 16px;
  max-width: 80%;
  text-align: left;
}
.cs-msg.admin .bubble {
  background: #fff;
  color: #333;
  display: inline-block;
  padding: 8px 14px;
  border-radius: 16px 16px 16px 4px;
  max-width: 80%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.cs-msg .bubble img { max-width: 200px; border-radius: 8px; display: block; margin-top: 4px; }
.cs-input {
  background: #fff;
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
.cs-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: 13px;
  outline: none;
}
.cs-input input:focus { border-color: var(--purple); }
.cs-btn-img {
  padding: 8px 10px;
  background: var(--purple-bg);
  border: 1px solid var(--purple-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.cs-btn-img:hover { background: #ebe4ff; }
.cs-input button.send {
  padding: 8px 16px;
  background: #ccc;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.cs-input button.send.active { background: var(--purple); }
