* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #7c5cff;
  --primary-dark: #5a3fd6;
  --primary-light: #f0edff;
  --bg: #f7f6fb;
  --card: #ffffff;
  --text: #2a2440;
  --text-light: #8a84a0;
  --ok: #34c759;
  --border: #ece9f5;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(124, 92, 255, 0.08);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 16px 40px;
  position: relative;
}

.view { display: none; }
.view.active { display: block; }

.hidden { display: none !important; }

/* ---------- 首页 ---------- */
.brand { text-align: center; margin-bottom: 24px; }
.brand h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.tagline { color: var(--text-light); font-size: 13px; margin-bottom: 16px; }
.slogan { font-size: 24px; font-weight: 700; line-height: 1.4; margin-bottom: 8px; }
.slogan br { display: none; }
.sub { color: var(--text-light); font-size: 14px; margin-bottom: 6px; }
.meta { color: var(--text-light); font-size: 12px; margin-bottom: 16px; }

.example {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--primary-light);
  border-radius: var(--radius);
}
.chip {
  background: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}
.chip.ok { background: var(--ok); color: #fff; }
.cross, .arrow { color: var(--text-light); font-size: 14px; }

/* tabs */
.tabs {
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}
.tab.active {
  background: var(--primary);
  color: #fff;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: none;
}
.panel.active { display: block; }

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  margin-top: 4px;
}

input[type="text"], input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border 0.2s;
  background: var(--bg);
}
input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--primary);
  background: #fff;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 8px;
}
.row-label { font-size: 14px; font-weight: 600; }
.seg { display: flex; gap: 6px; }
.seg-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-light);
  font-weight: 500;
}
.seg-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.primary-btn {
  width: 100%;
  padding: 14px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.2s, transform 0.1s;
}
.primary-btn:active { transform: scale(0.98); }
.primary-btn.disabled { background: #c8c2e0; cursor: not-allowed; }

.hint { text-align: center; color: var(--text-light); font-size: 12px; margin-top: 12px; }
.foot { text-align: center; margin-top: 32px; color: var(--text-light); font-size: 12px; }

/* ---------- 房间页 ---------- */
.room-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--card);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--text);
  flex-shrink: 0;
}
#share-btn { width: auto; padding: 0 14px; font-size: 14px; }
.room-info { flex: 1; }
.room-info h2 { font-size: 17px; font-weight: 700; }
.room-info p { font-size: 12px; color: var(--text-light); }

.stage { display: none; }
.stage.active { display: block; }

/* 等待阶段 */
.waiting-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.waiting-box h3 { font-size: 18px; margin-bottom: 16px; }
.code-big {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--primary);
  margin-bottom: 8px;
}
.player-list {
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
}
.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.player-name { font-weight: 600; flex: 1; text-align: left; }
.player-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
}
.tip { color: var(--text-light); font-size: 13px; margin-top: 8px; }

/* 游戏阶段 */
.round-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 600;
}
.timer {
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 12px;
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
}

.prompt-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.prompt-label { color: var(--text-light); font-size: 13px; margin-bottom: 8px; }
.current-word {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}
.prompt-words {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.prompt-word-single {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}
.prompt-word {
  font-size: 22px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 12px;
  min-width: 80px;
}
.prompt-word.p1 { background: var(--primary-light); color: var(--primary); }
.prompt-word.p2 { background: #e8f5e9; color: #2e7d32; }
.prompt-cross { color: var(--text-light); font-size: 20px; font-weight: 700; }

.input-box {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.input-box input { flex: 1; }
.input-box .primary-btn {
  width: auto;
  margin-top: 0;
  padding: 0 20px;
  white-space: nowrap;
}

.submit-status {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 16px;
}

.submitted-list {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.submitted-list h4 { font-size: 14px; margin-bottom: 10px; color: var(--text-light); }
.submitted-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.submitted-player:last-child { border-bottom: none; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd;
}
.dot.done { background: var(--ok); }

/* 揭晓阶段 */
#reveal-stage { text-align: center; }
#reveal-stage h3 { font-size: 20px; margin-bottom: 20px; }
.reveal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.reveal-item {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.reveal-item .player-name { flex: 1; text-align: left; }
.reveal-word {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.reveal-item.match .reveal-word { color: var(--ok); }

.reveal-result {
  font-size: 18px;
  font-weight: 700;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}
.reveal-result.win { background: #e8f8ec; color: var(--ok); }
.reveal-result.lose { background: var(--primary-light); color: var(--primary); }

/* 胜利头部 */
.win-header {
  text-align: center;
  margin-bottom: 24px;
}
.win-header h2 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 8px;
}
.win-header p {
  font-size: 16px;
  color: var(--text-light);
}
.win-header p strong {
  color: var(--primary);
  font-size: 20px;
}

/* 历史回顾 */
.history-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.history-section h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-light);
}
.history-round {
  margin-bottom: 14px;
}
.history-round:last-child { margin-bottom: 0; }
.history-round-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
}
.history-round-words {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hword {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
}
.hword.p1 { background: var(--primary-light); color: var(--primary); }
.hword.p2 { background: #e8f5e9; color: #2e7d32; }
.hword.win { background: #e8f8ec; color: var(--ok); }
.hcross { color: var(--text-light); font-weight: 700; font-size: 16px; }

/* toast */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(42, 36, 64, 0.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 1000;
  animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, 10px); } }
