:root {
  --bg: #fdf6e3;
  --panel: #fff;
  --ink: #333;
  --accent: #d98c00;
  --muted: #999;
  --p0: #e76f51;
  --p1: #3a86ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

#app { max-width: 480px; margin: 0 auto; padding: 0 12px 24px; }

#hud { display: flex; align-items: center; gap: 10px; padding: 12px 4px; }
#hud-title { flex: 1; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-left { text-decoration: none; font-size: 20px; }

.card {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  margin-top: 8px;
}
.card h2 { font-size: 20px; margin-bottom: 12px; }

.rules { list-style: none; margin-bottom: 18px; }
.rules li { padding: 6px 0 6px 18px; position: relative; font-size: 14px; line-height: 1.5; color: #555; }
.rules li::before { content: "•"; position: absolute; left: 4px; color: var(--accent); font-weight: 700; }

.field { display: block; margin-bottom: 16px; }
.label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
input[type="text"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn.big { display: block; width: 100%; padding: 14px; font-size: 17px; }
.btn.ghost { background: #fff; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.waiting { background: #bbb; }
.btn:disabled { opacity: 0.5; cursor: default; }

.err { color: #e63946; margin-top: 10px; font-size: 14px; }
.hint { color: #888; font-size: 13px; margin-top: 10px; text-align: center; }

/* 游戏区 */
#stage { position: relative; }
#game-canvas {
  display: block;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(30, 20, 10, 0.35);
  border-radius: 12px;
}
.panel-box {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  text-align: center;
}
.panel-box h2 { font-size: 22px; margin-bottom: 12px; }

#panel-result { margin-bottom: 12px; }
.result-scores { display: flex; justify-content: center; align-items: baseline; gap: 10px; font-weight: 800; }
.result-scores .s { font-size: 28px; }
.result-scores .vs { color: var(--muted); font-size: 16px; }
.result-wins { color: #777; font-size: 13px; margin-top: 4px; }

#panel-players { list-style: none; margin-bottom: 14px; text-align: left; }
#panel-players li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #faf6ee;
  margin-bottom: 6px;
  font-size: 15px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pname { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pstate { font-size: 13px; color: #888; flex: none; }
.pstate.ok { color: #2a9d8f; font-weight: 700; }
.pstate.off { color: #e63946; }
#panel-players li.empty .pname { color: #aaa; font-weight: 400; }

#share-box { margin-bottom: 14px; }
#share-box .hint { margin: 0 0 8px; }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; min-width: 0; font-size: 13px; padding: 9px 10px; }

/* 画布下面：炸药 + 表情 */
#actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
#taunts { display: flex; gap: 8px; flex: 1; justify-content: flex-end; }
.act {
  height: 46px;
  min-width: 46px;
  border: none;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.08s, opacity 0.2s;
}
.act:active:not(:disabled) { transform: scale(0.92); }
.act:disabled { opacity: 0.35; cursor: default; }
.act.dyn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  background: #ffe8d6;
}
.act.dyn:not(:disabled) { background: #ff8c42; box-shadow: 0 0 0 3px rgba(255,140,66,0.35); }
.act.dyn span { font-size: 16px; font-weight: 800; color: #6b3d1a; }
.act.dyn:not(:disabled) span { color: #fff; }
#taunts .act.cool { opacity: 0.45; }

#conn-status {
  text-align: center;
  color: #e63946;
  font-size: 13px;
  margin-top: 8px;
}
#error { text-align: center; }
#error-msg { font-size: 16px; margin-bottom: 16px; }
