:root {
  --sc-bg: #08111a;
  --sc-panel: rgba(7, 13, 20, 0.7);
  --sc-panel-strong: rgba(11, 18, 27, 0.88);
  --sc-border: rgba(255, 255, 255, 0.14);
  --sc-text: #f5efe3;
  --sc-muted: rgba(245, 239, 227, 0.72);
  --sc-accent: #f6b36c;
  --sc-accent-2: #89f1ff;
  --sc-danger: #ff8d74;
  --sc-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  --sc-radius-xl: 32px;
  --sc-radius-lg: 24px;
  --sc-radius-pill: 999px;
  --sc-font-sans: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --sc-font-display: "Cormorant Garamond", Georgia, serif;
}

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

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--sc-bg);
  color: var(--sc-text);
  font-family: var(--sc-font-sans);
}

body {
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button,
a,
kbd {
  font: inherit;
}

button,
a,
canvas {
  touch-action: manipulation;
}

.sc-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(246, 179, 108, 0.24), transparent 24%),
    radial-gradient(circle at 84% 12%, rgba(137, 241, 255, 0.16), transparent 20%),
    linear-gradient(180deg, rgba(6, 10, 15, 0.6), rgba(6, 10, 15, 0.92));
}

.sc-bg-video,
.sc-bg-overlay,
.sc-bg-grid {
  position: absolute;
  inset: 0;
}

.sc-bg-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.2;
  filter: saturate(0.8) contrast(1.1);
}

.sc-bg-overlay {
  background:
    linear-gradient(180deg, rgba(6, 10, 16, 0.15) 0%, rgba(6, 10, 16, 0.48) 46%, rgba(6, 10, 16, 0.88) 100%),
    radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.08), transparent 18%);
}

.sc-bg-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.22;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.95));
}

.sc-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(36px);
  opacity: 0.45;
}

.sc-orb-a {
  width: 16rem;
  height: 16rem;
  left: -5rem;
  top: 8rem;
  background: rgba(246, 179, 108, 0.22);
}

.sc-orb-b {
  width: 22rem;
  height: 22rem;
  right: -8rem;
  bottom: -4rem;
  background: rgba(137, 241, 255, 0.14);
}

.sc-shell {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  height: 100dvh;
  margin: 0 auto;
  padding: 0.9rem 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.7rem;
}

.glass {
  border: 1px solid var(--sc-border);
  border-radius: var(--sc-radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.015) 100%),
    var(--sc-panel);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: var(--sc-shadow);
}

.sc-stage-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 16px;
  overflow: hidden;
}

.sc-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  max-height: calc(100dvh - 180px);
  margin: 0 auto;
  border-radius: calc(var(--sc-radius-xl) - 1px);
  overflow: hidden;
  background: rgba(4, 8, 13, 0.6);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  image-rendering: crisp-edges;
  touch-action: none;
}

.sc-scoreboard {
  display: flex;
  gap: 20px;
  z-index: 10;
  background: rgba(6, 10, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  padding: 8px 22px 8px 24px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.sc-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
  padding: 4px 6px;
}

.sc-stat + .sc-stat {
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  padding-left: 16px;
}

.sc-stat-label {
  margin: 0 0 4px;
  color: rgba(246, 179, 108, 0.85);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.62rem;
  font-weight: 700;
}

.sc-stat strong {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sc-audio-toggle {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 10;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(6, 10, 16, 0.65);
  color: var(--sc-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.sc-audio-toggle:hover,
.sc-audio-toggle:focus-visible {
  background: rgba(246, 179, 108, 0.12);
  border-color: rgba(246, 179, 108, 0.4);
  transform: scale(1.02);
}

.sc-audio-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.sc-audio-icon-off {
  display: none;
}

.sc-audio-toggle[aria-pressed="true"] .sc-audio-icon-on {
  display: none;
}

.sc-audio-toggle[aria-pressed="true"] .sc-audio-icon-off {
  display: block;
}

.sc-help {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 0.72rem;
  color: var(--sc-muted);
  background: rgba(6, 10, 16, 0.55);
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.sc-help-hidden {
  opacity: 0;
  pointer-events: none;
}

.sc-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 20;
  background: linear-gradient(180deg, rgba(4, 8, 13, 0.1), rgba(4, 8, 13, 0.65));
  transition: opacity 180ms ease;
}

.sc-overlay.sc-hidden {
  opacity: 0;
  pointer-events: none;
}

.sc-overlay-card {
  width: min(100%, 24rem);
  padding: 1.15rem 1.1rem 1.2rem;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(9, 15, 24, 0.92);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sc-overlay-kicker {
  margin: 0 0 0.45rem;
  color: rgba(246, 179, 108, 0.88);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}

.sc-overlay-card h2 {
  margin-bottom: 0.15rem;
  font-family: var(--sc-font-display);
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 0.92;
  font-weight: 600;
}

#gameOverOverlay .sc-overlay-card h2 {
  margin-top: 0.25rem;
  margin-bottom: 0.95rem;
  max-width: 17ch;
}

#startOverlay .sc-overlay-card h2 {
  margin-top: 0.1rem;
  margin-bottom: 0.85rem;
}

.sc-overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 0.45rem;
}

.sc-overlay-actions .sc-button {
  margin-top: 0;
}

.sc-overlay-link {
  display: inline-flex;
  margin-top: 0.9rem;
  color: rgba(245, 239, 227, 0.82);
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(245, 239, 227, 0.22);
  transition: color 180ms ease, border-color 180ms ease;
}

.sc-overlay-link:hover,
.sc-overlay-link:focus-visible {
  color: var(--sc-accent);
  border-color: rgba(246, 179, 108, 0.5);
  outline: none;
}

.sc-chip,
.sc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.85rem 1.2rem;
  border-radius: var(--sc-radius-pill);
  border: 1px solid var(--sc-border);
  background: rgba(9, 15, 22, 0.72);
  color: var(--sc-text);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.sc-chip:hover,
.sc-chip:focus-visible,
.sc-button:hover,
.sc-button:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: rgba(246, 179, 108, 0.58);
  background: rgba(246, 179, 108, 0.15);
}

.sc-button-launch {
  background: rgba(36, 126, 66, 0.9);
  border-color: rgba(122, 234, 160, 0.34);
  color: #f2fff5;
}

.sc-button-launch:hover,
.sc-button-launch:focus-visible {
  background: rgba(45, 151, 79, 0.96);
  border-color: rgba(163, 255, 193, 0.54);
}

.sc-chip-exit {
  justify-self: center;
  width: fit-content;
  margin: 0 auto;
  font-size: 0.68rem;
  padding: 0.55rem 1rem;
  min-height: 36px;

  background: rgba(255, 141, 116, 0.18);
  border-color: rgba(255, 141, 116, 0.4);
  color: #ff9a8a;
}

.sc-chip-exit:hover {
  background: rgba(255, 141, 116, 0.3);
  border-color: rgba(255, 141, 116, 0.65);
  color: #ffcfc5;
  transform: translateY(-1px);
}

/* Subtle grid lines inside canvas area are drawn in JS for precision */

@media (prefers-reduced-motion: reduce) {
  .sc-bg-video {
    display: none;
  }

  .sc-orb {
    opacity: 0.2;
    filter: none;
  }
}
