:root {
  --bg: #0f1420;
  --panel: #1a2233;
  --text: #e8edf7;
  --muted: #8a96ad;
  --p1: #4fd1c5;
  --p2: #f6ad55;
  --accent: #7c5cff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #1b2740 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top {
  text-align: center;
  padding: 24px 16px 8px;
}

.top h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: 0.05em;
}

.sub {
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 520px;
  line-height: 1.6;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid #2c3850;
  font-family: inherit;
  font-size: 0.85em;
}

.wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 12px 12px 24px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 420px;
  gap: 8px;
}

.player {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.player.p1 { border-color: rgba(79, 209, 197, 0.35); }
.player.p2 { border-color: rgba(246, 173, 85, 0.35); }

.player .name { font-weight: 600; }
.player.p1 .name { color: var(--p1); }
.player.p2 .name { color: var(--p2); }

.wins {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.vs {
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.1em;
}

#board {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 16px;
  background: #0b1019;
  border: 2px solid #26324a;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

.status {
  margin: 0;
  min-height: 1.5em;
  font-size: 1.05rem;
  text-align: center;
}

.start-btn {
  padding: 12px 40px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #4fd1c5);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
  transition: transform 0.1s, opacity 0.2s;
}

.start-btn:hover { transform: translateY(-1px); }
.start-btn:active { transform: translateY(1px); }
.start-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.pads {
  display: flex;
  justify-content: space-around;
  width: 100%;
  gap: 12px;
  margin-top: 6px;
}

.pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pad-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 52px);
  gap: 6px;
}

.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }

.dpad button {
  border: 1px solid #2c3850;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

.dpad button:active { background: #26324a; }

.tip {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.6;
}

.foot {
  text-align: center;
  padding: 16px;
  font-size: 0.9rem;
}

.foot a {
  color: var(--muted);
  text-decoration: none;
}

.foot a:hover { color: var(--text); }

@media (max-width: 420px) {
  .dpad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(2, 46px);
  }
  .wins { font-size: 1.3rem; }
}
