:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #111111;
  --faded: #777777;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
}

body {
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  -webkit-font-smoothing: none;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 360px;
  overflow: hidden;
  touch-action: none;
  background: var(--paper);
}

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

.start-card {
  position: absolute;
  top: 50%;
  left: clamp(24px, 8vw, 112px);
  width: min(340px, calc(100vw - 48px));
  transform: translateY(-50%);
  transition: opacity 180ms linear, visibility 180ms linear;
}

.start-card.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5.2vw, 4.8rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.07em;
}

#startButton {
  min-width: 180px;
  min-height: 44px;
  margin-top: clamp(26px, 4vh, 38px);
  padding: 10px 22px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
}

#startButton:hover,
#startButton:focus-visible {
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

#startButton:disabled {
  cursor: wait;
  opacity: 0.72;
}

.controls {
  width: fit-content;
  max-width: 100%;
  padding: 4px 6px;
  background: var(--paper);
  margin: 14px 0 0;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.controls span {
  color: var(--faded);
  font-weight: 400;
}

.game-controls {
  position: absolute;
  z-index: 3;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: none;
  align-items: center;
  gap: 8px;
}

.game-controls.is-visible {
  display: flex;
}

.sound-button,
.pause-button {
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.pause-button {
  display: grid;
  place-items: center;
  width: 44px;
  padding: 10px;
}

.pause-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.pause-button .play-icon,
.pause-button[data-paused="true"] .pause-icon {
  display: none;
}

.pause-button[data-paused="true"] .play-icon {
  display: block;
}

.sound-button:focus-visible,
.pause-button:focus-visible {
  outline: 1px dotted var(--ink);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

noscript {
  position: absolute;
  right: 24px;
  bottom: 24px;
  font-size: 1rem;
}

@media (max-width: 640px) {
  .start-card {
    top: 29%;
    left: 24px;
    transform: translateY(-50%);
  }

  h1 {
    font-size: clamp(2.35rem, 12vw, 4rem);
  }

  #startButton {
    margin-top: 28px;
  }

  .controls {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .start-card {
    transition: none;
  }
}

/* Keep the desktop start screen above the slope in embedded layouts. */
@media (min-width: 641px) {
  .start-card {
    top: 35%;
  }

  .controls {
    width: auto;
    padding: 0;
    background: transparent;
  }
}
