* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px;
}

#stage {
  position: relative;
  width: 672px;
  height: 864px;
  box-shadow: 0 0 0 1px #1c1c3a;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.4%;
  padding: 6%;
  background: rgba(0, 0, 0, 0.8);
  text-align: center;
}

.overlay.dim {
  background: rgba(0, 0, 0, 0.45);
}

.overlay[hidden],
#toolbar[hidden] {
  display: none;
}

h1 {
  margin: 0;
  font-family: 'Courier New', ui-monospace, monospace;
  font-weight: 900;
  font-size: clamp(28px, 6.5vmin, 56px);
  letter-spacing: 0.08em;
  color: #d97757;
  text-shadow: 3px 3px 0 #7a3a22;
}

h2 {
  margin: 0;
  font-size: clamp(18px, 3.4vmin, 28px);
  color: #ffd23f;
}

.sub {
  margin: 0;
  color: #9fb3ff;
  font-size: clamp(12px, 2vmin, 16px);
}

#menu-art {
  width: 90%;
  image-rendering: pixelated;
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(78%, 320px);
}

button {
  font: inherit;
  cursor: pointer;
}

.buttons button {
  padding: 10px 14px;
  font-size: clamp(14px, 2.4vmin, 18px);
  font-weight: 700;
  color: #000;
  background: #ffd23f;
  border: 3px solid #fff;
  border-radius: 6px;
}

.buttons button small {
  display: block;
  font-weight: 400;
  font-size: 0.75em;
  margin-top: 2px;
}

.buttons button.secondary {
  background: #3b2fbf;
  color: #fff;
}

.buttons button:hover,
.buttons button:focus-visible {
  outline: 3px solid #d97757;
  outline-offset: 2px;
}

.scores {
  width: min(86%, 360px);
  font-family: 'Courier New', ui-monospace, monospace;
  font-size: clamp(12px, 2vmin, 15px);
}

.scores ol {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.scores li {
  display: grid;
  grid-template-columns: 2em 1fr 4em 7em;
  gap: 4px;
  padding: 2px 0;
}

.scores li:first-child {
  color: #ffd23f;
}

.scores li.empty {
  display: block;
  color: #888;
}

.help-list {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: clamp(12px, 2.1vmin, 16px);
  line-height: 1.9;
}

kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid #888;
  border-radius: 3px;
  background: #222;
  font-family: 'Courier New', monospace;
}

#toolbar {
  position: absolute;
  top: 1%;
  right: 1%;
  display: flex;
  gap: 6px;
}

#toolbar button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 16px;
  background: rgba(59, 47, 191, 0.35);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
}

/* 触屏按键：仅在粗指针设备显示 */
#touchpad {
  display: none;
  width: min(100%, 420px);
  grid-template-columns: 72px 72px 1fr;
  gap: 10px;
}

#touchpad button {
  height: 60px;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: #16163d;
  border: 2px solid #3b2fbf;
  border-radius: 12px;
  touch-action: none;
}

#touchpad button.fire {
  background: #5a2412;
  border-color: #d97757;
}

#touchpad button.down {
  filter: brightness(1.6);
}

@media (pointer: coarse) {
  #touchpad {
    display: grid;
  }
}
