:root {
  --bg: #eef3fb;
  --card: rgba(255, 255, 255, 0.72);
  --line: rgba(255, 255, 255, 0.9);
  --text: #10131a;
  --muted: #6b7280;
  --accent: #0a84ff;
  --danger: #ff3b30;
  --radius: 20px;
  --shadow: 0 16px 40px rgba(31, 45, 74, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 12% 8%, #ffffff, transparent 42%),
    linear-gradient(135deg, #eaf2ff 0%, #f7fbff 46%, #fff4f2 100%);
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 82% 0%, rgba(10, 132, 255, 0.16), transparent 55%);
}

h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; color: var(--muted); font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(14px, 4vw, 32px);
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.9);
}
.logo { font-weight: 700; color: inherit; }
.logo span { color: var(--accent); }
.nav { display: flex; gap: 4px; background: rgba(255,255,255,.55); padding: 4px; border-radius: 999px; }
.nav-item { padding: 6px 16px; border-radius: 999px; font-size: 14px; color: var(--muted); }
.nav-item.active { background: #fff; color: var(--text); box-shadow: 0 4px 14px rgba(31,45,74,.1); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #5ac8fa); color: #fff; font-weight: 600; font-size: 13px;
  flex: none;
}

.page { max-width: 1080px; margin: 0 auto; padding: 22px clamp(14px, 4vw, 28px) 48px; display: grid; gap: 18px; }
.section { display: grid; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.two-col { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(20px); padding: 16px;
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.room-card {
  display: grid; gap: 6px; padding: 14px 16px; border-radius: 16px; color: inherit;
  background: rgba(255,255,255,.8); border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 8px 20px rgba(31,45,74,.08); transition: transform .15s;
}
.room-card:hover { transform: translateY(-2px); }
.room-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: rgba(10,132,255,.12); color: var(--accent); }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

.form { display: grid; gap: 4px; align-content: start; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 10px; }
input, textarea {
  font: inherit; color: var(--text); background: rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.07); border-radius: 12px; padding: 10px 12px; outline: none; width: 100%;
}
input:focus, textarea:focus { border-color: rgba(10,132,255,.6); }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; color: var(--text);
  border-radius: 999px; padding: 9px 18px; border: 1px solid rgba(0,0,0,.07);
  background: rgba(255,255,255,.85); transition: transform .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, #0a84ff, #4aa8ff); color: #fff; border-color: transparent; box-shadow: 0 10px 22px rgba(10,132,255,.25); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.link { border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }

/* 登录 */
.auth { display: grid; place-items: center; padding: 9vh 16px; }
.auth-card { width: min(420px, 100%); padding: 26px; display: grid; gap: 12px; }
.tabs { display: flex; gap: 6px; background: rgba(255,255,255,.7); padding: 4px; border-radius: 999px; }
.tab { flex: 1; border: 0; background: none; padding: 8px; border-radius: 999px; font: inherit; color: var(--muted); cursor: pointer; }
.tab.active { background: #fff; color: var(--text); box-shadow: 0 4px 14px rgba(31,45,74,.1); }

/* 房间页 */
.room-page { max-width: 860px; }
.room-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.room-actions { display: flex; gap: 8px; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.messages { display: grid; gap: 10px; overflow-y: auto; max-height: 58vh; min-height: 320px; padding: 4px; }
.msg { display: flex; gap: 8px; align-items: flex-start; }
.msg.mine { flex-direction: row-reverse; }
.msg .avatar { width: 30px; height: 30px; font-size: 12px; }
.msg-body { max-width: min(72%, 520px); }
.msg.mine .msg-body { text-align: right; }
.who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bubble {
  display: inline-block; text-align: left; background: rgba(255,255,255,.92);
  border-radius: 16px; padding: 8px 12px; font-size: 14px; word-break: break-word;
  box-shadow: 0 6px 16px rgba(31,45,74,.07);
}
.msg.mine .bubble { background: linear-gradient(135deg,#0a84ff,#4aa8ff); color: #fff; }
.msg.agent .bubble { background: rgba(255, 246, 214, .96); }
.bubble img { display: block; max-width: 120px; max-height: 120px; margin: 4px 0; border-radius: 10px; }

.composer { display: grid; gap: 8px; }
.composer-row { display: flex; gap: 8px; align-items: center; }
.icon-btn { border: 0; background: rgba(255,255,255,.8); width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; flex: none; }
.msg-input { flex: 1; border-radius: 999px; padding: 11px 16px; }
.sticker-panel {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px;
  max-height: 190px; overflow-y: auto; padding: 8px;
  background: rgba(255,255,255,.92); border-radius: 16px;
}
.sticker-panel img { width: 100%; max-width: 34px; cursor: pointer; border-radius: 6px; padding: 2px; }
.sticker-panel img:hover { background: rgba(10,132,255,.12); }
.picked { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.picked img { width: 26px; height: 26px; border-radius: 6px; }

/* 飞行棋 */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; align-items: start; }
.game-card { display: grid; gap: 12px; }
.game-bar { display: flex; align-items: center; justify-content: center; gap: 14px; }
.dice { font-size: 22px; font-weight: 700; min-width: 40px; text-align: center; }
.game-side { display: grid; gap: 8px; align-content: start; }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.player-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 6px 8px; border-radius: 10px; }
.player-list li.active { background: rgba(10,132,255,.1); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.game-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 12px; color: var(--muted); max-height: 220px; overflow-y: auto; }

.ludo-wrap { width: 100%; display: grid; place-items: center; }
.ludo-board {
  position: relative; display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr);
  aspect-ratio: 1/1; width: 100%; max-width: 480px;
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.ludo-cell { border: 1px solid rgba(0,0,0,.04); }
.ludo-cell.path { background: rgba(10,132,255,.07); }
.ludo-cell.center { background: rgba(10,132,255,.16); }
.ludo-cell.base-0 { background: rgba(255,95,87,.22); }
.ludo-cell.base-1 { background: rgba(40,200,64,.20); }
.ludo-cell.base-2 { background: rgba(10,132,255,.20); }
.ludo-cell.base-3 { background: rgba(255,189,46,.24); }
.ludo-cell.home-0 { background: rgba(255,95,87,.42); }
.ludo-cell.home-1 { background: rgba(40,200,64,.40); }
.ludo-cell.home-2 { background: rgba(10,132,255,.40); }
.ludo-cell.home-3 { background: rgba(255,189,46,.45); }

.token {
  position: absolute; border: 0; padding: 0;
  width: calc(100% / 15 * 0.7); height: calc(100% / 15 * 0.7);
  left: calc(var(--c) * 100% / 15); top: calc(var(--r) * 100% / 15);
  border-radius: 50%; color: #fff; font-size: 9px; font-weight: 700;
  display: grid; place-items: center; cursor: default;
  box-shadow: 0 2px 6px rgba(0,0,0,.25), inset 0 0 0 1.5px rgba(255,255,255,.9);
  transition: left .22s ease, top .22s ease;
}
.token.movable { cursor: pointer; animation: tokenPulse 1.1s infinite; }
@keyframes tokenPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.16); } }

.agent-card { display: grid; gap: 6px; }

@media (max-width: 820px) {
  .game-layout { grid-template-columns: 1fr; }
  .msg-body { max-width: 82%; }
  .sticker-panel { grid-template-columns: repeat(8, 1fr); }
}
