/* Dino Runner — page chrome. The game paints its own palette and pushes it
   into --bg / --ink so the page and the canvas stay in sync through the
   day/night cycle. */

:root {
  --bg: #f7f7f7;
  --ink: #4c4c4c;
  --radius: 26px;
  --edge: color-mix(in srgb, var(--ink) 16%, transparent);
  --edge-soft: color-mix(in srgb, var(--ink) 9%, transparent);
  --font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3.5vw, 40px);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(1160px, 100%);
  display: grid;
  gap: clamp(14px, 2vw, 20px);
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 26px;
  height: 28px;
  display: block;
  flex: none;
}

h1 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  white-space: nowrap;
}

.chip {
  flex: none;
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 10px;
  letter-spacing: 0.22em;
  opacity: 0.85;
}

.chip b {
  font-weight: 700;
  margin-left: 5px;
  letter-spacing: 0.1em;
}

/* ---------------------------------------------------------------- stage */
.stage {
  position: relative;
  height: clamp(180px, 44vh, 420px);
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--ink) 5%, transparent);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* ---------------------------------------------------------------- controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.14em;
  opacity: 0.7;
}

.keys span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

kbd {
  font: inherit;
  font-size: 9px;
  padding: 4px 6px;
  border: 1px solid var(--edge);
  border-bottom-width: 2px;
  border-radius: 5px;
  letter-spacing: 0.06em;
}

.buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: inherit;
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: 11px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
  touch-action: manipulation;
}

button:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

button:active {
  transform: translateY(1px);
}

button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
}

button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* on-screen controls for touch devices */
.touch-controls {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.touch-controls button {
  padding: 17px 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  border-radius: 14px;
}

@media (pointer: coarse) {
  .touch-controls {
    display: grid;
  }

  .keys {
    display: none;
  }

  .controls {
    justify-content: center;
  }
}

/* ---------------------------------------------------------------- footer */
.foot {
  margin: 0;
  font-size: 9.5px;
  letter-spacing: 0.13em;
  line-height: 1.9;
  opacity: 0.5;
}

.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;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 620px) {
  .app {
    gap: 14px;
  }

  .stage {
    height: clamp(160px, 40svh, 320px);
    border-radius: 18px;
  }

  h1 {
    font-size: 10px;
    letter-spacing: 0.28em;
  }

  .mark {
    width: 22px;
    height: 24px;
  }

  .chip {
    padding: 6px 10px;
    font-size: 9px;
  }

  button {
    padding: 9px 12px;
  }

  .foot {
    display: none;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .stage {
    height: clamp(140px, 52svh, 300px);
  }

  .foot {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }
}
