:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --glow: rgba(88, 166, 255, 0.35);
  --cell-radius: 4px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #1a2332 0%, var(--bg) 55%);
  color: var(--text);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #79c0ff 0%, #a371f7 50%, #ff7b72 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 1.25rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.panel--right {
  max-width: 220px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.stat__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat__value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.next__label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

#next {
  display: block;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  background: #0d1117;
  border: 1px solid var(--border);
}

.board-wrap {
  position: relative;
  border-radius: 12px;
  padding: 4px;
  background: linear-gradient(145deg, #21262d, #0d1117);
  box-shadow: 0 0 0 1px var(--border), 0 12px 48px var(--glow);
}

#board {
  display: block;
  width: min(432px, calc(100vw - 40px));
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: #010409;
  outline: none;
}

#board:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.overlay {
  position: absolute;
  inset: 4px;
  border-radius: 8px;
  background: rgba(1, 4, 9, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.overlay__card {
  text-align: center;
  padding: 1.25rem 1.5rem;
}

.overlay__title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
}

.overlay__hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #238636, #2ea043);
  box-shadow: 0 2px 8px rgba(46, 160, 67, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(46, 160, 67, 0.5);
}

.btn:active {
  transform: translateY(0);
}

.help h2 {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.help ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--text);
}

.help li {
  margin-bottom: 0.35rem;
}

kbd {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  font-size: 0.72rem;
  font-family: inherit;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #21262d;
  color: var(--accent);
}

/* 引力回旋新增 */
.stat__value--small {
  font-size: 1.15rem;
}

.stat--row {
  flex-direction: row;
  gap: 1.25rem;
}

.stat--row > div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.gravity {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.gravity__arrow {
  font-size: 1.8rem;
  line-height: 1;
  color: var(--accent);
}

.gravity__countdown {
  font-size: 0.82rem;
  color: var(--muted);
}

.gravity__countdown.is-warning {
  color: #ff7b72;
  font-weight: 700;
}

.help + .help {
  margin-top: 1rem;
}

.help__note {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}

#board {
  touch-action: none;
}

.center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.btn--ghost {
  margin-top: 0.4rem;
  width: 100%;
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
  color: var(--text);
  background: #21262d;
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn--ghost:hover {
  box-shadow: none;
  border-color: var(--accent);
}

/* 触屏控制：仅在粗指针（手机/平板）上显示 */
.touch {
  display: none;
  width: min(432px, calc(100vw - 32px));
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  user-select: none;
  -webkit-user-select: none;
}

@media (pointer: coarse) {
  .touch {
    display: flex;
  }
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
}

.dpad__up { grid-area: 1 / 2; }
.dpad__left { grid-area: 2 / 1; }
.dpad__right { grid-area: 2 / 3; }
.dpad__down { grid-area: 3 / 2; }

.touch__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  max-width: 160px;
}

.tbtn {
  touch-action: manipulation;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.tbtn--wide {
  height: 44px;
  font-size: 0.95rem;
}

.tbtn--accent {
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  border-color: transparent;
  color: #fff;
}

.tbtn.is-down {
  background: #30363d;
  transform: scale(0.96);
}

.tbtn--accent.is-down {
  background: #1158c7;
}

@media (max-width: 720px) {
  .panel--right {
    width: 100%;
    max-width: none;
  }
}
