:root {
  --purple: #6d28d9;
  --purple-deep: #3b0f75;
  --purple-soft: #a78bfa;
  --yellow: #ffd166;
  --pink: #ef476f;
  --green: #38b000;
  --ink: #2b1746;
  --muted: #7c6a96;
  --card: #ffffff;
  --line: #ece5f7;
  --shadow: 0 18px 50px rgba(31, 8, 71, .28);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #5b21b6 0%, #6d28d9 45%, #4c1d95 100%);
  min-height: 100vh;
  overflow-x: hidden;
}
.bg-decor { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bg-decor span { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .16; }
.bg-decor span:nth-child(1) { width: 380px; height: 380px; background: #ffd166; top: -120px; right: -80px; }
.bg-decor span:nth-child(2) { width: 300px; height: 300px; background: #f472b6; bottom: -110px; left: -60px; }
.bg-decor span:nth-child(3) { width: 200px; height: 200px; background: #7dd3fc; top: 45%; left: 55%; }
#app { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 20px 60px; }

/* 顶部 */
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 20px; font-weight: 800; letter-spacing: .5px; cursor: pointer; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--yellow); color: var(--purple-deep); font-size: 24px; transform: rotate(-8deg); }
.top-right { display: flex; align-items: center; gap: 10px; }
.conn-badge { font-size: 12px; color: #fff; background: rgba(255,255,255,.16); padding: 6px 12px; border-radius: 99px; backdrop-filter: blur(6px); }
.conn-badge.on { background: rgba(56,176,0,.75); }
.conn-badge.off { background: rgba(239,71,111,.85); }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; font-size: 18px; font-weight: 700; cursor: pointer; }

/* 屏幕切换 */
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 通用卡片与按钮 */
.panel { background: var(--card); border-radius: 24px; box-shadow: var(--shadow); padding: 26px; }
h1, h2, h3 { margin: 0 0 12px; }
h1 { font-size: clamp(44px, 7vw, 74px); line-height: 1.05; color: #fff; letter-spacing: -2px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.btn { border: 0; border-radius: 14px; padding: 12px 22px; font-size: 15px; font-weight: 700; cursor: pointer; transition: transform .12s, box-shadow .12s, opacity .12s; font-family: inherit; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--yellow); color: #4a1d00; box-shadow: 0 6px 0 #d9a629; }
.btn-primary:hover { box-shadow: 0 8px 0 #d9a629; }
.btn-ghost { background: #f1ebfb; color: var(--purple); }
.btn-mini { padding: 7px 13px; font-size: 13px; border-radius: 10px; background: var(--purple); color: #fff; }
.text-btn { background: none; border: 0; color: var(--yellow); font-weight: 700; cursor: pointer; font-size: 14px; padding: 10px; }
.hidden { display: none !important; }
input, textarea, select {
  width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 13px 15px;
  font-size: 15px; font-family: inherit; outline: none; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--purple-soft); }
textarea { resize: vertical; min-height: 110px; line-height: 1.6; }

/* 首页 */
.home-hero { text-align: center; padding: 34px 0 22px; }
.hero-badge { display: inline-block; background: rgba(255,255,255,.16); color: #fff; padding: 7px 16px; border-radius: 99px; font-size: 13px; margin-bottom: 20px; letter-spacing: 1px; }
.dot { color: var(--yellow); }
.hero-sub { color: #ede9fe; font-size: 17px; line-height: 1.7; margin: 18px 0 24px; }
.feature-row { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 26px; }
.feature { display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,.14); color: #fff; padding: 9px 15px; border-radius: 99px; font-size: 13px; }
.feature b { font-size: 17px; }
.home-actions { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.btn-lg { padding: 16px 36px; font-size: 17px; border-radius: 18px; }
.join-inline { display: flex; gap: 8px; max-width: 320px; margin: 18px auto 0; }
.join-inline input { text-align: center; letter-spacing: 6px; text-transform: uppercase; font-weight: 700; }
.how-card { margin: 16px auto 0; max-width: 860px; background: rgba(255,255,255,.95); border-radius: 24px; padding: 24px; box-shadow: var(--shadow); }
.how-card h3 { text-align: center; }
.how-steps { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.how-steps > div:not(.arrow) { display: flex; align-items: center; gap: 9px; }
.how-steps b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--purple); color: #fff; font-size: 14px; }
.how-steps span { font-size: 14px; font-weight: 700; line-height: 1.35; }
.how-steps small { font-weight: 400; color: var(--muted); }
.arrow { color: var(--purple-soft); font-size: 20px; }

/* 昵称设置 */
.panel-setup { max-width: 520px; margin: 40px auto; text-align: center; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 20px 0; }
.avatar-opt { aspect-ratio: 1; border-radius: 14px; border: 3px solid transparent; background: #f6f2ff; font-size: 26px; cursor: pointer; display: grid; place-items: center; }
.avatar-opt.sel { border-color: var(--purple); background: #ede4ff; transform: scale(1.06); }
.setup-actions { display: flex; gap: 12px; margin-top: 18px; }
.setup-actions .btn { flex: 1; }

/* 大厅 */
.lobby-grid { display: grid; grid-template-columns: 340px 1fr; gap: 18px; margin-top: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: 11px; background: #f1ebfb; color: var(--purple); padding: 4px 9px; border-radius: 99px; }
.setting-row { margin: 16px 0; }
.setting-row label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.setting-row select, .setting-row input { padding: 10px 12px; font-size: 14px; }
.setting-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.room-code-box { text-align: center; background: #f7f3ff; border-radius: 18px; padding: 18px; }
.code-line { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0; }
.code-line strong { font-size: 42px; letter-spacing: 10px; color: var(--purple-deep); }
.players-head { display: flex; justify-content: space-between; align-items: baseline; margin: 20px 0 10px; }
.player-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.player-chip { display: flex; align-items: center; gap: 9px; background: #f8f5ff; border: 2px solid transparent; border-radius: 14px; padding: 10px; }
.player-chip.off { opacity: .6; border-color: #ffd166; }
.player-chip .av { font-size: 24px; }
.player-chip .nm { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-chip .st { font-size: 11px; color: var(--muted); }
.player-chip.host .nm::after { content: '👑'; margin-left: 4px; font-size: 11px; }
.player-chip.me { border-color: var(--purple); }
.lobby-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* 游戏 */
.away-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #fff3cd; color: #7a5200; border-radius: 16px; padding: 12px 18px; margin: 12px 0 0; font-size: 14px; }
.game-grid { display: grid; grid-template-columns: 1fr 280px; gap: 18px; margin-top: 12px; }
.game-main { min-height: 560px; }
.game-top { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--line); padding-bottom: 14px; margin-bottom: 18px; }
.game-phase { display: flex; align-items: center; gap: 12px; }
.phase-badge { background: var(--purple); color: #fff; border-radius: 99px; padding: 7px 14px; font-size: 13px; font-weight: 700; }
.timer { font-size: 28px; font-weight: 800; color: var(--purple); font-variant-numeric: tabular-nums; min-width: 74px; text-align: right; }
.timer.urgent { color: var(--pink); animation: pulse .8s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.task-area { min-height: 400px; }
.task-title { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.task-desc { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.draw-canvas { width: 100%; max-width: 780px; aspect-ratio: 4 / 3; background: #fff; border: 3px solid var(--purple-soft); border-radius: 16px; touch-action: none; cursor: crosshair; display: block; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.tools-group { display: flex; gap: 6px; background: #f6f2ff; padding: 6px; border-radius: 12px; }
.tool { border: 0; background: #fff; border-radius: 9px; padding: 7px 11px; font-size: 13px; font-weight: 700; cursor: pointer; }
.tool.sel { background: var(--purple); color: #fff; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #e5dcf7; cursor: pointer; }
.swatch.sel { box-shadow: 0 0 0 3px var(--purple); }
.size-range { width: 100px; }
.guess-image { max-width: 100%; max-height: 330px; border-radius: 16px; border: 3px solid var(--line); display: block; margin-bottom: 14px; }
.task-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.wait-box { text-align: center; padding: 80px 20px; }
.wait-box .big { font-size: 52px; }
.player-list.compact { grid-template-columns: 1fr; }
.game-side h3 { margin-bottom: 12px; }
.host-tools { border-top: 2px solid var(--line); margin-top: 18px; padding-top: 14px; }
.host-tools .btn { width: 100%; margin-bottom: 8px; font-size: 13px; }
.safety-note { margin-top: 18px; background: #f3ecff; border-radius: 14px; padding: 13px; font-size: 12px; color: #5b3d8c; }
.safety-note p { margin: 6px 0 0; line-height: 1.6; }

/* 揭晓 */
.reveal-panel { max-width: 900px; margin: 12px auto; }
.reveal-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--line); padding-bottom: 12px; }
.reveal-stage { max-height: 58vh; overflow-y: auto; padding-top: 12px; }
.reveal-owner-bar { display: flex; align-items: center; justify-content: center; gap: 8px; background: linear-gradient(135deg,#f3ecff,#ede0ff); border: 1px solid #e3d4ff; border-radius: 14px; padding: 10px 14px; margin: 0 0 14px; box-shadow: 0 3px 10px rgba(80,40,160,.1); }
.reveal-owner-bar .owner-avatar { font-size: 26px; line-height: 1; }
.reveal-owner-bar .owner-text { font-size: 15px; color: #4a2e7a; }
.reveal-owner-bar .owner-text b { color: var(--purple); font-size: 17px; }
.reveal-items { display: flex; flex-direction: column; gap: 20px; padding: 16px 0 28px; }
.draw-replay { background: #fff; border-radius: 10px; overflow: hidden; line-height: 0; }
.replay-canvas { width: 100%; height: auto; display: block; }
.replay-canvas.replay-done { animation: replayPop .3s ease; }
@keyframes replayPop { from { filter: brightness(1.15); } to { filter: none; } }
.chat-row { display: flex; align-items: flex-start; gap: 10px; opacity: 0; transform: translateY(22px) scale(.94); transition: opacity .38s ease, transform .42s cubic-bezier(.2,.85,.3,1.15); scroll-margin-top: 72px; }
.chat-row.pop-in { opacity: 1; transform: none; }
.chat-row.from-left { flex-direction: row; }
.chat-row.from-right { flex-direction: row-reverse; }
.chat-face { flex: 0 0 60px; text-align: center; }
.chat-avatar { width: 50px; height: 50px; margin: 0 auto 5px; border-radius: 50%; background: #f3ecff; border: 2px solid #ede4ff; box-shadow: 0 2px 10px rgba(80,40,160,.18); display: grid; place-items: center; font-size: 28px; line-height: 1; }
.chat-name { font-size: 12px; font-weight: 700; color: #4a2e7a; line-height: 1.35; word-break: break-all; }
.chat-name span { font-size: 10px; font-weight: 500; color: var(--muted); }
.chat-bubble { position: relative; max-width: calc(100% - 74px); background: #fff; border-radius: 16px; padding: 13px 16px; box-shadow: 0 4px 14px rgba(80,40,160,.12); }
.from-left .chat-bubble { border-top-left-radius: 5px; }
.from-right .chat-bubble { border-top-right-radius: 5px; }
.chat-bubble .content-text { font-size: 21px; font-weight: 800; line-height: 1.4; word-break: break-word; }
.chat-bubble img { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; background: #fff; }
.chat-bubble .hidden-art { min-height: 90px; display: grid; place-items: center; color: var(--muted); background: repeating-linear-gradient(45deg,#f3ecff,#f3ecff 12px,#e9ddff 12px,#e9ddff 24px); border-radius: 10px; }
.reveal-actions { display: flex; justify-content: center; gap: 12px; }
.reveal-roombar { margin-top: 18px; border-top: 2px dashed var(--line); padding-top: 14px; text-align: center; }
.reveal-room-code { font-size: 14px; color: var(--muted); }
.reveal-room-code strong { font-size: 26px; letter-spacing: 4px; color: var(--purple); margin-left: 8px; font-family: monospace; }
.reveal-room-actions { margin-top: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.reveal-room-actions .text-btn { font-size: 12px; }

/* 弹窗与提示 */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(24,8,52,.65); display: grid; place-items: center; padding: 20px; }
.modal-card { background: #fff; border-radius: 22px; max-width: 560px; width: 100%; padding: 28px; position: relative; max-height: 86vh; overflow: auto; }
.modal-card h2 { padding-right: 30px; }
.modal-card li { margin: 8px 0; line-height: 1.6; }
.modal-close { position: absolute; right: 16px; top: 14px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--muted); }
.help-highlight { background: #f3ecff; border-radius: 14px; padding: 14px 18px; font-size: 13px; line-height: 1.7; }
.help-highlight ul { padding-left: 18px; margin: 8px 0 0; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #2b1746; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; z-index: 40; box-shadow: 0 10px 30px rgba(0,0,0,.25); }

@media (max-width: 900px) {
  .lobby-grid, .game-grid { grid-template-columns: 1fr; }
  .settings-panel { order: 2; }
  .game-side { order: 2; }
  .how-steps { justify-content: center; }
  .arrow { display: none; }
}
@media (max-width: 520px) {
  #app { padding: 0 12px 40px; }
  .panel { padding: 18px; border-radius: 18px; }
  .avatar-grid { grid-template-columns: repeat(4, 1fr); }
  .code-line strong { font-size: 32px; }
  .btn-lg { padding: 14px 24px; }
}
