:root {
  --bg: #0f1420;
  --panel: #1b1f2b;
  --text: #e8ecf4;
  --muted: #8b93a7;
  --accent: #4ade80;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Clear Sans", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  touch-action: manipulation;
}

.container { width: min(92vw, 480px); padding: 16px 0 24px; }

header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }

.title { font-size: 46px; font-weight: 800; color: var(--accent); line-height: 1; }

.scores { display: flex; gap: 8px; }

.score-box {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  padding: 6px 14px;
  text-align: center;
  min-width: 78px;
}
.score-label { font-size: 12px; letter-spacing: 1px; color: var(--muted); }
.score-box .value { font-size: 24px; font-weight: 700; color: var(--text); }

.sub { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 14px; font-size: 14px; color: var(--muted); }

button {
  background: var(--accent);
  color: #0f1420;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
button:active { transform: scale(.96); }

.board-wrap { position: relative; }

#game {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--panel);
  border-radius: 10px;
  touch-action: none;
}

.paused-badge {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(15, 20, 32, .85);
  border: 1px solid rgba(255, 255, 255, .15);
  color: var(--text);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  display: none;
  z-index: 5;
}
.paused-badge.visible { display: block; }

#overlay {
  position: absolute; inset: 0;
  background: rgba(15, 20, 32, .78);
  border-radius: 10px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  z-index: 10;
  padding: 16px;
}
#overlay.visible { display: flex; }
#overlay-title { font-size: 38px; font-weight: 800; color: var(--text); }
#overlay-text { font-size: 16px; color: var(--muted); }
#overlay-btn { margin-top: 6px; }

.dpad { display: flex; flex-direction: column; align-items: center; margin-top: 16px; gap: 6px; }
.dpad-row { display: flex; gap: 6px; }
.dpad-btn {
  width: 58px; height: 48px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px;
  color: var(--text);
  font-size: 18px;
  padding: 0;
  touch-action: manipulation;
}
.dpad-btn:active { background: #2a3042; transform: scale(.94); }

footer { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }

@media (max-width: 480px) {
  .title { font-size: 38px; }
  .score-box { min-width: 64px; padding: 4px 10px; }
  .score-box .value { font-size: 20px; }
  .sub { font-size: 12.5px; }
  #overlay-title { font-size: 30px; }
  footer { font-size: 12px; }
  .dpad-btn { width: 52px; height: 44px; }
}
