#bg-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 50%, #FD79A8 100%);
  background-size: 200% 200%;
  animation: bgShift 12s ease infinite;
}

@keyframes bgShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

#game {
  position: fixed;
  inset: 0;
  z-index: var(--z-game);
}

#ui-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-ui);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

#ui-layer > * {
  pointer-events: auto;
}

#fx {
  position: fixed;
  inset: 0;
  z-index: var(--z-fx);
  pointer-events: none;
}

#modal-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-smooth);
}

#modal-layer.active {
  pointer-events: auto;
  opacity: 1;
}

#modal-layer .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 27, 105, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#modal-layer .modal-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

/* Screen container */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-smooth),
              transform var(--duration-slow) var(--ease-bounce);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

.screen.slide-in-right {
  transform: translateX(100%);
}
.screen.slide-in-right.active {
  transform: translateX(0);
}

.screen.slide-out-left {
  transform: translateX(-100%);
  opacity: 0;
}

/* Responsive */
@media (max-width: 600px) {
  :root {
    --font-size-title: 36px;
    --font-size-xxl: 28px;
    --font-size-xl: 22px;
    --space-xl: 24px;
    --space-xxl: 32px;
  }
}

@media (min-width: 601px) and (max-width: 1024px) {
  :root {
    --font-size-title: 48px;
  }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-top)) {
  #ui-layer {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}
