:root {
  --bg: #13161d;
  --panel: #1c2029;
  --panel-2: #232834;
  --border: #2c313c;
  --text: #e8eaed;
  --muted: #9aa0ab;
  --gold: #d4af37;
  --gold-dim: #b8941f;
  --red: #e05656;
  --green: #4caf7c;
  --orange: #e0a800;
  --blue: #5b9bd5;
  --purple: #9b7bd4;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0,0,0,0.35);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background .15s, opacity .15s, transform .05s;
}
.btn:hover { background: #2a3140; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 600; }
.btn-primary:hover { background: var(--gold-dim); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; width: 100%; }

/* ---------- 开始页 ---------- */
#start-screen { align-items: center; justify-content: center; padding: 24px; flex-direction: column; gap: 18px; }
.start-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}
.brand { color: var(--gold); font-size: 14px; letter-spacing: 4px; font-weight: 600; }
.title { font-size: 30px; margin: 8px 0 4px; color: var(--text); }
.subtitle { color: var(--muted); margin-bottom: 22px; font-size: 14px; }
.rules { text-align: left; margin: 0 0 24px; list-style: none; }
.rules li { padding: 7px 0 7px 22px; position: relative; color: #c8ccd4; font-size: 14px; border-bottom: 1px solid var(--border); }
.rules li:last-child { border-bottom: none; }
.rules li::before { content: "◆"; color: var(--gold); position: absolute; left: 0; top: 7px; font-size: 11px; }
.rules b { color: var(--gold); }
.error-text { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- 页脚备案 ---------- */
.site-footer { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.7; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.footer-sep { margin: 0 6px; opacity: .6; }

/* ---------- 游戏页 ---------- */
#game-screen { flex-direction: row; }

.status-bar {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.status-block { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.status-block .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.status-block .value { font-size: 20px; font-weight: 600; }
.status-row { display: flex; gap: 10px; }
.status-row .status-block { flex: 1; }

.balance-block { text-align: center; }
.balance { font-size: 26px; font-weight: 700; color: var(--gold); }
.balance-raw { font-size: 11px; color: var(--muted); margin-top: 2px; }
.balance.flash { animation: flash .6s; }
@keyframes flash { 0%{color:var(--gold);} 50%{color:var(--red);} 100%{color:var(--gold);} }

.muted { color: var(--muted); font-weight: 400; }
.accent-red { color: var(--red); }
.accent-green { color: var(--green); }

.bar { height: 8px; background: #0e1117; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; width: 20%; background: var(--green); transition: width .4s, background .4s; }

.mood-tag { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; background: var(--green); color: #0e1117; }
.mood-tag.m-red { background: var(--red); color: #fff; }
.mood-tag.m-orange { background: var(--orange); color: #1a1408; }
.mood-tag.m-blue { background: var(--blue); color: #fff; }
.mood-tag.m-green { background: var(--green); color: #0e1117; }

.token-block .token-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; font-size: 13px; }
.token-grid .muted { font-size: 11px; display: block; }

/* 聊天区 */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.msg { max-width: 80%; display: flex; flex-direction: column; gap: 5px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.ai { align-self: flex-start; align-items: flex-start; }

.bubble { padding: 10px 14px; border-radius: 12px; font-size: 14px; word-break: break-word; white-space: pre-wrap; }
.msg.user .bubble { background: var(--gold); color: #1a1408; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.msg-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.tag { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.tag-mood { background: #2a3140; color: var(--muted); }
.tag-action { background: #2a3140; color: #c8ccd4; }
.tag-action.out { background: rgba(224,86,86,.18); color: var(--red); }
.tag-action.def { background: rgba(76,175,124,.18); color: var(--green); }
.tag-action.sp { background: rgba(155,123,212,.2); color: var(--purple); }
.tag-amount { color: var(--red); font-weight: 700; }
.tag-event { background: #232834; color: var(--muted); border: 1px solid var(--border); }
.thought { font-size: 12px; color: var(--muted); font-style: italic; max-width: 80%; }

.turn-banner { text-align: center; font-size: 13px; color: var(--gold); padding: 6px; font-weight: 600; }
.turn-banner.win { color: var(--red); }

.input-area { display: flex; flex-direction: column; gap: 6px; padding: 12px 16px 10px; border-top: 1px solid var(--border); background: var(--panel); }
.input-row { display: flex; gap: 10px; }
.input { flex: 1; resize: none; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; color: var(--text); font-family: inherit; font-size: 14px; max-height: 120px; }
.input:focus { outline: none; border-color: var(--gold); }
#btn-send { align-self: stretch; }
.char-count { font-size: 11px; color: var(--muted); text-align: right; }
.char-count.warn { color: var(--red); }

.thinking { display: inline-flex; gap: 4px; align-items: center; }
.thinking .dot { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; }

/* ---------- 结算页 ---------- */
#end-screen { align-items: center; justify-content: center; padding: 24px; flex-direction: column; gap: 18px; }
.end-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 40px 36px; max-width: 560px; width: 100%; text-align: center; box-shadow: var(--shadow);
}
.end-title { color: var(--muted); font-size: 16px; letter-spacing: 2px; }
.end-amount { font-size: 44px; font-weight: 800; color: var(--gold); margin: 10px 0; }
.end-amount.loss { color: var(--red); }
.end-amount.zero { color: var(--muted); }
.end-sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.end-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 28px; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 8px; }
.stat-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 16px; font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: var(--radius); font-size: 13px; box-shadow: var(--shadow);
  z-index: 100; max-width: 90%; text-align: center;
}
.toast.err { border-color: var(--red); color: var(--red); }

.hidden { display: none !important; }

/* ---------- 响应式：手机 ---------- */
@media (max-width: 899px) {
  #game-screen { flex-direction: column; }
  .status-bar {
    width: 100%; border-right: none; border-bottom: 1px solid var(--border);
    flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 10px; overflow-x: auto;
  }
  .status-bar .status-block { padding: 8px 10px; flex: 1; min-width: 90px; }
  .balance-block { flex: 1 1 100%; text-align: left; }
  .balance { font-size: 22px; }
  .token-block { display: none; } /* 手机端隐藏 token 细节，省空间 */
  #btn-end { flex: 1 1 100%; }
  .messages { padding: 14px; }
  .msg { max-width: 88%; }
  .input-area { padding: 10px; }
  .end-stats { grid-template-columns: 1fr 1fr; }
  .end-amount { font-size: 34px; }
}
