html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #000; font-family: -apple-system, sans-serif; }
#video {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1);
}
#glcanvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
}
#overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; color: #cfefff; text-align: center;
  background: rgba(0,0,0,0.55); z-index: 10; padding: 24px; box-sizing: border-box;
}
#overlay h1 { font-size: 20px; margin-bottom: 8px; }
#overlay p { font-size: 14px; opacity: 0.85; line-height: 1.6; margin: 4px 0; }
#startBtn {
  margin-top: 20px; padding: 12px 28px; font-size: 15px; border-radius: 24px;
  border: 1px solid #7fdcff; background: rgba(50,150,220,0.25); color: #eafbff;
  cursor: pointer; backdrop-filter: blur(4px);
}
#startBtn:hover { background: rgba(80,180,255,0.4); }
#status {
  position: absolute; bottom: 14px; left: 0; width: 100%; text-align: center;
  color: rgba(200,240,255,0.8); font-size: 12px; z-index: 5; pointer-events: none;
  text-shadow: 0 0 6px rgba(0,0,0,0.8);
}
#flash {
  position: fixed; inset: 0; background: #fff; z-index: 60;
  opacity: 0; pointer-events: none;
}
#flash.flash-anim { animation: flashPop 0.4s ease-out forwards; }
@keyframes flashPop {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}

#hud {
  position: absolute; top: 0; left: 0; width: 100%; z-index: 20; pointer-events: none;
  display: none; justify-content: space-between; align-items: flex-start;
  padding: 16px 32px; box-sizing: border-box; color: #fff;
  text-shadow: 0 0 12px rgba(0,0,0,0.9), 0 0 4px rgba(0,0,0,0.9);
}
#hud.show { display: flex; }
#hud .box { display: flex; flex-direction: column; align-items: center; min-width: 160px; }
#hud .label { font-size: 22px; font-weight: 700; opacity: 0.85; }
#hud .num { font-size: 96px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
#hudTime.low { color: #ff4a3a; }

#result {
  position: fixed; inset: 0; z-index: 70; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  background: rgba(5,10,25,0.88); color: #fff; text-align: center;
}
#result.show { display: flex; }
#result .label { font-size: 32px; font-weight: 700; opacity: 0.8; }
#resultScore { font-size: 200px; font-weight: 900; line-height: 1; color: #ffd54a; }
#result .best { font-size: 36px; margin-top: 12px; opacity: 0.9; }
#retryBtn {
  margin-top: 40px; padding: 24px 80px; font-size: 44px; font-weight: 800; border-radius: 60px;
  border: 4px solid #7fdcff; background: #1e7fd0; color: #fff; cursor: pointer;
}
#retryBtn:hover { background: #2f9bff; }

#fatalError {
  position: fixed; inset: 0; z-index: 200; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  background: rgba(4,8,20,0.94); color: #eafbff; text-align: center;
  padding: 48px; box-sizing: border-box; gap: 36px;
}
#fatalError.show { display: flex; }
#fatalError .msg {
  font-size: 40px; font-weight: 800; line-height: 1.6; max-width: 800px; color: #ffd54a;
}
#fatalRetryBtn {
  padding: 22px 72px; font-size: 36px; font-weight: 800; border-radius: 56px;
  border: 4px solid #7fdcff; background: #1e7fd0; color: #fff; cursor: pointer;
}
#fatalRetryBtn:hover { background: #2f9bff; }

body.fatal-error #overlay,
body.fatal-error #hud,
body.fatal-error #result {
  display: none;
}
