* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  background: #101820;
  color: #f8fafc;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

#scene {
  display: block;
  height: 100%;
  width: 100%;
  touch-action: none;
}

#overlay {
  left: max(18px, env(safe-area-inset-left));
  max-width: min(390px, calc(100vw - 36px));
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  z-index: 4;
}

.brand {
  color: #fbbf24;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 8px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 7vw, 4.2rem);
  line-height: 0.95;
  margin: 0 0 12px;
}

p {
  color: #dbeafe;
  font-size: 0.98rem;
  line-height: 1.45;
  margin: 0 0 16px;
  max-width: 32rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  appearance: none;
  background: #f59e0b;
  border: 0;
  border-radius: 8px;
  color: #111827;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  padding: 0 16px;
}

button:hover {
  background: #fbbf24;
}

#reset {
  background: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
}

#attack {
  background: #38bdf8;
}

#stats {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  top: max(18px, env(safe-area-inset-top));
  width: min(310px, calc(100vw - 36px));
  z-index: 4;
}

.stat-row {
  align-items: center;
  display: flex;
  font-size: 0.78rem;
  font-weight: 800;
  justify-content: space-between;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.stat-row strong {
  color: #e2e8f0;
  font-size: 0.76rem;
}

.bar {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  height: 13px;
  margin-bottom: 12px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  transform-origin: left center;
  transition: transform 180ms ease;
  width: 100%;
}

.health i {
  background: linear-gradient(90deg, #22c55e, #84cc16);
}

.xp i {
  background: linear-gradient(90deg, #38bdf8, #a78bfa);
}

#hud {
  align-items: center;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  left: max(18px, env(safe-area-inset-left));
  position: fixed;
  z-index: 4;
}

#hud span,
#unsupported {
  backdrop-filter: blur(12px);
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 10px;
}

#unsupported {
  bottom: 74px;
  left: max(18px, env(safe-area-inset-left));
  max-width: min(360px, calc(100vw - 36px));
  position: fixed;
  z-index: 4;
}

#exit-ar {
  background: #f8fafc;
  bottom: max(18px, env(safe-area-inset-bottom));
  color: #111827;
  display: none;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  z-index: 6;
}

.xr-active #exit-ar {
  display: block;
}

.xr-active #overlay {
  pointer-events: none;
}

.xr-active #overlay .actions,
.xr-active #overlay .brand {
  display: none;
}

@media (max-width: 640px) {
  #overlay {
    right: 18px;
  }

  p {
    font-size: 0.92rem;
  }

  #stats {
    left: max(18px, env(safe-area-inset-left));
    right: auto;
    top: auto;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 54px);
  }
}
