:root {
  color-scheme: light;
  --cream: #f8f1dc;
  --ink: #050505;
  --muted: #6d665b;
  --line: rgba(5, 5, 5, 0.18);
  --scribble: #9b6cff;
  --runner-scale: 1.85;
  --runner-scale-x: var(--runner-scale);
  --runner-scale-y: var(--runner-scale);
  --runner-focus-scale-x: 1;
  --runner-focus-scale-y: 1.5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--cream);
  color: var(--ink);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

main {
  display: grid;
  min-height: 100svh;
  grid-template-rows: auto auto 1fr auto;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(22px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
}

.wordmark {
  display: block;
  width: clamp(114px, 7.6vw, 136px);
  height: auto;
}

.say-hi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0 16px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  font-weight: 900;
  white-space: nowrap;
}

.say-hi:hover,
.say-hi:focus-visible {
  background: var(--ink);
  color: var(--cream);
  outline: none;
}

.announcement {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(34px, 5vw, 72px) clamp(22px, 4vw, 56px) 24px;
}

h1 {
  max-width: 940px;
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 6.8rem);
  font-weight: 950;
  line-height: 0.94;
  letter-spacing: 0;
}

.announcement p {
  position: relative;
  width: fit-content;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  font-weight: 850;
  line-height: 1.25;
}

.announcement p::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -11px;
  width: 100%;
  height: 8px;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='8' viewBox='0 0 100 8' preserveAspectRatio='none' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 5 C9 2.5 15 6.5 23 4 C31 1.7 39 6.2 48 4 C57 1.8 66 6.1 75 4 C84 2.2 91 4.5 99 3.7' stroke='%239b6cff' stroke-width='2.8' stroke-linecap='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  transform: rotate(-1deg);
}

.runner-section {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  min-height: calc((150px * var(--runner-scale-y)) + 110px);
  padding: 16px clamp(22px, 4vw, 56px) 42px;
}

.game-focus-button,
.game-exit-button {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 900 0.78rem "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  padding: 0 13px;
  white-space: nowrap;
  cursor: pointer;
}

.game-focus-button:hover,
.game-focus-button:focus-visible,
.game-exit-button:hover,
.game-exit-button:focus-visible {
  background: var(--ink);
  color: var(--cream);
  outline: none;
}

.runner-note {
  width: min(calc(700px * var(--runner-scale-x)), calc(100vw - 44px));
  margin: 0;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.trex-runner {
  position: relative;
  width: min(calc(700px * var(--runner-scale-x)), calc(100vw - 44px));
  height: calc(150px * var(--runner-scale-y));
  overflow: hidden;
  background: transparent;
  touch-action: manipulation;
}

.icon {
  -webkit-user-select: none;
  user-select: none;
  display: inline-block;
}

.icon-offline {
  visibility: hidden;
  position: relative;
}

.runner-container {
  position: absolute;
  top: 0;
  left: 50%;
  width: 44px;
  height: 150px;
  max-width: 700px;
  margin: 0;
  overflow: hidden;
  transform: translateX(-50%) scale(var(--runner-scale-x), var(--runner-scale-y));
  transform-origin: top center;
}

.runner-canvas {
  position: absolute;
  top: 0;
  z-index: 2;
  width: 700px;
  height: 150px;
  max-width: 700px;
  overflow: hidden;
  image-rendering: pixelated;
}

.flappy-canvas {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  display: none;
  width: 700px;
  height: 150px;
  image-rendering: auto;
  transform: translateX(-50%) scale(var(--runner-scale-x), var(--runner-scale-y));
  transform-origin: top center;
  touch-action: manipulation;
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.game-overlay[hidden] {
  display: none;
}

.unlock-badge {
  position: absolute;
  top: 18%;
  left: 50%;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.7rem, 1.2vw, 0.95rem);
  font-weight: 900;
  padding: 7px 12px;
  text-transform: lowercase;
  transform: translateX(-50%);
  white-space: nowrap;
}

.countdown-value {
  color: var(--ink);
  font-family: Impact, "Arial Black", Inter, sans-serif;
  font-size: clamp(4rem, 10vw, 8rem);
  line-height: 0.85;
}

.trex-runner.is-transition .runner-container,
.trex-runner.is-flappy .runner-container {
  opacity: 0.18;
}

.trex-runner.is-flappy .runner-container {
  display: none;
}

.trex-runner.is-flappy .flappy-canvas {
  display: block;
}

.controller,
#offline-resources {
  display: none;
}

.runner-container.playing {
  transform: translateX(-50%) scale(var(--runner-scale-x), var(--runner-scale-y)) !important;
}

.link-bands {
  display: grid;
  grid-template-columns: repeat(6, auto);
  justify-content: center;
  gap: clamp(14px, 3vw, 38px);
  padding: 20px clamp(22px, 4vw, 56px) 28px;
  border-top: 1px solid var(--line);
}

.band {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.band:hover,
.band:focus-visible {
  color: var(--ink);
  outline: none;
}

@media (max-width: 980px) {
  :root {
    --runner-scale: 1.45;
  }

  .announcement {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  :root {
    --runner-scale: 0.5;
    --runner-scale-x: 0.5;
    --runner-scale-y: 0.82;
  }

  .masthead {
    padding: 18px;
  }

  .say-hi {
    min-height: 34px;
    padding: 0 13px;
    font-size: 0.78rem;
  }

  .game-focus-button {
    display: inline-flex;
  }

  .announcement {
    padding: 30px 18px 14px;
  }

  h1 {
    font-size: clamp(2.25rem, 12vw, 3.3rem);
  }

  .runner-section {
    min-height: 250px;
    padding: 14px 18px 34px;
  }

  .runner-note,
  .trex-runner {
    width: min(calc(700px * var(--runner-scale-x)), calc(100vw - 36px));
  }

  .link-bands {
    grid-template-columns: repeat(3, auto);
    row-gap: 14px;
    padding: 18px;
  }
}

@media (max-width: 920px), (max-height: 520px) {
  body.is-game-focus {
    overflow: hidden;
  }

  body.is-game-focus main {
    display: block;
    min-height: 100dvh;
  }

  body.is-game-focus .masthead,
  body.is-game-focus .announcement,
  body.is-game-focus .link-bands {
    display: none;
  }

  body.is-game-focus .runner-section {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    align-content: center;
    justify-items: stretch;
    gap: 18px;
    min-height: 100dvh;
    padding: max(18px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
    background: var(--cream);
  }

  body.is-game-focus .game-focus-button {
    display: none;
  }

  body.is-game-focus .game-exit-button {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    z-index: 22;
    display: inline-flex;
    background: var(--cream);
  }

  body.is-game-focus .runner-note {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 21;
    width: auto;
    font-size: 0.72rem;
  }

  body.is-game-focus .trex-runner {
    width: calc(100vw - 24px);
    height: calc(150px * var(--runner-focus-scale-y));
    margin: 0 auto;
  }

  body.is-game-focus .runner-container,
  body.is-game-focus .flappy-canvas,
  body.is-game-focus .runner-container.playing {
    left: 0;
    transform: scale(var(--runner-focus-scale-x), var(--runner-focus-scale-y)) !important;
    transform-origin: top left;
  }
}

@media (max-width: 620px) and (orientation: portrait) {
  :root {
    --runner-focus-scale-x: 0.86;
    --runner-focus-scale-y: 1.74;
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  :root {
    --runner-focus-scale-x: 1.1;
    --runner-focus-scale-y: 1.38;
  }

  .game-focus-button {
    display: inline-flex;
  }

  body.is-game-focus .runner-section {
    padding-inline: 16px;
  }

  body.is-game-focus .trex-runner {
    width: calc(100vw - 32px);
  }
}

@media (max-width: 380px) {
  :root {
    --runner-scale-x: 0.46;
    --runner-scale-y: 0.8;
  }
}

@media (max-width: 340px) {
  :root {
    --runner-scale-x: 0.4;
    --runner-scale-y: 0.76;
  }
}
