*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a1628;
  color: #e8f0ff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

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

/* —— HUD —— */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  pointer-events: none;
}

.hud-row {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  opacity: 0.9;
}

.hud-row span {
  background: rgba(10, 22, 40, 0.55);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(120, 180, 255, 0.2);
}

/* —— Settings button —— */
#btn-settings {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 20;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(120, 180, 255, 0.35);
  border-radius: 10px;
  background: rgba(10, 22, 40, 0.7);
  color: #c8dcff;
  font-size: 1.25rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

#btn-settings:active {
  background: rgba(30, 50, 80, 0.85);
}

/* —— Stick zones —— */
.stick-zone {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 15;
  width: 140px;
  height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  touch-action: none;
}

#stick-left {
  left: calc(16px + env(safe-area-inset-left, 0px));
}

#stick-right {
  right: calc(16px + env(safe-area-inset-right, 0px));
}

.stick-base {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(60, 90, 140, 0.45), rgba(10, 22, 40, 0.65));
  border: 2px solid rgba(120, 180, 255, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.3);
  touch-action: none;
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin-left: -24px;
  margin-top: -24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7eb0ff, #3a6aa8 60%, #1e3a5f);
  border: 2px solid rgba(200, 220, 255, 0.5);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  will-change: transform;
}

.stick-label {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.65;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Landscape: slightly larger sticks on wide screens */
@media (orientation: landscape) and (min-width: 600px) {
  .stick-zone {
    width: 160px;
    height: 160px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .stick-base {
    width: 128px;
    height: 128px;
  }

  .stick-knob {
    width: 54px;
    height: 54px;
    margin-left: -27px;
    margin-top: -27px;
  }
}

/* —— Settings overlay —— */
#settings-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 10, 20, 0.72);
  backdrop-filter: blur(4px);
  padding: 16px;
}

#settings-overlay.hidden {
  display: none;
}

.settings-panel {
  width: min(360px, 100%);
  background: #122038;
  border: 1px solid rgba(120, 180, 255, 0.3);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.settings-panel h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.setting-row select {
  appearance: none;
  background: #0a1628;
  color: #e8f0ff;
  border: 1px solid rgba(120, 180, 255, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.hint {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-bottom: 16px;
  line-height: 1.4;
}

.settings-panel button {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid rgba(120, 180, 255, 0.35);
  background: rgba(60, 100, 160, 0.35);
  color: #e8f0ff;
  font-size: 0.95rem;
  cursor: pointer;
}

.settings-panel button:active {
  background: rgba(80, 130, 200, 0.45);
}

#btn-close-settings {
  background: rgba(30, 50, 80, 0.6);
}
