/* ========== 拔河大作战 样式 ========== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg1: #0f172a;
  --bg2: #1e293b;
  --card: rgba(30, 41, 59, .78);
  --line: rgba(148, 163, 184, .18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --red: #ef4444;
  --blue: #3b82f6;
  --gold: #fde047;
  --green: #22c55e;
}

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 60%, #0b1220);
  min-height: 100dvh;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

.view { min-height: 100dvh; display: flex; flex-direction: column; max-width: 900px; margin: 0 auto; padding: 12px; }

button {
  font: inherit; color: inherit; cursor: pointer;
  background: rgba(51, 65, 85, .8); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; transition: .15s;
}
button:hover:not(:disabled) { background: rgba(71, 85, 105, .9); transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, #f97316, #ef4444); border: none; font-weight: 700; }
button.primary:hover:not(:disabled) { filter: brightness(1.1); }
button.wide { width: 100%; }
button.big { font-size: 1.15rem; padding: 14px; }
button.small { padding: 6px 10px; font-size: .85rem; }
button.danger { border-color: rgba(239, 68, 68, .4); color: #fca5a5; }

input, select {
  font: inherit; color: var(--text);
  background: rgba(15, 23, 42, .7); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(59, 130, 246, .5); }

/* ---------- 大厅 ---------- */
#view-lobby { justify-content: center; }
.lobby-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 28px; backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.lobby-card h1 { text-align: center; font-size: 1.9rem; }
.sub { text-align: center; color: var(--muted); margin: 6px 0 20px; }

.field { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
.field input, .field select { margin-top: 6px; color: var(--text); }

.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.panel { background: rgba(15, 23, 42, .45); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.panel h2 { font-size: 1rem; margin-bottom: 10px; }
.panel button { margin-top: 6px; }

.hint { color: var(--gold); font-size: .82rem; margin-bottom: 8px; }
.tip { color: var(--muted); font-size: .8rem; margin-top: 16px; text-align: center; }

@media (max-width: 620px) { .lobby-grid { grid-template-columns: 1fr; } }

/* ---------- 房间 ---------- */
.room-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.room-code { font-size: 1rem; }
.room-code b { color: var(--gold); letter-spacing: 2px; font-size: 1.15rem; }
.room-head .spacer, .game-head .spacer { flex: 1; }

.net-dot { width: 10px; height: 10px; border-radius: 50%; background: #64748b; display: inline-block; }
.net-dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.ping { color: var(--muted); font-size: .8rem; min-width: 44px; }

.invite-row { margin-bottom: 8px; }
.invite-input { font-size: .82rem; color: var(--muted); background: rgba(15, 23, 42, .5); }

.room-status { color: var(--gold); text-align: center; margin-bottom: 10px; font-size: .95rem; }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.team { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-height: 140px; }
.team h3 { font-size: .95rem; margin-bottom: 8px; }
.team ul { list-style: none; }
.team li { padding: 6px 8px; border-radius: 8px; margin-bottom: 4px; font-size: .92rem; background: rgba(15, 23, 42, .35); }
.team-red li { border-left: 3px solid var(--red); }
.team-blue li { border-left: 3px solid var(--blue); }
.team li .crown { margin-left: 6px; }
.team li.off { opacity: .45; }
.team li .you { color: var(--gold); font-size: .78rem; }

#btn-start { margin: 14px auto 0; min-width: 260px; }

.chat-panel { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; flex: 1; display: flex; flex-direction: column; min-height: 200px; }
.chat-log { flex: 1; overflow-y: auto; padding: 6px; font-size: .9rem; min-height: 120px; }
.chat-msg { margin-bottom: 5px; word-break: break-all; line-height: 1.45; }
.chat-msg.sys { color: var(--muted); font-size: .82rem; font-style: italic; }
.chat-msg.me b { color: var(--gold); }
.chat-msg b { color: #cbd5e1; }
.chat-row { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- 游戏 ---------- */
#view-game { padding: 8px; }

.game-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
#hud-time { font-variant-numeric: tabular-nums; min-width: 64px; }

.meters { flex: 1; display: flex; gap: 6px; }
.meter { flex: 1; height: 10px; background: rgba(15, 23, 42, .7); border-radius: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; transition: width .12s linear; }
.meter.red i { background: linear-gradient(90deg, #f87171, var(--red)); float: right; }
.meter.blue i { background: linear-gradient(90deg, var(--blue), #60a5fa); }
.head-btns { display: flex; gap: 6px; }

#tapzone { position: relative; flex: 1; min-height: 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: clamp(64px, 18vw, 150px); font-weight: 900; color: var(--gold);
  text-shadow: 0 6px 30px rgba(253, 224, 71, .45);
  animation: pulse .9s infinite; pointer-events: none;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }

#reconnect-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(239, 68, 68, .92); color: #fff; font-size: .85rem;
  padding: 6px 14px; border-radius: 999px; z-index: 5; white-space: nowrap;
}

#chat-drawer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  background: rgba(10, 15, 28, .88); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 8px;
  display: flex; flex-direction: column; max-height: 45%;
}
#chat-drawer .chat-log { min-height: 90px; max-height: 28vh; }

.rope-progress { position: relative; height: 10px; margin-top: 8px; border-radius: 6px; overflow: visible; display: flex; }
.rope-progress .zone { flex: 1; height: 100%; }
.rope-progress .red { background: linear-gradient(90deg, #7f1d1d, #ef4444); border-radius: 6px 0 0 6px; }
.rope-progress .blue { background: linear-gradient(90deg, #3b82f6, #1e3a8a); border-radius: 0 6px 6px 0; }
#rope-marker {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -54%);
  font-size: 18px; transition: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6));
}

.tap-hint { text-align: center; color: var(--muted); font-size: .85rem; margin: 8px 0 2px; animation: blink 2.4s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- 结算 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, .72); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.overlay-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 26px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.overlay-card h2 { font-size: 1.6rem; margin-bottom: 6px; }
.overlay-card p { color: var(--muted); margin-bottom: 14px; }

#end-stats { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 16px; }
#end-stats td, #end-stats th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
#end-stats th { color: var(--muted); font-weight: 500; font-size: .8rem; }
#end-stats td.num { text-align: right; font-variant-numeric: tabular-nums; }
#end-stats tr.t1 td:first-child { border-left: 3px solid var(--red); }
#end-stats tr.t2 td:first-child { border-left: 3px solid var(--blue); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, .95); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; font-size: .9rem; z-index: 99;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: 90vw; text-align: center;
}
