/* ===== Claude 游戏工坊 ===== */
:root {
  --bg: #0c0e13;
  --panel: #14171f;
  --panel-2: #191d28;
  --border: #262c3b;
  --text: #dfe3ec;
  --dim: #8b93a5;
  --accent: #7c5cff;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #171327 0%, var(--bg) 55%);
  color: var(--text);
  font-family: system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}
.hidden { display: none !important; }
.view { height: 100vh; display: flex; flex-direction: column; }
.spacer { flex: 1; }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }
.opt { color: var(--dim); font-weight: 400; font-size: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 10px; }
label { display: block; margin: 14px 0 6px; font-weight: 600; }
input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); }
code { font-family: var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.hint { color: var(--dim); font-size: 12px; line-height: 1.6; }

.btn {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.block { display: block; width: 100%; margin-top: 12px; }

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 12px;
  color: var(--text);
  cursor: default;
}
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--accent); }
.chip.dim { color: var(--dim); }

/* ===== 登录 ===== */
#view-auth { align-items: center; justify-content: center; }
.auth-card { width: min(400px, 92vw); }
.auth-card .sub { color: var(--dim); margin: 0 0 8px; }

/* ===== 大厅 ===== */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 23, 31, 0.7);
}
.brand { font-weight: 700; }
.lobby-wrap { max-width: 980px; width: 100%; margin: 0 auto; padding: 24px 20px; overflow: auto; }
.lobby-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lobby-h { margin: 26px 0 12px; color: var(--dim); font-size: 13px; letter-spacing: 0.08em; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.room-card h3 { margin: 0 0 4px; font-size: 15px; }
.room-card .meta { color: var(--dim); font-size: 12px; margin-bottom: 12px; }
.empty-tip { color: var(--dim); padding: 24px; text-align: center; grid-column: 1 / -1; }

/* ===== 房间 ===== */
.roombar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 23, 31, 0.7);
  flex-wrap: wrap;
}
.room-title { font-weight: 700; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players-row { display: flex; gap: 6px; flex-wrap: wrap; }
.player-chip {
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--border); background: var(--panel-2);
}
.player-chip.host { border-color: var(--accent); color: #cabdff; }
.player-chip.me { background: #20263a; }
.room-main { flex: 1; display: flex; min-height: 0; }

.canvas-wrap { flex: 1; position: relative; min-width: 0; background: #080a0f; }
#game-frame { width: 100%; height: 100%; border: 0; display: block; }
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); background: #0b0d12; pointer-events: none;
  transition: opacity 0.25s;
}
.overlay.off { opacity: 0; }

/* ===== 聊天 ===== */
.chat-panel {
  width: 360px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
.target-seg { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); }
.seg {
  flex: 1; padding: 7px 0; border-radius: 9px; font-size: 13px;
  border: 1px solid var(--border); background: transparent; color: var(--dim); cursor: pointer;
}
.seg.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg[data-target="claude"].active { background: #5b8def; border-color: #5b8def; }

.chat-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 92%; line-height: 1.5; word-break: break-word; }
.msg .head { font-size: 11px; color: var(--dim); margin-bottom: 2px; display: flex; gap: 6px; align-items: baseline; }
.msg .head .name { color: var(--text); font-weight: 600; font-size: 12px; }
.msg .bubble {
  padding: 8px 11px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  white-space: pre-wrap;
}
.msg.player .head .name { color: #9fc1ff; }
.msg.ask-claude .bubble { border-color: #3c4d86; background: #141a2b; }
.msg.claude .bubble { border-color: #3c4d86; background: #171d31; }
.msg.claude .head .name { color: #8fb0ff; }
.msg.system { align-self: center; max-width: 96%; text-align: center; color: var(--dim); font-size: 12px; padding: 2px 6px; }
.msg.pending .bubble { opacity: 0.75; }

.typing { padding: 6px 14px; color: #8fb0ff; font-size: 12px; }
.dots i {
  display: inline-block; width: 4px; height: 4px; margin-left: 3px;
  border-radius: 50%; background: #8fb0ff; animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.chips { display: flex; gap: 6px; padding: 0 10px 8px; flex-wrap: wrap; }
.chips button {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px dashed #3c4d86; background: transparent; color: #8fb0ff; cursor: pointer;
}
.chips button:hover { background: #171d31; }

#chat-form, #claude-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
#chat-input, #claude-input { flex: 1; }

/* ===== 弹窗 / 提示 ===== */
.modal {
  position: fixed; inset: 0; background: rgba(5, 6, 10, 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-card { width: min(560px, 92vw); max-height: 80vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
#rules-text {
  white-space: pre-wrap; font-family: inherit; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 10px 0 0;
}
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 99; align-items: center;
}
.toast-item {
  background: #232939; border: 1px solid var(--border); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 13px;
  animation: fadein 0.2s; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.toast-item.err { border-color: var(--danger); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 860px) {
  .room-main { flex-direction: column; }
  .chat-panel { width: 100%; flex: 1; border-left: 0; border-top: 1px solid var(--border); }
  .canvas-wrap { min-height: 45vh; }
  .lobby-actions { grid-template-columns: 1fr; }
}

/* ===== 注册 ===== */
.divider { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; margin: 16px 0 6px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.reg-row { display: flex; gap: 8px; }
.reg-row input { flex: 1; }

/* ===== 聊天标签页 ===== */
.tab-page { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ===== 待应用版本横幅 ===== */
.pending-bar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 10px;
  background: #241f0e; border: 1px solid #8a6d1a; color: #f5d67b; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); max-width: 92%; flex-wrap: wrap; justify-content: center;
}
.pending-bar .btn { padding: 4px 12px; font-size: 12px; }
