@font-face {
  font-family: 'Press Start 2P';
  src: url(/fonts/press-start-2p.woff2) format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'VT323';
  src: url(/fonts/vt323.woff2) format('woff2');
  font-display: swap;
}

:root {
  --ink: #1a1028;
  --night: #10082a;
  --gold: #ffd23f;
  --cream: #fff3b0;
  --pink: #ff6f91;
  --lilac: #a78bfa;
  --lime: #4ad34a;
  --pixel: 'Press Start 2P', monospace;
  --term: 'VT323', monospace;
  --win: Tahoma, 'Segoe UI', Verdana, sans-serif;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: #fff;
  font: 24px/1.15 var(--term);
}

h1,
h2,
p,
ul,
dl,
dd {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px dashed var(--gold);
  outline-offset: 3px;
}

::selection {
  background: var(--pink);
  color: var(--ink);
}

/* ------------------------------------------------------------ boot */

.boot {
  display: none;
}

.booting body {
  overflow: hidden;
}

.booting .boot {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 32px;
  background: #000;
  color: #c0c0c0;
  cursor: pointer;
}

.boot pre {
  margin: 0;
  font: 26px/1.2 var(--term);
  white-space: pre-wrap;
}

/* ------------------------------------------------------------ hero */

.hero {
  --px: 4px;
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 440px;
  overflow: hidden;
  background: var(--ink);
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: absolute;
  left: 0;
  bottom: 0;
  image-rendering: pixelated;
  touch-action: manipulation;
  cursor: pointer;
}

.title {
  position: absolute;
  top: max(48px, calc(var(--px) * 10));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: calc(var(--px) * 3);
  pointer-events: none;
}

.logo {
  width: clamp(min(300px, 92vw), calc(200 * (var(--px) - 1px)), 94vw);
  aspect-ratio: 200 / 60;
  background: url(/img/logo.png) 0 0 / 2400% 100% no-repeat;
  image-rendering: pixelated;
  animation: frames 1.8s steps(24, jump-none) infinite;
}

.tagline {
  font: clamp(10px, 1.3vw, 16px) / 1 var(--pixel);
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: calc(32 * var(--px) + clamp(40px, 12vh, 120px));
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 16px;
  width: max-content;
  max-width: 94vw;
  text-align: center;
  pointer-events: none;
}

.start {
  pointer-events: auto;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--gold);
  font: clamp(16px, 2.2vw, 24px) / 1 var(--pixel);
  text-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  animation: blink 1s steps(1) infinite;
}

.start:hover {
  color: #fff;
}

.hint,
.final {
  font: 10px/1.4 var(--pixel);
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink);
}

.gameover {
  font: clamp(24px, 4vw, 48px) / 1 var(--pixel);
  color: var(--pink);
  text-shadow: 4px 4px 0 var(--ink);
}

.hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 140px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font: 12px/1 var(--pixel);
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink);
  pointer-events: none;
}

.hud b {
  font-weight: 400;
  color: #fff;
}

.mute {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 6px 8px;
  border: 2px solid var(--cream);
  background: rgb(26 16 40 / 0.6);
  color: var(--cream);
  font: 10px/1 var(--pixel);
  cursor: pointer;
}

.mute[aria-pressed='true'] {
  color: var(--pink);
  border-color: var(--pink);
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--px) * 10);
  transform: translateX(-50%);
  color: var(--cream);
  font: 10px/1 var(--pixel);
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
}

.scroll-hint:hover {
  color: #fff;
}

.hud,
.gameover,
.final {
  display: none;
}

.hero:is([data-mode='play'], [data-mode='dying'], [data-mode='over']) .hud {
  display: flex;
}

.hero[data-mode='over'] :is(.gameover, .final) {
  display: block;
}

.hero:not([data-mode='attract']) .title,
.hero:is([data-mode='play'], [data-mode='dying']) :is(.prompt, .scroll-hint) {
  display: none;
}

.hero[data-mode='over'] .hint {
  display: none;
}

.hero[data-mode='play'] #game {
  touch-action: none;
}

@media (max-aspect-ratio: 1 / 1) {
  .prompt {
    bottom: 50%;
  }
}

/* ------------------------------------------------------------ homepage */

.home {
  padding-bottom: 48px;
  background: var(--night)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' shape-rendering='crispEdges'%3E%3Cg fill='%23fff3b0'%3E%3Crect x='6' y='9' width='1' height='1'/%3E%3Crect x='41' y='4' width='1' height='1'/%3E%3Crect x='27' y='30' width='1' height='1'/%3E%3Crect x='55' y='37' width='1' height='1'/%3E%3Crect x='13' y='52' width='1' height='1'/%3E%3C/g%3E%3Cg fill='%23a78bfa'%3E%3Crect x='20' y='18' width='1' height='1'/%3E%3Crect x='50' y='58' width='1' height='1'/%3E%3Crect x='3' y='33' width='1' height='1'/%3E%3C/g%3E%3Cg fill='%23ffffff'%3E%3Crect x='46' y='20' width='1' height='3'/%3E%3Crect x='45' y='21' width='3' height='1'/%3E%3Crect x='34' y='47' width='1' height='3'/%3E%3Crect x='33' y='48' width='3' height='1'/%3E%3C/g%3E%3C/svg%3E")
    0 0 / 128px 128px;
  image-rendering: pixelated;
}

.marquee {
  overflow: hidden;
  border-block: 4px ridge #c0c0c0;
  background: #000;
  color: var(--lime);
  font-size: 28px;
  white-space: nowrap;
}

.marquee-track {
  display: flex;
  width: max-content;
  padding-block: 6px;
  animation: marquee 40s linear infinite;
}

.page {
  display: grid;
  gap: 32px;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 16px 0;
}

/* Windows 95 chrome */
.win {
  padding: 3px;
  background: #c0c0c0;
  color: #000;
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #dfdfdf, inset -2px -2px #808080, inset 2px 2px #fff,
    6px 6px 0 rgb(0 0 0 / 0.45);
}

.win :focus-visible {
  outline: 2px dotted #000;
  outline-offset: 2px;
}

.win-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 3px 3px 6px;
  background: linear-gradient(90deg, #000080, #1084d0);
  color: #fff;
}

.win-bar h2 {
  font: 700 13px/1.4 var(--win);
}

.win-buttons {
  display: flex;
  gap: 2px;
}

.win-buttons i {
  display: grid;
  place-items: center;
  width: 16px;
  height: 14px;
  background: #c0c0c0;
  color: #000;
  font: 700 11px/1 var(--win);
  font-style: normal;
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080;
}

.win-menu {
  display: flex;
  gap: 14px;
  padding: 4px 6px 3px;
  font: 13px/1.2 var(--win);
}

.win-body {
  display: grid;
  gap: 12px;
  margin: 2px;
  padding: 14px 16px;
  background: #fff;
  box-shadow: inset 1px 1px #808080, inset -1px -1px #fff, inset 2px 2px #0a0a0a, inset -2px -2px #dfdfdf;
}

.notepad {
  max-width: none;
  font-size: 26px;
  line-height: 1.1;
}

.center {
  justify-items: center;
  text-align: center;
}

.small {
  font-size: 20px;
  color: #444;
}

.win a {
  color: #0000ee;
}

.win a:visited {
  color: #551a8b;
}

.construction {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px;
  background: repeating-linear-gradient(-45deg, var(--gold) 0 16px, var(--ink) 16px 32px);
}

.construction p {
  padding: 14px 16px;
  background: var(--ink);
  color: var(--gold);
  font: 12px/1.8 var(--pixel);
  text-align: center;
}

.chip-spin {
  flex: none;
  width: 96px;
  height: 96px;
  background: url(/img/chip.png) 0 0 / 1600% 100% no-repeat;
  image-rendering: pixelated;
  animation: frames 1.1s steps(16, jump-none) infinite;
}

.trio {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  align-items: start;
}

.trio .win-body {
  min-height: 210px;
  align-content: center;
}

.odometer {
  padding: 8px 6px 8px 10px;
  border: 0;
  background: #000;
  color: var(--lime);
  font: 20px/1 var(--pixel);
  letter-spacing: 4px;
  box-shadow: inset 0 0 0 2px #333, 0 0 0 2px #808080;
  cursor: pointer;
}

.at-spin {
  width: 64px;
  height: 64px;
  background: url(/img/at.png) 0 0 / 1600% 100% no-repeat;
  image-rendering: pixelated;
  animation: frames 1.2s steps(16, jump-none) infinite;
}

.scores {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: space-between;
  gap: 10px 12px;
  font: 11px/1.4 var(--pixel);
}

.scores dd {
  color: #000080;
  text-align: right;
}

.links {
  display: grid;
  gap: 8px;
  padding-left: 28px;
  list-style: none;
}

.links li::before {
  content: '★';
  margin-left: -26px;
  margin-right: 8px;
  color: #c0c0c0;
}

.links a {
  margin-right: 6px;
}

.webring {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 14px;
  border: 6px ridge #c0c0c0;
  background: #000;
  font: 12px/1.6 var(--pixel);
  text-align: center;
}

.webring a {
  color: var(--gold);
}

.webring small {
  font-size: 9px;
  color: var(--lilac);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 0;
  list-style: none;
}

.badge,
.badge a {
  display: grid;
  place-content: center;
  gap: 6px;
  width: 176px;
  height: 62px;
  font: 10px/1 var(--pixel);
  text-align: center;
  text-decoration: none;
  color: inherit;
}

.badge b {
  font-weight: 400;
}

.badge span {
  font-size: 14px;
}

.b-now {
  background: linear-gradient(#000080, #000);
  border: 2px solid #808080;
  color: var(--gold);
}

.b-now span {
  color: var(--pink);
}

.b-any {
  background: #fff;
  border: 2px solid #0000ee;
  color: #000;
}

.b-any span {
  color: #0000ee;
}

.b-html {
  background: #c0c0c0;
  color: #000080;
  box-shadow: inset -2px -2px #0a0a0a, inset 2px 2px #fff;
}

.b-track {
  background: #000;
  border: 2px solid var(--lime);
  color: var(--lime);
}

.b-track span {
  font-size: 10px;
}

.b-cf {
  background: #f38020;
  border: 2px solid #fff;
  color: #fff;
}

.b-cf span {
  font-size: 11px;
}

.b-bit {
  background: linear-gradient(90deg, #c23c8e, #5a2a8a);
  border: 2px solid var(--gold);
  color: var(--gold);
}

.footer {
  display: grid;
  gap: 6px;
  padding: 24px 16px 40px;
  background: var(--night);
  color: var(--lilac);
  text-align: center;
}

.footer a {
  color: var(--gold);
}

/* ------------------------------------------------------------ extras */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: 92vw;
  padding: 14px 16px;
  border: 3px solid var(--gold);
  background: var(--ink);
  color: var(--gold);
  font: 12px/1.6 var(--pixel);
  text-align: center;
  transform: translate(-50%, calc(100% + 40px));
  transition: transform 220ms steps(4);
  pointer-events: none;
}

.toast.show {
  transform: translate(-50%, 0);
}

.sparkles {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
}

.falling-chip {
  position: fixed;
  top: -110px;
  z-index: 55;
  width: 96px;
  height: 96px;
  background: url(/img/chip.png) 0 0 / 1600% 100% no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
  animation:
    frames 0.9s steps(16, jump-none) infinite,
    fall var(--fall, 2.4s) linear forwards;
}

.rainbow {
  animation: hue 1.2s linear 2;
}

@keyframes frames {
  to {
    background-position: 100% 0;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes marquee {
  to {
    transform: translateX(-50%);
  }
}

@keyframes fall {
  to {
    transform: translateY(calc(100vh + 220px));
  }
}

@keyframes hue {
  to {
    filter: hue-rotate(360deg);
  }
}

@media (max-width: 560px) {
  .construction .chip-spin {
    width: 48px;
    height: 48px;
  }

  .webring {
    gap: 12px;
    font-size: 10px;
  }

  .hud {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .logo,
  .chip-spin,
  .at-spin,
  .start,
  .marquee-track {
    animation: none;
  }

  .marquee {
    white-space: normal;
  }

  .marquee-track span + span {
    display: none;
  }
}
