:root {
  --ink: #cfe9ff;
  --muted: #5d7fa6;
  --cyan: #3ef2ff;
  --pink: #ff5bd0;
  --bg: #04060d;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  background: var(--bg);
  background-image:
    radial-gradient(1100px 700px at 50% -10%, #0d1b36 0%, #060a16 45%, #04060d 75%),
    radial-gradient(700px 500px at 85% 110%, rgba(255, 47, 179, 0.06) 0%, transparent 60%);
  color: var(--ink);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.noscript {
  margin: 0;
  padding: 14px;
  color: #ff8b9b;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-align: center;
}

.shell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 14px;
  width: 100%;
}

.frame {
  position: relative;
  width: min(94vw, calc(84vh * 1.5), 1360px);
  aspect-ratio: 3 / 2;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 18% 8%, var(--accent-soft, rgba(62, 242, 255, 0.12)) 0%, transparent 58%),
    radial-gradient(ellipse at 84% 92%, rgba(255, 91, 208, 0.10) 0%, transparent 62%),
    linear-gradient(180deg, #050810 0%, #070c18 52%, #0b1026 100%);
  box-shadow:
    0 0 0 1px rgba(62, 242, 255, 0.20),
    0 0 70px rgba(62, 242, 255, 0.10),
    0 0 140px rgba(255, 91, 208, 0.06),
    0 30px 90px rgba(0, 0, 0, 0.7);
  isolation: isolate;
}

.ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
  background-image:
    repeating-linear-gradient(90deg, rgba(90, 160, 255, 0.045) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(0deg, rgba(90, 160, 255, 0.045) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(90deg, rgba(100, 180, 255, 0.055) 0 1px, transparent 1px 192px),
    repeating-linear-gradient(0deg, rgba(100, 180, 255, 0.055) 0 1px, transparent 1px 192px);
}

.orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.82;
  will-change: transform;
  animation-duration: 22s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.orb-a {
  width: 62%;
  aspect-ratio: 1;
  left: -12%;
  top: -25%;
  background: radial-gradient(circle, rgba(29, 229, 255, 0.17) 0%, rgba(29, 229, 255, 0.05) 40%, transparent 68%);
  animation-name: orb-a;
}

.orb-b {
  width: 74%;
  aspect-ratio: 1;
  right: -18%;
  bottom: -30%;
  background: radial-gradient(circle, rgba(255, 47, 179, 0.14) 0%, rgba(255, 47, 179, 0.04) 42%, transparent 68%);
  animation-name: orb-b;
  animation-duration: 26s;
}

.orb-c {
  width: 66%;
  aspect-ratio: 1;
  left: 20%;
  top: 12%;
  background: radial-gradient(circle, rgba(91, 91, 255, 0.13) 0%, rgba(91, 91, 255, 0.04) 44%, transparent 70%);
  animation-name: orb-c;
  animation-duration: 30s;
}

@keyframes orb-a {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(5%, 4%, 0) scale(1.07); }
}

@keyframes orb-b {
  from { transform: translate3d(2%, 2%, 0) scale(1.04); }
  to { transform: translate3d(-4%, -3%, 0) scale(1); }
}

@keyframes orb-c {
  from { transform: translate3d(-3%, 2%, 0) scale(1); }
  to { transform: translate3d(3%, -2%, 0) scale(1.05); }
}

#game {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
  cursor: crosshair;
}

.vignette,
.danger,
.scanlines,
.glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}

.vignette {
  z-index: 2;
  background: radial-gradient(ellipse at 50% 46%, transparent 32%, rgba(0, 0, 0, 0.14) 66%, rgba(0, 0, 0, 0.58) 100%);
}

.danger {
  z-index: 3;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(255, 40, 80, 0.18) 100%);
  box-shadow: inset 0 0 90px rgba(255, 40, 80, 0.24);
}

.frame.is-danger .danger {
  opacity: 1;
  animation: danger-pulse 1.8s ease-in-out infinite;
}

@keyframes danger-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.scanlines {
  z-index: 4;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.026) 0,
    rgba(255, 255, 255, 0.026) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.38;
}

.glass {
  z-index: 5;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.05) 0%, transparent 32%, transparent 70%, rgba(255, 255, 255, 0.025) 100%);
}

.touchbar {
  display: none;
  justify-content: center;
  gap: 8px;
}

.touchbar button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(62, 242, 255, 0.42);
  background: rgba(5, 11, 22, 0.72);
  color: #bff8ff;
  font: 700 11px/1 "Consolas", monospace;
  letter-spacing: 1px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 14px rgba(62, 242, 255, 0.14);
}

.touchbar button:active {
  transform: scale(0.93);
  background: rgba(62, 242, 255, 0.16);
}

.touchbar button.is-off {
  color: #ff8b9b;
  border-color: rgba(255, 91, 110, 0.5);
  box-shadow: 0 0 14px rgba(255, 91, 110, 0.16);
}

.hint {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  user-select: none;
}

.hint .for-touch { display: none; }
.hint .rotate-note { display: none; }

@media (hover: none), (pointer: coarse) {
  .hint .for-desktop { display: none; }
  .hint .for-touch { display: inline; }
  .touchbar { display: flex; }
  #game { cursor: default; }
  .shell { gap: 8px; padding: 8px; }
  .frame { width: min(94vw, calc((100vh - 96px) * 1.5), 1360px); }
}

@media (orientation: portrait) and (hover: none), (orientation: portrait) and (pointer: coarse) {
  .hint .rotate-note { display: inline; }
}

@media (max-width: 720px) {
  .hint { font-size: 9px; letter-spacing: 0.10em; }
  .shell { gap: 10px; padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .scanlines { display: none; }
  .orb { animation: none; }
  .frame.is-danger .danger { animation: none; opacity: 1; }
}
