:root {
  --bg: #f7f7f7;
  --fg: #535353;
  --muted: #8a8a8a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background-color .6s ease, color .6s ease;
  -webkit-tap-highlight-color: transparent;
}

body.night {
  --bg: #202124;
  --fg: #e8eaed;
  --muted: #9aa0a6;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 12vh max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}

.offline-msg h1 {
  font-size: 1.4rem;
  font-weight: 500;
  margin: 0 0 4px;
}

.offline-msg p {
  margin: 0 0 24px;
  color: var(--muted);
}

.stage {
  position: relative;
  width: 100%;
  touch-action: none;           /* no scroll, pinch or double-tap zoom on the game */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;  /* no long-press callout on iOS */
  overscroll-behavior: contain;
  cursor: pointer;
}

.controls {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 148px;
  min-height: 48px;             /* comfortable touch target */
  padding: 10px 22px;
  border: 2px solid var(--fg);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color .15s ease, color .15s ease, transform .08s ease;
}

.play-btn:hover { background: var(--fg); color: var(--bg); }
.play-btn:active,
.play-btn.pressed { transform: scale(.96); }
.play-btn:focus-visible { outline: 3px solid var(--muted); outline-offset: 3px; }
.play-btn[data-state="running"] { border-style: dashed; }

.play-icon {
  font-size: .9em;
  line-height: 1;
  letter-spacing: -.12em;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  outline: none;
}

.help {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: .85rem;
  color: var(--muted);
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  border: 1px solid var(--muted);
  border-bottom-width: 2px;
  border-radius: 4px;
  font: inherit;
  font-size: .8em;
  text-align: center;
  color: var(--fg);
}

/* Phones held sideways: little vertical room, so tighten the spacing. */
@media (max-height: 500px) and (orientation: landscape) {
  .wrap { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 12px; }
  .offline-msg h1 { font-size: 1.1rem; }
  .offline-msg p { margin-bottom: 8px; }
  .controls { margin-top: 10px; }
  .help { display: none; }
}

/* Touch-only devices don't need the keyboard hints. */
@media (hover: none) and (pointer: coarse) {
  .help li:not(:last-child) { display: none; }
  .play-btn:hover { background: transparent; color: var(--fg); }
}
