:root {
  color-scheme: dark;
  --bg-inner: #202431;
  --bg-center: #1b2230;
  --bg-mid: #141821;
  --bg-outer: #10131a;
  --bg-edge: #0a0d14;
  --mode-tint-rgb: 66, 86, 118;
  --mode-tint-opacity: 0.1;
  --mode-tint-opacity-soft: 0.035;
  --text: rgba(255, 255, 255, 0.88);
  --muted: rgba(255, 255, 255, 0.5);
  --halo-scene-size: min(672px, calc(100vw - 48px), 68vh);
  --glass-bg: rgba(255, 255, 255, 0.12);
  --glass-edge: rgba(255, 255, 255, 0.22);
  --glass-sheen: rgba(255, 255, 255, 0.35);
  --glass-shadow: rgba(6, 10, 18, 0.55);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html.force-cursor,
html.force-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cdefs%3E%3CradialGradient id='haloGlow'%3E%3Cstop offset='0%25' style='stop-color:rgb(245,250,255);stop-opacity:1'/%3E%3Cstop offset='40%25' style='stop-color:rgb(180,210,255);stop-opacity:0.75'/%3E%3Cstop offset='100%25' style='stop-color:rgb(120,170,255);stop-opacity:0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='20' cy='20' r='16' fill='url(%23haloGlow)'/%3E%3Ccircle cx='20' cy='20' r='4.5' fill='rgb(255,255,255)' opacity='1'/%3E%3C/svg%3E") 20 20, auto !important;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background-color: var(--bg-edge);
  background:
    radial-gradient(
      ellipse 132% 118% at 35% 45%,
      var(--bg-inner) 0%,
      var(--bg-center) 18%,
      var(--bg-mid) 44%,
      var(--bg-outer) 72%,
      var(--bg-edge) 100%
    ),
    radial-gradient(
      ellipse 74% 66% at 30% 34%,
      rgba(255, 255, 255, 0.018) 0%,
      rgba(255, 255, 255, 0.006) 34%,
      transparent 76%
    );
  color: var(--text);
  transition: background 1.18s ease-in-out;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 86% 78% at 35% 42%,
      rgba(var(--mode-tint-rgb), var(--mode-tint-opacity)) 0%,
      rgba(var(--mode-tint-rgb), var(--mode-tint-opacity-soft)) 44%,
      transparent 80%
    ),
    radial-gradient(
      ellipse 82% 74% at 40% 40%,
      rgba(255, 255, 255, 0.04) 0%,
      rgba(255, 255, 255, 0.012) 42%,
      transparent 78%
    ),
    radial-gradient(
      ellipse 104% 92% at 60% 60%,
      rgba(0, 0, 0, 0.4) 0%,
      rgba(0, 0, 0, 0.16) 40%,
      transparent 78%
    );
  z-index: 0;
  transition: opacity 0.8s ease-in-out;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256' viewBox='0 0 256 256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.48' numOctaves='3'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.22'/%3E%3C/svg%3E");
  z-index: 0;
  mix-blend-mode: screen;
}

.layout {
  position: relative;
  height: 100%;
  width: 100%;
  z-index: 1;
  isolation: isolate;
}

.session-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.4s ease;
}

.session-bar.is-visible {
  opacity: 0.6;
}

.session-bar__fill {
  height: 100%;
  width: 100%;
  background: rgba(255, 255, 255, 0.7);
  transform-origin: left;
  transform: scaleX(1);
  transition: transform 0.2s linear;
}

.entrance-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  opacity: 1;
  transition: opacity 1s ease-in-out;
}

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

.entrance-text {
  max-width: min(560px, calc(100vw - 48px));
  text-align: center;
  color: rgba(255, 255, 255, 0.72);
  text-wrap: balance;
  animation: fadeInUp 1.2s ease-out;
}

.entrance-text p {
  font-size: 18px;
  line-height: 1.6;
  font-weight: 400;
  margin: 0;
}

.entrance-text p + p {
  margin-top: 12px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

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

.home-button {
  position: fixed;
  top: 60px;
  left: 60px;
  z-index: 1000;
  width: 24px;
  height: 24px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  transition: all 0.3s ease;
  display: block;
}

.home-button img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 0.3s ease;
}

.home-button .home-default {
  opacity: 1;
}

.home-button .home-hover {
  opacity: 0;
}

.home-button:hover .home-default {
  opacity: 0;
}

.home-button:hover .home-hover {
  opacity: 1;
}

.home-button:active {
  transform: scale(0.95);
}

.visual-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
}

.halo-scene {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--halo-scene-size);
  height: var(--halo-scene-size);
  flex: 0 0 auto;
}

#haloCanvas {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  height: 100%;
}

.halo-text {
  grid-area: 1 / 1;
  align-self: center;
  justify-self: center;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  opacity: 1;
  transition: opacity 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.halo-label,
.halo-countdown {
  font-family: inherit;
  font-weight: 600;
}

.halo-label {
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.88);
}

.halo-countdown {
  font-size: 20px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

.halo-text[data-state="idle"] {
  opacity: 0;
}

.halo-text[data-state="countdown"] .halo-countdown {
  font-size: 20px;
}

.status {
  position: fixed;
  bottom: 120px;
  left: 50%;
  width: min(760px, calc(100vw - 40px));
  transform: translateX(-50%);
  text-align: center;
  z-index: 2;
  pointer-events: none;
}

.mode-description {
  display: block;
  max-width: min(760px, calc(100vw - 40px));
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  line-height: 1.6;
  text-wrap: balance;
  opacity: 0.9;
  transform: translateY(0);
  visibility: visible;
  transition:
    opacity 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 1.15s ease;
}

.mode-description.is-transitioning {
  opacity: 0;
  transform: translateY(3px);
}

.mode-description.is-faded {
  opacity: 0;
  transform: translateY(4px);
  visibility: hidden;
}

.controls {
  position: fixed;
  bottom: 60px;
  left: 60px;
  display: grid;
  gap: 14px;
  z-index: 3;
  overflow: visible;
  width: min(360px, calc(100vw - 56px));
  padding: 8px 0;
}

.control-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

label {
  font-size: 14px;
  color: var(--muted);
}

select,
button {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06));
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  font-size: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -8px 16px rgba(6, 10, 18, 0.25);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
}

select {
  padding: 12px 16px;
  padding-right: 44px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 L6 6.5 L11 1.5' fill='none' stroke='rgba(255,255,255,0.7)' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 12px 8px;
  background-position: calc(100% - 16px) center;
}

button {
  padding: 12px 16px;
  cursor: pointer;
  min-width: 96px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

button.primary {
  background:
    linear-gradient(150deg, rgba(130, 180, 255, 0.42), rgba(120, 150, 255, 0.18));
  border-color: rgba(140, 180, 255, 0.55);
  box-shadow:
    0 10px 24px rgba(80, 130, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

button:not(:disabled):hover,
select:not(:disabled):hover {
  border-color: rgba(255, 255, 255, 0.38);
  box-shadow:
    0 12px 22px rgba(15, 20, 32, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

button:not(:disabled):active {
  transform: translateY(1px) scale(0.99);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  :root {
    --halo-scene-size: min(672px, calc(100vw - 40px), 60vh);
  }

  .controls {
    left: 20px;
    right: 20px;
    width: calc(100vw - 40px);
  }

  .status {
    bottom: 140px;
  }

  .home-button {
    left: 24px;
    top: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  .entrance-overlay,
  .entrance-text,
  .home-button,
  button,
  select,
  .mode-description,
  .session-bar,
  .session-bar__fill {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }

  button:not(:disabled):hover,
  select:not(:disabled):hover {
    transform: none;
  }
}
