* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  min-height: 100vh;
  background: #fff;
  color: #535353;
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button {
  font-family: inherit;
  cursor: pointer;
}
.top {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
}
.back {
  color: #535353;
  font-weight: 700;
  text-decoration: none;
}
.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 16px 30px;
}
h1 {
  margin: 0 0 10px;
  font-size: clamp(24px, 4vw, 32px);
  color: #555;
}
.desc {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.5;
  color: #555;
}

/* ---------- Khung trò chơi ---------- */
.game {
  position: relative;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 15px 0;
  background: #f7f7f7;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
#canvas {
  display: block;
  width: 100%;
  aspect-ratio: 600 / 150;
  image-rendering: pixelated;
  transition: filter 0.35s linear;
}
#canvas.night {
  filter: invert(1);
}
.game.night {
  background: #080808;
  transition: background 0.35s linear;
}
.start {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 7px 12px;
  border: 0;
  border-radius: 3px;
  background: #535353;
  color: #fff;
  font-size: 14px;
  transform: translate(-50%, -50%);
}
.start:hover {
  background: #333;
}
.start[hidden] {
  display: none;
}

/* ---------- Gợi ý phím ---------- */
.keys {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  font-size: 15px;
  color: #666;
}
.arrows {
  display: grid;
  grid-template-columns: repeat(3, 22px);
  grid-template-rows: repeat(2, 22px);
  gap: 3px;
}
.k {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border: 0;
  border-radius: 3px;
  background: #535353;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
.k.off {
  background: #b5b5b5;
}
.arrows .k {
  padding: 0;
}
/* ↑ ở giữa hàng trên; ← ↓ → ở hàng dưới */
#kUp {
  grid-column: 2;
  grid-row: 1;
}
.arrows > :nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}
#kDown {
  grid-column: 2;
  grid-row: 2;
}
.arrows > :nth-child(4) {
  grid-column: 3;
  grid-row: 2;
}
.k.space {
  height: 20px;
  font-size: 12px;
}
.k:active {
  background: #222;
}
.credit {
  margin: 18px 0 0;
  text-align: center;
  font-size: 11px;
  color: #aaa;
}
.mute {
  border: 0;
  background: none;
  font-size: 18px;
  opacity: 0.6;
}

/* màn hình cảm ứng: phím to hơn để bấm */
@media (pointer: coarse) {
  .arrows {
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(2, 46px);
    gap: 6px;
  }
  .arrows .k {
    height: 46px;
    font-size: 20px;
  }
  .k.space {
    height: 46px;
    padding: 0 18px;
    font-size: 15px;
  }
}
