:root {
  --black: #111;
  --ink: #1b1b1b;
  --gray-0: #fff;
  --gray-1: #f2f2f2;
  --gray-2: #e3e3e3;
  --gray-3: #c7c7c7;
  --gray-4: #9d9d9d;
  --gray-5: #6b6b6b;
  --panel: #efefef;
  --panel-deep: #dbdbdb;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Geneva", "Chicago", "Arial", sans-serif;
  background:
    linear-gradient(45deg, #000 25%, transparent 25%) -2px 0 / 4px 4px,
    linear-gradient(-45deg, #000 25%, transparent 25%) -2px 0 / 4px 4px,
    linear-gradient(45deg, transparent 75%, #000 75%) -2px 0 / 4px 4px,
    linear-gradient(-45deg, transparent 75%, #000 75%) -2px 0 / 4px 4px,
    #fff;
  overflow-x: hidden;
  -webkit-user-select: text;
  user-select: text;
}

.scanlines,
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.scanlines {
  opacity: 0;
  background-image: none;
}

.noise {
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: radial-gradient(rgba(0, 0, 0, 0.5) 0.4px, transparent 0.4px);
  background-size: 3px 3px;
  animation: noiseShift 0.2s steps(3) infinite;
}

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

.shell {
  position: relative;
  z-index: 1;
  width: min(690px, 95vw);
  min-height: calc(100dvh - 20px);
  margin: 10px auto;
  padding: 14px 14px 102px;
  border: 4px solid #000;
  border-radius: 2px;
  background:
    linear-gradient(45deg, #fff 25%, transparent 25%) 0 0 / 6px 6px,
    linear-gradient(-45deg, #fff 25%, transparent 25%) 0 0 / 6px 6px,
    linear-gradient(45deg, transparent 75%, #fff 75%) 0 0 / 6px 6px,
    linear-gradient(-45deg, transparent 75%, #fff 75%) 0 0 / 6px 6px,
    #f4f4f4;
  box-shadow:
    inset 2px 2px 0 #fff,
    inset -2px -2px 0 #565656,
    0 6px 0 #000,
    0 12px 24px rgba(0, 0, 0, 0.44);
  display: flex;
  flex-direction: column;
  text-align: center;
}

.ticker {
  margin: 0 0 12px;
  padding: 6px 8px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0;
  color: #fff;
  text-transform: uppercase;
  border: 3px solid #000;
  background:
    linear-gradient(45deg, #111 25%, transparent 25%) 0 0 / 6px 6px,
    linear-gradient(-45deg, #111 25%, transparent 25%) 0 0 / 6px 6px,
    linear-gradient(45deg, transparent 75%, #111 75%) 0 0 / 6px 6px,
    linear-gradient(-45deg, transparent 75%, #111 75%) 0 0 / 6px 6px,
    #000;
}

h1 {
  margin: 0;
  white-space: pre-line;
  line-height: 0.75;
  text-transform: lowercase;
  color: #000;
  font-family: "Jacquard 24", "Courier New", monospace;
  font-size: clamp(3rem, 13vw, 6.6rem);
  letter-spacing: 1.6px;
  text-shadow:
    2px 0 0 #000,
    0 2px 0 #000,
    -2px 0 0 #000,
    0 -2px 0 #000;
}

.glitch {
  position: relative;
  display: inline-block;
  animation: heroFlicker 2.8s steps(2, end) infinite;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glitch::before {
  color: #222;
  transform: translate(3px, -1px);
  clip-path: polygon(0 0, 100% 0, 100% 44%, 0 44%);
  opacity: 0.92;
  animation: heroShiftA 1.9s steps(2, end) infinite;
}

.glitch::after {
  color: #6f6f6f;
  transform: translate(-3px, 1px);
  clip-path: polygon(0 56%, 100% 56%, 100% 100%, 0 100%);
  opacity: 0.9;
  animation: heroShiftB 2.1s steps(2, end) infinite;
}

.intro {
  margin: 14px auto 0;
  max-width: 600px;
  font-family: "Times New Roman", Times, serif;
  font-size: clamp(1rem, 3.1vw, 1.16rem);
  line-height: 1.35;
}

.intro-mobile-break {
  display: none;
}

.name {
  font-weight: 700;
}

.controls {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.fate-btn {
  width: min(336px, 100%);
  min-height: 60px;
  border: 3px solid #000;
  border-radius: 0;
  background:
    linear-gradient(45deg, #fff 25%, transparent 25%) 0 0 / 6px 6px,
    linear-gradient(-45deg, #fff 25%, transparent 25%) 0 0 / 6px 6px,
    linear-gradient(45deg, transparent 75%, #fff 75%) 0 0 / 6px 6px,
    linear-gradient(-45deg, transparent 75%, #fff 75%) 0 0 / 6px 6px,
    #fff;
  color: #000;
  font-family: "Geneva", "Chicago", "Arial", sans-serif;
  font-weight: 700;
  font-size: clamp(1.4rem, 6vw, 2rem);
  text-transform: lowercase;
  letter-spacing: 0.3px;
  box-shadow:
    inset 2px 2px 0 #fff,
    inset -2px -2px 0 #777,
    0 4px 0 #000;
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 80ms ease, filter 100ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.fate-btn:hover {
  filter: brightness(1.02);
}

.fate-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset -1px -1px 0 #fff,
    inset 1px 1px 0 #7c7c7c,
    0 1px 0 #555;
}

.status {
  margin: 16px auto 0;
  width: min(600px, 100%);
  min-height: 24px;
  font-family: "Times New Roman", Times, serif;
  font-size: 18px;
  line-height: 1.3;
  text-align: center;
}

.result {
  position: relative;
  width: min(561px, 100%);
  margin: 20px auto 0;
  padding: 24px 14px 14px;
  border: 4px solid #000;
  border-radius: 2px;
  background:
    linear-gradient(180deg, #fff 0%, #fff 100%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.08) 0 2px, rgba(255, 255, 255, 0) 2px 4px);
  box-shadow:
    inset 2px 2px 0 #fff,
    inset -2px -2px 0 #666;
}

.mode-chip {
  position: absolute;
  left: 50%;
  top: -12px;
  transform: translateX(-50%);
  min-width: 212px;
  padding: 4px 12px;
  border: 2px solid #000;
  border-radius: 2px;
  background: #fff;
  color: #000;
  font-family: "Geneva", "Chicago", "Arial", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.phrase {
  margin: 22px auto 0;
  max-width: 528px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: "Times New Roman", Times, serif;
  font-size: clamp(1.3rem, 4.7vw, 1.8rem);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: 0;
  color: #111;
}

.phrase.revealing {
  letter-spacing: 0.8px;
}

.copy-badge {
  margin: 4px 0 0;
  min-height: 14px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
  color: #000;
  opacity: 0;
  transition: opacity 120ms ease;
}

.copy-badge.show {
  opacity: 1;
}

.result-actions {
  margin: 10px 0 8px;
}

.result.wiki-mode {
  padding: 8px 8px 6px;
}

.result.wiki-mode .result-actions {
  display: none;
}

.result.wiki-mode .copy-badge {
  display: none;
}

.result.wiki-mode .phrase {
  margin: 12px auto 4px;
  min-height: 0;
  font-size: clamp(1.02rem, 3.2vw, 1.25rem);
  line-height: 1.15;
  text-transform: uppercase;
}

.result.wiki-mode .wiki-card {
  margin-top: 4px;
  border: 2px dashed #6d6d6d;
  background: #f4f4f4;
  box-shadow: none;
}

.result.wiki-mode .wiki-meta {
  padding: 7px 8px 8px;
}

.result.wiki-mode .wiki-title {
  margin-bottom: 4px;
}

.result.wiki-mode .wiki-blurb {
  margin: 0 0 5px;
  font-size: 14px;
  line-height: 1.22;
}

.result.wiki-mode .wiki-link {
  font-size: 11px;
}

.copy-btn {
  border: 2px solid #000;
  border-radius: 0;
  background: #fff;
  color: #000;
  font-family: "Geneva", "Chicago", "Arial", sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 6px 10px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.copy-btn:hover {
  filter: brightness(1.03);
}

.schema {
  margin: 0;
  max-width: 528px;
  margin-inline: auto;
  font-family: "Courier New", monospace;
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #111;
}

.wiki-card {
  margin: 10px auto 0;
  width: min(528px, 100%);
  border: 3px solid #000;
  border-radius: 0;
  background: #fff;
  overflow: hidden;
  display: none;
}

.wiki-img {
  width: 100%;
  height: min(42vw, 220px);
  object-fit: contain;
  background: #fff;
  filter: grayscale(1) contrast(1.05);
}

.wiki-meta {
  padding: 10px;
}

.wiki-title {
  margin: 0;
  font-family: "Geneva", "Chicago", "Arial", sans-serif;
  font-size: clamp(0.95rem, 3.2vw, 1.1rem);
  color: #111;
  text-transform: uppercase;
}

.wiki-blurb {
  margin: 6px 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  line-height: 1.28;
}

.wiki-link {
  color: #000;
  font-family: "Geneva", "Chicago", "Arial", sans-serif;
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.tiny-row {
  width: min(561px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 12px auto 0;
  font-family: "Geneva", "Chicago", "Arial", sans-serif;
  font-size: clamp(0.88rem, 2.3vw, 1rem);
}

.chaos-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#hardChaos,
#wikiOnlyMode {
  width: 18px;
  height: 18px;
}

.hide {
  display: none;
}

.footer-easter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lever-wrap {
  position: static;
  width: 100%;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.party-btn {
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: #000;
  font-family: "Chicago", "Geneva", "Courier New", monospace;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1;
  padding: 0;
  box-shadow: none;
  cursor: pointer;
  transition: transform 90ms ease, opacity 120ms ease;
  -webkit-user-select: none;
  user-select: none;
  opacity: 0.72;
}

.party-btn::before {
  content: none;
}

.party-btn.pressed {
  transform: scale(0.9);
  opacity: 1;
}

.party-btn.wink {
  opacity: 1;
  transform: translateY(-1px) scale(1.05);
}

.party-btn.flash {
  filter: invert(1);
}

.shell.screen-flash {
  animation: screenFlash 110ms steps(2, end);
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 30;
}

.confetti-bit {
  position: absolute;
  opacity: 0.96;
  animation: confettiFly 1200ms ease-out forwards;
}

.confetti-bit--dot {
  border-radius: 50%;
}

.confetti-bit--dash {
  border-radius: 999px;
}

.confetti-bit--rect {
  border-radius: 2px;
}

.confetti-bit--tri {
  border-radius: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

@keyframes confettiFly {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  35% {
    transform: translate(calc(var(--dx) * 0.32 + var(--curve)), calc(var(--dy) * 0.28)) rotate(calc(var(--rot) * 0.45))
      scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), calc(var(--dy) + var(--drop))) rotate(var(--rot)) scale(0.74);
    opacity: 0;
  }
}

@keyframes screenFlash {
  0% {
    filter: none;
  }
  50% {
    filter: invert(1);
  }
  100% {
    filter: none;
  }
}

.hard-chaos {
  animation: hardShake 120ms steps(2) infinite;
}

@keyframes hardShake {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(-1px, 1px) rotate(-0.4deg);
  }
  50% {
    transform: translate(1px, -1px) rotate(0.4deg);
  }
  75% {
    transform: translate(-1px, -1px) rotate(0.2deg);
  }
  100% {
    transform: translate(1px, 1px) rotate(-0.2deg);
  }
}

.blink {
  animation: none;
}

.ticker.blink {
  animation: tickerTextBlink 1.1s step-end infinite;
}

@keyframes heroFlicker {
  0%,
  100% {
    transform: translate(0, 0);
    opacity: 1;
  }
  22% {
    transform: translate(0.5px, 0);
    opacity: 0.98;
  }
  23% {
    transform: translate(-0.5px, 0.5px);
    opacity: 0.94;
  }
  24% {
    transform: translate(0, 0);
    opacity: 1;
  }
  71% {
    transform: translate(-0.5px, 0);
  }
  72% {
    transform: translate(0.5px, -0.5px);
  }
  73% {
    transform: translate(0, 0);
  }
}

@keyframes heroShiftA {
  0%,
  100% {
    transform: translate(2px, -1px);
  }
  34% {
    transform: translate(3px, -1px);
  }
  35% {
    transform: translate(1px, -1px);
  }
  76% {
    transform: translate(2px, 0);
  }
}

@keyframes heroShiftB {
  0%,
  100% {
    transform: translate(-2px, 1px);
  }
  28% {
    transform: translate(-3px, 1px);
  }
  29% {
    transform: translate(-1px, 0);
  }
  74% {
    transform: translate(-2px, 0);
  }
}

@keyframes tickerTextBlink {
  0%,
  100% {
    color: #fff;
  }
  50% {
    color: rgba(255, 255, 255, 0.28);
  }
}

@media (max-width: 760px) {
  .shell {
    width: calc(100vw - 10px);
    min-height: calc(100dvh - 10px);
    margin: 5px auto;
    padding: 12px 10px 90px;
    border-radius: 0;
  }

  .ticker {
    font-size: 11px;
    padding: 5px 6px;
  }

  h1 {
    font-size: clamp(2.7rem, 20vw, 5.1rem);
  }

  .intro {
    margin-top: 12px;
    font-size: clamp(0.95rem, 5.2vw, 1.08rem);
  }

  .intro-mobile-break {
    display: block;
  }

  .controls {
    margin-top: 14px;
  }

  .fate-btn {
    width: min(304px, 100%);
    min-height: 56px;
    font-size: clamp(1.2rem, 8.4vw, 1.7rem);
  }

  .status {
    margin-top: 14px;
    font-size: 16px;
  }

  .result {
    margin-top: 18px;
    padding: 22px 10px 10px;
  }

  .mode-chip {
    min-width: 192px;
    font-size: 10px;
  }

  .phrase {
    min-height: 82px;
    margin-top: 20px;
    font-size: clamp(1.12rem, 6.3vw, 1.45rem);
  }

  .schema {
    font-size: 10px;
    letter-spacing: 0.4px;
  }

  .wiki-img {
    height: min(56vw, 200px);
  }

  .tiny-row {
    margin-top: 10px;
    font-size: clamp(0.8rem, 4.2vw, 0.94rem);
  }

  .lever-wrap {
    height: 66px;
  }

  .party-btn {
    width: 20px;
    height: 20px;
    font-size: 20px;
  }

  .footer-easter {
    bottom: 6px;
  }
}
