/* Dino Runner — the page chrome around the canvas.
   The --bg / --fg custom properties are driven by the game's day/night cycle. */

:root {
  --bg: #f7f7f7;
  --fg: #535353;
  --radius: 10px;
  --max-width: 1040px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;
  transition: background-color 220ms linear, color 220ms linear;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(12px, 3vw, 28px) clamp(12px, 3vw, 24px) 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------- header --- */

.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.title {
  margin: 0;
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.btn {
  font: inherit;
  font-size: 13px;
  color: inherit;
  background: transparent;
  border: 2px solid currentColor;
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  transition: opacity 120ms linear, transform 60ms ease-out;
}

.btn:hover { opacity: 0.7; }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="false"] { opacity: 0.5; }

.btn:focus-visible,
canvas:focus-visible,
.pad:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

/* --------------------------------------------------------------- game --- */

.shell {
  position: relative;
  border: 2px solid currentColor;
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
}

#game {
  display: block;
  width: 100%;
  height: clamp(170px, 30vw, 300px);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  background: var(--bg);
}

#game:focus { outline: none; }

/* ------------------------------------------------------ touch controls --- */

.touch {
  display: none;
  gap: 10px;
  margin-top: 12px;
}

.pad {
  flex: 1;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: inherit;
  background: transparent;
  border: 2px solid currentColor;
  border-radius: var(--radius);
  padding: 16px 0;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pad:active { opacity: 0.55; }
.pad--primary { flex: 1.6; }

/* Only show the on-screen pads where there's no precise pointer. */
@media (hover: none) and (pointer: coarse) {
  .touch { display: flex; }
}

/* ------------------------------------------------------------- legend --- */

.legend {
  margin-top: 22px;
}

.legend__title {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.65;
}

.keys {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 14px;
}

kbd {
  display: inline-block;
  min-width: 1.9em;
  text-align: center;
  font: inherit;
  font-size: 12px;
  border: 2px solid currentColor;
  border-radius: 6px;
  padding: 1px 6px;
  line-height: 1.4;
}

.muted { opacity: 0.62; }

.note {
  margin: 14px 0 0;
  max-width: 62ch;
  font-size: 13.5px;
  opacity: 0.75;
}

.foot {
  margin-top: 26px;
  font-size: 12px;
  opacity: 0.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
  .btn, .pad { transition: none; }
}
