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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1220;
  color: #e8eaf6;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.game {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.panel {
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel h2 {
  font-size: 15px;
  font-weight: 600;
  color: #8a90b8;
  letter-spacing: 2px;
}

.panel canvas {
  background: #181c30;
  border-radius: 8px;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: #181c30;
  border-radius: 8px;
  padding: 10px 14px;
}

.stat span {
  color: #8a90b8;
  font-size: 13px;
}

.stat strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.board-wrap {
  position: relative;
}

#board {
  background: #181c30;
  border-radius: 8px;
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(10, 12, 24, 0.82);
  border-radius: 8px;
  text-align: center;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  font-size: 28px;
}

.overlay p {
  color: #8a90b8;
}

.help {
  background: #181c30;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 2;
  color: #8a90b8;
}

kbd {
  background: #262b47;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 11px;
}

/* 触屏控制按钮（默认隐藏，窄屏显示） */
.touch-controls {
  display: none;
  width: 92vw;
  max-width: 400px;
  flex-direction: column;
  gap: 8px;
}

.touch-row {
  display: flex;
  gap: 8px;
}

.touch-row button {
  flex: 1;
  padding: 14px 0;
  border: none;
  border-radius: 8px;
  background: #262b47;
  color: #e8eaf6;
  font-size: 16px;
  font-family: inherit;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-row button:active {
  background: #39406b;
}

.touch-hint {
  text-align: center;
  color: #8a90b8;
  font-size: 12px;
}

#board {
  touch-action: none;
}

@media (max-width: 720px) {
  body {
    align-items: flex-start;
    padding: 12px 0;
  }

  .game {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }

  .board-wrap {
    order: 1;
  }

  .touch-controls {
    display: flex;
    order: 2;
  }

  .panel {
    order: 3;
    flex-direction: row;
    flex-wrap: wrap;
    width: 92vw;
    max-width: 400px;
    justify-content: center;
    align-items: center;
  }

  .panel h2 {
    display: none;
  }

  .panel canvas {
    width: 60px;
    height: 60px;
  }

  #next {
    height: 150px;
  }

  #board {
    width: min(92vw, 46vh);
    height: auto;
  }

  .stat {
    padding: 6px 10px;
  }

  .stat strong {
    font-size: 16px;
  }

  .help {
    display: none;
  }
}
