/* ═══════════════════════════════════════════════════════════════
   TURDQUEST — OFFICIAL STYLESHEET OF CHAMPIONS
   A Serious Athletic Institution. Est. 2024.
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── Variables ── */
:root {
  --bg:          #05050f;
  --panel:       #0c0c20;
  --panel-alt:   #0a0a1a;
  --green:       #00ff41;
  --green-dim:   #004d18;
  --green-dark:  #002d0f;
  --gold:        #ffd700;
  --gold-dark:   #b89800;
  --red:         #ff3333;
  --orange:      #ff6b35;
  --blue:        #3399ff;
  --purple:      #9933ff;
  --white:       #e8e8e8;
  --grey:        #444455;
  --grey-light:  #777799;
  --text:        #00ff41;
  --text-dim:    #6fa878;
  --border-gold: 3px solid #ffd700;
  --border-green: 3px solid #00ff41;
  --pixel-shadow: 4px 4px 0px #000000;
  --font:        'Press Start 2P', 'Courier New', monospace;
}

/* ── Base ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.95;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  image-rendering: pixelated;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--white); text-decoration: underline; }

/* ── Scanline overlay ── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.07) 3px,
    rgba(0,0,0,0.07) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── Nav ─────────────────────────────────────────────────── */
.nav {
  background: #000008;
  border-bottom: 3px solid var(--gold);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-logo {
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 #000, 0 0 20px rgba(255,215,0,0.5);
  text-decoration: none !important;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-logo:hover { color: var(--white); }

.nav-logo .poop-icon { font-size: 20px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--text);
  padding: 6px 10px;
  font-size: 10px;
  border: 2px solid transparent;
  transition: all 0.1s;
  text-decoration: none !important;
}

.nav-link:hover, .nav-link.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(255, 215, 0, 0.08);
  text-decoration: none !important;
}

.nav-link.play-btn {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
  font-weight: bold;
}

.nav-link.play-btn:hover {
  background: var(--white);
  color: #000;
  border-color: var(--white);
}

.nav-user {
  font-size: 9px;
  color: var(--text-dim);
}

/* ── Flash Messages ── */
.flash-container {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}

.flash {
  padding: 12px 16px;
  font-size: 10px;
  line-height: 1.6;
  border: 3px solid;
  background: var(--panel);
  position: relative;
  box-shadow: 4px 4px 0 #000;
  animation: slideIn 0.2s ease;
}

.flash-close {
  position: absolute;
  top: 6px; right: 8px;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-family: var(--font);
  font-size: 8px;
}

.flash.success  { border-color: var(--green);  color: var(--green); }
.flash.error    { border-color: var(--red);    color: var(--red); }
.flash.warning  { border-color: var(--gold);   color: var(--gold); }
.flash.info     { border-color: var(--blue);   color: var(--blue); }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Main Layout ── */
.main {
  flex: 1;
  padding: 24px 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Hero Section ── */
.hero {
  text-align: center;
  padding: 60px 24px 40px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255,215,0,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.hero-poop {
  font-size: 72px;
  display: block;
  margin-bottom: 16px;
  animation: bounce 2s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(255,215,0,0.4));
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.hero-title {
  font-size: 36px;
  color: var(--gold);
  text-shadow: 4px 4px 0 #000, 0 0 30px rgba(255,215,0,0.4);
  margin-bottom: 12px;
  letter-spacing: 4px;
}

.hero-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 3px;
}

.hero-tagline {
  font-size: 9px;
  color: var(--grey-light);
  margin-bottom: 40px;
  max-width: 480px;
  margin-inline: auto;
}

.hero-cta {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  font-family: var(--font);
  font-size: 10px;
  padding: 14px 24px;
  border: 3px solid;
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.1s;
  text-align: center;
  position: relative;
  top: 0;
  box-shadow: 4px 4px 0 #000;
}

.btn:active {
  top: 2px;
  box-shadow: 2px 2px 0 #000;
}

.btn-gold {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
}

.btn-gold:hover {
  background: var(--white);
  color: #000;
  border-color: var(--white);
  text-decoration: none;
}

.btn-green {
  background: var(--green);
  color: #000;
  border-color: var(--green);
}

.btn-green:hover {
  background: var(--white);
  color: #000;
  border-color: var(--white);
}

.btn-outline {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold);
}

.btn-outline:hover {
  background: rgba(255,215,0,0.1);
  color: var(--gold);
}

.btn-outline-green {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
}

.btn-outline-green:hover {
  background: rgba(0,255,65,0.1);
  color: var(--green);
}

.btn-red {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-sm {
  font-size: 8px;
  padding: 8px 14px;
  box-shadow: 3px 3px 0 #000;
}

.btn-lg {
  font-size: 13px;
  padding: 18px 32px;
}

/* ── Panels / Cards ── */
.panel {
  background: var(--panel);
  border: 3px solid var(--gold);
  box-shadow: 6px 6px 0 #000;
  padding: 20px;
  margin-bottom: 20px;
}

.panel-green {
  border-color: var(--green);
}

.panel-title {
  font-size: 12px;
  color: var(--gold);
  border-bottom: 2px solid var(--gold-dark);
  padding-bottom: 10px;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.panel-title.green { color: var(--green); border-color: var(--green-dim); }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--panel-alt);
  border: 2px solid var(--grey);
  padding: 14px 12px;
  text-align: center;
}

.stat-box.gold  { border-color: var(--gold); }
.stat-box.green { border-color: var(--green); }

.stat-label {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: block;
}

.stat-value {
  font-size: 20px;
  color: var(--gold);
  display: block;
}

.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

th {
  color: var(--gold);
  border-bottom: 2px solid var(--gold-dark);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  letter-spacing: 1px;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #1a1a30;
  color: var(--white);
  vertical-align: middle;
}

tr:hover td { background: rgba(255,215,0,0.04); }

.rank-1 td:first-child { color: var(--gold); }
.rank-2 td:first-child { color: var(--white); }
.rank-3 td:first-child { color: var(--orange); }

.badge {
  display: inline-block;
  font-size: 7px;
  padding: 2px 6px;
  border: 1px solid;
  margin-left: 4px;
}

.badge-admin  { border-color: var(--red);    color: var(--red); }
.badge-coin   { border-color: var(--gold);   color: var(--gold); }
.badge-guest  { border-color: var(--grey);   color: var(--grey); }

/* ── Forms ── */
.form-container {
  max-width: 480px;
  margin: 40px auto;
}

.form-title {
  font-size: 16px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 32px;
  text-shadow: 3px 3px 0 #000;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.form-input {
  display: block;
  width: 100%;
  background: #000010;
  border: 3px solid var(--grey);
  color: var(--green);
  font-family: var(--font);
  font-size: 10px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.1s;
}

.form-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255,215,0,0.15);
}

.form-input::placeholder { color: var(--grey); }

.form-hint {
  font-size: 7px;
  color: var(--grey-light);
  margin-top: 4px;
}

.form-divider {
  text-align: center;
  color: var(--grey);
  font-size: 8px;
  margin: 20px 0;
  position: relative;
}

.form-divider::before, .form-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--grey);
}
.form-divider::before { left: 0; }
.form-divider::after  { right: 0; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 8px;
  color: var(--text-dim);
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
}

/* ── Game Page ── */
.game-wrapper {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 0;
  flex-wrap: wrap;
}

.game-sidebar {
  width: 180px;
  flex-shrink: 0;
}

.game-center {
  flex: 1;
  min-width: 300px;
  max-width: 820px;
}

.game-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 3px solid var(--gold);
  box-shadow: 6px 6px 0 #000, 0 0 40px rgba(255,215,0,0.15);
  cursor: pointer;
}

.game-instructions {
  text-align: center;
  margin-top: 12px;
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.game-instructions strong {
  color: var(--gold);
}

/* sidebar stat rows */
.sidebar-stat {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #1a1a30;
  font-size: 8px;
}

.sidebar-stat:last-child { border-bottom: none; }

.sidebar-stat .label { color: var(--text-dim); }
.sidebar-stat .value { color: var(--gold); }
.sidebar-stat .value.green { color: var(--green); }

/* TurdCoin notification */
.coin-notif {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--gold);
  color: #000;
  font-family: var(--font);
  font-size: 14px;
  padding: 16px 24px;
  border: 4px solid #000;
  box-shadow: 8px 8px 0 #000;
  z-index: 100;
  text-align: center;
  animation: coinPop 0.3s ease;
  pointer-events: none;
}

@keyframes coinPop {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

/* Game over overlay */
.game-over-ui {
  display: none;
  text-align: center;
  margin-top: 16px;
}

.game-over-ui.visible { display: block; }

.game-over-ui .result-title {
  font-size: 18px;
  margin-bottom: 12px;
}

.game-over-ui .result-score {
  font-size: 36px;
  color: var(--gold);
  margin-bottom: 16px;
}

.game-over-ui .shot-breakdown {
  font-size: 9px;
  margin-bottom: 20px;
  line-height: 2;
}

.game-over-ui .actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Hero Stats Bar ── */
.hero-stats-bar {
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
  padding: 24px;
  border-top: 2px solid var(--green-dim);
  border-bottom: 2px solid var(--green-dim);
  margin: 32px 0;
}

.hero-stat {
  text-align: center;
}

.hero-stat .num {
  display: block;
  font-size: 22px;
  color: var(--green);
  margin-bottom: 4px;
}

.hero-stat .label {
  font-size: 7px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

/* ── Top Players ── */
.top-players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.player-card {
  background: var(--panel-alt);
  border: 2px solid var(--green-dim);
  padding: 14px;
  transition: border-color 0.1s;
}

.player-card:hover { border-color: var(--green); }

.player-rank {
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.player-name {
  font-size: 10px;
  color: var(--white);
  margin-bottom: 8px;
}

.player-coins {
  color: var(--gold);
  font-size: 9px;
}

.player-pct {
  font-size: 8px;
  color: var(--text-dim);
}

/* ── Profile ── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px;
  border-bottom: 2px solid var(--green-dim);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.profile-avatar {
  font-size: 48px;
}

.profile-username {
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 6px;
}

.profile-meta {
  font-size: 10px;
  color: var(--text-dim);
}

/* Profile readability pass: the pixel font gets cramped below 9px. */
.profile-page {
  font-size: 11px;
}

.profile-page [style*="font-size:6px"],
.profile-page [style*="font-size: 6px"],
.profile-page [style*="font-size:7px"],
.profile-page [style*="font-size: 7px"] {
  font-size: 9px !important;
  line-height: 2.1 !important;
}

.profile-page [style*="font-size:8px"],
.profile-page [style*="font-size: 8px"] {
  font-size: 10px !important;
  line-height: 2.05 !important;
}

.profile-page [style*="font-size:9px"],
.profile-page [style*="font-size: 9px"] {
  font-size: 11px !important;
  line-height: 2.05 !important;
}

.profile-page .stat-label {
  font-size: 9px;
}

.profile-page table {
  font-size: 10px;
}

/* ── Admin ── */
.admin-warning {
  background: rgba(255, 51, 51, 0.1);
  border: 2px solid var(--red);
  color: var(--red);
  padding: 12px 16px;
  font-size: 9px;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

/* ── Coming Soon ── */
.coming-soon-wrap {
  text-align: center;
  padding: 60px 20px;
}

.coming-soon-title {
  font-size: 28px;
  color: var(--gold);
  margin-bottom: 20px;
  text-shadow: 4px 4px 0 #000;
}

.mystery-icons {
  font-size: 48px;
  display: flex;
  gap: 20px;
  justify-content: center;
  margin: 32px 0;
  filter: drop-shadow(0 0 10px rgba(255,215,0,0.4));
}

.mystery-icon {
  animation: pulse 1.5s ease-in-out infinite;
}

.mystery-icon:nth-child(2) { animation-delay: 0.2s; }
.mystery-icon:nth-child(3) { animation-delay: 0.4s; }
.mystery-icon:nth-child(4) { animation-delay: 0.6s; }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.1); opacity: 0.7; }
}

.coming-soon-text {
  font-size: 10px;
  color: var(--text-dim);
  max-width: 400px;
  margin: 0 auto 32px;
  line-height: 2;
}

/* ── Leaderboard Tabs ── */
.tab-bar {
  display: flex;
  border-bottom: 3px solid var(--gold-dark);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  font-family: var(--font);
  font-size: 8px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  margin-bottom: -3px;
  letter-spacing: 1px;
  transition: all 0.1s;
}

.tab-btn:hover { color: var(--gold); }

.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Footer ── */
.footer {
  background: #000008;
  border-top: 3px solid var(--green-dim);
  padding: 20px 24px;
  text-align: center;
  font-size: 7px;
  color: var(--text-dim);
  letter-spacing: 2px;
  line-height: 2;
}

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

/* ── Flicker animation ── */
@keyframes flicker {
  0%   { opacity: 1; }
  92%  { opacity: 1; }
  93%  { opacity: 0.8; }
  94%  { opacity: 1; }
  96%  { opacity: 0.9; }
  100% { opacity: 1; }
}

.flicker { animation: flicker 8s infinite; }

/* ── Pixel blinking cursor ── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.blink { animation: blink 1s step-end infinite; }

/* ── Highlight on coin earn ── */
@keyframes coinGlow {
  0%   { text-shadow: none; }
  50%  { text-shadow: 0 0 12px var(--gold), 0 0 24px var(--gold); }
  100% { text-shadow: none; }
}

.coin-glow { animation: coinGlow 0.8s ease; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hero-title { font-size: 22px; }
  .nav-logo   { font-size: 11px; }
  .game-sidebar { width: 100%; display: flex; flex-wrap: wrap; gap: 12px; }
  .game-sidebar .panel { flex: 1; min-width: 140px; }
  .hero-stats-bar { gap: 24px; }
  .hero-stat .num { font-size: 16px; }
  .tab-btn { font-size: 7px; padding: 8px 10px; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 16px; }
  .hero-poop  { font-size: 48px; }
  .btn        { font-size: 8px; padding: 12px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   THE YEAR IN THE FOOTER
   It looks like the rest of the footer until something touches it.
   See static/js/year_cipher.js.
   ═══════════════════════════════════════════════════════════════ */
.year-cipher {
  position: relative;
  display: inline-block;
  min-width: 4ch;
  color: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: color .18s ease, text-shadow .18s ease;
  -webkit-tap-highlight-color: transparent;
}

.year-cipher.glitching {
  color: #ff4fd8;
  text-shadow:
    -1px 0 0 rgba(0, 240, 255, .85),
     1px 0 0 rgba(255, 32, 140, .85),
     0 0 10px rgba(255, 79, 216, .55);
  animation: yearJitter .09s steps(2, end) infinite;
}

/* Two offset copies of the same digits, one cyan and one magenta, each showing
   only a horizontal band of itself. The bands slide independently, so the
   number looks torn apart into colour channels rather than merely shaken.
   The copy comes from data-glitch, which the script keeps in step with the
   text actually on screen. */
.year-cipher.glitching::before,
.year-cipher.glitching::after {
  content: attr(data-glitch);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  pointer-events: none;
  text-shadow: none;
}

.year-cipher.glitching::before {
  color: #00f0ff;
  animation: yearSliceTop .22s steps(2, end) infinite;
}

.year-cipher.glitching::after {
  color: #ff208c;
  animation: yearSliceBottom .19s steps(2, end) infinite;
}

@keyframes yearSliceTop {
  0%   { clip-path: inset(0 0 62% 0); transform: translate(-3px, -1px); }
  40%  { clip-path: inset(12% 0 48% 0); transform: translate(4px, 0); }
  70%  { clip-path: inset(0 0 70% 0); transform: translate(-5px, 1px); }
  100% { clip-path: inset(30% 0 40% 0); transform: translate(2px, -1px); }
}

@keyframes yearSliceBottom {
  0%   { clip-path: inset(58% 0 0 0); transform: translate(3px, 1px); }
  35%  { clip-path: inset(44% 0 18% 0); transform: translate(-4px, 0); }
  75%  { clip-path: inset(66% 0 0 0); transform: translate(5px, -1px); }
  100% { clip-path: inset(40% 0 22% 0); transform: translate(-2px, 1px); }
}

@keyframes yearJitter {
  0%   { transform: translate(0, 0)      skewX(0deg); }
  33%  { transform: translate(-1px, 0)   skewX(-6deg); }
  66%  { transform: translate(1px, -1px) skewX(4deg); }
  100% { transform: translate(0, 1px)    skewX(0deg); }
}

/* The hard warp, applied for single frames rather than continuously: the
   glyphs stretch and shear as if the tape is being dragged past the head. */
.year-cipher.warping {
  animation: yearWarp .08s steps(1, end) infinite;
}

@keyframes yearWarp {
  0%   { transform: scale(1.35, .72) skewX(-18deg); filter: blur(.4px); }
  50%  { transform: scale(.78, 1.28) skewX(14deg); }
  100% { transform: scale(1.18, .88) skewX(-9deg); filter: blur(.3px); }
}

.year-cipher.settled {
  cursor: pointer;
  color: #ff2fa0;
  text-shadow:
    0 0 6px rgba(255, 47, 160, .95),
    0 0 18px rgba(255, 47, 160, .65),
    0 0 34px rgba(160, 0, 255, .45);
  animation: yearHum 2.4s ease-in-out infinite;
}

/* A slow signal wobble, plus a static band that crawls up the digits. */
@keyframes yearHum {
  0%, 100% { opacity: 1; }
  47%      { opacity: .82; }
  49%      { opacity: 1; transform: translateX(.5px); }
  51%      { opacity: .9; transform: translateX(-.5px); }
  53%      { transform: translateX(0); }
}

.year-cipher.settled::after {
  content: '';
  position: absolute;
  inset: -2px -4px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 255, 255, .38) 46%,
    rgba(0, 240, 255, .30) 52%,
    transparent 60%
  );
  mix-blend-mode: screen;
  animation: yearStatic 3.1s linear infinite;
}

@keyframes yearStatic {
  0%, 72%  { opacity: 0; transform: translateY(120%); }
  76%      { opacity: 1; }
  92%      { opacity: .7; transform: translateY(-120%); }
  93%, 100% { opacity: 0; }
}

.year-cipher:focus-visible { text-decoration: underline dotted; text-underline-offset: 4px; }
.year-cipher.entering { color: #fff; text-shadow: 0 0 20px #fff, 0 0 40px #ff2fa0; }

/* ── The way out of the site and into 1986 ── */
.year-cipher-theatre {
  position: fixed;
  inset: 0;
  z-index: 100000;
  pointer-events: none;
  background: transparent;
  opacity: 0;
  transition: opacity .12s linear, background-color .18s linear;
}
.year-cipher-theatre.on {
  opacity: 1;
  background-color: rgba(255, 47, 160, .10);
  animation: theatreFlicker .42s steps(2, end) 2;
}
.year-cipher-theatre.black { background-color: #000; }

@keyframes theatreFlicker {
  0%   { background-color: rgba(255, 47, 160, .05); }
  25%  { background-color: rgba(0, 240, 255, .16); }
  50%  { background-color: rgba(0, 0, 0, .75); }
  75%  { background-color: rgba(255, 47, 160, .20); }
  100% { background-color: rgba(0, 0, 0, .35); }
}

/* The horizontal tear that rips across the screen as the signal goes. */
.yct-tear {
  position: absolute;
  left: -10%;
  width: 120%;
  height: 26%;
  top: 38%;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, .5) 0 2px,
    rgba(0, 240, 255, .35) 2px 4px,
    rgba(255, 47, 160, .35) 4px 6px,
    transparent 6px 11px
  );
  mix-blend-mode: screen;
  transform: translateY(-60vh) scaleY(.4);
  opacity: 0;
}
.year-cipher-theatre.on .yct-tear {
  animation: tearSweep .55s cubic-bezier(.3, .7, .2, 1) forwards;
}

@keyframes tearSweep {
  0%   { opacity: 0; transform: translateY(-60vh) scaleY(.35) skewX(0deg); }
  20%  { opacity: 1; transform: translateY(-10vh) scaleY(1.4) skewX(-14deg); }
  60%  { opacity: 1; transform: translateY(20vh) scaleY(.7) skewX(10deg); }
  100% { opacity: 0; transform: translateY(70vh) scaleY(.2) skewX(0deg); }
}

.yct-flash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: clamp(42px, 13vw, 140px);
  letter-spacing: 12px;
  color: #ff2fa0;
  text-shadow: 0 0 18px #ff2fa0, 0 0 60px rgba(160, 0, 255, .8), 4px 0 0 rgba(0, 240, 255, .7);
  opacity: 0;
}
.year-cipher-theatre.flashing .yct-flash {
  animation: yearFlash .52s steps(1, end) forwards;
}

@keyframes yearFlash {
  0%   { opacity: 0; transform: scale(1.5); }
  15%  { opacity: 1; transform: scale(1); }
  35%  { opacity: .2; }
  50%  { opacity: 1; }
  80%  { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1.18); }
}

@media (prefers-reduced-motion: reduce) {
  .year-cipher.glitching,
  .year-cipher.glitching::before,
  .year-cipher.glitching::after,
  .year-cipher.warping,
  .year-cipher.settled,
  .year-cipher.settled::after,
  .year-cipher-theatre.on,
  .year-cipher-theatre.on .yct-tear,
  .year-cipher-theatre.flashing .yct-flash { animation: none; }
  .year-cipher.settled::after { opacity: 0; }
  .year-cipher.glitching::before,
  .year-cipher.glitching::after { display: none; }
}
