* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #0d1526;
  color: #ecf4ff;
  /* 日本語を含め、文字のベースラインが自然な通常フォントで描画する */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Yu Gothic", "Meiryo", sans-serif;
  line-height: 1.45;
}
.game { width: min(800px, 100%); }
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 17px;
}
h1 {
  margin: 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.25;
  letter-spacing: .02em;
  font-weight: 900;
}
h1 span { color: #43e6bf; }
.header p, .hint { margin: 8px 0 0; color: #b1c4d6; font-size: 14px; line-height: 1.6; }
.scores { display: flex; align-items: center; gap: 20px; text-align: right; }
.scores div { display: grid; align-content: center; gap: 3px; }
.scores small {
  color: #a4bacc;
  letter-spacing: .08em;
  font: 700 12px/1.3 Consolas, "Courier New", monospace;
}
.scores strong {
  font: 800 27px/1.1 Consolas, "Courier New", monospace;
  font-variant-numeric: tabular-nums;
}
.viewport { position: relative; width: 100%; }
.sprite-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.sprite {
  position: absolute;
  display: block;
  image-rendering: pixelated;
  object-fit: fill;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 3px solid #425b76;
  border-radius: 0;
  background: #16273b;
  box-shadow: 6px 6px 0 #06111e;
  image-rendering: pixelated;
}
.controls {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 21px;
  font-size: 14px;
  line-height: 1.6;
}
.controls div { display: flex; align-items: center; gap: 8px; }
.controls span { color: #99adc5; }
.key-btn {
  appearance: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 44px;
  padding: 8px 14px;
  background: #23374d;
  border: 2px solid #57718c;
  border-bottom-width: 5px;
  border-radius: 0;
  font: 700 14px/1 Consolas, "Courier New", monospace;
  color: #f4fcff;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
.key-btn:focus { outline: none; }
.key-btn:focus-visible {
  outline: 2px solid #43e6bf;
  outline-offset: 3px;
}
.key-btn:active,
.key-btn.is-pressed {
  transform: translateY(3px);
  border-bottom-width: 2px;
  background: #1c4c62;
}
.hint { text-align: center; margin-top: 16px; font-size: 12px; }
@media (max-width: 520px) {
  .scores { gap: 12px; }
  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .controls div {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    text-align: center;
  }
  .controls span { display: none; }
  .key-btn {
    width: 100%;
    min-height: 64px;
    font-size: 16px;
  }
  .hint { font-size: 11px; }
}
