* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: linear-gradient(160deg, #fff6f0 0%, #fdeef6 100%);
  color: #3a3a3a;
  min-height: 100vh;
  padding: 24px 16px 90px;
}

#app { width: 100%; max-width: 460px; margin: 0 auto; }

h1 {
  text-align: center;
  font-size: 26px;
  margin: 8px 0 22px;
  color: #d6698a;
  letter-spacing: 2px;
}

.tip {
  font-size: 13px;
  color: #888;
  line-height: 1.6;
  background: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
}

input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #f0cdd9;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  background: #fff;
}
input:focus { border-color: #d6698a; }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  padding: 12px 18px;
  background: #f3d9e2;
  color: #7a3a52;
  transition: transform .08s ease, background .2s;
}
button:hover { background: #ecc6d4; }
button:active { transform: scale(0.97); }

button.primary {
  width: 100%;
  background: #d6698a;
  color: #fff;
  font-weight: 600;
  margin: 12px 0;
}
button.primary:hover { background: #c8587c; }

.join { display: flex; gap: 8px; }
.join input { flex: 1; }
.join button { white-space: nowrap; }

.hint {
  font-size: 13px;
  color: #c0587c;
  margin-top: 12px;
  word-break: break-all;
  min-height: 18px;
}

/* 菜单 */
.status-line {
  text-align: center;
  font-weight: 600;
  color: #7a3a52;
  margin-bottom: 12px;
}
.room-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #888;
  background: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 18px;
}
.room-bar b { color: #d6698a; letter-spacing: 1px; }
.room-bar button { padding: 6px 12px; font-size: 13px; }
.sub { font-size: 14px; color: #666; margin: 0 0 10px; }

.game-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(214, 105, 138, 0.12);
  transition: transform .1s, box-shadow .2s;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(214, 105, 138, 0.22); }
.gc-name { font-size: 17px; font-weight: 600; color: #d6698a; margin-bottom: 6px; }
.gc-desc { font-size: 12px; color: #999; line-height: 1.5; }

/* 游戏顶栏 */
.game-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.game-top button { padding: 8px 14px; font-size: 14px; }
.game-title { font-size: 18px; font-weight: 600; color: #7a3a52; }

/* 四子棋 */
.c4-status {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #7a3a52;
  margin-bottom: 12px;
  min-height: 22px;
}
.c4-columns {
  display: grid;
  grid-template-columns: repeat(7, 44px);
  gap: 6px;
  justify-content: center;
  margin-bottom: 4px;
}
.col-btn {
  width: 44px; height: 30px; padding: 0;
  background: #f3d9e2; font-size: 16px; color: #b0567a;
}
.col-btn:hover { background: #ecc6d4; }
.c4-board {
  display: grid;
  grid-template-columns: repeat(7, 44px);
  gap: 6px;
  justify-content: center;
  background: #1f4e96;
  padding: 8px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(31, 78, 150, 0.25);
}
.cell {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #dfe6f0;
  cursor: pointer;
  transition: background .15s;
}
.cell.red { background: #e74c3c; }
.cell.yellow { background: #f1c40f; }
.c4-restart { display: block; margin: 16px auto 0; background: #f3d9e2; }

/* 五子棋 */
.go-board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 2px;
  background: #f0d9b5;
  padding: 6px;
  border-radius: 10px;
  max-width: 390px;
  margin: 0 auto;
  box-shadow: 0 6px 16px rgba(120, 80, 30, 0.25);
}
.go-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background .12s;
}
.go-cell:hover { background: rgba(0,0,0,0.08); }
.go-cell.red { background: #e74c3c; cursor: default; }
.go-cell.yellow { background: #f1c40f; cursor: default; }

/* 你画我猜 */
.dw-status { text-align: center; color: #c0587c; font-weight: 600; min-height: 20px; margin-bottom: 8px; }
.dw-info {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  font-size: 13px; color: #7a3a52; margin-bottom: 10px;
}
.dw-info #dw-word { font-weight: 700; color: #d6698a; }
#dw-canvasWrap {
  background: #fff; border-radius: 12px; padding: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
#dw-canvas {
  width: 100%; height: auto; display: block;
  background: #fff; border-radius: 8px; touch-action: none;
  border: 1px solid #eee;
}
.dw-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.dw-color {
  width: 28px; height: 28px; padding: 0; border-radius: 50%;
  border: 2px solid transparent;
}
.dw-color.on { border-color: #333; }
.dw-act { padding: 7px 14px; font-size: 13px; background: #f3d9e2; }
.dw-guess { display: flex; gap: 8px; margin: 6px 0; }
.dw-guess input { flex: 1; }
.dw-feed {
  height: 110px; overflow-y: auto;
  background: #fff; border-radius: 10px; padding: 8px;
  font-size: 13px; line-height: 1.6;
}
.dw-msg.me { color: #d6698a; }
.dw-msg.peer { color: #4a7ab5; }

/* 浮动聊天 */
.chat-panel {
  position: fixed; right: 16px; bottom: 16px;
  width: 260px; max-width: 80vw;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  overflow: hidden;
}
.chat-head {
  background: #d6698a; color: #fff;
  padding: 8px 12px; font-size: 14px; font-weight: 600;
}
.chat-log {
  height: 150px; overflow-y: auto;
  padding: 8px; font-size: 13px; line-height: 1.6;
}
.chat-msg.me { color: #d6698a; }
.chat-msg.peer { color: #4a7ab5; }
.chat-input { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #f0e0e7; }
.chat-input input { flex: 1; padding: 8px 10px; font-size: 13px; }
.chat-input button { padding: 8px 12px; font-size: 13px; }

/* 顶栏 */
.topbar {
  width: 100%; max-width: 460px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.brand { font-size: 20px; font-weight: 700; color: #d6698a; letter-spacing: 1px; }
.auth-area { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.auth-area .who { font-size: 14px; color: #7a3a52; font-weight: 600; }
.auth-area button { padding: 7px 14px; font-size: 13px; }

button.ghost {
  background: transparent; color: #7a3a52; border: 1.5px solid #f0cdd9;
  align-self: flex-start; margin-bottom: 14px;
}
button.ghost:hover { background: #fdeef6; }
.view-title { text-align: center; color: #d6698a; margin: 6px 0 18px; }
.view-sub { color: #7a3a52; margin: 18px 0 8px; font-size: 15px; }

/* 表单 */
#lobby input { margin-bottom: 10px; }
#lobby .join input { margin-bottom: 0; }
#lobby .nick-line { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
#lobby .nick-line label { font-size: 14px; color: #7a3a52; white-space: nowrap; }
#lobby .nick-line input { flex: 1; margin-bottom: 0; }

/* 记录表格 */
.rec-table {
  width: 100%; border-collapse: collapse; background: #fff;
  border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(214,105,138,0.12);
  font-size: 13px;
}
.rec-table th, .rec-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #f3e6ec; }
.rec-table th { background: #fdeef6; color: #7a3a52; font-weight: 600; }
.rec-table tr:last-child td { border-bottom: none; }
.r-win { color: #27ae60; font-weight: 600; }
.r-lose { color: #c0587c; font-weight: 600; }
.r-draw { color: #888; }
.rec-table .del { padding: 5px 10px; font-size: 12px; background: #fbe3ea; color: #c0587c; }
.rec-table .del:hover { background: #f6cdd9; }

/* 登录/注册弹窗 */
.modal { display: none; }
.modal:not([hidden]) {
  position: fixed; inset: 0; background: rgba(60,30,45,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-box {
  position: relative; width: 100%; max-width: 340px; background: #fff;
  border-radius: 16px; padding: 26px 22px; box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.modal-box h2 { text-align: center; color: #d6698a; margin: 0 0 18px; }
.modal-close {
  position: absolute; top: 10px; right: 14px; background: transparent;
  font-size: 22px; color: #bbb; padding: 0 6px; line-height: 1;
}
.modal-close:hover { background: transparent; color: #888; }
.modal-box form { display: flex; flex-direction: column; gap: 10px; }
.modal-box input { margin: 0; }
.err { color: #c0587c; font-size: 13px; min-height: 16px; margin: 0; text-align: center; }
.switch { text-align: center; font-size: 13px; color: #888; margin: 14px 0 0; }
.switch a { color: #d6698a; font-weight: 600; text-decoration: none; }

/* 战绩统计与成就 */
.stats-card {
  background: #fff; border-radius: 14px; padding: 14px 12px;
  box-shadow: 0 4px 12px rgba(214,105,138,0.12); margin-bottom: 4px;
}
.stats-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.stat { background: #fdeef6; border-radius: 10px; padding: 10px 4px; }
.stat-v { font-size: 18px; font-weight: 700; color: #d6698a; }
.stat-k { font-size: 11px; color: #999; margin-top: 2px; }
.per-game { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.per-game .pg {
  font-size: 12px; color: #7a3a52; background: #f3d9e2;
  border-radius: 20px; padding: 5px 12px;
}
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ach {
  border-radius: 12px; padding: 12px 10px; border: 1.5px solid #f0e0e7;
}
.ach.on { background: linear-gradient(135deg,#fff4f8,#ffe6ef); border-color: #f0b8cd; }
.ach.off { background: #fafafa; opacity: 0.7; }
.ach-name { font-size: 14px; font-weight: 700; color: #7a3a52; }
.ach.off .ach-name { color: #aaa; }
.ach-desc { font-size: 11px; color: #999; margin: 3px 0 6px; line-height: 1.4; }
.ach-flag { font-size: 11px; font-weight: 600; }
.ach.on .ach-flag { color: #27ae60; }
.ach.off .ach-flag { color: #bbb; }
