:root {
  --bg-top: #08111f;
  --bg-bottom: #111f38;
  --ink: #f6fbff;
  --ink-soft: rgba(246, 251, 255, 0.78);
  --card: rgba(8, 17, 31, 0.72);
  --card-border: rgba(183, 229, 255, 0.18);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  --focus: #ffe082;
  --overlay-z: 30;
  --control-z: 20;
  --font-display: "Fredoka", "Trebuchet MS", "Gill Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none; /* prevent pull-to-refresh / rubber-band */
}

body {
  overflow: hidden;
  background: var(--bg-top);
  color: var(--ink);
  font-family: var(--font-display);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* prevent browser zoom/scroll/gestures on canvas */
}

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 1.6rem;
  z-index: 5;
  margin: 0;
  padding: 0.8rem 1.1rem;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(8, 17, 31, 0.46);
  color: var(--ink-soft);
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  letter-spacing: 0.02em;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px);
  visibility: visible;
  transition: opacity 240ms ease, transform 240ms ease, visibility 0s linear 240ms;
}

.stage-hint.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(8px);
}

.fullscreen-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: var(--control-z);
  min-width: 9rem;
  padding: 0.8rem 1rem;
  border: 0;
  border-radius: 999px;
  background: rgba(8, 17, 31, 0.52);
  color: var(--ink);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(16px);
  cursor: pointer;
  touch-action: manipulation;
  transition: all 200ms ease;
}

.fullscreen-toggle.is-close {
  min-width: 0;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  font-size: 1.2rem;
  line-height: 2.2rem;
  text-align: center;
  opacity: 0.5;
}

.fullscreen-toggle.is-close:hover {
  opacity: 0.85;
}

.start-overlay {
  position: absolute;
  inset: 0;
  z-index: var(--overlay-z);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at top, rgba(112, 206, 255, 0.12), transparent 40%),
    rgba(5, 12, 24, 0.3);
  backdrop-filter: blur(18px);
  transition: opacity 240ms ease, visibility 240ms ease;
}

.start-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  width: min(92vw, 34rem);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--card-border);
  border-radius: 2rem;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
  animation: card-enter 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.eyebrow {
  margin: 0 0 0.9rem;
  color: #9de2ff;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: fade-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

.start-card h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 0.96;
  animation: fade-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.intro {
  margin: 1rem 0 0;
  font-size: clamp(1rem, 2.6vw, 1.18rem);
  line-height: 1.45;
  animation: fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.45s both;
}

.footnote {
  margin: 1rem 0 0;
  font-size: clamp(1rem, 2.6vw, 1.18rem);
  line-height: 1.45;
  animation: fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.7s both;
}

.github-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--ink-soft);
  opacity: 0.45;
  transition: opacity 200ms ease;
  animation: fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.8s both;
}

.github-link:hover {
  opacity: 0.9;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.actions {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.6rem;
  animation: fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.55s both;
}

.action {
  min-height: 3.8rem;
  padding: 1rem 1.25rem;
  border: 0;
  border-radius: 1.4rem;
  cursor: pointer;
  touch-action: manipulation; /* prevent double-tap zoom on buttons */
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.action:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(23, 50, 77, 0.12);
}

.action-primary {
  background: linear-gradient(135deg, #ff7aa8, #ffcb57);
  color: #09121f;
  font-weight: 800;
}

.action-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-weight: 700;
}

@media (max-width: 720px) {
  .fullscreen-toggle {
    top: auto;
    right: 50%;
    bottom: 0.9rem;
    transform: translateX(50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .action,
  .start-overlay,
  .stage-hint {
    transition-duration: 0ms;
  }
  .start-card,
  .eyebrow,
  .start-card h1,
  .intro,
  .actions,
  .footnote,
  .github-link {
    animation: none;
  }
}
