* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #050510;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: "Courier New", "Microsoft YaHei", "PingFang SC", sans-serif;
  overflow: hidden;
  -webkit-overflow-scrolling: none;
  overscroll-behavior: none;
}

#bgCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

#container {
  position: relative;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  box-shadow:
    0 0 80px rgba(77,166,255,0.06),
    inset 0 0 60px rgba(0,0,0,0.3);
  z-index: 1;
  line-height: 0;
}

canvas {
  display: block;
  border-radius: 8px;
  touch-action: none;
}

/* ─── Overlay ─── */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  z-index: 10;
  overflow-y: auto;
}

.overlay-content {
  text-align: center;
  color: #e0e0f0;
  width: 100%;
  max-width: 460px;
  padding: 36px 32px 32px;
  background: rgba(10,10,30,0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.4);
  margin: 20px;
}

/* ─── Title ─── */
.overlay-content h1 {
  font-size: 40px;
  font-weight: 300;
  letter-spacing: 8px;
  color: #ffffff;
  margin-bottom: 4px;
  text-shadow:
    0 0 40px rgba(77,166,255,0.45),
    0 0 80px rgba(77,166,255,0.15);
}

.overlay-content .sub-en {
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  margin-bottom: 24px;
}

/* ─── Subtitle ─── */
.overlay-content > p {
  font-size: 13px;
  color: rgba(255,255,255,0.30);
  margin: 0 0 24px;
  letter-spacing: 1px;
  line-height: 1.6;
}

/* ─── Rules card ─── */
#rules {
  margin: 0 auto 24px auto;
  max-width: 400px;
  text-align: left;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 10px 16px;
}

#rules:empty {
  display: none;
}

#rules .rule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.50);
  padding: 2px 0;
  line-height: 1.7;
}

#rules .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

#rules .dot.square {
  border-radius: 2px;
  width: 8px;
  height: 8px;
}

#rules .rule-row > span:nth-child(2) {
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  min-width: 56px;
  font-size: 13px;
}

#rules .rule-row > span:nth-child(3) {
  color: rgba(255,255,255,0.30);
  font-size: 12px;
  margin-left: auto;
  text-align: right;
}

#rules .sep {
  border: none;
  height: 1px;
  margin: 5px 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
}

/* ─── Buttons ─── */
#btn-group {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 14px 38px;
  font-size: 16px;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 3px;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.btn:hover { transform: scale(1.06); }
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: rgba(77,166,255,0.10);
  color: rgba(77,166,255,0.9);
  border: 1px solid rgba(77,166,255,0.22);
}
.btn-primary:hover { background: rgba(77,166,255,0.20); border-color: rgba(77,166,255,0.5); box-shadow: 0 0 22px rgba(77,166,255,0.25); }

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #ccc;
  border: 1px solid rgba(255,255,255,0.12);
}
.btn-secondary:hover { background: rgba(255,255,255,0.14); box-shadow: 0 0 20px rgba(255,255,255,0.1); }

.btn-resume {
  background: rgba(255,215,0,0.10);
  color: rgba(255,215,0,0.9);
  border: 1px solid rgba(255,215,0,0.22);
}
.btn-resume:hover { background: rgba(255,215,0,0.20); border-color: rgba(255,215,0,0.5); box-shadow: 0 0 22px rgba(255,215,0,0.25); }

.btn-restart {
  background: rgba(255,68,68,0.10);
  color: rgba(255,68,68,0.9);
  border: 1px solid rgba(255,68,68,0.22);
}
.btn-restart:hover { background: rgba(255,68,68,0.20); border-color: rgba(255,68,68,0.5); box-shadow: 0 0 22px rgba(255,68,68,0.25); }

.btn-green {
  background: rgba(68,255,68,0.10);
  color: rgba(68,255,68,0.9);
  border: 1px solid rgba(68,255,68,0.22);
}
.btn-green:hover { background: rgba(68,255,68,0.20); border-color: rgba(68,255,68,0.5); box-shadow: 0 0 22px rgba(68,255,68,0.25); }

.btn-danger {
  background: rgba(255,68,68,0.10);
  color: rgba(255,68,68,0.9);
  border: 1px solid rgba(255,68,68,0.22);
}
.btn-danger:hover { background: rgba(255,68,68,0.20); border-color: rgba(255,68,68,0.5); box-shadow: 0 0 22px rgba(255,68,68,0.25); }

.btn-easy {
  background: rgba(68,255,68,0.08); color: rgba(68,255,68,0.9);
  border: 1px solid rgba(68,255,68,0.2); padding: 15px 46px; font-size: 17px; letter-spacing: 6px;
}
.btn-easy:hover { background: rgba(68,255,68,0.20); border-color: rgba(68,255,68,0.5); box-shadow: 0 0 30px rgba(68,255,68,0.30); }
.btn-normal {
  background: rgba(77,166,255,0.08); color: rgba(77,166,255,0.9);
  border: 1px solid rgba(77,166,255,0.2); padding: 15px 46px; font-size: 17px; letter-spacing: 6px;
}
.btn-normal:hover { background: rgba(77,166,255,0.20); border-color: rgba(77,166,255,0.5); box-shadow: 0 0 30px rgba(77,166,255,0.30); }
.btn-hard {
  background: rgba(255,68,68,0.08); color: rgba(255,68,68,0.9);
  border: 1px solid rgba(255,68,68,0.2); padding: 15px 46px; font-size: 17px; letter-spacing: 6px;
}
.btn-hard:hover { background: rgba(255,68,68,0.20); border-color: rgba(255,68,68,0.5); box-shadow: 0 0 30px rgba(255,68,68,0.30); }

/* ─── Mobile ─── */
@media (max-width: 600px) {
  .overlay-content { padding: 24px 20px; margin: 12px; }
  .overlay-content h1 { font-size: 28px; letter-spacing: 5px; }
  .overlay-content .sub-en { font-size: 11px; letter-spacing: 4px; margin-bottom: 16px; }
  .overlay-content > p { font-size: 12px; margin-bottom: 16px; }
  #rules { padding: 8px 12px; margin-bottom: 16px; }
  #rules .rule-row { font-size: 11px; padding: 1px 0; }
  #rules .rule-row > span:nth-child(2) { min-width: 44px; font-size: 11px; }
  #rules .rule-row > span:nth-child(3) { font-size: 10px; }
  .btn { padding: 12px 28px; font-size: 14px; }
  #btn-group { gap: 10px; }
}

/* ─── Mobile pause button ─── */
#mobile-pause-btn {
  display: none;
  position: absolute;
  top: 8px; right: 8px;
  z-index: 20;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  font-size: 18px;
  cursor: pointer;
  justify-content: center;
  align-items: center;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s;
}
#mobile-pause-btn:hover { background: rgba(255,255,255,0.12); }
#mobile-pause-btn:active { background: rgba(255,255,255,0.2); transform: scale(0.92); }
