/* 双人贪吃蛇 · 样式（.g-twosnake 前缀） */

.g-twosnake {
  gap: 8px;
  padding-bottom: calc(10px + var(--safe-b));
}

/* ---------------- 顶部比分 ---------------- */

.g-twosnake .ts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  flex: none;
}

.g-twosnake .ts-pbox {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}

.g-twosnake .ts-pbox.p1 {
  border-color: rgba(121, 184, 255, 0.35);
  background: rgba(121, 184, 255, 0.1);
}

.g-twosnake .ts-pbox.p2 {
  border-color: rgba(255, 92, 108, 0.35);
  background: rgba(255, 92, 108, 0.1);
}

.g-twosnake .ts-pname { font-size: 10.5px; color: var(--dim); }

.g-twosnake .ts-score-num {
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.g-twosnake .ts-score-num.p1 { color: #79b8ff; }
.g-twosnake .ts-score-num.p2 { color: #ff7a86; }

.g-twosnake .ts-len { font-size: 9.5px; color: var(--faint); }

.g-twosnake .ts-timer {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 20, 0.5);
  font-size: 13px;
  font-weight: 800;
  color: #dff0ff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.g-twosnake .ts-timer.low { color: #ff5c6c; border-color: rgba(255, 92, 108, 0.4); }

/* ---------------- 棋盘 ---------------- */

.g-twosnake .ts-board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.g-twosnake .ts-board-host {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(121, 184, 255, 0.18);
  background: #0b1622;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 22px 50px -28px rgba(0, 0, 0, 0.95);
}

.g-twosnake .ts-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.g-twosnake .ts-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(4, 8, 14, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.g-twosnake .ts-overlay.show { display: flex; animation: fadeIn 0.18s ease both; }

.g-twosnake .ts-ov-card {
  width: min(88%, 300px);
  padding: 20px 16px 14px;
  border-radius: 18px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #161d2c, #0e131d);
  box-shadow: 0 28px 60px -24px rgba(0, 0, 0, 0.92), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
}

.g-twosnake .ts-ov-badge { font-size: 10px; letter-spacing: 0.2em; color: var(--faint); }
.g-twosnake .ts-ov-badge.p1 { color: #79b8ff; }
.g-twosnake .ts-ov-badge.p2 { color: #ff7a86; }
.g-twosnake .ts-ov-badge.draw { color: #ffd166; }

.g-twosnake .ts-ov-title {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 900;
  color: #eaf4ff;
}

.g-twosnake .ts-ov-score {
  margin: 8px 0 6px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.g-twosnake .ts-ov-detail {
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--dim);
  margin-bottom: 14px;
}

.g-twosnake .ts-ov-card .btn { min-height: 44px; flex: 1; }

/* ---------------- 底部双方向键 ---------------- */

.g-twosnake .ts-pads {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.g-twosnake .ts-pad {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
  gap: 2px;
  flex: none;
}

.g-twosnake .ts-dpad {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: #cfe4ff;
  font-size: 12px;
  line-height: 1;
  touch-action: manipulation;
  transition: background 0.12s ease, transform 0.1s ease;
}

.g-twosnake .ts-pad.p1 .ts-dpad { color: #a8d4ff; border-color: rgba(121, 184, 255, 0.32); }
.g-twosnake .ts-pad.p2 .ts-dpad { color: #ffb3ba; border-color: rgba(255, 92, 108, 0.32); }
.g-twosnake .ts-dpad:active { transform: scale(0.94); background: rgba(255, 255, 255, 0.16); }

.g-twosnake .ts-hint {
  flex: 1;
  text-align: center;
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--faint);
  pointer-events: none;
}

/* ---------------- 窄屏 ---------------- */

@media (max-height: 700px) {
  .g-twosnake .ts-head { min-height: 40px; }
  .g-twosnake .ts-pad { grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 30px); }
  .g-twosnake .ts-dpad { width: 30px; height: 30px; font-size: 11px; }
  .g-twosnake .ts-hint { font-size: 9px; }
  .g-twosnake .ts-board-host { width: min(100%, 330px); }
}

@media (max-width: 359px) {
  .g-twosnake .ts-len { display: none; }
  .g-twosnake .ts-hint { display: none; }
}

.g-twosnake .ts-ready {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(4, 8, 14, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  pointer-events: none;
  text-align: center;
}

.g-twosnake .ts-ready b {
  font-size: 30px;
  font-weight: 900;
  color: #eaf4ff;
  letter-spacing: 0.18em;
  text-shadow: 0 0 26px rgba(121, 184, 255, 0.4);
}

.g-twosnake .ts-ready span {
  font-size: 11px;
  color: var(--dim);
}

.g-twosnake .ts-ready.hidden { display: none; }
