:root {
  --bg0: #07060f;
  --bg1: #120b22;
  --cyan: #3cf0ff;
  --mag: #ff3d8e;
  --yel: #ffd166;
  --pur: #8b5cff;
  --lime: #5dff9f;
  --ink: #eaf6ff;
  --dim: #8ea0c4;
  --panel: rgba(10, 12, 28, 0.72);
  --line: rgba(60, 240, 255, 0.45);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg0);
  color: var(--ink);
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  user-select: none;
}

body {
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(255, 61, 142, 0.18), transparent 55%),
    radial-gradient(900px 600px at 110% 10%, rgba(60, 240, 255, 0.16), transparent 50%),
    radial-gradient(800px 500px at 50% 120%, rgba(139, 92, 255, 0.16), transparent 50%),
    linear-gradient(180deg, #0b0816 0%, #07060f 40%, #05040c 100%);
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 40%, #000 40%, transparent 80%);
  opacity: 0.5;
  transform: translateZ(0);
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.cabinet {
  width: min(920px, 100%);
  position: relative;
  padding: 18px 18px 22px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(28, 20, 48, 0.9), rgba(8, 8, 18, 0.94));
  box-shadow:
    0 0 0 1px rgba(60, 240, 255, 0.25),
    0 0 40px rgba(255, 61, 142, 0.12),
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* build number, sits in the cabinet's bottom padding under the screen */
.version-tag {
  position: absolute;
  right: 28px;
  bottom: 5px;
  margin: 0;
  color: var(--dim);
  opacity: 0.7;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.18em;
  pointer-events: none;
}

.cabinet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 12px;
}

.brand-mark {
  font-family: Orbitron, sans-serif;
  font-weight: 700;
  letter-spacing: 0.28em;
  font-size: 11px;
  color: var(--dim);
}

.cabinet-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mute {
  appearance: none;
  border: 1px solid rgba(60, 240, 255, 0.35);
  background: rgba(8, 10, 24, 0.6);
  color: var(--cyan);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.12em;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.mute:hover,
.mute:focus-visible {
  border-color: var(--mag);
  color: var(--mag);
  outline: none;
}

.mute.is-on {
  border-color: rgba(60, 240, 255, 0.9);
  color: #06131a;
  background: var(--cyan);
}

.mute.is-on:hover,
.mute.is-on:focus-visible {
  border-color: var(--mag);
  background: var(--mag);
  color: #1a0614;
}

.screen-frame {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: #05040c;
  box-shadow:
    inset 0 0 0 1px rgba(60, 240, 255, 0.2),
    inset 0 0 80px rgba(0, 0, 0, 0.55);
  min-height: min(78svh, 760px);
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.03) 0 1px,
    transparent 1px 3px
  );
  opacity: 0.22;
  transform: translateZ(0);
}

.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  box-shadow: inset 0 0 120px 20px rgba(0, 0, 0, 0.55);
  transform: translateZ(0);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

#screen-title {
  align-items: center;
  justify-content: center;
  padding: 28px 24px 22px;
  gap: 8px;
  z-index: 1;
  background: transparent;
}

#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 0;
}

.title-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.logo {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-weight: 900;
  font-size: clamp(30px, 8.2vw, 84px);
  letter-spacing: 0.08em;
  line-height: 0.9;
  white-space: nowrap;
  color: #7af6ff;
  text-shadow:
    0 0 18px rgba(60, 240, 255, 0.55),
    0 0 42px rgba(255, 61, 142, 0.35),
    0 8px 0 rgba(255, 61, 142, 0.18);
  animation: logoPulse 3.4s ease-in-out infinite;
}

.logo span {
  display: inline-block;
  transform-origin: 50% 80%;
  animation: letterBob 2.4s ease-in-out infinite;
}

.logo span:nth-child(1) { color: #7af6ff; animation-delay: 0s; }
.logo span:nth-child(2) { color: #3cf0ff; animation-delay: 0.07s; }
.logo span:nth-child(3) { color: #6ea8ff; animation-delay: 0.14s; }
.logo span:nth-child(4) { color: #8b5cff; animation-delay: 0.21s; }
.logo span:nth-child(5) { color: #ff3d8e; animation-delay: 0.28s; }
.logo span:nth-child(6) { color: #ff6b6b; animation-delay: 0.35s; }
.logo span:nth-child(7) { color: #ff9f0a; animation-delay: 0.42s; }
.logo span:nth-child(8) { color: #ffd166; animation-delay: 0.49s; }
.logo span:nth-child(9) { color: #3dff8a; animation-delay: 0.56s; }

.tagline {
  margin: 0 0 8px;
  color: var(--yel);
  letter-spacing: 0.42em;
  font-size: 12px;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.4);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, 86vw);
  margin-top: 12px;
}

.btn {
  appearance: none;
  font-family: Orbitron, sans-serif;
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 16px;
  padding: 14px 18px;
  border-radius: 12px;
  border: 2px solid var(--cyan);
  color: var(--cyan);
  background: linear-gradient(180deg, rgba(60, 240, 255, 0.08), rgba(60, 240, 255, 0.02));
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 0 0 0 rgba(60, 240, 255, 0.35);
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease, border-color 0.12s ease,
    box-shadow 0.12s ease;
}

.btn:hover,
.btn.selected,
.btn:focus-visible {
  outline: none;
  color: #081018;
  background: linear-gradient(180deg, #7af6ff, #3cf0ff);
  border-color: #fff;
  box-shadow: 0 0 24px rgba(60, 240, 255, 0.45);
  transform: translateY(-1px);
}

.btn.alt:hover,
.btn.alt.selected,
.btn.alt:focus-visible {
  background: linear-gradient(180deg, #ff8ab8, #ff3d8e);
  border-color: #fff;
  color: #1a0610;
  box-shadow: 0 0 24px rgba(255, 61, 142, 0.4);
}

.how {
  margin-top: 22px;
  padding: 12px 16px;
  border: 1px solid rgba(139, 92, 255, 0.35);
  background: var(--panel);
  border-radius: 12px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  min-width: min(420px, 86vw);
}

.how b {
  color: var(--ink);
  font-weight: 400;
}

.kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  border: 1px solid rgba(60, 240, 255, 0.4);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--cyan);
  font-size: 11px;
}

#screen-game {
  background: #05040c;
  z-index: 2;
}

#game {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(5, 4, 12, 0.55);
  text-align: center;
  padding: 24px;
}

.overlay.active {
  display: flex;
}

.overlay h2 {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: clamp(28px, 6vw, 48px);
  letter-spacing: 0.16em;
  color: #fff;
  text-shadow: 0 0 22px rgba(255, 61, 142, 0.6);
}

.overlay p {
  margin: 0;
  color: var(--dim);
  letter-spacing: 0.12em;
}

.overlay .score-xl {
  color: var(--yel);
  font-size: 28px;
  text-shadow: 0 0 16px rgba(255, 209, 102, 0.5);
}

.overlay .menu {
  margin-top: 10px;
}

.overlay.is-high .score-xl {
  color: #ffd166;
  text-shadow: 0 0 22px rgba(255, 209, 102, 0.85);
}

.overlay.is-high h2 {
  text-shadow: 0 0 26px rgba(255, 209, 102, 0.7);
}

.initials {
  display: flex;
  gap: 12px;
  margin: 8px 0 4px;
}

.letter {
  width: 72px;
  height: 88px;
  display: grid;
  place-items: center;
  font-family: Orbitron, sans-serif;
  font-size: 48px;
  font-weight: 900;
  color: var(--cyan);
  border: 2px solid rgba(60, 240, 255, 0.3);
  border-radius: 12px;
  background: rgba(8, 10, 28, 0.7);
  cursor: pointer;
  user-select: none;
}

.letter.active {
  border-color: var(--mag);
  color: #fff;
  box-shadow: 0 0 24px rgba(255, 61, 142, 0.35);
  transform: translateY(-4px);
}

#screen-scores {
  padding: 28px 28px 22px;
  align-items: stretch;
  z-index: 2;
  background: rgba(5, 4, 12, 0.94);
}

.scores-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.scores-head h1 {
  margin: 0;
  font-family: Orbitron, sans-serif;
  letter-spacing: 0.18em;
  font-size: clamp(22px, 4vw, 34px);
  background: linear-gradient(90deg, var(--yel), var(--mag));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.scores-head p {
  margin: 0;
  color: var(--dim);
  letter-spacing: 0.16em;
  font-size: 12px;
}

.scoreboard {
  flex: 1;
  overflow: auto;
  border: 1px solid rgba(60, 240, 255, 0.2);
  border-radius: 14px;
  background: rgba(6, 8, 20, 0.55);
}

.scoreboard table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 15px;
}

.scoreboard th,
.scoreboard td {
  padding: 11px 16px;
  text-align: left;
}

.scoreboard th {
  color: var(--dim);
  font-weight: 400;
  letter-spacing: 0.18em;
  font-size: 11px;
  border-bottom: 1px solid rgba(60, 240, 255, 0.18);
}

.scoreboard td:nth-child(1),
.scoreboard th:nth-child(1) {
  width: 12%;
  color: var(--yel);
}

.scoreboard td:nth-child(2),
.scoreboard th:nth-child(2) {
  width: 38%;
}

.scoreboard td:nth-child(2) {
  font-family: Orbitron, sans-serif;
  letter-spacing: 0.2em;
  color: #fff;
}

.scoreboard td:nth-child(3),
.scoreboard th:nth-child(3) {
  width: 32%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.scoreboard td:nth-child(4),
.scoreboard th:nth-child(4) {
  width: 18%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.scoreboard tr.fresh {
  background: linear-gradient(90deg, rgba(255, 61, 142, 0.28), rgba(255, 61, 142, 0.06));
}

.scoreboard tr.fresh td {
  color: #fff;
}

.scoreboard tr.fresh td:nth-child(2) {
  color: var(--cyan);
}

.scores-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.scores-actions .btn {
  flex: 1;
  min-width: 180px;
}

.hint {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-align: center;
}

/* --- retro sync loader (shown inside the scoreboard while syncing) --- */
.scoreboard.is-loading {
  display: flex;
  align-items: center;
  justify-content: center;
}

.scoreboard.is-loading table {
  display: none;
}

.sync-loader[hidden] {
  display: none;
}

.sync-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
  width: 100%;
}

.sync-loader-title {
  margin: 0;
  font-family: Orbitron, sans-serif;
  letter-spacing: 0.24em;
  font-size: 12px;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(60, 240, 255, 0.55);
  animation: syncTitleFlicker 2.2s steps(2, end) infinite;
}

.sync-bar {
  display: flex;
  gap: 4px;
  padding: 6px;
  border: 2px solid rgba(60, 240, 255, 0.45);
  border-radius: 4px;
  background: rgba(6, 8, 20, 0.85);
  box-shadow:
    0 0 18px rgba(60, 240, 255, 0.15),
    inset 0 0 12px rgba(0, 0, 0, 0.6);
}

.sync-bar i {
  display: block;
  width: 14px;
  height: 22px;
  background: rgba(60, 240, 255, 0.1);
  border-radius: 1px;
  animation: syncSweep 1.6s steps(1, end) infinite;
}

.sync-bar i:nth-child(1) { animation-delay: 0s; }
.sync-bar i:nth-child(2) { animation-delay: 0.08s; }
.sync-bar i:nth-child(3) { animation-delay: 0.16s; }
.sync-bar i:nth-child(4) { animation-delay: 0.24s; }
.sync-bar i:nth-child(5) { animation-delay: 0.32s; }
.sync-bar i:nth-child(6) { animation-delay: 0.4s; }
.sync-bar i:nth-child(7) { animation-delay: 0.48s; }
.sync-bar i:nth-child(8) { animation-delay: 0.56s; }
.sync-bar i:nth-child(9) { animation-delay: 0.64s; }
.sync-bar i:nth-child(10) { animation-delay: 0.72s; }
.sync-bar i:nth-child(11) { animation-delay: 0.8s; }
.sync-bar i:nth-child(12) { animation-delay: 0.88s; }
.sync-bar i:nth-child(13) { animation-delay: 0.96s; }
.sync-bar i:nth-child(14) { animation-delay: 1.04s; }
.sync-bar i:nth-child(15) { animation-delay: 1.12s; }
.sync-bar i:nth-child(16) { animation-delay: 1.2s; }

/* segments for completed steps stay lit */
.sync-bar i.on {
  animation: none;
  background: linear-gradient(180deg, var(--yel), var(--mag));
  box-shadow: 0 0 10px rgba(255, 61, 142, 0.6);
}

.sync-loader-step {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.16em;
}

.sync-loader-step .cursor {
  color: var(--cyan);
  animation: syncCursor 1s steps(1, end) infinite;
}

@keyframes syncSweep {
  0%, 30% {
    background: var(--cyan);
    box-shadow: 0 0 12px rgba(60, 240, 255, 0.7);
  }
  31%, 100% {
    background: rgba(60, 240, 255, 0.1);
    box-shadow: none;
  }
}

@keyframes syncCursor {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

@keyframes syncTitleFlicker {
  0%, 92% { opacity: 1; }
  93%, 100% { opacity: 0.55; }
}

.sync-status {
  margin: 8px 0 0;
  min-height: 14px;
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-align: center;
}

@keyframes logoPulse {
  0%,
  100% {
    text-shadow:
      0 0 12px rgba(60, 240, 255, 0.45),
      0 0 28px rgba(255, 61, 142, 0.25),
      0 8px 0 rgba(255, 61, 142, 0.16);
  }
  50% {
    text-shadow:
      0 0 26px rgba(255, 61, 142, 0.55),
      0 0 40px rgba(60, 240, 255, 0.35),
      0 8px 0 rgba(60, 240, 255, 0.16);
  }
}

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

@media (max-width: 640px) {
  .cabinet {
    padding: 10px 10px 16px;
    border-radius: 18px;
  }

  .version-tag {
    right: 20px;
    bottom: 3px;
  }

  .screen-frame {
    min-height: min(82svh, 720px);
    border-radius: 12px;
  }

  .how {
    font-size: 12px;
  }

  .scoreboard th,
  .scoreboard td {
    padding: 10px 10px;
  }

  .sync-bar i {
    width: 10px;
    height: 18px;
  }
}

.update-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 24px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--yel);
  background: rgba(10, 8, 20, 0.94);
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.35);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--yel);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.update-toast.active {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.update-toast-btn {
  appearance: none;
  font-family: Orbitron, sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--yel);
  background: var(--yel);
  color: #1a1405;
  cursor: pointer;
}

.update-toast-btn:hover,
.update-toast-btn:focus-visible {
  outline: none;
  border-color: #fff;
  background: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .update-toast {
    transition: none;
  }

  .sync-bar i,
  .sync-loader-title {
    animation: none;
  }
}
