@font-face {
  font-family: 'UnifrakturMaguntia';
  src: url('fonts/UnifrakturMaguntia-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Archivo Black';
  src: url('fonts/ArchivoBlack-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --cream: #f4e7c6;
  --ink: #10201f;
  --teal: #0d4a4c;
  --amber: #ffc65c;
  --deep: #031010;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b3b3d;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

#world {
  position: absolute;
  left: 0;
  top: 0;
  width: 2304px;
  height: 1024px;
  transform-origin: 0 0;
  z-index: 0;
}

#plate-shake {
  position: absolute;
  inset: 0;
  width: 2304px;
  height: 1024px;
}

.plate {
  display: block;
  width: 2304px;
  height: 1024px;
  user-select: none;
  -webkit-user-drag: none;
}

#stage {
  position: absolute;
  left: 384px;
  top: 160px;
  width: 1536px;
  height: 864px;
}

#scene {
  position: absolute;
  inset: 0;
  width: 1536px;
  height: 864px;
  pointer-events: none;
}

#underlight {
  position: absolute;
  inset: 0;
  -webkit-mask: url('assets/grate_slots_mask.png') 0 0 / 1536px 864px no-repeat;
  mask: url('assets/grate_slots_mask.png') 0 0 / 1536px 864px no-repeat;
  opacity: 1;
}

#glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 260px 70px at 768px 740px, var(--amber), transparent 70%);
  opacity: .25;
  animation: breathe 4s ease-in-out infinite;
}

#underlight.hot #glow {
  animation: none;
  opacity: 1;
}

#train-band {
  position: absolute;
  left: 0;
  top: 0;
  width: 220px;
  height: 864px;
  opacity: 0;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .72) 0 10px, rgba(0, 0, 0, 0) 10px 28px),
    linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 45%, #ffc65c 58%, rgba(255, 214, 140, 0));
}

@keyframes breathe {
  0%, 100% { opacity: .15; }
  50% { opacity: .35; }
}

#haze {
  position: absolute;
  left: 468px;
  top: 520px;
  width: 600px;
  height: 290px;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 214, 140, .35), transparent 65%);
  opacity: 0;
  transition: opacity .3s ease;
}

#shadow {
  position: absolute;
  left: 668px;
  top: 744px;
  width: 200px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .35);
  filter: blur(3px);
  transform-origin: 768px 759px;
}

#streaks-back, #streaks-front, #dust, #flashes, #flash-pulse {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#flash-pulse {
  background: #ffffff;
  opacity: 0;
  will-change: opacity;
}

#flashes {
  overflow: visible;
  transition: opacity .3s ease;
}

.streak {
  position: absolute;
  width: 6px;
  border-radius: 6px;
  background: linear-gradient(to top, rgba(255, 249, 232, 0), rgba(255, 249, 232, .85), rgba(255, 249, 232, 0));
  opacity: 0;
}

.flash {
  position: absolute;
  width: 320px;
  height: 320px;
  opacity: 0;
  background:
    radial-gradient(circle, #fff 0 6%, rgba(255, 255, 255, .55) 12%, transparent 34%),
    linear-gradient(90deg, transparent 0 46%, rgba(255, 255, 255, .9) 50%, transparent 54%) center / 100% 6px no-repeat,
    linear-gradient(0deg, transparent 0 46%, rgba(255, 255, 255, .9) 50%, transparent 54%) center / 6px 100% no-repeat;
}

.dust {
  position: absolute;
  width: 16px;
  height: 9px;
  border-radius: 50%;
  background: var(--cream);
  opacity: 0;
}

#flight {
  position: absolute;
  inset: 0;
  width: 1536px;
  height: 864px;
  transform-origin: 768px 450px;
  will-change: transform, filter, opacity;
}

#merlin-inner {
  position: absolute;
  inset: 0;
  transform-origin: 768px 760px;
}

.merlin-frame {
  position: absolute;
  left: 0;
  top: 0;
  width: 1536px;
  height: 864px;
  opacity: 0;
  visibility: hidden;
  user-select: none;
  -webkit-user-drag: none;
}

.merlin-frame.on {
  opacity: 1;
  visibility: visible;
}

#merlin-inner.flutter { animation: flutter 360ms linear infinite; }
#merlin-inner.flutter-strong { animation: flutter-strong 360ms linear infinite; }

@keyframes flutter {
  0% { transform: scaleY(1) skewX(-.6deg); }
  50% { transform: scaleY(1.012) skewX(.6deg); }
  100% { transform: scaleY(1) skewX(-.6deg); }
}

@keyframes flutter-strong {
  0% { transform: scaleY(1) skewX(-.9deg); }
  50% { transform: scaleY(1.018) skewX(.9deg); }
  100% { transform: scaleY(1) skewX(-.9deg); }
}

#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hud { pointer-events: auto; }

#title {
  position: absolute;
  left: 72px;
  top: 92px;
  margin: 0;
  color: var(--cream);
  font-family: 'UnifrakturMaguntia', serif;
  font-weight: 400;
  font-size: 132px;
  line-height: .92;
  text-shadow: 0 4px 0 #062a2b;
  white-space: nowrap;
}

#ticker {
  position: absolute;
  left: 80px;
  top: 380px;
  display: flex;
  gap: 14px;
  align-items: center;
  font-family: 'Archivo Black', sans-serif;
}

#ticker b {
  font-size: 34px;
  color: var(--ink);
  background: var(--cream);
  padding: 4px 14px 2px;
  border-radius: 6px;
  white-space: nowrap;
}

#ticker span {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 17px;
  color: var(--cream);
  opacity: .85;
  max-width: 270px;
  line-height: 1.25;
}

#hud {
  position: absolute;
  left: 1046px;
  top: 530px;
  width: 424px;
}

#board {
  box-sizing: content-box;
  background: #081c1c;
  border: 3px solid var(--deep);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--amber);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .6), 0 6px 0 rgba(0, 0, 0, .25);
  height: 66px;
}

#board .l1 {
  font-size: 13px;
  letter-spacing: .12em;
  opacity: .75;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#board .l2 {
  white-space: nowrap;
  overflow: hidden;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .05em;
  margin-top: 4px;
  text-shadow: 0 0 8px rgba(255, 198, 92, .6);
}

#status.blink { animation: blink .5s steps(1, end) infinite; }

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: .35; }
}

#meter {
  display: flex;
  gap: 5px;
  margin: 12px 0 14px;
}

#meter i {
  flex: 1;
  height: 34px;
  border-radius: 4px;
  background: rgba(8, 28, 28, .85);
  border: 2px solid var(--deep);
  font: 700 12px/30px 'IBM Plex Mono', monospace;
  color: rgba(244, 231, 198, .45);
  text-align: center;
  font-style: normal;
  letter-spacing: .04em;
  overflow: hidden;
  white-space: nowrap;
}

#meter i.on {
  background: var(--amber);
  color: var(--ink);
  box-shadow: 0 0 12px rgba(255, 198, 92, .7);
}

#meter i.on.max {
  background: #fff2c9;
}

#cta {
  width: 100%;
  height: 96px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: var(--cream);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 14px;
  font-family: 'Archivo Black', sans-serif;
  font-size: 30px;
  white-space: nowrap;
  letter-spacing: .01em;
  box-shadow: 0 8px 0 var(--ink), 0 14px 30px rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}

#cta .bullet {
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  display: grid;
  place-items: center;
  font-size: 34px;
}

#cta:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--ink), 0 6px 12px rgba(0, 0, 0, .3);
}

#cta.dis,
#cta.dis:active {
  opacity: .55;
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--ink);
  cursor: default;
}

#launch {
  position: fixed;
  top: clamp(16px, 2vh, 30px);
  right: clamp(16px, 2vh, 30px);
  display: flex;
  gap: .65em;
  font-size: clamp(13px, 1.4vh, 21px);
  z-index: 60;
}

.pill {
  font: 700 clamp(13px, 1.4vh, 21px)/1 'IBM Plex Mono', monospace;
  color: var(--cream);
  background: rgba(6, 30, 31, .7);
  border: 2px solid rgba(244, 231, 198, .55);
  border-radius: 999px;
  padding: .7em 1.1em;
  text-decoration: none;
  letter-spacing: .06em;
  cursor: pointer;
}

.pill.ca {
  background: var(--cream);
  color: var(--ink);
  border-color: var(--cream);
}

#cta:focus-visible,
.pill:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

#toast {
  position: absolute;
  top: calc(100% + .7em);
  right: 0;
  font: 700 clamp(12px, 1.05vh, 16px)/1 'IBM Plex Mono', monospace;
  color: var(--ink);
  background: var(--amber);
  padding: .6em 1em;
  border-radius: .6em;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease;
}

#toast.show {
  opacity: 1;
  visibility: visible;
}

#grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .08;
  z-index: 50;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

#plate-shake.shake-sm, #scene.shake-sm, #flashes.shake-sm { animation: shake-sm 60ms linear infinite; }
#plate-shake.shake-big, #scene.shake-big, #flashes.shake-big { animation: shake-big 200ms ease-in-out 1; }

@keyframes shake-sm {
  0% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  100% { transform: translate(-2px, 1px); }
}

@keyframes shake-big {
  0% { transform: translate(-6px, 2px); }
  25% { transform: translate(5px, -3px); }
  50% { transform: translate(-4px, 3px); }
  75% { transform: translate(4px, -2px); }
  100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  #glow { animation: none; opacity: .25; }
  #merlin-inner.flutter,
  #merlin-inner.flutter-strong { animation: none; }
  #plate-shake.shake-sm, #scene.shake-sm, #flashes.shake-sm,
  #plate-shake.shake-big, #scene.shake-big, #flashes.shake-big { animation: none; }
  #status.blink { animation: none; }
  #haze, #flashes, #cta { transition: none; }
}
