/* 你画我猜 —— 样式（纯手写，无外部资源） */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg1: #6a5af9;
  --bg2: #9b6dff;
  --card: #ffffff;
  --ink: #2b2b3a;
  --muted: #8a8a99;
  --primary: #6a5af9;
  --primary-dark: #5748e0;
  --danger: #e74c3c;
  --good: #2ecc71;
  --radius: 16px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1), var(--bg2) 55%, #ff8fb1);
  min-height: 100vh;
  overflow-x: hidden;
}

#app { min-height: 100vh; }

/* ---------- 屏幕切换 ---------- */
.screen { display: none; min-height: 100vh; padding: 16px; }
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#screen-game.active { justify-content: flex-start; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(40, 20, 90, 0.35);
  padding: 28px;
  width: 100%;
  max-width: 460px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: #eeeef6;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: #e2e2f0; }
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(106, 90, 249, 0.4); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.big { padding: 13px 22px; font-size: 17px; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: rgba(255, 255, 255, 0.25); color: #fff; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.4); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

input[type="text"], input:not([type]), select {
  border: 2px solid #e2e2f0;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 16px;
  outline: none;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease;
}
input:focus, select:focus { border-color: var(--primary); }

.hint-text { color: var(--muted); font-size: 13px; margin-top: 14px; text-align: center; }
.hint-text code { background: #f0f0f8; padding: 1px 6px; border-radius: 6px; }
.error-text { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; text-align: center; }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

/* ---------- 首页 ---------- */
.home-card { text-align: center; }
.logo {
  font-size: 42px;
  letter-spacing: 6px;
  background: linear-gradient(90deg, #6a5af9, #ff5e9c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline { color: var(--muted); margin: 6px 0 22px; }
.logo-art { position: relative; height: 54px; margin-bottom: 4px; }
.logo-art .brush { font-size: 40px; position: absolute; left: 50%; top: 4px; transform: translateX(-50%) rotate(-15deg); animation: wave 2.4s ease-in-out infinite; }
@keyframes wave { 0%,100% { transform: translateX(-50%) rotate(-18deg); } 50% { transform: translateX(-50%) rotate(10deg) translateY(-4px); } }
.logo-art .dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; top: 22px; }
.logo-art .d1 { left: 26%; background: #ffd166; }
.logo-art .d2 { right: 26%; background: #06d6a0; }
.logo-art .d3 { left: 32%; top: 40px; width: 8px; height: 8px; background: #ef476f; }

#inp-name { width: 100%; text-align: center; margin-bottom: 14px; }
#btn-create { width: 100%; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #e6e6f0; }
.join-row { display: flex; gap: 10px; }
#inp-code { width: 0; flex: 1; text-align: center; text-transform: uppercase; letter-spacing: 6px; font-weight: 700; }

/* ---------- 大厅 ---------- */
.lobby-card { max-width: 560px; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.lobby-head .btn.ghost { color: var(--muted); background: #f0f0f8; }
.room-code-box { font-size: 15px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.room-code {
  font-size: 26px; font-weight: 800; letter-spacing: 5px; color: var(--primary);
  background: #f0efff; padding: 2px 12px; border-radius: 10px;
}
.section-title { font-size: 16px; margin-bottom: 10px; color: var(--muted); }
.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.player-card {
  display: flex; align-items: center; gap: 8px;
  background: #f6f6fc; border-radius: 12px; padding: 8px 10px;
  font-weight: 600; font-size: 14px;
}
.player-card.offline { opacity: 0.45; }
.player-card .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-card .badges { margin-left: auto; font-size: 13px; }
.bot-tag { background: #ffe9a8; color: #8a6d00; border-radius: 6px; padding: 1px 5px; font-size: 11px; font-weight: 700; }

.lobby-settings { display: flex; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.lobby-settings label { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.lobby-settings select { padding: 7px 10px; font-size: 14px; }
.lobby-actions { display: flex; gap: 12px; }
.lobby-actions .btn { flex: 1; }

/* ---------- 游戏页 ---------- */
#screen-game { padding: 10px; gap: 10px; max-width: 1280px; margin: 0 auto; width: 100%; }
.game-head {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 14px; padding: 10px 16px;
  box-shadow: 0 6px 18px rgba(40, 20, 90, 0.25);
}
.round-info { font-weight: 700; color: var(--muted); white-space: nowrap; }
.word-info { flex: 1; text-align: center; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-info b { color: var(--primary); font-size: 20px; }
.word-info .cat { color: var(--muted); font-size: 13px; }
.word-info .blanks { letter-spacing: 4px; color: #b7b7cc; }
.timer {
  font-size: 22px; font-weight: 800; min-width: 62px; text-align: center;
  background: #f0efff; color: var(--primary); border-radius: 10px; padding: 2px 8px;
}
.timer.danger { background: #ffe3e0; color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.game-head .btn.ghost { color: var(--muted); background: #f0f0f8; }

.game-body { width: 100%; flex: 1; display: flex; gap: 10px; min-height: 0; }
.board-col { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.94); border-radius: 12px; padding: 8px 10px;
}
.toolbar.hidden { display: none; }
.tool-btn {
  border: 2px solid transparent; background: #eeeef6; border-radius: 10px;
  padding: 6px 12px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink);
}
.tool-btn.active { border-color: var(--primary); background: #f0efff; }
.tool-btn.danger { background: #ffe3e0; color: var(--danger); }
.swatches { display: flex; gap: 5px; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.12);
}
.swatch.active { outline: 3px solid var(--primary); outline-offset: 1px; }
#inp-color { width: 34px; height: 34px; border: none; background: none; padding: 0; cursor: pointer; }
.size-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
#inp-size { width: 90px; accent-color: var(--primary); }

.canvas-wrap {
  flex: 1; min-height: 280px;
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 6px 18px rgba(40, 20, 90, 0.25);
  display: flex;
}
#board { width: 100%; height: 100%; touch-action: none; display: block; background: #fff; }

.side-col {
  width: 300px; flex: none;
  display: flex; flex-direction: column; gap: 8px; min-height: 0;
}
.side-players {
  background: rgba(255, 255, 255, 0.94); border-radius: 12px; padding: 8px;
  max-height: 210px; overflow-y: auto;
}
.player-row {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 6px; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.player-row.me { background: #f0efff; }
.player-row.offline { opacity: 0.45; }
.player-row .rank { width: 16px; color: var(--muted); font-size: 12px; }
.player-row .avatar { width: 26px; height: 26px; font-size: 12px; }
.player-row .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .pscore { color: var(--primary); font-weight: 800; }

.chat-list {
  flex: 1; min-height: 120px;
  background: rgba(255, 255, 255, 0.94); border-radius: 12px; padding: 10px;
  overflow-y: auto; font-size: 14px; line-height: 1.5;
}
.chat-msg { margin-bottom: 5px; word-break: break-word; }
.chat-msg b { color: var(--primary); }
.chat-msg.sys { color: var(--muted); font-size: 13px; text-align: center; }
#chat-form { display: flex; gap: 8px; }
#chat-input { flex: 1; width: 0; }

/* ---------- 结算 / 回合覆盖层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(30, 18, 70, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay.hidden { display: none; }
.panel {
  background: #fff; border-radius: 18px; padding: 26px 30px;
  max-width: 430px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  max-height: 85vh; overflow-y: auto;
}
.panel h2 { margin-bottom: 10px; }
.panel .answer { font-size: 19px; margin: 8px 0; }
.panel .answer b { color: var(--primary); font-size: 24px; }
.panel .reason { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.score-table { margin: 12px 0; text-align: left; }
.score-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-weight: 600; }
.score-row.me { background: #f0efff; }
.score-row .medal { width: 26px; text-align: center; }
.score-row .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .pscore { color: var(--primary); font-weight: 800; }
.panel .dim { color: var(--muted); font-size: 13px; margin-top: 8px; }
.panel .btn-row { display: flex; gap: 10px; margin-top: 16px; }
.panel .btn-row .btn { flex: 1; }

/* ---------- 全局提示 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: rgba(30, 25, 60, 0.92); color: #fff; padding: 10px 20px;
  border-radius: 24px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: #ff6b5e; color: #fff; text-align: center;
  padding: 7px; font-size: 14px; font-weight: 600;
}
#conn-banner.hidden { display: none; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 900px) {
  .game-body { flex-direction: column; }
  .side-col { width: 100%; }
  .side-players { max-height: 130px; }
  .chat-list { min-height: 140px; max-height: 220px; }
  .canvas-wrap { min-height: 300px; flex: none; aspect-ratio: 4 / 3; }
  .word-info { font-size: 14px; }
  .timer { font-size: 18px; min-width: 52px; }
  .card { padding: 20px; }
  .logo { font-size: 34px; }
}
