html,
body,
#app {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050505;
  color: #eee;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#webgl {
  display: block;
  width: 100%;
  height: 100%;
  background: #050505;
}

#loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: #050505;
  transition: opacity 300ms ease, visibility 300ms ease;
}

#loadingScreen.is-complete {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card { width: min(100%, 260px); text-align: center; }
.loading-mark {
  width: 8px;
  height: 8px;
  margin: 0 auto 18px;
  background: #fff;
  border-radius: 50%;
  animation: loading-pulse 1.2s ease-in-out infinite;
}
.loading-card h1 { display: none; }
.loading-card p { margin: 0 0 12px; color: #fff; font-size: 12px; letter-spacing: 0.18em; }
.loading-track { height: 2px; overflow: hidden; background: #292929; }
#loadingProgress { width: 0; height: 100%; background: #fff; transition: width 180ms ease; }
#loadingPercent { margin: 9px 0 0; color: #888; font-variant-numeric: tabular-nums; }
.loading-card small { display: none; }
@keyframes loading-pulse { 50% { opacity: 0.25; } }

#gameUi {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

#gameScore {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 12px #000;
}

#gameScore.score-hit-high { animation: score-hit-high 420ms ease-out; }
#gameScore.score-hit-mid { animation: score-hit-mid 360ms ease-out; }
#gameScore.score-hit-low { animation: score-hit-low 300ms ease-out; }

.game-hit-feedback {
  position: fixed;
  z-index: 21;
  opacity: 0;
  color: #fff;
  font-size: clamp(22px, 6vw, 40px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 12px #000;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.game-hit-feedback.is-visible { animation: game-hit 620ms ease-out both; }
.game-hit-high { color: #fff36a; font-size: clamp(30px, 8vw, 52px); }
.game-hit-mid { color: #fff; }
.game-hit-low { color: #aaa; font-size: clamp(18px, 5vw, 30px); }

@keyframes game-hit {
  0% { opacity: 0; transform: translate(-50%, -45%) scale(0.65); }
  18% { opacity: 1; transform: translate(-50%, -62%) scale(1.16); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.92); }
}

@keyframes score-hit-high {
  40% { color: #fff36a; transform: translateX(-50%) scale(1.24); }
}

@keyframes score-hit-mid {
  40% { transform: translateX(-50%) scale(1.12); }
}

@keyframes score-hit-low {
  40% { color: #aaa; transform: translateX(-50%) scale(1.04); }
}

.game-main-button {
  position: absolute;
  left: 50%;
  bottom: max(11vh, calc(env(safe-area-inset-bottom) + 24px));
  transform: translateX(-50%);
  min-width: 180px;
  padding: 14px 32px;
  color: #050505;
  background: #fff;
  border: 0;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
  pointer-events: auto;
}

#gameMessage {
  position: absolute;
  left: 50%;
  bottom: 4vh;
  transform: translateX(-50%);
  margin: 0;
  color: #fff;
  font-size: 12px;
  text-align: center;
}

#gameUi [hidden] { display: none; }

body[data-player-mode="game"] #raycastInfo,
body[data-player-mode="game"] #controls {
  display: none;
}

#raycastInfo {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: calc(100% - 48px);
  padding: 7px 10px;
  overflow-wrap: anywhere;
  color: #e8f4ff;
  background: rgba(8, 10, 12, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  pointer-events: none;
  backdrop-filter: blur(8px);
  transition: opacity 120ms ease, visibility 120ms ease;
}

#controls {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 980px;
  padding: 10px 12px;
  background: rgba(8, 10, 12, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  box-sizing: border-box;
  backdrop-filter: blur(8px);
  transition: opacity 120ms ease, visibility 120ms ease;
}

#app.ui-hidden #raycastInfo,
#app.ui-hidden #controls {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compact label {
  min-width: 150px;
}

button,
select,
input {
  font: inherit;
}

button {
  padding: 5px 12px;
  color: #fff;
  background: #1464c8;
  border: 1px solid #2b7de1;
  border-radius: 4px;
  cursor: pointer;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  white-space: nowrap;
}

select,
input[type="number"] {
  min-width: 72px;
  color: #eee;
  background: #111820;
  border: 1px solid #334151;
  border-radius: 4px;
  padding: 3px 5px;
}

input[type="range"] {
  width: 90px;
}

#asyncAnimationControls {
  display: contents;
}

input[type="color"] {
  width: 34px;
  height: 25px;
  padding: 1px;
  border: 1px solid #334151;
  border-radius: 4px;
  background: #111820;
  cursor: pointer;
}

input[type="file"][hidden] {
  display: none;
}

#status {
  font-size: 12px;
  color: #9fb4c9;
}

#sequenceErrors {
  max-height: 120px;
  padding: 8px 10px;
  overflow: auto;
  color: #ffd7d7;
  background: rgba(100, 12, 12, 0.82);
  border: 1px solid #d05a5a;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 700px) {
  #controls {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .row {
    gap: 7px;
  }

  label {
    font-size: 12px;
  }

  .compact label {
    min-width: 120px;
  }
}
