:root {
  --bg-0: #0a0e1a;
  --bg-1: #131a2c;
  --bg-2: #1c2540;
  --bg-3: #2a3556;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8ecff;
  --muted: #8590b8;
  --gold: #ffc857;
  --gold-2: #f59e0b;
  --green: #22c55e;
  --green-dark: #16a34a;
  --red: #ef4444;
  --red-dark: #dc2626;
  --blue: #3b82f6;
  --purple: #a855f7;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(255, 200, 87, 0.10), transparent 60%),
    radial-gradient(800px 400px at 100% 100%, rgba(168, 85, 247, 0.10), transparent 60%),
    var(--bg-0);
  padding-bottom: calc(64px + var(--safe-bottom));
  position: relative;
}

/* ===== 顶栏 ===== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.app-header .title {
  font-size: 17px; font-weight: 700; letter-spacing: 1px;
  background: linear-gradient(120deg, #ffc857, #f97316 60%, #ef4444);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.app-header .balance {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, rgba(255, 200, 87, 0.15), rgba(245, 158, 11, 0.05));
  border: 1px solid rgba(255, 200, 87, 0.25);
  padding: 5px 10px; border-radius: 20px;
  font-size: 12px;
}
.coin-icon {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, #ffd778, #f59e0b);
  box-shadow: 0 0 8px rgba(255, 200, 87, 0.5);
  display: inline-block;
}
.balance .num { color: var(--gold); font-weight: 700; }
.balance .lock { color: var(--muted); font-size: 11px; }

/* ===== 底部 tab ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 0 calc(6px + var(--safe-bottom));
  z-index: 30;
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; font-size: 11px;
  color: var(--muted); cursor: pointer;
  transition: color 0.15s;
}
.tab-item .icon { font-size: 20px; line-height: 1; }
.tab-item.active { color: var(--gold); }

/* ===== 卡片 ===== */
.page { padding: 12px 16px 16px; }

.card {
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 15px; font-weight: 700; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  min-height: 38px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #ffc857, #f59e0b);
  color: #1a1402;
}
.btn-yes {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
}
.btn-no {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; min-height: 30px; font-size: 12px; }

/* ===== 输入框 ===== */
.input, .select, textarea.input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--gold);
}
.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px;
}

/* ===== 盘口卡片 ===== */
.market-card {
  background: linear-gradient(180deg, #1f2a4a 0%, #16203a 100%);
  border: 1px solid rgba(255, 200, 87, 0.15);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.market-card::before {
  content: '';
  position: absolute; top: 0; left: 0; width: 4px; height: 100%;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
}
.market-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.market-title {
  font-size: 15px; font-weight: 700;
}
.market-title .boss { color: var(--gold); }
.market-title .eq { color: #c084fc; }
.market-meta {
  font-size: 11px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 10px;
}
.tag {
  padding: 2px 8px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.tag.gold { color: var(--gold); border-color: rgba(255, 200, 87, 0.3); background: rgba(255, 200, 87, 0.08); }
.tag.green { color: var(--green); border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.08); }
.tag.red { color: var(--red); border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.08); }
.tag.blue { color: var(--blue); border-color: rgba(59, 130, 246, 0.3); background: rgba(59, 130, 246, 0.08); }
.tag.purple { color: var(--purple); border-color: rgba(168, 85, 247, 0.3); background: rgba(168, 85, 247, 0.08); }
.tag.gray { color: var(--muted); }

.market-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: rgba(0,0,0,0.2); border-radius: 10px; padding: 10px;
  margin-bottom: 10px;
}
.market-body .col { text-align: center; }
.market-body .label { color: var(--muted); font-size: 11px; }
.market-body .val { font-size: 15px; font-weight: 700; }
.market-body .val.green { color: var(--green); }
.market-body .val.red { color: var(--red); }
.market-body .val.gold { color: var(--gold); }

.progress {
  height: 6px; background: rgba(255,255,255,0.06);
  border-radius: 4px; overflow: hidden; margin-bottom: 8px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  border-radius: 4px;
  transition: width 0.3s;
}

.market-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--muted);
}

/* ===== 副本卡片 ===== */
.dungeon-card {
  background: linear-gradient(135deg, #1c2540 0%, #131a2c 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
}
.dungeon-card .name { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.dungeon-card .desc { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.dungeon-status {
  position: absolute; top: 12px; right: 12px;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.dungeon-status.open { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.dungeon-status.closed { background: rgba(245, 158, 11, 0.15); color: var(--gold-2); }
.dungeon-status.settled { background: rgba(139, 142, 168, 0.15); color: var(--muted); }

/* ===== 列表 ===== */
.list-empty {
  text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px;
}

.tx-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.tx-item:last-child { border-bottom: none; }
.tx-item .left .type { font-weight: 600; }
.tx-item .left .desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tx-item .amt.pos { color: var(--green); font-weight: 700; }
.tx-item .amt.neg { color: var(--red); font-weight: 700; }
.tx-item .time { font-size: 11px; color: var(--muted); margin-top: 2px; text-align: right; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s;
}
.modal {
  width: 100%; max-width: 480px;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.25s;
  padding-bottom: calc(16px + var(--safe-bottom));
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer; font-size: 18px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.85);
  color: #fff; padding: 10px 18px; border-radius: 8px;
  z-index: 200; font-size: 13px;
  animation: fadeIn 0.15s;
}

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column;
  justify-content: center; padding: 0 24px;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .name {
  font-size: 28px; font-weight: 800;
  background: linear-gradient(120deg, #ffc857, #f97316);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 6px;
}
.login-logo .sub { color: var(--muted); font-size: 12px; }

/* ===== 投注方向按钮组 ===== */
.side-group {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.side-btn {
  padding: 12px; border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--bg-1);
  color: var(--text); font-weight: 700; font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.side-btn .label { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: normal; }
.side-btn.active.yes {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}
.side-btn.active.no {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

/* ===== 表单组 ===== */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ===== 数据条 ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.stat {
  background: var(--bg-2);
  border-radius: 10px; padding: 10px;
  text-align: center;
}
.stat .label { font-size: 11px; color: var(--muted); }
.stat .val { font-size: 18px; font-weight: 700; margin-top: 2px; }

/* boss-equipment item */
.be-row {
  display: flex; gap: 6px; margin-bottom: 6px;
  align-items: center;
}
.be-row .input { flex: 1; padding: 8px 10px; }
.be-row .del {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(239, 68, 68, 0.15); color: var(--red);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0;
}

.result-toggle {
  display: flex; gap: 4px;
}
.result-toggle button {
  flex: 1; padding: 6px; border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--muted); font-size: 12px; cursor: pointer;
}
.result-toggle button.active.yes { background: rgba(34,197,94,0.15); color: var(--green); border-color: var(--green); }
.result-toggle button.active.no { background: rgba(239,68,68,0.15); color: var(--red); border-color: var(--red); }

/* 盘口详情中的下注列表 */
.bet-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px;
}
.bet-list-item:last-child { border-bottom: none; }

/* 段标题 */
.section-title {
  font-size: 13px; color: var(--muted); margin: 12px 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.section-title::before {
  content: ''; display: block; width: 3px; height: 12px;
  background: var(--gold); border-radius: 2px;
}

/* 顶栏 admin 标识 */
.admin-badge {
  display: inline-block; font-size: 10px;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  color: #fff; padding: 2px 6px; border-radius: 4px;
  margin-left: 4px;
}

/* ===== 管理员操作栏 ===== */
.admin-bar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.08), rgba(99, 102, 241, 0.05));
  border: 1px dashed rgba(168, 85, 247, 0.3);
  border-radius: 10px;
  padding: 8px;
  margin: 8px 0 4px;
}
.admin-bar .btn { flex: 1; min-width: 60px; padding: 6px 8px; font-size: 11px; min-height: 28px; }

/* 已取消盘口 */
.market-card.cancelled {
  opacity: 0.5;
  filter: grayscale(50%);
}

/* ===== 双向盘口（出/不出 并排显示）===== */
.two-side {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 10px;
}
.side-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  position: relative;
}
.side-box.yes { border-color: rgba(34, 197, 94, 0.3); }
.side-box.no  { border-color: rgba(239, 68, 68, 0.3); }
.side-box.win {
  box-shadow: 0 0 0 2px var(--green) inset;
  background: rgba(34, 197, 94, 0.08);
}
.side-box.no.win {
  box-shadow: 0 0 0 2px var(--red) inset;
  background: rgba(239, 68, 68, 0.08);
}
.side-box .side-name {
  font-size: 12px; color: var(--muted); margin-bottom: 4px;
  text-align: center;
}
.side-box.yes .side-name::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 4px; vertical-align: middle; }
.side-box.no  .side-name::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin-right: 4px; vertical-align: middle; }
.side-box .side-odds {
  font-size: 18px; font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
}
.side-box.yes .side-odds { color: var(--green); }
.side-box.no  .side-odds { color: var(--red); }
.side-box .side-foot {
  font-size: 10px; color: var(--muted);
  text-align: center;
  margin: 4px 0;
}
.progress-bar.green { background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress-bar.red   { background: linear-gradient(90deg, #ef4444, #dc2626); }

/* 滚动条 */
.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 2px; }
