/* =========================================================================
 * 摇一摇口令房间 · 全局样式
 * 移动端优先，桌面端居中窄栏，微信内置浏览器兼容
 * ======================================================================= */

:root {
  --primary: #FF5A5F;
  --primary-dark: #F0305A;
  --accent: #FFB020;
  --bg: #FFF7ED;
  --ink: #1F2430;
  --muted: #8A94A6;
  --line: #EDF0F5;
  --ok: #128A4E;
  --bad: #C4253A;
  --card-shadow: 0 8px 22px rgba(120, 20, 45, .14);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(165deg, #FF8A65 0%, var(--primary) 45%, var(--primary-dark) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  padding: calc(14px + env(safe-area-inset-top)) 12px calc(28px + env(safe-area-inset-bottom));
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 通用容器 ---------------- */
.screen {
  max-width: 520px;
  margin: 0 auto;
  animation: fadein .22s ease both;
}

.hidden { display: none !important; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

h1 {
  color: #fff;
  font-size: 22px;
  margin: 6px 0 6px;
  letter-spacing: .5px;
  text-align: center;
}

h2 {
  color: #fff;
  font-size: 19px;
  margin: 4px 0 12px;
  letter-spacing: .4px;
  text-align: center;
}

h2.title-ok { color: #fff; }

h3 {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .6px;
  margin: 0 0 10px;
}

.sub {
  color: rgba(255, 255, 255, .88);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  margin: 0 0 14px;
}

.muted { color: var(--muted); font-size: 12.5px; }

.hint {
  font-size: 12.5px;
  color: rgba(255, 255, 255, .82);
  line-height: 1.6;
  text-align: center;
  margin: 12px 0 0;
}

.row { display: flex; gap: 10px; }
.row.center { justify-content: center; align-items: center; }

.card {
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--card-shadow);
  margin-bottom: 12px;
}

/* ---------------- 顶部状态条 ---------------- */
.topbar {
  max-width: 520px;
  margin: 0 auto 10px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, .92);
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(120, 20, 45, .12);
}

.chip-ok { color: var(--ok); background: #E7F7EE; }
.chip-bad { color: var(--bad); background: #FDE8EA; }
.chip-warn { color: #A86500; background: #FFF4E0; }
.chip-offline { color: var(--bad); background: #FDE8EA; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  padding: 15px 20px;
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: transform .06s ease, opacity .15s ease;
}

.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; }

.btn-primary {
  background: linear-gradient(135deg, #FF7A5C, var(--primary-dark));
  color: #fff;
  box-shadow: 0 8px 18px rgba(240, 48, 90, .32);
}

.btn-secondary {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: var(--card-shadow);
}

.btn-ghost {
  background: rgba(255, 255, 255, .18);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, .6);
}

.btn-outline {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  width: auto;
  padding: 9px 13px;
  font-size: 13px;
  border-radius: 11px;
}

.btn-large { padding: 26px 18px; font-size: 17px; flex-direction: column; }
.btn-large i { font-size: 26px; margin-bottom: 4px; }

/* ---------------- 表单 ---------------- */
.field { display: block; margin-bottom: 12px; }

.field > span {
  display: block;
  color: rgba(255, 255, 255, .9);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 6px;
  padding-left: 2px;
}

.field input {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--card-shadow);
  outline: none;
}

.field input::placeholder { color: #B9C0CC; font-weight: 600; }
.field input:focus { box-shadow: 0 0 0 3px rgba(255, 255, 255, .55), var(--card-shadow); }

#hostCode, #joinCode {
  letter-spacing: 6px;
  text-align: center;
  font-size: 26px;
  font-weight: 900;
}

.result {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  min-height: 20px;
  margin: 2px 0 12px;
  color: rgba(255, 255, 255, .9);
}

.result.bad { color: #FFE3E6; }

/* ---------------- 口令展示 ---------------- */
.codebox {
  background: rgba(255, 255, 255, .95);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--card-shadow);
  font-size: 13px;
  color: var(--muted);
}

.codebox strong {
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--ink);
  margin-right: auto;
}

.pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.pill-ok { background: #E7F7EE; color: var(--ok); }
.pill-bad { background: #FDE8EA; color: var(--bad); }
.pill-warn { background: #FFF4E0; color: #A86500; }
.pill-gray { background: var(--line); color: var(--muted); }

/* ---------------- 名单 / 排行榜 ---------------- */
.list { list-style: none; margin: 0; padding: 0; }

.list li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}

.list li:last-child { border-bottom: 0; }

.list li .idx {
  width: 24px;
  flex: 0 0 24px;
  text-align: center;
  font-weight: 900;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.list li .idx.top1 { color: #E8A417; }
.list li .idx.top2 { color: #9AA7B8; }
.list li .idx.top3 { color: #C4794A; }

.list li .who {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.list li .who .me { color: var(--primary-dark); }

.list li .val {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--primary-dark);
}

.list li .val.zero { color: #C7CDD8; }

.list li.is-me { background: #FFF3F4; border-radius: 9px; padding-left: 8px; padding-right: 8px; }

.list .empty { color: var(--muted); font-size: 13px; justify-content: center; }

/* ---------------- 计分区 ---------------- */
.score { text-align: center; margin: 6px 0 4px; }

.score .big {
  display: block;
  font-size: 76px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow: 0 6px 20px rgba(150, 20, 50, .35);
  font-variant-numeric: tabular-nums;
}

.score-meta {
  color: rgba(255, 255, 255, .92);
  font-size: 13px;
  margin-top: 6px;
}

.score-meta .muted { color: rgba(255, 255, 255, .7); }

.shake-btn {
  margin-top: 14px;
  padding: 22px;
  font-size: 20px;
  border-radius: 18px;
}

.pop {
  animation: popIn .14s ease;
}
@keyframes popIn {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ---------------- 主持人控制条 ---------------- */
.hostbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .96);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: var(--card-shadow);
}

.hostbar .pill { margin-right: auto; }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: rgba(31, 36, 48, .93);
  color: #fff;
  padding: 12px 18px;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
  max-width: 86vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 99;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px) {
  .score .big { font-size: 62px; }
  #hostCode, #joinCode { font-size: 22px; letter-spacing: 4px; }
}
