/*!
 * dino.game site chrome. Game runner layout follows Chromium neterror.css
 * behaviour, scoped to the stage.
 * Game code and sprites © The Chromium Authors.
 * Redistribution under the BSD 3-Clause licence. See /license/ and LICENSE.
 */

:root {
  --page-bg: #fafaf8;
  --game-bg: #f7f7f7;
  --text: #1b1b19;
  --muted: #5c5c56;
  --line: #e3e3de;
  --ad-bg: #f2f2ee;
  --max: 48rem;
  --stage-max: 72rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

body {
  overflow-wrap: break-word;
}

[hidden] {
  display: none !important;
}

img,
canvas {
  max-width: 100%;
}

a {
  color: var(--text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 20;
  background: #fff;
  padding: 0.4rem 0.7rem;
}

.skip-link:focus {
  top: 0.75rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--stage-max);
  margin: 0 auto;
  padding: 0.85rem 1.25rem 0.7rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

.hero {
  max-width: var(--stage-max);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 650;
}

.dek {
  margin: 0 0 0.85rem;
  color: var(--muted);
  max-width: 40rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin: 0 0 0.5rem;
}

.controls-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.toolbar-actions {
  display: flex;
  gap: 0.4rem;
  margin-inline-start: auto;
}

/* Device-specific start/restart cue, overlaid on the stage so it does not shift layout. */
.stage-hint {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 3;
  margin: 0;
  padding: 0 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}
.stage-hint[hidden],
.stage-hint[data-state="running"],
.stage-hint[data-state="restart"],
.stage-hint[data-state="restart-pending"] {
  display: none !important;
}
.stage-hint .hint-start,
.stage-hint .hint-restart {
  display: none;
}
.stage-hint[data-state="start"] .hint-start,
.stage-hint[data-state="restart"] .hint-restart,
.stage-hint[data-state="restart-pending"] .hint-restart {
  display: inline;
}
/* Space is ignored for 1.2s after a crash; don't show the keyboard
   restart hint until it works. Tap/click already work, so the touch
   hint is visible in restart-pending. */
.stage-hint[data-state="restart-pending"] .hint-keyboard {
  display: none !important;
}
.stage-hint .hint-keyboard {
  display: none;
}
.stage-hint .hint-touch {
  display: inline;
}
@media (hover: hover) and (pointer: fine) {
  .stage-hint .hint-keyboard {
    display: inline;
  }
  .stage-hint .hint-touch {
    display: none;
  }
}
#game-stage:fullscreen .stage-hint,
#game-stage:-webkit-full-screen .stage-hint {
  font-size: 1.05rem;
}

.toolbar button {
  appearance: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.45rem 0.7rem;
  min-height: 36px;
}

.toolbar button:hover,
.toolbar button:focus-visible {
  border-color: #b9b9b2;
  outline: 2px solid #1b1b19;
  outline-offset: 1px;
}

/* Reserved game stage: 600×150 logical aspect, no CLS. */
#game-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  /* Below 600px the logical canvas is as wide as the stage and 150px tall.
     From 600px up, scale the 600×150 canvas to the stage width (4:1). */
  height: 150px;
  background: var(--game-bg);
  overflow: hidden;
  image-rendering: pixelated;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-touch-callout: none;
}

@media (min-width: 600px) {
  #game-stage {
    height: auto;
    aspect-ratio: 600 / 150;
    min-height: 150px;
  }
}

#game-stage.inverted {
  background-color: #fff;
  filter: invert(1);
}

/* Hidden Chromium hook: Runner.init() asserts .icon-offline exists. */
.icon-offline {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  visibility: hidden;
}

.hidden {
  display: none !important;
}

#game-stage .runner-container {
  direction: ltr;
  height: 150px;
  max-width: 600px;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 600px;
  transform-origin: top left;
  image-rendering: pixelated;
  z-index: 2;
}

#game-stage .runner-container:focus {
  outline: none;
}

/* Keyboard focus is drawn around the whole stage, not the 44 px idle box
   (a 3 px outline on that box looked like a stray black bar in the desert). */
#game-stage:focus-within {
  outline: 3px solid #1b1b19;
  outline-offset: 2px;
}

#game-stage:fullscreen,
#game-stage:-webkit-full-screen,
#game-stage:fullscreen:focus-within,
#game-stage:-webkit-full-screen:focus-within {
  outline: none;
}

#game-stage .runner-canvas {
  height: 150px;
  max-width: 600px;
  opacity: 1;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  image-rendering: pixelated;
}

#game-stage .controller {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9;
  touch-action: manipulation;
}

#game-stage.arcade-mode,
#game-stage.arcade-mode .runner-container,
#game-stage.arcade-mode .runner-canvas {
  image-rendering: pixelated;
  max-width: 100%;
  overflow: hidden;
}

.offline-runner-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: polygon(0 0, 0 0, 0 0);
}

/* Accessibility "Start slower" toggle, shown when the runner is focused
   (same behaviour as chrome://dino). */
.slow-speed-option {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  bottom: 8px;
  color: var(--text);
  display: inline-flex;
  font-size: 0.85rem;
  left: 0;
  line-height: 1.1;
  margin: 0 auto;
  padding: 2px 12px 3px 16px;
  position: absolute;
  right: 0;
  width: max-content;
  z-index: 20;
}

.slow-speed-option.hidden {
  display: none !important;
}

.slow-speed-option [type=checkbox] {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.slow-speed-option .slow-speed-toggle {
  cursor: pointer;
  margin-inline-start: 8px;
  padding: 8px 4px;
  position: relative;
}

.slow-speed-option .slow-speed-toggle::before,
.slow-speed-option .slow-speed-toggle::after {
  content: '';
  display: block;
  margin: 0 3px;
}

.slow-speed-option .slow-speed-toggle::before {
  background: #c8c8c2;
  border-radius: 0.65em;
  height: 0.9em;
  width: 2em;
}

.slow-speed-option .slow-speed-toggle::after {
  background: #fff;
  border: 1px solid #b9b9b2;
  border-radius: 50%;
  height: 1.15em;
  position: absolute;
  top: 51%;
  transform: translate(-20%, -50%);
  width: 1.15em;
}

.slow-speed-option [type=checkbox]:checked + .slow-speed-toggle::before {
  background: #1b1b19;
  opacity: 0.45;
}

.slow-speed-option [type=checkbox]:checked + .slow-speed-toggle::after {
  background: #1b1b19;
  border-color: #1b1b19;
  transform: translate(calc(2em - 90%), -50%);
}

#game-stage:fullscreen,
#game-stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  aspect-ratio: auto;
  background: var(--game-bg);
}

#exit-fullscreen {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  appearance: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.45rem 0.7rem;
  min-height: 36px;
}

#game-stage:fullscreen #exit-fullscreen,
#game-stage:-webkit-full-screen #exit-fullscreen {
  display: block;
}

#offline-resources {
  display: none;
}

.score-line {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* When an ad is approved, drop .ad-slot--empty so the reserved 90px slot
   appears from the first paint (no late JS show, no CLS). */
.ad-slot {
  width: 100%;
  max-width: 728px;
  height: 90px;
  min-height: 90px;
  margin: 1.25rem auto 0;
  background: transparent;
  border: 0;
  overflow: hidden;
}

.ad-slot--empty {
  display: none;
  height: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
}

.ad-slot .ad-slot-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.article {
  max-width: var(--stage-max);
  margin: 0 auto;
  padding: 4.5rem 1.25rem 3rem;
}

.article h2,
.article h3,
.article p,
.article ul {
  max-width: var(--max);
}

.article h2 {
  margin: 2.4rem 0 0.7rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.article h2:first-child {
  margin-top: 0;
}

.article h3 {
  margin: 1.5rem 0 0.4rem;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.article p,
.article ul {
  margin: 0 0 0.9rem;
}

.article ul {
  padding-left: 1.2rem;
}

.article li {
  margin: 0 0 0.35rem;
}

.article code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
  padding: 0.05em 0.35em;
}

.site-footer {
  border-top: 1px solid var(--line);
  max-width: var(--stage-max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0 0 0.7rem;
  max-width: 46rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-page {
  max-width: var(--stage-max);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.legal-page h1,
.legal-page h2,
.legal-page p,
.legal-page ul,
.legal-page pre,
.legal-page table {
  max-width: var(--max);
}

.legal-page h1 {
  margin: 0 0 1rem;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}

.legal-page pre {
  white-space: pre-wrap;
  font-size: 0.85rem;
  line-height: 1.45;
  background: #fff;
  border: 1px solid var(--line);
  padding: 1rem;
}

.legal-page h2 {
  margin: 1.75rem 0 0.6rem;
  font-size: 1.15rem;
}

.legal-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1rem;
  font-size: 0.95rem;
}

.legal-page code {
  overflow-wrap: anywhere;
}

.legal-page th,
.legal-page td {
  text-align: left;
  vertical-align: top;
  padding: 0.4rem 0.75rem 0.4rem 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.legal-page th {
  font-weight: 600;
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .hero h1 {
    font-size: 1.45rem;
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .article {
    padding-top: 3rem;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .site-header {
    padding: 0.35rem 1rem;
  }

  .hero {
    padding-top: 0.4rem;
  }

  .hero h1 {
    font-size: 1.15rem;
    margin-bottom: 0.15rem;
  }

  .dek,
  .controls-hint {
    display: none;
  }

  .toolbar {
    margin-bottom: 0.25rem;
  }

  #game-stage {
    height: auto;
    aspect-ratio: auto;
    max-height: calc(100dvh - 6.5rem);
    min-height: 110px;
    width: 100%;
    /* Keep 4:1 unless the viewport is shorter than that. */
    height: min(calc(100dvh - 6.5rem), 25vw);
  }

  .score-line {
    margin-top: 0.35rem;
  }

  .ad-slot {
    /* Short landscape: hide the empty slot outright (no reserved 90px,
       no later JS show that would shift layout). */
    display: none;
    height: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  .article {
    padding-top: 2rem;
  }
}

#consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  background: #fff;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.75rem 1.25rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.04);
}

#consent-banner[hidden] {
  display: none !important;
}

/* Programmatic focus after Cookie settings (not :focus-visible). */
#consent-banner:focus {
  outline: 2px solid #1b1b19;
  outline-offset: -2px;
}

#consent-banner p {
  margin: 0;
  flex: 1 1 16rem;
  max-width: 40rem;
}

.consent-actions {
  display: flex;
  gap: 0.4rem;
}

#consent-banner button {
  appearance: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.5rem 1rem;
  min-height: 44px;
  min-width: 44px;
}


@media (orientation: landscape) and (max-height: 500px) {
  /* After the base #consent-banner rules so top/bottom/padding actually apply. */
  #consent-banner {
    top: 0;
    bottom: auto;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    padding: calc(0.35rem + env(safe-area-inset-top, 0px)) 1rem 0.35rem;
    font-size: 0.8rem;
    gap: 0.35rem 0.75rem;
  }

  #consent-banner p {
    flex: 1 1 auto;
    max-width: none;
  }

  #consent-banner button {
    min-height: 44px;
  }
}
