:root {
  --bg-1: #030a1a;
  --bg-2: #071631;
  --bg-3: #10284f;
  --text: #e7f6ff;
  --muted: #a7c4df;
  --card: rgba(5, 23, 47, 0.73);
  --stroke: rgba(128, 193, 236, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  position: relative;
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(
      circle at 12% 16%,
      rgba(61, 134, 227, 0.25),
      transparent 38%
    ),
    radial-gradient(
      circle at 78% 82%,
      rgba(78, 199, 243, 0.2),
      transparent 40%
    ),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 48%, var(--bg-3));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(
      circle at 50% 50%,
      rgba(129, 215, 255, 0.25),
      transparent 52%
    ),
    linear-gradient(
      110deg,
      rgba(7, 20, 42, 0.98) 18%,
      rgba(10, 33, 68, 0.86) 50%,
      rgba(7, 20, 42, 0.98) 82%
    );
  transform: translateX(110%);
}

body.startup::before {
  animation: boot-wipe 1.1s cubic-bezier(0.22, 0.68, 0, 1) forwards;
}

.boot-sequence {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background:
    radial-gradient(
      circle at 50% 45%,
      rgba(136, 213, 255, 0.2),
      rgba(5, 18, 39, 0.95) 54%,
      rgba(3, 10, 27, 0.98)
    ),
    linear-gradient(
      0deg,
      rgba(166, 232, 255, 0.08) 0,
      rgba(166, 232, 255, 0.01) 1px,
      transparent 1px,
      transparent 4px
    );
  background-size:
    100% 100%,
    100% 4px;
}

.boot-sequence::before {
  content: none;
}

body.startup .boot-sequence {
  visibility: visible;
  animation: intro-overlay 1.9s cubic-bezier(0.2, 0.75, 0, 1) forwards;
}

.boot-ring {
  position: absolute;
  z-index: 2;
  width: clamp(180px, 34vw, 440px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(167, 231, 255, 0.54);
  box-shadow:
    0 0 0 1px rgba(94, 179, 228, 0.16) inset,
    0 0 48px rgba(72, 182, 247, 0.48),
    0 0 130px rgba(11, 77, 172, 0.38);
  opacity: 0;
  transform: scale(0.7);
}

.boot-ring::before,
.boot-ring::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 1px solid rgba(180, 237, 255, 0.6);
}

.boot-ring::after {
  inset: 30%;
  border-color: rgba(212, 247, 255, 0.86);
}

body.startup .boot-ring {
  animation: ring-pop 1.5s cubic-bezier(0.17, 0.84, 0.2, 1) both;
}

body.startup .boot-ring::before {
  animation: ring-pulse 1.5s ease-out both;
}

body.startup .boot-ring::after {
  animation: ring-pulse 1.5s ease-out 110ms both;
}

.boot-text {
  position: relative;
  z-index: 3;
  margin: 0;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(174, 233, 255, 0.35);
  background: rgba(6, 23, 49, 0.62);
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: clamp(0.82rem, 2vw, 1.12rem);
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: #d8f3ff;
  text-shadow: 0 0 18px rgba(141, 227, 255, 0.86);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
}

body.startup .boot-text {
  animation: boot-text-in 1.35s cubic-bezier(0.14, 0.9, 0.25, 1) 140ms both;
}

#automation-bg,
.noise {
  position: fixed;
  inset: 0;
}

#automation-bg {
  width: 100%;
  height: 100%;
  z-index: 0;
}

body.startup #automation-bg {
  animation: bg-boot 1.4s cubic-bezier(0.2, 0.78, 0.2, 1) both;
}

.noise {
  z-index: 1;
  pointer-events: none;
  opacity: 0.36;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.03) 0,
      rgba(255, 255, 255, 0.03) 1px,
      transparent 1px,
      transparent 80px
    ),
    radial-gradient(circle at 50% 120%, rgba(0, 0, 0, 0.6), transparent 50%);
}

body.startup .noise {
  animation: noise-boot 1.4s ease-out both;
}

.wrap {
  position: relative;
  z-index: 2;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 38px);
}

body.startup .wrap {
  animation: wrap-boot 1.05s cubic-bezier(0.2, 0.8, 0.2, 1) 180ms both;
}

.card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: min(720px, 100%);
  padding: clamp(24px, 4vw, 42px);
  border-radius: 26px;
  border: 1px solid var(--stroke);
  background: linear-gradient(155deg, rgba(7, 36, 76, 0.84), var(--card));
  box-shadow:
    0 26px 66px rgba(0, 0, 0, 0.52),
    inset 0 0 0 1px rgba(146, 197, 255, 0.1),
    inset 0 -30px 80px rgba(34, 145, 238, 0.16);
  backdrop-filter: blur(10px);
  animation: card-in 850ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

body.startup .card > * {
  opacity: 0;
  transform: translateY(16px);
  animation: content-rise 640ms cubic-bezier(0.16, 0.86, 0.18, 1) forwards;
}

body.startup .card > :nth-child(1) {
  animation-delay: 720ms;
}

body.startup .card > :nth-child(2) {
  animation-delay: 790ms;
}

body.startup .card > :nth-child(3) {
  animation-delay: 860ms;
}

body.startup .card > :nth-child(4) {
  animation-delay: 930ms;
}

body.startup .card > :nth-child(5) {
  animation-delay: 1s;
}

body.startup .card > :nth-child(6) {
  animation-delay: 1.07s;
}

body.startup .card > :nth-child(7) {
  animation-delay: 1.14s;
}

.eyebrow {
  margin: 0;
  font-size: 0.73rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 12px 0 10px;
  line-height: 1.08;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: clamp(2rem, 5vw, 3.6rem);
  font-weight: 800;
  text-wrap: balance;
}

.lead {
  margin: 0;
  font-size: clamp(1rem, 2.2vw, 1.18rem);
  color: #d3e9fb;
  max-width: 42ch;
}

.bio {
  margin: 16px 0 0;
  line-height: 1.6;
  color: #bddcf2;
  max-width: 50ch;
}

.links {
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 52px;
  height: 52px;
  display: inline-grid;
  place-items: center;
  color: #062248;
  text-decoration: none;
  border-radius: 50%;
  border: 1px solid rgba(184, 232, 255, 0.6);
  background: radial-gradient(circle at 30% 26%, #eaf8ff, #89caf9 72%);
  box-shadow:
    0 12px 26px rgba(57, 156, 227, 0.36),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  transition:
    transform 230ms ease,
    filter 180ms ease,
    box-shadow 230ms ease;
}

.icon-btn:hover {
  transform: translateY(-3px) scale(1.07);
  filter: brightness(1.06);
  box-shadow:
    0 16px 30px rgba(57, 156, 227, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.icon-btn:focus-visible {
  outline: 2px solid #9bd0ff;
  outline-offset: 2px;
}

.icon-btn-secondary {
  color: #e8f4ff;
  background: radial-gradient(circle at 34% 26%, #3f89ea, #0c3a72 74%);
  border-color: rgba(148, 190, 245, 0.7);
  box-shadow:
    0 12px 26px rgba(19, 73, 141, 0.52),
    inset 0 0 0 1px rgba(190, 220, 255, 0.2);
}

.icon {
  width: 22px;
  height: 22px;
}

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

.hint {
  margin: 20px 0 0;
  font-size: 0.9rem;
  color: #a7cfff;
  opacity: 0.92;
}

.protected-email {
  margin: 14px 0 0;
  font-size: 0.95rem;
  color: #c9e8fb;
}

.protected-email span {
  color: #ebf8ff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.play-btn {
  margin-top: 18px;
  min-height: 44px;
  padding: 0.7rem 1.2rem;
  border: 1px solid rgba(171, 232, 255, 0.65);
  border-radius: 999px;
  background: linear-gradient(135deg, #8fe2ff, #5ac7ff 44%, #1f8dd6);
  color: #031a34;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 0.94rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 10px 22px rgba(67, 185, 255, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  transition:
    transform 190ms ease,
    box-shadow 190ms ease,
    filter 190ms ease;
}

.play-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow:
    0 14px 30px rgba(67, 185, 255, 0.48),
    inset 0 0 0 1px rgba(255, 255, 255, 0.38);
}

.play-btn:focus-visible {
  outline: 2px solid #a8deff;
  outline-offset: 2px;
}

.game-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 220ms ease,
    visibility 220ms ease;
}

.game-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.game-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 10, 24, 0.74);
  backdrop-filter: blur(7px);
}

.game-modal-panel {
  position: relative;
  z-index: 1;
  width: min(430px, calc(100vw - 24px));
  border-radius: 18px;
  border: 1px solid rgba(138, 214, 255, 0.38);
  background: linear-gradient(
    170deg,
    rgba(6, 35, 70, 0.98),
    rgba(4, 21, 45, 0.97)
  );
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.58),
    inset 0 0 0 1px rgba(158, 211, 255, 0.12);
  padding: 14px;
}

.game-modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.game-modal-top h2 {
  margin: 0;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  color: #d8f5ff;
}

.game-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.game-switcher button {
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(141, 206, 247, 0.38);
  background: rgba(9, 44, 82, 0.72);
  color: #cbebff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.game-switcher button.is-active {
  border-color: rgba(192, 234, 255, 0.88);
  background: linear-gradient(145deg, #6fd5ff, #1f8dd6);
  color: #032445;
}

.game-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(170, 223, 255, 0.56);
  background: rgba(12, 52, 95, 0.8);
  color: #dff6ff;
  font-size: 1rem;
  cursor: pointer;
}

.mini-game-canvas {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(117, 199, 247, 0.35);
  background: linear-gradient(180deg, #0b2d58, #123a66 42%, #0e2847);
  touch-action: none;
  user-select: none;
}

.game-meta {
  margin-top: 10px;
}

.game-meta p {
  margin: 0;
  font-size: 0.84rem;
  color: #b7dcf2;
}

.game-score {
  margin-top: 6px !important;
  color: #e2f8ff !important;
  font-weight: 700;
}

.game-controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.game-controls button {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(147, 214, 255, 0.4);
  background: linear-gradient(
    150deg,
    rgba(41, 121, 191, 0.9),
    rgba(21, 73, 127, 0.9)
  );
  color: #e8f8ff;
  font-weight: 600;
  cursor: pointer;
}

.game-controls button:hover {
  filter: brightness(1.08);
}

.game-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

body.modal-open {
  overflow: hidden;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes boot-wipe {
  0% {
    opacity: 1;
    transform: translateX(0%);
  }

  60% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

@keyframes intro-overlay {
  0% {
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes ring-pop {
  0% {
    opacity: 0;
    transform: scale(0.66);
  }

  32% {
    opacity: 1;
    transform: scale(1.05);
  }

  100% {
    opacity: 0;
    transform: scale(1.42);
  }
}

@keyframes ring-pulse {
  0% {
    opacity: 0.8;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(1.3);
  }
}

@keyframes boot-text-in {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    letter-spacing: 0.26em;
  }

  40% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-12px) scale(1.02);
    letter-spacing: 0.38em;
  }
}

@keyframes content-rise {
  0% {
    opacity: 0;
    transform: translateY(16px);
    filter: blur(6px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes bg-boot {
  from {
    transform: scale(1.07);
    filter: saturate(1.45) brightness(1.25);
  }

  to {
    transform: scale(1);
    filter: saturate(1) brightness(1);
  }
}

@keyframes noise-boot {
  from {
    opacity: 0;
  }

  to {
    opacity: 0.36;
  }
}

@keyframes wrap-boot {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.99);
    filter: blur(9px);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@media (max-width: 700px) {
  .card {
    border-radius: 20px;
    padding-top: clamp(26px, 7vw, 34px);
  }

  h1 {
    font-size: clamp(1.8rem, 8vw, 2.7rem);
  }

  .icon-btn {
    width: 50px;
    height: 50px;
  }

  .play-btn {
    width: 100%;
    margin-top: 16px;
  }

  .game-modal-panel {
    width: min(360px, calc(100vw - 12px));
    max-height: calc(100dvh - 12px);
    overflow-y: auto;
    padding: 10px;
  }

  .mini-game-canvas {
    width: auto;
    max-width: 100%;
    max-height: 40dvh;
    display: block;
    margin-inline: auto;
  }

  .game-meta {
    margin-top: 8px;
  }

  .game-meta p {
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .game-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 10px;
  }

  .game-controls button {
    min-height: 36px;
    font-size: 0.82rem;
  }

  .game-switcher {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  #automation-bg,
  .noise,
  .wrap,
  .card,
  .card > * {
    animation: none !important;
  }

  .play-btn,
  .game-modal {
    transition: none !important;
  }

  body.startup .card > * {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
